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
/
result.html
183 lines (181 loc) · 4.62 KB
/
result.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
---
title: 我的成果2.0
---
<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]
}
if(getQueryString("id") != null) {
$(".result").css("visibility", "visible")
var id = getQueryString("id")
var query = new MW.Query("MwordsResult")
var user = new MW.Query("_User")
var oobject = new Array()
var ouser = new Array()
var unit
var nuidx = new Array()
query.descending("diyhelp")
query.find().then(function(object) {
$(object).each(function(index) {
if(object[index].id == id) {
unit = object[index].get("unit")
}
})
$(object).each(function(index) {
if(object[index].get("unit") != unit) {
nuidx.push(index)
}
})
var i = 0
$(nuidx).each(function(index) {
object.splice(nuidx[index] - i, 1)
i++
})
i = null
$(object).each(function(index) {
if(ouser.indexOf(object[index].get("userid")) < 0) {
ouser.push(object[index].get("userid"))
}
})
user.find().then(function(users) {
$(users).each(function(index) {
$(object).each(function(idx) {
if(object[idx].id == id && object[idx].get("userid") == users[index].id) {
var diyhelp = object[idx].get("diyhelp")
if(diyhelp == 0) {
diyhelp = "全部"
}
$("#result").html("我是" + users[index].get("nickname")
+ " 我的唯一用户名是" + users[index].get("username")
+ " 我在" + object[idx].createdAt.toLocaleString()
+ " 默写了" + unit + "的单词"
+ " 用时" + getMSSTime(object[idx].get("timer"))
+ " 使用提示字数" + diyhelp
+ " 提示了" + object[idx].get("help") + "次")
$("#result2").html("数据更新于" + object[idx].updatedAt.toLocaleString())
$("#result3").html("妥善保管数据ID " + object[idx].id)
}
})
})
$(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))
//return true
}
})
})
oobject.sort(descend)
$(oobject).each(function(idx) {
oobject = oobject.slice(0, 5)
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)
}
})
} else {
$(".search").css("visibility", "visible")
$(".myInput").off("keydown").on("keydown",
function(e) {
if(e.keyCode == 13) {
window.location = "?id=" + $(".myInput").val()
}
})
}
})
</script>
<style type="text/css">
.card {
text-align: center;
border-radius:5px;
box-shadow: 1px 1px 5px #888888;
max-height: 200px;
overflow: auto;
}
.result {
visibility: hidden;
}
.search {
visibility: hidden;
}
.myInput {
height: 33px;
width: 100%;
font-size: 20px;
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);
}
.myInput:focus {
border-bottom: 3px solid #30FF30;
}
</style>
<div class="result">
<div class="card">
<p>排行榜(提示数为先决条件)</p>
<span id="leader"></span>
</div>
<p id="result"></p>
<p id="result2"></p>
<p id="result3"></p>
<a href="/mword/#%E4%BC%A0%E9%80%81%E9%97%A8">我也试一试!</a>
</div>
<div class="search">
<input class="myInput" placeholder="数据ID">
</div>