]> git.sesse.net Git - ultimatescore/commitdiff
Make tournament title and sheet IDs configurable on a separate file.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 25 Feb 2019 21:20:54 +0000 (22:20 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 25 Feb 2019 22:05:52 +0000 (23:05 +0100)
carousel.js
config.js [new file with mode: 0644]
quickhelp.html
quickl3.js
roster.js
score.html
update_sheets.js

index 0a3d707e641d0b2a39e4eece0ef1c020b3e8340f..b5bf8e294ee80b01d1a8368ee766714536def05c 100644 (file)
@@ -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<br />" + group_name);
+       addheading(carousel, 5, "Current standings, " + ultimateconfig['tournament_title'] + "<br />" + 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<br />" + covered_days.join('/') + " (all times CET)");
+       addheading(carousel, 3, "Stream schedule, " + ultimateconfig['tournament_title'] + "<br />" + 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 (file)
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'
+};
index d6aa4177f43b4b8a4c2f322046b4874a3b56d7bb..1d1653a0499c82025e5e1d31c423ddc67b472435 100644 (file)
@@ -55,6 +55,7 @@
     <h1 id="callsheading">Calls</h1>
     <ul id="calls">
     </ul>
+<script src="config.js" type="text/javascript"></script>
 <script src="quickhelp.js" type="text/javascript"></script>
   </body>
 </html>
index ffb20bd48cb2e67b9ea69ddaa4f90083beb5b6d3..325df7d7d4e48a07352e38f36242c97cc7483eea 100644 (file)
@@ -28,7 +28,7 @@ function load_l3(sheet, prefix, cb)
                        text = text.replace(/\n/, '<br />');
                        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();
 };
 
index c8cd2e3a5f823275176f6d76762deea46465a579..638b37337f2e238db604048642fb19355500c319 100644 (file)
--- 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();
 };
 
index 3985d78fc62bb5d99ed70fbd1345aafd244aca95..f3b6350d8c5191c1153569b103d8d6dbd973a658 100644 (file)
@@ -93,6 +93,7 @@
 
 <script src="jsrsasign-all-min.js" type="text/javascript"></script>
 
+<script src="config.js" type="text/javascript"></script>
 <script src="carousel.js" type="text/javascript"></script>
 <script src="score.js" type="text/javascript"></script>
 <script src="quickl3.js" type="text/javascript"></script>
index 68797088ea476f16ecc23ae75944199c222ddef0..e1df3a0ff5f367c92bb73684551d24e7e3d45a3e 100644 (file)
@@ -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);
                });
 
        });