X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=roster.js;h=14f1cb46160b04f73e897ba2fa93b137f87d9783;hb=4d2991a8d05b23222912fb904b436af5f4d740c2;hp=3524189a741c799dfb823582504f1a24b60bfcc9;hpb=6326db7bf5bf6b75ae574b2d4c34467e946cde8e;p=ultimatescore diff --git a/roster.js b/roster.js index 3524189..14f1cb4 100644 --- a/roster.js +++ b/roster.js @@ -31,9 +31,19 @@ function load_roster(sheet, cb) "name": name }); } + roster.sort(function(a, b) { + let an = a['number']; + let bn = b['number']; + if (!(parseInt(an) > 0)) an = 1000; + if (!(parseInt(bn) > 0)) bn = 1000; + if (an !== bn) { + return an - bn; + } + return a['name'].localeCompare(b['name']); + }); cb(team_name, roster); }; - req.open('GET', 'https://sheets.googleapis.com/v4/spreadsheets/1VyLIS2GeohLlIRFs6c8kk6g0ZnBFXXiYNh_JROC-iZM/values/\'' + sheet + '\'!A1:J50?key=AIzaSyAuP9yQn8g0bSay6r_RpGtpFeIbwprH1TU'); + req.open('GET', 'https://sheets.googleapis.com/v4/spreadsheets/' + ultimateconfig['roster_sheet_id'] + '/values/\'' + sheet + '\'!A1:J50?key=' + ultimateconfig['api_key']); req.send(); };