app/static/rankoverflow.js
/**
 * User has clicked on "Calculate Rank!"
 */
User has clicked on "Calculate Rank!"
User has clicked on " Calculate Rank! "
function calculateRank() {
    $(".loader").removeClass("hidden");
    $("#rank-status").html("Your ranks are getting calculated, please wait...");
    var siteId = 0;
    var siteName = "";
    var selectedSite = $("#sites").find(":selected").text().trim();
    sites.forEach(function(site) {
        if(selectedSite === site.site_full_name) {
            siteId = site.site_id;
            siteName = site.site_name;
        }
    });
    $(".col-xs-12.card-margin").addClass("hidden");
    var userId = parseInt($("#sites").val());
    fetch(`/api/ranks/${siteName}/${siteId}/${userId}`).then(function(resp){
        return resp.json();
    }).then(function(data) {
        displayRanks("week", data.week.user_rank, data.week.max_page, data.week.last_rank);
        displayRanks("month", data.month.user_rank, data.month.max_page, data.month.last_rank);
        displayRanks("quarter", data.quarter.user_rank, data.quarter.max_page, data.quarter.last_rank);
        displayRanks("year", data.year.user_rank, data.year.max_page, data.year.last_rank);
        displayRanks("alltime", data.alltime.user_rank, data.alltime.max_page, data.alltime.last_rank);
        $("#rank-stats").addClass("hidden");
    }).catch(function(e){console.error(e)});
}
function calculateRank ( ) { $ ( ".loader" ) . removeClass ( "hidden" ) ; $ ( "#rank-status" ) . html ( "Your ranks are getting calculated, please wait..." ) ; var siteId = 0 ; var siteName = "" ; var selectedSite = $ ( "#sites" ) . find ( ":selected" ) . text ( ) . trim ( ) ; sites . forEach ( function ( site ) { if ( selectedSite === site . site_full_name ) { siteId = site . site_id ; siteName = site . site_name ; } } ) ; $ ( ".col-xs-12.card-margin" ) . addClass ( "hidden" ) ; var userId = parseInt ( $ ( "#sites" ) . val ( ) ) ; fetch ( ` ${ siteName } ${ siteId } ${ userId } ` ) . then ( function ( resp ) { return resp . json ( ) ; } ) . then ( function ( data ) { displayRanks ( "week" , data . week . user_rank , data . week . max_page , data . week . last_rank ) ; displayRanks ( "month" , data . month . user_rank , data . month . max_page , data . month . last_rank ) ; displayRanks ( "quarter" , data . quarter . user_rank , data . quarter . max_page , data . quarter . last_rank ) ; displayRanks ( "year" , data . year . user_rank , data . year . max_page , data . year . last_rank ) ; displayRanks ( "alltime" , data . alltime . user_rank , data . alltime . max_page , data . alltime . last_rank ) ; $ ( "#rank-stats" ) . addClass ( "hidden" ) ; } ) . catch ( function ( e ) { console . error ( e ) } ) ; }
User has clicked on "Calculate Rank!"
User has clicked on " Calculate Rank! "
//Show loader and loading image //Clear existing results and get ranks //Read mode from data