Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name ELTP Live In Game F11 (new layout)
- // @version 1.2.1
- // @include http://*.koalabeast.com*
- // @include http://maptest*.newcompte.fr*
- // @author RonSpawnson and modified by Chuck_Finley
- // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
- // @grant GM_addStyle
- // ==/UserScript==
- /*jshint multistr:true*/
- if (!tagpro.group.socket) return;
- var scoreFontSize = "40px";
- var timerFontSize = "35px";
- var teamFontSize = "30px";
- function waitForInitialized(fn) {
- if (!tagpro) {
- setTimeout(function() {
- waitForInitialized(fn);
- }, 10);
- } else {
- fn();
- }
- }
- waitForInitialized(function() {
- tagpro.ready(function() {
- hideElements();
- var redTeamScore = 0;
- var blueTeamScore = 0;
- var redTeamName = $.cookie("redTeamName");
- var blueTeamName = $.cookie("blueTeamName");
- var g1aggregateRedScore = $.cookie("g1aggregate.RedScore");
- var g2aggregateRedScore = $.cookie("g2aggregate.RedScore");
- var g1aggregateBlueScore = $.cookie("g1aggregate.BlueScore");
- var g2aggregateBlueScore = $.cookie("g2aggregate.BlueScore");
- var halfIndicator = "http://i.imgur.com/5PiE5Vt.png";
- var halfIndicator2 = "http://i.imgur.com/aVKc7jA.png";
- var halfIndicator3 = "http://i.imgur.com/5B0hZpm.png";
- var halfIndicator4 = "http://i.imgur.com/stBbV9A.png";
- var halfIndicator5 = "http://i.imgur.com/8lThKal.png";
- var halfIndicator6 = "http://i.imgur.com/uUxBdWV.png";
- var goldenCap = "http://i.imgur.com/pDgOUvz.png";
- var overtime = "http://i.imgur.com/MPw9Ozj.png";
- var game1Indicator = "http://i.imgur.com/lkTQudy.png";
- var game2Indicator = "http://i.imgur.com/g4jrSHg.png";
- var game1_2Indicator = "http://i.imgur.com/kExyhcF.png";
- var game1IndicatorInverted = "http://i.imgur.com/nvKeXiO.png";
- var game2IndicatorInverted = "http://i.imgur.com/owjAyXQ.png";
- var game1_2IndicatorInverted = "http://i.imgur.com/66j6qIV.png";
- var game1HalfIndicator = "http://i.imgur.com/uGRiQva.png";
- var game2HalfIndicator = "http://i.imgur.com/an1Lonn.png";
- var game1_2HalfIndicator = "http://i.imgur.com/rtGAFq3.png";
- var scoreboardBanner = "http://i.imgur.com/tmk0Fkr.png";
- var scoreboardBannerInverted = "http://i.imgur.com/bZt5ozA.png";
- //Canvas
- var canvasWidth = 1280;
- var canvasHeight = 800;
- var canvasLeft = 180;//320//80
- var canvasTop = -654.5;//298.5 (bot)//-672.5 (top without halfindication)
- //Scoreboard
- var scoreboardWidth = 486;
- var scoreboardHeight = 103;
- var scoreboardBotPos = 20;
- var scoreboardLineHeight = 32;//36
- var scoreboardTop = canvasTop + (canvasHeight-(scoreboardBotPos+scoreboardHeight));
- var scoreboardLeft = canvasLeft /*+ (0.5*canvasWidth-0.5*scoreboardWidth)*/;
- //Scores
- var scoreWidth = 50;
- var redScoreTopPos = 16;
- var blueScoreTopPos = 56;
- var redScoreLeftPos = 100;
- var blueScoreLeftPos = 100;
- var game1LeftPos= -80;
- var game2LeftPos= -140;
- var game1TopPos = 10;
- var game2TopPos = 10;
- var game1Height = 83;
- var game2Height = 83;
- var game1LineHeight = 42;
- var game2LineHeight = 42;
- var gameScoreWidth = 81;
- var game1HalfHeight = 112;
- var game2HalfHeight = 112;
- var game1HalfTopPos = -19;
- var game2HalfTopPos = -19;
- var redScoreTop = scoreboardTop + redScoreTopPos;
- var blueScoreTop = scoreboardTop + blueScoreTopPos;
- var redScoreLeft = scoreboardLeft + redScoreLeftPos;
- var blueScoreLeft = scoreboardLeft + blueScoreLeftPos;
- var game1Left = scoreboardLeft + game1LeftPos;
- var game2Left = scoreboardLeft + game2LeftPos;
- var game1ScoreTop = scoreboardTop + game1TopPos;
- var game2ScoreTop = scoreboardTop + game2TopPos;
- var game1HalfScoreTop = scoreboardTop + game1HalfTopPos;
- var game2HalfScoreTop = scoreboardTop + game2HalfTopPos;
- //Teams
- var teamWidth = 340;
- var redTeamTopPos = 16;
- var blueTeamTopPos = 56;
- var redTeamLeftPos = 148;
- var blueTeamLeftPos = 148;
- var redTeamTop = scoreboardTop + redTeamTopPos;
- var blueTeamTop = scoreboardTop + blueTeamTopPos;
- var redTeamLeft = scoreboardLeft + redTeamLeftPos;
- var blueTeamLeft = scoreboardLeft + blueTeamLeftPos;
- //Timer
- var timerWidth = 96;
- var timerTopPos = 34;
- var timerLeftPos = 5;
- var timerTop = scoreboardTop + timerTopPos;
- var timerLeft = scoreboardLeft + timerLeftPos;
- //Half Indicators
- var indicatorWidth = 197;
- var indicatorHeight = 35;
- var indicatorTopPos = -22;
- var indicator1LeftPos = 52;
- var indicator2LeftPos = 52;
- var indicator3LeftPos = 52;
- var indicator4LeftPos = 52;
- var indicator5LeftPos = 52;
- var indicator6LeftPos = 52;
- var indicatorTop = scoreboardTop + indicatorTopPos;
- var indicator1Left = scoreboardLeft + indicator1LeftPos;
- var indicator2Left = scoreboardLeft + indicator2LeftPos;
- var indicator3Left = scoreboardLeft + indicator3LeftPos;
- var indicator4Left = scoreboardLeft + indicator4LeftPos;
- var indicator5Left = scoreboardLeft + indicator5LeftPos;
- var indicator6Left = scoreboardLeft + indicator6LeftPos;
- //Score and Team Text
- var redFontElement = createFontElement(0, scoreFontSize);
- var blueFontElement = createFontElement(0, scoreFontSize);
- var redTeamFontElement = createFontElement(redTeamName, teamFontSize);
- var blueTeamFontElement = createFontElement(blueTeamName, teamFontSize);
- var g1Red = createFontElement(g1aggregateRedScore, teamFontSize);
- var g2Red = createFontElement(g2aggregateRedScore, teamFontSize);
- var g1Blue = createFontElement(g1aggregateBlueScore, teamFontSize);
- var g2Blue = createFontElement(g2aggregateBlueScore, teamFontSize);
- var selectedHalf = "";
- var domain = ".koalabeast.com";
- //var domain = ".newcompte.fr";
- GM_addStyle(
- 'body {margin-bottom: 0px;}' +
- 'a#exit{position:fixed; top:0px;}'
- );
- var element = document.getElementById("loadingMessage");
- var newElement = '<div id="scoreboardBannerInvertedOT" style="position:absolute; left:'+ scoreboardLeft + 'px; top:'+ scoreboardTop + 'px;"> \
- <img src="'+ scoreboardBannerInverted + '" \> \
- </div> \
- <div id="scoreboardBannerInverted" style="position:absolute; left:'+ scoreboardLeft + 'px; top:'+ scoreboardTop + 'px;"> \
- <img src="'+ scoreboardBannerInverted + '" \> \
- </div> \
- <div id="scoreboardBanner" style="position:absolute; left:'+ scoreboardLeft + 'px; top:'+ scoreboardTop + 'px;"> \
- <img src="'+ scoreboardBanner + '" \> \
- </div> \
- <div id="redScore" style="position:absolute; top:'+ redScoreTop + 'px; left:'+ redScoreLeft + 'px; width:'+ scoreWidth + 'px; height:'+ scoreboardLineHeight + 'px; line-height:'+ scoreboardLineHeight + 'px"> \
- ' + redFontElement + ' \
- </div> \
- <div id="blueScore" style="position:absolute; top:'+ blueScoreTop + 'px; left:'+ blueScoreLeft + 'px; width:'+ scoreWidth + 'px; height:'+ scoreboardLineHeight + 'px; line-height:'+ scoreboardLineHeight + 'px"> \
- ' + blueFontElement + ' \
- </div> \
- <div id="redTeam" style="position:absolute; top:'+ redTeamTop + 'px; left:'+ redTeamLeft + 'px; width:'+ teamWidth + 'px; height:'+ scoreboardLineHeight + 'px; line-height:'+ scoreboardLineHeight + 'px;"> \
- ' + redTeamFontElement + ' \
- </div> \
- <div id="blueTeam" style="position:absolute; top:'+ blueTeamTop + 'px; left:'+ blueTeamLeft + 'px; width:'+ teamWidth + 'px; height:'+ scoreboardLineHeight + 'px; line-height:'+ scoreboardLineHeight + 'px"> \
- ' + blueTeamFontElement + ' \
- </div> \
- <div id="timer" style="position:absolute; top:'+ timerTop + 'px; left:'+ timerLeft + 'px; width:' + timerWidth + 'px; height:' + scoreboardLineHeight + 'px; line-height:' + scoreboardLineHeight + 'px"> \
- 12:00 \
- </div> \
- <div id="gameScoresHalf3" style="display:none; position:absolute; top:'+ game1HalfScoreTop + 'px; left:'+ game1Left + 'px; width:' + gameScoreWidth + 'px; height:' + game1HalfHeight + 'px; line-height:' + game1LineHeight + 'px; background-image: url(' + game1HalfIndicator + ')"> \
- </div> \
- <div id="gameScoresHalf4" style="display:none; position:absolute; top:'+ game2HalfScoreTop + 'px; left:'+ game2Left + 'px; width:' + gameScoreWidth + 'px; height:' + game2HalfHeight + 'px; line-height:' + game2LineHeight + 'px; background-image: url(' + game1_2HalfIndicator + ')"> \
- </div> \
- <div id="gameScoresHalf5" style="display:none; position:absolute; top:'+ game1HalfScoreTop + 'px; left:'+ game1Left + 'px; width:' + gameScoreWidth + 'px; height:' + game1HalfHeight + 'px; line-height:' + game1LineHeight + 'px; background-image: url(' + game2HalfIndicator + ')"> \
- </div> \
- <div id="gameScores3Invert" style="display:none; position:absolute; top:'+ game1ScoreTop + 'px; left:'+ game1Left + 'px; width:' + gameScoreWidth + 'px; height:' + game1Height + 'px; line-height:' + game1LineHeight + 'px; background-image: url(' + game1Indicator + ')"> \
- '+ g1Blue + g1Red + ' \
- </div> \
- <div id="gameScores3" style="display:none; position:absolute; top:'+ game1ScoreTop + 'px; left:'+ game1Left + 'px; width:' + gameScoreWidth + 'px; height:' + game1Height + 'px; line-height:' + game1LineHeight + 'px; background-image: url(' + game1Indicator + ')"> \
- '+ g1Red + g1Blue + ' \
- </div> \
- <div id="gameScores4Invert" style="display:none; position:absolute; top:'+ game2ScoreTop + 'px; left:'+ game2Left + 'px; width:' + gameScoreWidth + 'px; height:' + game2Height + 'px; line-height:' + game2LineHeight + 'px; background-image: url(' + game1_2Indicator + ')"> \
- '+ g1Blue + g1Red + ' \
- </div> \
- <div id="gameScores4" style="display:none; position:absolute; top:'+ game2ScoreTop + 'px; left:'+ game2Left + 'px; width:' + gameScoreWidth + 'px; height:' + game2Height + 'px; line-height:' + game2LineHeight + 'px; background-image: url(' + game1_2Indicator + ')"> \
- ' + g1Red + g1Blue + ' \
- </div> \
- <div id="gameScores5Invert" style="display:none; position:absolute; top:'+ game1ScoreTop + 'px; left:'+ game1Left + 'px; width:' + gameScoreWidth + 'px; height:' + game1Height + 'px; line-height:' + game1LineHeight + 'px; background-image: url(' + game2Indicator + ')"> \
- '+ g2Blue + g2Red + ' \
- </div> \
- <div id="gameScores5" style="display:none; position:absolute; top:'+ game1ScoreTop + 'px; left:'+ game1Left + 'px; width:' + gameScoreWidth + 'px; height:' + game1Height + 'px; line-height:' + game1LineHeight + 'px; background-image: url(' + game2Indicator + ')"> \
- ' + g2Red + g2Blue + ' \
- </div> \
- <div id="halfIndicator1" style="display:none; position:absolute; top:'+ indicatorTop + 'px; left:'+ indicator1Left + 'px; width:' + indicatorWidth + 'px; height:' + indicatorHeight + 'px; background-image: url(' + halfIndicator + ')"> \
- </div> \
- <div id="halfIndicator2" style="display:none; position:absolute; top:'+ indicatorTop + 'px; left:'+ indicator2Left + 'px; width:' + indicatorWidth + 'px; height:' + indicatorHeight + 'px; background-image: url(' + halfIndicator2 + ')"> \
- </div> \
- <div id="halfIndicator3" style="display:none; position:absolute; top:'+ indicatorTop + 'px; left:'+ indicator3Left + 'px; width:' + indicatorWidth + 'px; height:' + indicatorHeight + 'px; background-image: url(' + halfIndicator3 + ')"> \
- </div> \
- <div id="halfIndicator4" style="display:none; position:absolute; top:'+ indicatorTop + 'px; left:'+ indicator4Left + 'px; width:' + indicatorWidth + 'px; height:' + indicatorHeight + 'px; background-image: url(' + halfIndicator4 + ')"> \
- </div> \
- <div id="halfIndicator5" style="display:none; position:absolute; top:'+ indicatorTop + 'px; left:'+ indicator5Left + 'px; width:' + indicatorWidth + 'px; height:' + indicatorHeight + 'px; background-image: url(' + halfIndicator5 + ')"> \
- </div> \
- <div id="halfIndicator6" style="display:none; position:absolute; top:'+ indicatorTop + 'px; left:'+ indicator6Left + 'px; width:' + indicatorWidth + 'px; height:' + indicatorHeight + 'px; background-image: url(' + halfIndicator6 + ')"> \
- </div> \
- <div id="halfIndicator7" style="display:none; position:absolute; top:'+ indicatorTop + 'px; left:'+ indicator6Left + 'px; width:' + indicatorWidth + 'px; height:' + indicatorHeight + 'px; background-image: url(' + overtime + ')"> \
- </div> \
- <div id="halfIndicator8" style="display:none; position:absolute; top:'+ indicatorTop + 'px; left:'+ indicator6Left + 'px; width:' + indicatorWidth + 'px; height:' + indicatorHeight + 'px; background-image: url(' + goldenCap + ')"> \
- </div>';
- element.insertAdjacentHTML('afterend', newElement);
- //element = document.getElementsByTagName('head');
- //newElement = "<link href='http://fonts.googleapis.com/css?family=//Play' rel='stylesheet' type='text/css'>";
- //element[0].insertAdjacentHTML('afterend', newElement);
- addHalfSelection();
- createFirstHalfOffsetSection();
- setupFirstHalfOffsetOverrideListeners();
- createTimeoutOffsetSection();
- createTeamNameSwitchButton();
- setupTimeoutOffsetOverrideListeners();
- setupOnScoreFunction();
- // update timer text
- requestAnimationFrame(function updateTimerText() {
- requestAnimationFrame(updateTimerText);
- updateTimer();
- });
- //hide UI Flags
- setTimeout(function() {
- tagpro.ui.sprites.redFlag.alpha = 0;
- tagpro.ui.sprites.blueFlag.alpha = 0;
- tagpro.ui.sprites.yellowFlagTakenByRed.alpha = 0;
- tagpro.ui.sprites.yellowFlagTakenByBlue.alpha = 0;
- }, 1000);
- function hideSpectatorInfo1() {
- if (tagpro.ui.sprites.spectatorInfo1 !== undefined) {
- setTimeout(function() {tagpro.ui.sprites.spectatorInfo1.visible = false;}, 0);
- } else {
- setTimeout(hideSpectatorInfo1, 200);
- }
- }
- function hideSpectatorInfo2() {
- if (tagpro.ui.sprites.spectatorInfo2 !== undefined) {
- setTimeout(function() {tagpro.ui.sprites.spectatorInfo2.visible = false;}, 0);
- } else {
- setTimeout(hideSpectatorInfo2, 200);
- }
- }
- function hideRedScore() {
- if (tagpro.ui.sprites.redScore !== undefined) {
- setTimeout(function() {tagpro.ui.sprites.redScore.visible = false;}, 0);
- } else {
- setTimeout(hideRedScore, 200);
- }
- }
- function hideBlueScore() {
- if (tagpro.ui.sprites.blueScore !== undefined) {
- setTimeout(function() {tagpro.ui.sprites.blueScore.visible = false;}, 0);
- } else {
- setTimeout(hideBlueScore, 200);
- }
- }
- function hideChat() {
- document.getElementById("chatHistory").style.display = "all";
- }
- function hideTimer() {
- if (tagpro.ui.sprites.timer !== undefined) {
- setTimeout(function() {tagpro.ui.sprites.timer.visible = false;}, 0);
- } else {
- setTimeout(hideTimer, 200);
- }
- }
- function hideElements() {
- hideSpectatorInfo1();
- hideSpectatorInfo2();
- hideRedScore();
- hideBlueScore();
- hideChat();
- hideTimer();
- }
- function createFontElement(num, size) {
- return '<div style="text-align:center; font-weight:normal; color:white; font-family:\'Play\'; font-size:' + size + ';text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;">' + num + '</div>';
- }
- function setupOnScoreFunction() {
- tagpro.socket.on('score', function(score) {
- console.log(score);
- updateScores(score);
- });
- }
- function updateScores(score) {
- var redFirstHalfOffset = $("#firstHalfRedOffset").val();
- var blueFirstHalfOffset = $("#firstHalfBlueOffset").val();
- var redTimeoutOffset = $("#redTimeoutOffset").val();
- var blueTimeoutOffset = $("#blueTimeoutOffset").val();
- console.log("1: ");
- console.log(score);
- document.getElementById("redScore").innerHTML = createFontElement(parseInt(score.r) + parseInt(redFirstHalfOffset) + parseInt(redTimeoutOffset), scoreFontSize);
- document.getElementById("blueScore").innerHTML = createFontElement(parseInt(score.b) + parseInt(blueFirstHalfOffset) + parseInt(blueTimeoutOffset), scoreFontSize);
- // add new cookie
- var options = {
- domain: domain,
- path: '/'
- };
- $.cookie(selectedHalf + ".RedScore", parseInt(score.r) + parseInt(redTimeoutOffset), options);
- $.cookie(selectedHalf + ".BlueScore", parseInt(score.b) + parseInt(blueTimeoutOffset), options);
- }
- function fillInHalfIndicators(num) {
- var html = "";
- for (var i = 1; i <= 8; i++) {
- if (num >= i) {
- document.getElementById("halfIndicator" + i).style.display = "block";
- } else {
- document.getElementById("halfIndicator" + i).style.display = "none";
- }
- }
- }
- function updateTimer() {
- document.getElementById("timer").innerHTML = createFontElement(getTime(), timerFontSize);
- }
- function getTime() {
- var millis = Math.max(0, tagpro.gameEndsAt - Date.now());
- var min = (millis/1000/60) << 0;
- var sec = fixSeconds(((millis/1000) % 60 << 0));
- return min + ":" + sec;
- }
- function addHalfSelection() {
- var element = document.getElementById("assets");
- var newElement = '<div id="halfSelection" style="margin-top:-18px; font-family: arial; font-size: 14px; color: black; margin-left:800px;"> \
- <button type="button" id="g1h1" sequence="1" class="halfSelection hideGameScores" style="margin-left:10px; margin-bottom:10px">g1h1</button> \
- <button type="button" id="g1h2" sequence="2" class="halfSelection hideGameScores" style="margin-left:10px; margin-bottom:10px">g1h2</button> \
- <button type="button" id="g2h1" sequence="3" class="halfSelection game1Scores" style="margin-left:10px; margin-bottom:10px">g2h1</button> \
- <button type="button" id="g2h2" sequence="4" class="halfSelection game1Scores" style="margin-left:10px; margin-bottom:10px">g2h2</button> \
- <button type="button" id="g3h1" sequence="5" class="halfSelection game2Scores" style="margin-left:10px; margin-bottom:10px">g3h1</button> \
- <button type="button" id="g3h2" sequence="6" class="halfSelection game2Scores" style="margin-left:10px; margin-bottom:10px">g3h2</button> \
- <button type="button" id="overtime" sequence="7" class="overtimeAndGoldenCap" style="margin-left:10px; margin-bottom:10px; width:85px">Overtime</button> \
- <button type="button" id="goldenCap" sequence="8" class="overtimeAndGoldenCap" style="margin-left:10px; margin-bottom:10px">Golden Cap</button> \
- </div><div id="message"><p style="font-size:23px;margin-left:1690px;margin-top:-33px;color:red">SELECT A HALF<p></div>';
- element.insertAdjacentHTML( 'afterend', newElement );
- // Add event listeners
- $(".halfSelection").each(function(index) {
- $(this).on("click", function(){
- var buttonId = $(this).attr('id');
- var sequence = $(this).attr('sequence');
- selectedHalf = buttonId;
- console.log("button id: " + selectedHalf);
- document.getElementById("message").innerHTML = '<p style="font-size:23px;margin-left:1690px;margin-top:-33px;color:green">' + selectedHalf + ' selected<p>';
- loadFirstHalfOffset(selectedHalf);
- fillInTeamNames(selectedHalf);
- //invertscoreboardBanner(selectedHalf);
- fillInHalfIndicators(sequence);
- });
- });
- $(".hideGameScores").each(function(index) {
- $(this).on("click", function(){
- var buttonId = $(this).attr('id');
- var sequence = $(this).attr('sequence');
- selectedHalf = buttonId;
- hideGameBanner(selectedHalf);
- });
- });
- $(".game1Scores").each(function(index) {
- $(this).on("click", function(){
- var buttonId = $(this).attr('id');
- var sequence = $(this).attr('sequence');
- selectedHalf = buttonId;
- showGame1Banner(selectedHalf);
- });
- });
- $(".game2Scores").each(function(index) {
- $(this).on("click", function(){
- var buttonId = $(this).attr('id');
- var sequence = $(this).attr('sequence');
- selectedHalf = buttonId;
- showGame2Banner(selectedHalf);
- });
- });
- $(".overtimeAndGoldenCap").each(function(index) {
- $(this).on("click", function(){
- var buttonId = $(this).attr('id');
- var sequence = $(this).attr('sequence');
- selectedHalf = buttonId;
- console.log("button id: " + selectedHalf);
- fillInHalfIndicators(sequence);
- });
- });
- }
- function fillInTeamNames() {
- var invert = $.cookie(selectedHalf + "Inversion");
- if (invert == "true") {
- $("#blueTeam").html(createFontElement(redTeamName, teamFontSize));
- $("#redTeam").html(createFontElement(blueTeamName, teamFontSize));
- } else {
- $("#redTeam").html(createFontElement(redTeamName, teamFontSize));
- $("#blueTeam").html(createFontElement(blueTeamName, teamFontSize));
- }
- }
- /*function invertscoreboardBanner() {
- var invert = $.cookie(selectedHalf + "Inversion");
- if (invert == "true") {
- $("#scoreboardBannerInverted").show();
- $("#scoreboardBanner").hide();
- } else {
- $("#scoreboardBanner").show();
- $("#scoreboardBannerInverted").hide();
- }
- }*/
- function hideGameBanner() {
- $("#gameScores3").hide();
- $("#gameScores4").hide();
- $("#gameScores5").hide();
- $("#gameScoresHalf3").hide();
- $("#gameScoresHalf4").hide();
- $("#gameScoresHalf5").hide();
- $("#gameScores3Invert").hide();
- $("#gameScores4Invert").hide();
- $("#gameScores5Invert").hide();
- }
- function showGame1Banner() {
- var invert = $.cookie(selectedHalf + "Inversion");
- if (invert == "true") {
- $("#gameScores3").hide();
- $("#gameScores4").hide();
- $("#gameScores5").hide();
- $("#gameScoresHalf3").show();
- $("#gameScoresHalf4").hide();
- $("#gameScoresHalf5").hide();
- $("#gameScores3Invert").show();
- $("#gameScores4Invert").hide();
- $("#gameScores5Invert").hide();
- } else {
- $("#gameScores3").show();
- $("#gameScores4").hide();
- $("#gameScores5").hide();
- $("#gameScoresHalf3").show();
- $("#gameScoresHalf4").hide();
- $("#gameScoresHalf5").hide();
- $("#gameScores3Invert").hide();
- $("#gameScores4Invert").hide();
- $("#gameScores5Invert").hide();
- }
- }
- function showGame2Banner() {
- var invert = $.cookie(selectedHalf + "Inversion");
- if (invert == "true") {
- $("#gameScores3").hide();
- $("#gameScores4").hide();
- $("#gameScores5").hide();
- $("#gameScoresHalf3").hide();
- $("#gameScoresHalf4").show();
- $("#gameScoresHalf5").show();
- $("#gameScores3Invert").show();
- $("#gameScores4Invert").show();
- $("#gameScores5Invert").show();
- } else {
- $("#gameScores3").show();
- $("#gameScores4").show();
- $("#gameScores5").show();
- $("#gameScoresHalf3").hide();
- $("#gameScoresHalf4").show();
- $("#gameScoresHalf5").show();
- $("#gameScores3Invert").hide();
- $("#gameScores4Invert").hide();
- $("#gameScores5Invert").hide();
- }
- }
- function fixSeconds(seconds) {
- if (seconds < 10) {
- seconds = "0" + seconds;
- }
- return seconds;
- }
- function createFirstHalfOffsetSection() {
- var element = document.getElementById("assets");
- var newElement = createFirstHalfOffsetElement(0,0);
- element.insertAdjacentHTML( 'afterend', newElement );
- }
- function createFirstHalfOffsetElement(redOffset, blueOffset) {
- return '<div id="firstHalfOffset" style="margin-left:0px; margin-top:1025px;font-family: arial; font-size: 14px;> \
- <label for="firstHalfRedOffset">First Half Red Offset: </label><input id="firstHalfRedOffset" class="firstHalfOffsetOverride" name="firstHalfRedOffset" style="width:40px; margin-left:2px; color: black; " value="' + redOffset + '"/> \
- <label for="firstHalfBlueOffset">First Half Blue Offset: </label><input id="firstHalfBlueOffset" class="firstHalfOffsetOverride" name="firstHalfBlueOffset" style="width:40px; color: black; " value="' + blueOffset + '"/> \
- </div>';
- }
- function loadFirstHalfOffset(selectedHalf) {
- // Only load offset if in half 2
- if (selectedHalf.slice(-1) == "2") {
- var originalHalf = selectedHalf.slice(0, -1) + "1";
- var redOffset = 0;
- var blueOffset = 0;
- console.log($.cookie(originalHalf + "Inversion"));
- console.log($.cookie(selectedHalf + "Inversion"));
- var invert = $.cookie(originalHalf + "Inversion") != $.cookie(selectedHalf + "Inversion");
- if ($.cookie(originalHalf + "." + invertTeamIfApplicable(invert, "Red") + "Score") !== undefined) {
- redOffset = $.cookie(originalHalf + "." + invertTeamIfApplicable(invert, "Red") + "Score");
- }
- if ($.cookie(originalHalf + "." + invertTeamIfApplicable(invert, "Blue") + "Score") !== undefined) {
- blueOffset = $.cookie(originalHalf + "." + invertTeamIfApplicable(invert, "Blue") + "Score");
- }
- // Update html and trigger score update
- $("#firstHalfOffset").html(createFirstHalfOffsetElement(redOffset, blueOffset));
- setupFirstHalfOffsetOverrideListeners();
- updateScores(tagpro.score);
- }
- }
- function setupFirstHalfOffsetOverrideListeners() {
- $(".firstHalfOffsetOverride").change(overrideFirstHalfOffset);
- }
- function overrideFirstHalfOffset(obj) {
- updateScores(tagpro.score);
- }
- function createTimeoutOffsetSection() {
- var element = document.getElementById("firstHalfOffset");
- var newElement = createTimeoutOffsetElement(0,0);
- element.insertAdjacentHTML('afterend', newElement );
- }
- function createTimeoutOffsetElement(redOffset, blueOffset) {
- return '<div id="timeoutOffset" style="margin-left:400px; margin-top:-24px;font-family: arial; font-size: 14px; "> \
- <label for="redTimeoutOffset">Red Timeout Offset: </label><input id="redTimeoutOffset" class="timeoutOffset" name="redTimeoutOffset" style="width:40px; margin-left:2px; color: black; " value="' + redOffset + '"/> \
- <label for="blueTimeoutOffset">Blue Timeout Offset: </label><input id="blueTimeoutOffset" class="timeoutOffset" name="blueTimeoutOffset" style="width:40px; color: black; " value="' + blueOffset + '"/> \
- </div>';
- }
- function setupTimeoutOffsetOverrideListeners() {
- $(".timeoutOffset").change(overrideTimeoutOffset);
- }
- function overrideTimeoutOffset(obj) {
- updateScores(tagpro.score);
- }
- function createScoreObject(redScore, blueScore) {
- console.log("redScore = " + redScore);
- return "{r: " + redScore + ", b:" + blueScore + "}";
- }
- function createTeamNameSwitchButton() {
- var element = document.getElementById("timeoutOffset");
- var newElement = "<div id='teamSwitchButtons' style='margin-left:1382px; margin-top:-24px; padding-bottom:00px;font-family: arial; font-size: 14px; color: black; '> \
- <button id='teamSwitchButtonG1' type='button'>Switch Team Names (OT Only)</button> \</div>";
- element.insertAdjacentHTML('afterend', newElement );
- document.getElementById ("teamSwitchButtonG1").addEventListener ("click", switchTeamNamesG1, false);
- //document.getElementById ("teamSwitchButtonG2").addEventListener ("click", switchTeamNamesG2, false);
- //document.getElementById ("teamSwitchButtonG3").addEventListener ("click", switchTeamNamesG3, false);
- }
- function switchTeamNamesG1() {
- var blueTeamHTML = $("#blueTeam").html();
- var redTeamHTML = $("#redTeam").html();
- //var bannerInverted = $("#scoreboardBannerInverted").toggle();
- //var banner = $("#scoreboardBanner").toggle();
- //$("#scoreboardBanner").toggle(bannerInverted);
- //$("#scoreboardBannerInverted").toggle(banner);
- $("#blueTeam").html(redTeamHTML);
- $("#redTeam").html(blueTeamHTML);
- }
- /*function switchTeamNamesG2() {
- var blueTeamHTML = $("#blueTeam").html();
- var redTeamHTML = $("#redTeam").html();
- var bannerInverted = $("#scoreboardBannerInverted").toggle();
- var banner = $("#scoreboardBanner").toggle();
- var gs3 = $("#gameScores3").toggle();
- var gs3i = $("#gameScores3Invert").toggle();
- $("#scoreboardBanner").toggle(bannerInverted);
- $("#scoreboardBannerInverted").toggle(banner);
- $("#gameScores3").toggle(gs3i);
- $("#gameScores3Invert").toggle(gs3);
- $("#blueTeam").html(redTeamHTML);
- $("#redTeam").html(blueTeamHTML);
- }
- function switchTeamNamesG3() {
- var blueTeamHTML = $("#blueTeam").html();
- var redTeamHTML = $("#redTeam").html();
- var bannerInverted = $("#scoreboardBannerInverted").toggle();
- var banner = $("#scoreboardBanner").toggle();
- var gs3 = $("#gameScores3").toggle();
- var gs4 = $("#gameScores4").toggle();
- var gs5 = $("#gameScores5").toggle();
- var gs3i = $("#gameScores3Invert").toggle();
- var gs4i = $("#gameScores4Invert").toggle();
- var gs5i = $("#gameScores5Invert").toggle();
- $("#scoreboardBanner").toggle(bannerInverted);
- $("#scoreboardBannerInverted").toggle(banner);
- $("#gameScores3").toggle(gs3i);
- $("#gameScores4").toggle(gs4i);
- $("#gameScores5").toggle(gs5i);
- $("#gameScores3Invert").toggle(gs3);
- $("#gameScores4Invert").toggle(gs4);
- $("#gameScores5Invert").toggle(gs5);
- $("#blueTeam").html(redTeamHTML);
- $("#redTeam").html(blueTeamHTML);
- }*/
- function invertTeamIfApplicable(invert, color) {
- if (invert) {
- if (color == "Red") {
- return "Blue";
- } else {
- return "Red";
- }
- } else {
- return color;
- }
- }
- });
- //////////////////////////////////
- // JQUERY COOKIE PLUGIN FOLLOWS //
- //////////////////////////////////
- (function (factory) {
- if (typeof define === 'function' && define.amd) {
- // AMD (Register as an anonymous module)
- define(['jquery'], factory);
- } else if (typeof exports === 'object') {
- // Node/CommonJS
- module.exports = factory(require('jquery'));
- } else {
- // Browser globals
- factory(jQuery);
- }
- }(function ($) {
- var pluses = /\+/g;
- function encode(s) {
- return config.raw ? s : encodeURIComponent(s);
- }
- function decode(s) {
- return config.raw ? s : decodeURIComponent(s);
- }
- function stringifyCookieValue(value) {
- return encode(config.json ? JSON.stringify(value) : String(value));
- }
- function parseCookieValue(s) {
- if (s.indexOf('"') === 0) {
- // This is a quoted cookie as according to RFC2068, unescape...
- s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
- }
- try {
- // Replace server-side written pluses with spaces.
- // If we can't decode the cookie, ignore it, it's unusable.
- // If we can't parse the cookie, ignore it, it's unusable.
- s = decodeURIComponent(s.replace(pluses, ' '));
- return config.json ? JSON.parse(s) : s;
- } catch(e) {}
- }
- function read(s, converter) {
- var value = config.raw ? s : parseCookieValue(s);
- return $.isFunction(converter) ? converter(value) : value;
- }
- var config = $.cookie = function (key, value, options) {
- // Write
- if (arguments.length > 1 && !$.isFunction(value)) {
- options = $.extend({}, config.defaults, options);
- if (typeof options.expires === 'number') {
- var days = options.expires, t = options.expires = new Date();
- t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
- }
- return (document.cookie = [
- encode(key), '=', stringifyCookieValue(value),
- options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
- options.path ? '; path=' + options.path : '',
- options.domain ? '; domain=' + options.domain : '',
- options.secure ? '; secure' : ''
- ].join(''));
- }
- // Read
- var result = key ? undefined : {},
- // To prevent the for loop in the first place assign an empty array
- // in case there are no cookies at all. Also prevents odd result when
- // calling $.cookie().
- cookies = document.cookie ? document.cookie.split('; ') : [],
- i = 0,
- l = cookies.length;
- for (; i < l; i++) {
- var parts = cookies[i].split('='),
- name = decode(parts.shift()),
- cookie = parts.join('=');
- if (key === name) {
- // If second argument (value) is a function it's a converter...
- result = read(cookie, value);
- break;
- }
- // Prevent storing a cookie that we couldn't decode.
- if (!key && (cookie = read(cookie)) !== undefined) {
- result[name] = cookie;
- }
- }
- return result;
- };
- config.defaults = {};
- $.removeCookie = function (key, options) {
- // Must not alter options, thus extending a fresh object...
- $.cookie(key, '', $.extend({}, options, { expires: -1 }));
- return !$.cookie(key);
- };
- }));
- });
Add Comment
Please, Sign In to add comment