-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
186 lines (164 loc) · 5.78 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!--doctype html-->
<html>
<head>
<meta charset="utf-8">
<title>Highscore</title>
<style type="text/css">
html, body{
height: 100%;
}
body {
background: #ff1cae;
font-family: sans-serif;
margin: 0;
padding: 0;
}
#users {
list-style-type: none;
margin: 0px;
padding: 0px;
position: relative;
height: 100%;
}
#users li {
display: inline-block;
position: absolute;
text-align: center;
}
#users li.spin {
-webkit-animation-iteration-count: infinite;
-webkit-animation-direction: normal, normal;
-webkit-animation-timing-function: linear, ease-in;
-webkit-animation-name: spin;
-webkit-animation-duration: 8s;
-moz-animation-iteration-count: infinite;
-moz-animation-direction: normal, normal;
-moz-animation-timing-function: linear, ease-in;
-moz-animation-name: spin;
-moz-animation-duration: 8s;
}
#users li.focus{
-webkit-transition:all 1.0s ease;
-moz-transition:all 1.0s ease;
}
#users li span{
display: block;
font-family: 'Helvetica Neue';
padding: 0.2em 0.5em;
}
#users li span.username{
-moz-border-radius-top-left: 0.3em;
-moz-border-radius-top-right: 0.3em;
-webkit-border-top-left-radius: 0.3em;
-webkit-border-top-right-radius: 0.3em;
background: #00ff00;
border: 0.1em solid #000;
color: #000;
/* font-weight: bold;*/
/* text-shadow: 0 2px 0 #9f9;*/
}
#users li span.ap{
-moz-border-radius-bottom-left: 0.3em;
-moz-border-radius-bottom-right: 0.3em;
-webkit-border-bottom-left-radius: 0.3em;
-webkit-border-bottom-right-radius: 0.3em;
background: #000;
color: #ff1cae;
font-size: -=2;
white-space: nowrap;
/* font-weight: 100;*/
}
.zeroAP {
opacity: 0.5;
}
@-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(-360deg);
}
}
@-moz-keyframes spin {
0% {
-moz-transform: rotate(0deg);
}
100% {
-moz-transform: rotate(-360deg);
}
}
/*
@-webkit-keyframes focus {
from {
left: 0px;
top: 0px;
}
to {
left: 500px;
top: 500px;
}
}
*/
</style>
</head>
<body id="" onload="">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var usersWithAP = new Array();
$(document).ready(function(){
$.getJSON("https://lan.bignetwork.se/index.php?event=wg11&controller=user&action=all&format=json&callback=?", function(users){
$.each(users, function(i, user){
// if (user.ap != 0){
$("<li id=\""+ user.id +"\" class=\"spin " + (user.ap > 0 ? "" : "zeroAP") + "\" style=\"z-index: -" + user.ap + "; font-size:"+ (parseInt(user.ap/100)+11) +"; top:"+ (3+Math.round(Math.random()*80)) +"%; left:"+ Math.round(Math.random()*98) +"%;\">").html("<span class=\"username\">" + user.username + "</span><span class=\"ap\">AP: " + thousandSeparator(user.ap, " ") + "</span>").appendTo("#users");
// Kolla att användarens LI inte är utanför skärmen (på högra sidan):
var outsideWindowX = $('#users > li#' + user.id).position().left + $('#users > li#' + user.id).width() - window.innerWidth + 20;
if (outsideWindowX > 0) {
var newX = $('#users > li#' + user.id).position().left - outsideWindowX - 30;
$('#users > li#' + user.id).css("left", newX + "px");
}
// Kolla att användarens LI inte är utanför skärmen (på nedre sidan):
var outsideWindowY = $('#users > li#' + user.id).position().top + $('#users > li#' + user.id).height() - window.innerHeight + 20;
if (outsideWindowY > 0) {
console.log(user.username + " är utanför");
var newY = $('#users > li#' + user.id).position().top - outsideWindowY - 30;
$('#users > li#' + user.id).css("top", newY + "px");
}
if (user.ap > 0) {
usersWithAP.push(user.id);
}
// }
}); // End each
focusUser(0);
}); // End getJSON
}); // End document.ready
function focusUser(index) {
//knfsdalkfds.stop().animate(sadf);
$("#" + usersWithAP[index]).stop().css("-webkit-animation-iteration-count", "1").css("-moz-animation-iteration-count", "1");//.removeClass("spin").addClass("focus").css("left", "50%");
}
/*
* thousandSeparator (NUMBER n, STRING separator) STRING
* or
* thousandSeparator (String n, STRING sep) STRING
*
* Convert a number to the format xxx,xxx,xxx.xxxx
* Accepts integers, floating point or string
*
* Does not accept exponential notation, etc.
*
* n – the number to be formatted
* sep – the separator character. if skipped, “,” is used
*/
function thousandSeparator(n,sep) {
var sRegExp = new RegExp('(-?[0-9]+)([0-9]{3})'), sValue=n+"";
if (sep === undefined) {
sep=',';
}
while(sRegExp.test(sValue)) {
sValue = sValue.replace(sRegExp, '$1'+sep+'$2');
}
return sValue;
}
</script>
<ul id="users"></ul>
</body>
</html>