Initial Commit

master
rubenwardy 2014-11-07 15:06:36 +00:00
commit 808343e2ac
4 changed files with 180 additions and 0 deletions

27
dark.css Normal file
View File

@ -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;
}

101
index.html Normal file
View File

@ -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 &lt;head&gt; of your webpage,
and then add one of the widgets to the &lt;body&gt; of your webpage.
</p>
<blockcode>
&lt;link rel="stylesheet" href="http://rubenwardy.github.io/lichess_widgets/dark.css" /&gt;<br />
&lt;script src="http://code.jquery.com/jquery-1.11.0.min.js"&gt;&lt;/script&gt;<br />
&lt;script src="http://rubenwardy.github.io/lichess_widgets/lichess_widgets.js"&gt;&lt;/script&gt;
</blockcode>
<table>
<tr>
<td>
<script>lichess.challenge_me("rubenwardy", "Lichess");</script>
</td>
<td>
<blockcode>
&lt;script&gt;lichess.challenge_me("rubenwardy", "Lichess");&lt;/script&gt;
</blockcode>
</td>
</tr>
<tr>
<td>
<script>lichess.challenge_me("rubenwardy");</script>
</td>
<td>
<blockcode>
&lt;script&gt;lichess.challenge_me("rubenwardy");&lt;/script&gt;
</blockcode>
</td>
</tr>
<tr>
<td>
<script>lichess.all_scores("rubenwardy");</script>
</td>
<td>
<blockcode>
&lt;script&gt;lichess.all_scores("rubenwardy");&lt;/script&gt;
</blockcode>
</td>
</tr>
<tr>
<td>
<script>lichess.all_scores("rubenwardy", "");</script>
</td>
<td>
<blockcode>
&lt;script&gt;lichess.all_scores("rubenwardy", "");&lt;/script&gt;
</blockcode>
</td>
</tr>
<tr>
<td>
<script>lichess.long_details("rubenwardy");</script>
</td>
<td>
<blockcode>
&lt;script&gt;lichess.long_details("rubenwardy");&lt;/script&gt;
</blockcode>
</td>
</tr>
</table>

46
lichess_widgets.js Normal file
View File

@ -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);
}
});
};

6
readme.md Normal file
View File

@ -0,0 +1,6 @@
Widgets for Lichess
===================
Create by rubenwardy
License: WTFPL