Initial Commit
commit
808343e2ac
|
@ -0,0 +1,27 @@
|
|||
/* Dark Style */
|
||||
.lichess_widget {
|
||||
display: inline-block;
|
||||
margin: 2px;
|
||||
background: #333;
|
||||
border: 1px solid #444;
|
||||
padding: 5px 7px 7px 5px;
|
||||
color: #e0e0e0;
|
||||
border-radius:4px;
|
||||
}
|
||||
.lichess_widget:hover {
|
||||
background: #4A4A4A;
|
||||
}
|
||||
.lichess_widget img {
|
||||
margin: 0 10px 0 0;
|
||||
display: inline-block;
|
||||
height: 20px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.lichess_widget span {
|
||||
display:inline-block;
|
||||
vertical-align:middle;
|
||||
}
|
||||
|
||||
.lichess_long {
|
||||
width: 200px;
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Lichess Widgets</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" href="dark.css" />
|
||||
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
|
||||
<script src="lichess_widgets.js"></script>
|
||||
<style>
|
||||
html {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: "Arial", sans-serif;
|
||||
}
|
||||
body {
|
||||
width: 90%;
|
||||
max-width: 900px;
|
||||
margin: auto;
|
||||
padding: 0;
|
||||
}
|
||||
table {
|
||||
margin: 20px 0 0 0;
|
||||
width: 100%;
|
||||
}
|
||||
table td {
|
||||
}
|
||||
blockcode {
|
||||
margin: 5px;
|
||||
padding: 5px 5px 5px 20px;
|
||||
background: #eee;
|
||||
border-radius: 5px;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>(Work in progress) Widgets for Lichess</h1>
|
||||
|
||||
<p>
|
||||
Add the following to the <head> of your webpage,
|
||||
and then add one of the widgets to the <body> of your webpage.
|
||||
</p>
|
||||
|
||||
<blockcode>
|
||||
<link rel="stylesheet" href="http://rubenwardy.github.io/lichess_widgets/dark.css" /><br />
|
||||
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script><br />
|
||||
<script src="http://rubenwardy.github.io/lichess_widgets/lichess_widgets.js"></script>
|
||||
</blockcode>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<script>lichess.challenge_me("rubenwardy", "Lichess");</script>
|
||||
</td>
|
||||
<td>
|
||||
<blockcode>
|
||||
<script>lichess.challenge_me("rubenwardy", "Lichess");</script>
|
||||
</blockcode>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<script>lichess.challenge_me("rubenwardy");</script>
|
||||
</td>
|
||||
<td>
|
||||
<blockcode>
|
||||
<script>lichess.challenge_me("rubenwardy");</script>
|
||||
</blockcode>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<script>lichess.all_scores("rubenwardy");</script>
|
||||
</td>
|
||||
<td>
|
||||
<blockcode>
|
||||
<script>lichess.all_scores("rubenwardy");</script>
|
||||
</blockcode>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<script>lichess.all_scores("rubenwardy", "");</script>
|
||||
</td>
|
||||
<td>
|
||||
<blockcode>
|
||||
<script>lichess.all_scores("rubenwardy", "");</script>
|
||||
</blockcode>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<script>lichess.long_details("rubenwardy");</script>
|
||||
</td>
|
||||
<td>
|
||||
<blockcode>
|
||||
<script>lichess.long_details("rubenwardy");</script>
|
||||
</blockcode>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
|
@ -0,0 +1,46 @@
|
|||
var lichess = {};
|
||||
var serial = 0;
|
||||
lichess.challenge_me = function(author, text) {
|
||||
if (text == null)
|
||||
text = author;
|
||||
var tmp = "<a class=\"lichess_widget\" href=\"http://lichess.org/@/" + author + "\">";
|
||||
tmp += "<img src=\"http://en.lichess.org/assets/images/favicon-32-white.png\" alt=\"lichess\" />"
|
||||
tmp += "<span>" + text + "</span></a>";
|
||||
document.write(tmp);
|
||||
};
|
||||
lichess.all_scores = function(author, text) {
|
||||
serial++;
|
||||
var id = serial;
|
||||
if (text == undefined)
|
||||
text = author;
|
||||
var tmp = "<a id=\"lichess_widget_" + id + "\" class=\"lichess_widget\" href=\"http://lichess.org/@/" + author + "\">";
|
||||
tmp += "<img src=\"http://en.lichess.org/assets/images/favicon-32-white.png\" alt=\"lichess\" />"
|
||||
tmp += "<span>Loading...</span></a>";
|
||||
document.write(tmp);
|
||||
$.ajax({
|
||||
url: "http://en.lichess.org/api/user/" + author,
|
||||
dataType: "jsonp",
|
||||
jsonp: "callback",
|
||||
success: function(data) {
|
||||
if (text && text != "")
|
||||
text = text + " | ";
|
||||
$("#lichess_widget_" + id + " > span").text(text + "Classical: " + data.perfs.classical.rating + " | Bullet: " + data.perfs.bullet.rating);
|
||||
}
|
||||
});
|
||||
};
|
||||
lichess.long_details = function(author) {
|
||||
serial++;
|
||||
var id = serial;
|
||||
var tmp = "<a id=\"lichess_long_" + author + "\" class=\"lichess_widget lichess_long\" href=\"http://lichess.org/@/" + author + "\">";
|
||||
tmp += "<img src=\"http://en.lichess.org/assets/images/favicon-32-white.png\" alt=\"lichess\" />Lichess<br /><br />"
|
||||
tmp += "<span>One: two<br />Three: four</span></a>";
|
||||
document.write(tmp);
|
||||
$.ajax({
|
||||
url: "http://en.lichess.org/api/user/" + author,
|
||||
dataType: "jsonp",
|
||||
jsonp: "callback",
|
||||
success: function(data) {
|
||||
$("#lichess_widget_" + id + " > span").text(author + "<br />Classical: " + data.perfs.classical.rating + "<br />Bullet: " + data.perfs.bullet.rating);
|
||||
}
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue