Tweek long widget
parent
808343e2ac
commit
44187c4450
10
dark.css
10
dark.css
|
@ -6,7 +6,8 @@
|
|||
border: 1px solid #444;
|
||||
padding: 5px 7px 7px 5px;
|
||||
color: #e0e0e0;
|
||||
border-radius:4px;
|
||||
border-radius: 4px;
|
||||
text-decoration: none;
|
||||
}
|
||||
.lichess_widget:hover {
|
||||
background: #4A4A4A;
|
||||
|
@ -25,3 +26,10 @@
|
|||
.lichess_long {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.lichess_long hr {
|
||||
margin: 6px 0 2px 0;
|
||||
background: #666;
|
||||
border: none;
|
||||
height: 1px
|
||||
}
|
||||
|
|
13
index.html
13
index.html
|
@ -34,7 +34,7 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>(Work in progress) Widgets for Lichess</h1>
|
||||
<h1>Widgets for Lichess (Work in progress)</h1>
|
||||
|
||||
<p>
|
||||
Add the following to the <head> of your webpage,
|
||||
|
@ -98,4 +98,15 @@
|
|||
</blockcode>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<script>lichess.long_details("rubenwardy", "My Lichess");</script>
|
||||
</td>
|
||||
<td>
|
||||
<blockcode>
|
||||
<script>lichess.long_details("rubenwardy", "My Lichess");</script>
|
||||
</blockcode>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
String.prototype.capitalize = function() {
|
||||
return this.charAt(0).toUpperCase() + this.slice(1);
|
||||
}
|
||||
|
||||
var lichess = {};
|
||||
var serial = 0;
|
||||
lichess.challenge_me = function(author, text) {
|
||||
|
@ -28,11 +32,13 @@ lichess.all_scores = function(author, text) {
|
|||
}
|
||||
});
|
||||
};
|
||||
lichess.long_details = function(author) {
|
||||
lichess.long_details = function(author, text) {
|
||||
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 />"
|
||||
if (text == undefined)
|
||||
text = author + " on Lichess";
|
||||
var tmp = "<a id=\"lichess_widget_" + id + "\" 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\" />" + text + "<hr />"
|
||||
tmp += "<span>One: two<br />Three: four</span></a>";
|
||||
document.write(tmp);
|
||||
$.ajax({
|
||||
|
@ -40,7 +46,15 @@ lichess.long_details = function(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);
|
||||
var res = "";
|
||||
for (var key in data.perfs) {
|
||||
if (data.perfs.hasOwnProperty(key) && data.perfs[key].games > 0) {
|
||||
if (res!="")
|
||||
res += "<br />";
|
||||
res += key.capitalize() + " rating: " + data.perfs[key].rating;
|
||||
}
|
||||
}
|
||||
$("#lichess_widget_" + id + " > span").html(res);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue