(function() { var mapset = {}; setData.ChildrenBeatmaps.forEach(function(diff) { mapset[diff.BeatmapID] = diff; }); console.log(mapset); function loadLeaderboard(b, m) { var wl = window.location; window.history.replaceState('', document.title, "/b/" + b + "?mode=" + m + wl.hash); api("scores?sort=score,desc&sort=id,asc", { mode : m, b : b, p : 1, l : 50, }, function(data) { console.log(data); var tb = $(".ui.table tbody"); tb.find("tr").remove(); if (data.scores == null) { data.scores = []; } var i = 0; data.scores.sort(function(a, b) { return b.score - a.score; }); data.scores.forEach(function(score) { var user = score.user; tb.append($("").append( $("") .text("#" + ((page - 1) * 50 + i)), $("").html("" + escapeHTML(user.username) + ""), $("") .html(addCommas(score.score)), $("").html(getScoreMods(score.mods, true)), $("") .text(score.accuracy.toFixed(2) + "%"), $("") .text(addCommas(score.max_combo)), $("") .html(score.pp.toFixed(2)))); }); }); } function changeDifficulty(bid) { // load info var diff = mapset[bid]; // column 2 $("#cs").html(diff.CS); $("#hp").html(diff.HP); $("#od").html(diff.OD); $("#passcount").html(addCommas(diff.Passcount)); $("#playcount").html(addCommas(diff.Playcount)); // column 3 $("#ar").html(diff.AR); $("#stars").html(diff.DifficultyRating.toFixed(2)); $("#length").html(timeFormat(diff.TotalLength)); $("#drainLength").html(timeFormat(diff.HitLength)); $("#bpm").html(diff.BPM); // hide mode for non-std maps console.log("favMode", favMode); if (diff.Mode != 0) { currentMode = (currentModeChanged ? currentMode : favMode); $("#mode-menu").hide(); } else { currentMode = diff.Mode; $("#mode-menu").show(); } // update mode menu $("#mode-menu .active.item").removeClass("active"); $("#mode-" + currentMode).addClass("active"); loadLeaderboard(bid, currentMode); } window.loadLeaderboard = loadLeaderboard; window.changeDifficulty = changeDifficulty; changeDifficulty(beatmapID); // loadLeaderboard(beatmapID, currentMode); $("#diff-menu .item") .click(function(e) { e.preventDefault(); $(this).addClass("active"); beatmapID = $(this).data("bid"); changeDifficulty(beatmapID); }); $("#mode-menu .item") .click(function(e) { e.preventDefault(); $("#mode-menu .active.item").removeClass("active"); $(this).addClass("active"); currentMode = $(this).data("mode"); loadLeaderboard(beatmapID, currentMode); currentModeChanged = true; }); $("table.sortable").tablesort(); })();