-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathload.js
More file actions
40 lines (36 loc) · 1.29 KB
/
load.js
File metadata and controls
40 lines (36 loc) · 1.29 KB
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
function loadJSON(callback) {
var xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json");
xobj.open('GET', './ranking.json', true);
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") {
callback(xobj.responseText);
}
};
xobj.send(null);
}
loadJSON(function(response) {
var data = JSON.parse(response);
var table = document.getElementById('rank');
var limit = (data.length > 100) ? 100 : data.length;
for(var i=0; i<limit; i++) {
var row = table.insertRow(i+1)
var c0 = row.insertCell(0);
var c1 = row.insertCell(1);
var c2 = row.insertCell(2);
var c3 = row.insertCell(3);
var c4 = row.insertCell(4);
var c5 = row.insertCell(5);
c0.innerText = data[i].num
c1.innerText = data[i].rank
c2.innerText = data[i].author
c3.innerText = data[i].total
c4.innerHTML = String(data[i].recent).concat(' ')
c5.innerHTML = String(' ').concat(data[i].affiliation)
// Style
c0.setAttribute("class", "numer1");
c1.setAttribute("class", "numer1");
c3.setAttribute("class", "numer2");
c4.setAttribute("class", "numer2");
}
});