This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lb.html
149 lines (145 loc) · 3.61 KB
/
lb.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
---
title: 排行榜
---
<script type="text/javascript" src="/jquery.js"></script>
<script type="text/javascript">
$(function() {
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)")
var r = window.location.search.substr(1).match(reg)
if(r != null) {
return decodeURI(r[2])
}
}
function getMSSTime(s) {
var timeresultM = 0, timeresultS = 0
while(s >= 60) {
s = s - 60
timeresultM++
}
if(s < 10) {
timeresultS = "0" + s
} else if(s >= 10) {
timeresultS = s
}
return timeresultM + ":" + timeresultS
}
function descend(x, y){
return y[1] - x[1]
}
function init(unit) {
$("#leader").html("")
$(".result").css("visibility", "visible")
var query = new MW.Query("MwordsResult")
var user = new MW.Query("_User")
var oobject = new Array()
var ouser = new Array()
query.descending("diyhelp")
query.equalTo("unit", unit)
query.find().then(function(object) {
$(object).each(function(index) {
if(ouser.indexOf(object[index].get("userid")) < 0) {
ouser.push(object[index].get("userid"))
}
})
user.find().then(function(users) {
$(ouser).each(function(index) {
$(users).each(function(indx) {
if(users[indx].id == ouser[index]) {
var speed = new Array()
var username = users[indx].get("username")
$(object).each(function(idx) {
if(object[idx].get("userid") == users[indx].id) {
speed.push(object[idx].get("speed"))
}
})
speed.sort()
speed.reverse()
speed = speed.slice(0, 1)
oobject.push(new Array(username, speed))
}
})
})
oobject.sort(descend)
$(oobject).each(function(idx) {
if (idx == oobject.length - 1) {
$("#leader").html($("#leader").html() + oobject[idx][0] + " " + oobject[idx][1] + "个单词/秒")
} else {
$("#leader").html($("#leader").html() + oobject[idx][0] + " " + oobject[idx][1] + "个单词/秒<br />")
}
})
}, function(e) {
switch(e.code) {
case 429:
alert("请求超限 请过一会再试")
break
default:
alert("错误:" + e)
}
})
}, function(e) {
switch(e.code) {
case 429:
alert("请求超限 请过一会再试")
break
default:
alert("错误:" + e)
}
})
}
$("#unit").off("change").on("change",
function() {
init($("#unit").val())
})
init("7b_u1")
})
</script>
<style type="text/css">
.card {
text-align: center;
border-radius: 5px;
box-shadow: 1px 1px 5px #888888;
}
.myInput {
margin-bottom: 5px;
transition: 0.5s;
outline: none;
text-align: center;
border-bottom: 2px solid #EEEEEE;
border-top: none;
border-left: none;
border-right: none;
background-color: rgba(0, 0, 0, 0);
width: 100%;
}
.myInput:focus {
border-bottom: 3px solid #FF7070;
}
.select {
outline: none;
text-align: center;
border-top: none;
border-left: none;
border-right: none;
border-bottom: 2px solid #FF7070;
background-color: rgba(0, 0, 0, 0);
}
</style>
<div style="text-align: center;">
<select class="select" id="unit" style="margin-bottom: 2px">
<option value="7b_u1">Unit 1</option>
<option value="7b_u2">Unit 2</option>
<option value="7b_u3">Unit 3</option>
<option value="7b_u4">Unit 4</option>
<option value="7b_u5">Unit 5</option>
<option value="7b_u6">Unit 6</option>
<option value="7b_u7">Unit 7</option>
<option value="7b_u8">Unit 8</option>
<option value="test">测试</option>
</select>
<div class="card">
<p>提示数为先决条件</p>
<span id="leader"></span>
</div>
<a href="/mword/#%E4%BC%A0%E9%80%81%E9%97%A8">我也试一试!</a>
</div>