$(document).ready(function() { // Antagelser: // 1. Alle rækker der selectes har A=1 // 2. Status-kolonnen er den sidste inden aktiviteterne var hiddenColumns = ["1", "Medlemmer", "Klasse", "Maaltid", "Ventetid", "Straf", "Statussort", "Sortering", "RegTid"]; var hideActivities = false; var level = "Fighter"; var series = "Alle"; var url = ""; var seriesClause = ""; $("#level li a").click(function(event) { $("#level li").removeClass("active"); $(this).parent().addClass("active"); level = $(this).text(); setFilter(); loadData(); }); $("#series label input").click(function(event) { series = $(this).val(); setFilter(); loadData(); }); function setFilter() { $("#scoreboard").css('min-height', 0); if(series == "Alle") { seriesClause = ""; } if(series == "Mix") { seriesClause = " and G=\"Mix\""; } if(series == "Herre") { seriesClause = " and G=\"Herre\""; } if(series == "Dame") { seriesClause = " and G=\"Dame\""; } // if(level == "Master") { // query = "select A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P where A=1" + seriesClause + " order by M,N,K,O"; // url = "https://docs.google.com/spreadsheets/d/1SODTiABbqTuRsvEG1BTFqTWN_RzTEFINDd00UehzFqQ/edit#gid=1498148972"; // } if(level == "Challenge") { query = "select A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R where A=1" + seriesClause + " order by M,N desc,K,O"; url = "https://docs.google.com/spreadsheets/d/18EtIySzS2hqi7jmlX8VII5YK33VuSGYlsBaUw75GYrM/edit#gid=900054975"; } if(level == "Fighter") { query = "select A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z where A=1" + seriesClause + " order by M,K,O"; url = "https://docs.google.com/spreadsheets/d/18EtIySzS2hqi7jmlX8VII5YK33VuSGYlsBaUw75GYrM/edit#gid=1084680271"; } } setFilter(); loadData(); var refreshInterval = 180 * 1000; setInterval(function() { $("#scoreboard").css('min-height', $("#scoreboard").height()); loadData(); }, refreshInterval); function loadData() { //console.log(url); $('#scoreboardHidden').html(""); // remove old data $('#scoreboardHidden').sheetrock({ url: url, query: query, resetStatus: true, callback: function (error, options, response) { if(error == null) { $('#scoreboard').html( $('#scoreboardHidden').html() ); var activitiesStartColumn; var activitiesEndColumn; var teamNameColumn; var teamMembersColumn; var statusColumn; var statusSortColumn; var timeColumn; // Loop table header $("#scoreboard thead tr th").each(function(index, elem) { var columnHeader = $(elem).text(); if(columnHeader == "Holdnr") { //$("#scoreboard th:nth-child(" + (index+1) + ")").html(""); } if(columnHeader == "Holdnavn") { teamNameColumn = index+1; } if(columnHeader == "Medlemmer") { teamMembersColumn = index+1; } if(columnHeader == "Status") { $("#scoreboard th:nth-child(" + (index+1) + "), #scoreboard td:nth-child(" + (index+1) + ")").addClass("status"); statusColumn = index+1; activitiesStartColumn = index+2; } if(columnHeader == "Statussort") { statusSortColumn = index+1; } if(columnHeader == "Tid") { timeColumn = index+1; } // Hide column if in array if(hiddenColumns.indexOf(columnHeader) >= 0) { $("#scoreboard th:nth-child(" + (index+1) + "), #scoreboard td:nth-child(" + (index+1) + ")").hide(); } activitiesEndColumn = index; }); for(var i = activitiesStartColumn; i <= activitiesEndColumn; i++) { // Center activity header text $("#scoreboard th:nth-child(" + (i) + ")").addClass("text-center"); if(hideActivities) { $("#scoreboard thead tr").find("th:nth-child(" + i + ")").hide(); } } // Add overall number column $("#scoreboard thead tr").prepend("