Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Added comments #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ranker.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
$(document).ready(function() {
// Base URL for DMOJ user info API
var base_url = "https://dmoj.ca/api/user/info/";

// Read users from mcpt.ca/ranks/users.json
$.getJSON("users.json", function(users) {
// Read users from mcpt.ca/ranks/problems.json
$.getJSON("problems.json", function(problems) {
var weight = {};
var points = {};
var weight = {}; // Weight of each problem
var points = {}; // Number of points received by this user for this problem

for(var p = 0; p < problems.length; p++)
for(var p = 0; p < problems.length; p++) // All the added problems
weight[problems[p].code] = problems[p].points;

for(var u = 0; u < users.length; u++) {
var curp = 0;
// Gets the specific user json
$.getJSON(base_url + users[u] + '?format=json', function(info) {
var solved = JSON.parse(info).solved_problems;
for(var s = 0; s < solved.length; s++) {
if(weight.hasOwnProperty(solved[s]))
curp += weight[solved[s]];
}
points[users[u]] = curp;
alert(users[u] + " " + curp);
// alert(users[u] + " " + curp);
});
}
});
Expand Down