-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheteng.js
41 lines (36 loc) · 893 Bytes
/
eteng.js
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
var uploadUrl = '//192.168.0.177:3001/api/score';
var rankUrl = '//192.168.0.177:3001/api/rank';
window.eteng = {
uploadScore: uploadScore,
getRank: getRank
};
function uploadScore(score) {
var openID = getOpenID();
return $.ajax({
method: 'PUT',
url: uploadUrl,
contentType: 'application/json',
data: JSON.stringify({
score: score,
openid: openID
})
});
}
function getRank() {
var openID = getOpenID();
return $.ajax({
url: rankUrl,
data: {
openid: openID
}
});
}
function getOpenID() {
return getParameterByName('openid');
}
function getParameterByName(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(window.location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}