From a78e18d53f4c00fbcb424144b53afc6c064a7d94 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 25 Feb 2019 22:20:54 +0100 Subject: [PATCH] Make tournament title and sheet IDs configurable on a separate file. --- carousel.js | 8 ++++---- config.js | 10 ++++++++++ quickhelp.html | 1 + quickl3.js | 4 ++-- roster.js | 2 +- score.html | 1 + update_sheets.js | 2 +- 7 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 config.js diff --git a/carousel.js b/carousel.js index 0a3d707..b5bf8e2 100644 --- a/carousel.js +++ b/carousel.js @@ -391,7 +391,7 @@ function display_group_parsed(teams, games, group_name) let carousel = document.getElementById('carousel'); clear_carousel(carousel); - addheading(carousel, 5, "Current standings, Trøndisk 2018
" + group_name); + addheading(carousel, 5, "Current standings, " + ultimateconfig['tournament_title'] + "
" + group_name); let tr = document.createElement("tr"); tr.className = "subfooter"; addth(tr, "rank", ""); @@ -427,7 +427,7 @@ function display_group_parsed(teams, games, group_name) let footer_tr = document.createElement("tr"); footer_tr.className = "footer"; let td = document.createElement("td"); - td.appendChild(document.createTextNode("www.trondheimfrisbeeklubb.no | #trøndisk")); + td.appendChild(document.createTextNode(ultimateconfig['tournament_footer'])); td.setAttribute("colspan", "5"); footer_tr.appendChild(td); carousel.appendChild(footer_tr); @@ -541,7 +541,7 @@ function display_stream_schedule_parsed(teams, games, page) { let carousel = document.getElementById('carousel'); clear_carousel(carousel); - addheading(carousel, 3, "Stream schedule, Trøndisk 2018
" + covered_days.join('/') + " (all times CET)"); + addheading(carousel, 3, "Stream schedule, " + ultimateconfig['tournament_title'] + "
" + covered_days.join('/') + " (all times CET)"); let teams_to_idx = make_teams_to_idx(teams); row_num = 0; @@ -581,7 +581,7 @@ function get_group(group_name, cb) req.onload = function(e) { cb(JSON.parse(req.responseText), group_name); }; - req.open('GET', 'https://sheets.googleapis.com/v4/spreadsheets/1DSRRcV6d6Dx9KbCZgOSFF0MX9wKRex9nHcUjjOG4DNE/values/\'' + group_name + '\'!A1:J50?key=AIzaSyAuP9yQn8g0bSay6r_RpGtpFeIbwprH1TU'); + req.open('GET', 'https://sheets.googleapis.com/v4/spreadsheets/' + ultimateconfig['score_sheet_id'] + '/values/\'' + group_name + '\'!A1:J50?key=' + ultimateconfig['api_key']); req.send(); } diff --git a/config.js b/config.js new file mode 100644 index 0000000..b6b675f --- /dev/null +++ b/config.js @@ -0,0 +1,10 @@ +var ultimateconfig = { + 'tournament_title': 'Battle of Oak Hill 2019', + 'tournament_footer': 'ekebergsk.com | #us4', + + // Share both sheets with ultimate-nm-2018@solskogen-cubemap.iam.gserviceaccount.com. + 'score_sheet_id': '1DSRRcV6d6Dx9KbCZgOSFF0MX9wKRex9nHcUjjOG4DNE', + 'roster_sheet_id': '1Mp6sWSxxvRl3YCCx4-RPlnCyuzkgNbJW1iCHnsH-9Ks', + + 'api_key': 'AIzaSyAuP9yQn8g0bSay6r_RpGtpFeIbwprH1TU' +}; diff --git a/quickhelp.html b/quickhelp.html index d6aa417..1d1653a 100644 --- a/quickhelp.html +++ b/quickhelp.html @@ -55,6 +55,7 @@

Calls

+ diff --git a/quickl3.js b/quickl3.js index ffb20bd..325df7d 100644 --- a/quickl3.js +++ b/quickl3.js @@ -28,7 +28,7 @@ function load_l3(sheet, prefix, cb) text = text.replace(/\n/, '
'); let subtext = response.values[i][3]; if (subtext === undefined || subtext === '') { - subtext = 'Trøndisk 2018'; + subtext = ultimateconfig['tournament_title']; } l3s[prefix + number] = { @@ -43,7 +43,7 @@ function load_l3(sheet, prefix, cb) } cb(l3s, sheet); }; - req.open('GET', 'https://sheets.googleapis.com/v4/spreadsheets/1Mp6sWSxxvRl3YCCx4-RPlnCyuzkgNbJW1iCHnsH-9Ks/values/\'' + sheet + '\'!A1:J50?key=AIzaSyAuP9yQn8g0bSay6r_RpGtpFeIbwprH1TU'); + req.open('GET', 'https://sheets.googleapis.com/v4/spreadsheets/' + ultimateconfig['score_sheet_id'] + '/values/\'' + sheet + '\'!A1:J50?key=' + ultimateconfig['api_key']); req.send(); }; diff --git a/roster.js b/roster.js index c8cd2e3..638b373 100644 --- a/roster.js +++ b/roster.js @@ -33,7 +33,7 @@ function load_roster(sheet, cb) } cb(team_name, roster); }; - req.open('GET', 'https://sheets.googleapis.com/v4/spreadsheets/1Mp6sWSxxvRl3YCCx4-RPlnCyuzkgNbJW1iCHnsH-9Ks/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(); }; diff --git a/score.html b/score.html index 3985d78..f3b6350 100644 --- a/score.html +++ b/score.html @@ -93,6 +93,7 @@ + diff --git a/update_sheets.js b/update_sheets.js index 6879708..e1df3a0 100644 --- a/update_sheets.js +++ b/update_sheets.js @@ -104,7 +104,7 @@ function publish_group_rank(group_name) "data": updates }; possibly_update_oauth_key(function() { - post_json('https://sheets.googleapis.com/v4/spreadsheets/1DSRRcV6d6Dx9KbCZgOSFF0MX9wKRex9nHcUjjOG4DNE/values:batchUpdate?key=AIzaSyAuP9yQn8g0bSay6r_RpGtpFeIbwprH1TU', json, function(response) {}, current_oauth_access_token); + post_json('https://sheets.googleapis.com/v4/spreadsheets/' + ultimateconfig['score_sheet_id'] + '/values:batchUpdate?key=' + ultimateconfig['api_key'], json, function(response) {}, current_oauth_access_token); }); }); -- 2.39.2