// ==UserScript== // @name Replay Rewrite // @description description // @namespace pbr/rr // @include http://*goallineblitz.com/game/replay.pl?game_id=*&pbp_id=* // @include http://glb.warriorgeneral.com/game/replay.pl?game_id=*&pbp_id=* // @copyright 2010, pabst // @license (CC) Attribution Share Alike; http://creativecommons.org/licenses/by-sa/3.0/ // @version 13.12.29 // @require https://greasyfork.org/scripts/1348-pbr-game-scout/code/pbr%20Game%20Scout.js?version=3550 // @require https://greasyfork.org/scripts/1373-pbr-game-scout-statslib/code/pbr%20Game%20Scout%20statslib.js?version=3538 // @require https://greasyfork.org/scripts/1371-libpbr2/code/libpbr2.js?version=3533 // @downloadURL https://update.greasyfork.icu/scripts/1370/Replay%20Rewrite.user.js // @updateURL https://update.greasyfork.icu/scripts/1370/Replay%20Rewrite.meta.js // ==/UserScript== /* * * pabst did this 09/07/21+ * * */ var scriptName = "Replay Rewrite"; var scriptVersion = "13.12.29"; var scriptWebpage = "http://userscripts.org/scripts/show/31640"; // you can modify the following variables var preDelay = 3000; var postDelay = 3000; var alwaysPause = false; var alwaysShowPlayText = (unsafeWindow.hide_scores != 1); // <--account option var showFallenPlayers = true; //should pancakes/falls/jukes be shown var showShrinkAnimation = false; var offenseOnBottom = false; var horizontalField = false; var frameRate = 1000/unsafeWindow.frameSpeed; // <--account option var visionDivSize = 2; var visionDivSkip = 4; // you can modify the previous variables // don't screw with these var ihavearealoperatingsystem = false; var pancakeCheck = function() { return; }; if (showFallenPlayers == true) { if (showShrinkAnimation == true) { pancakeCheck = playerShrink; } else { pancakeCheck = playerTrim; } } var replayRewrite = true; var plays = null; var currentPlay = -1; var playDone = false; var playPaused = false; var prePlayTimer = null; var postPlayTimer = null; var playFinishedTimer = null; var httpRequest = null; var frameSpeed = 925/frameRate; var frameTimer = null; var hometeam = unsafeWindow.home; var showVision = true; var showIcons = !unsafeWindow.drawIcons; var vision_data = null; var cam_data = null; var play_data = null; var poss_data = null; var currentFrame = 0; var playerDiv = new Array(); var playerOvr = new Array(); var ptid = unsafeWindow.ptid; var useDefaultColors = unsafeWindow.useDefaultColors; var replayArea = null; var lastTime = -1; var thisScore = unsafeWindow.this_score; var scoreUpdate = unsafeWindow.score_update; var playerExtrasIn = new Array(); var playerExtrasOut = new Array(); var firstRun = true; var ballImage = "/images/ball.gif"; var ballMotionImg = null; var gradient = [["#910000"],["#9a0000"],["#a30000"],["#ad0000"],["#b60000"],["#bf0000"],["#c90000"],["#d20000"],["#db0000"],["#e40000"],["#ed0000"],["#f70000"],["#ff0100"],["#ff0e00"],["#ff1c00"],["#ff2900"],["#ff3600"],["#ff4300"],["#ff5000"],["#ff5d00"],["#ff6a00"],["#ff7700"],["#ff8400"],["#ff9200"],["#ff9f00"],["#ffa600"],["#ffa800"],["#ffaa00"],["#ffad00"],["#ffaf00"],["#ffb200"],["#ffb400"],["#ffb600"],["#ffb900"],["#ffbb00"],["#ffbd00"],["#ffc000"],["#ffc200"],["#ffc500"],["#ffc700"],["#ffc900"],["#ffcc00"],["#ffce00"],["#ffd100"],["#ffd300"],["#ffd500"],["#ffd800"],["#ffda00"],["#ffdc00"],["#ffdf00"],["#ffe100"],["#ffe400"],["#ffe600"],["#ffe800"],["#ffeb00"],["#ffed00"],["#fff000"],["#fff200"],["#fff400"],["#fff700"],["#fff900"],["#fffc00"],["#fffe00"],["#fafc00"],["#f3f900"],["#ecf500"],["#e5f200"],["#dfef00"],["#d8eb00"],["#d1e800"],["#cae400"],["#c3e100"],["#bdde00"],["#b6da00"],["#afd700"],["#a8d300"],["#a2d000"],["#9bcd00"],["#94c900"],["#8dc600"],["#86c200"],["#80bf00"],["#79bc00"],["#72b900"],["#6bb500"],["#65b200"],["#5eaf00"],["#57ab00"],["#50a800"],["#49a400"],["#43a100"],["#3c9e00"],["#359a00"],["#2e9700"],["#289400"],["#219000"],["#1a8d00"],["#138900"],["#0c8600"],["#068300"],["#068300"]]; window.setTimeout( function() { unsafeWindow.pause(); clearTimeout(unsafeWindow.frameTimer); unsafeWindow.frameTimer = null; main(); } , 1); function main() { clearPlayers(); addScriptTags(); restructurePage(); addPlayerLinks(); bortFix(); pbpSetup(); } function createButton(title, cls) { var btn = document.createElement("a"); btn.className = "button left "+cls; btn.innerHTML = ""+title+""; return btn; } function addScriptTags() { var rrtag = document.createElement("div"); rrtag.setAttribute("id","rrtag"); var div = document.createElement("div"); div.id = "active_list"; div.innerHTML = "Active GM Scripts"; rrtag.appendChild(div); var rrplay = document.createElement("input"); rrplay.setAttribute("id","rrplay"); rrplay.setAttribute("style","display:none; visibility:hidden;"); rrplay.setAttribute("type","text"); rrplay.setAttribute("value",window.location.toString()); document.body.appendChild(rrtag); document.body.appendChild(rrplay); addToActive(); } function restructurePage() { var repfoot = document.getElementById("replay_footer"); repfoot.style.height = "90px"; var playHeader = document.getElementById("replay_header"); var playInfo = document.getElementById("play_info"); var playDesc = document.getElementById("play_outcome"); if (alwaysShowPlayText == false) { playDesc.style.display = "block"; playDesc.style.visibility = "hidden"; } var cnt = document.getElementById("play_container"); cnt.setAttribute("class","play_container"); var color = document.getElementById("color_options"); color.style.width = "190px"; var pposs = createButton("<< Prev Poss","ppossbtn"); var pplay = createButton("< Prev", "pplaybtn"); var rst = createButton("Reset","resetbtn"); var nplay = createButton("Next >", "nplaybtn"); var nposs = createButton("Next Poss >>", "npossbtn"); var rewbtn = document.createElement("a"); rewbtn.className = "button left rewbtn"; rewbtn.innerHTML = ''; var pausebtn = document.createElement("a"); pausebtn.setAttribute("class","button left pausebtn"); pausebtn.innerHTML = ''; var playbtn = document.createElement("a"); playbtn.setAttribute("class","button left playbtn"); playbtn.innerHTML = ''; var ffbtn = document.createElement("a"); ffbtn.setAttribute("class","button left ffbtn"); ffbtn.innerHTML = ''; var control = document.getElementById("controls"); control.style.width = "650px"; control.style.marginLeft = "0px"; while (control.childNodes.length > 0) { control.removeChild(control.firstChild); } control.appendChild(pposs); control.appendChild(pplay); control.appendChild(rst); control.appendChild(rewbtn); control.appendChild(pausebtn); control.appendChild(playbtn); control.appendChild(ffbtn); control.appendChild(nplay); control.appendChild(nposs); pposs.addEventListener("click",input,true); pplay.addEventListener("click",input,true); rst.addEventListener("click", reset, true); rewbtn.addEventListener("click",rew,true); playbtn.addEventListener("click",play,true); pausebtn.addEventListener("click",pauseReplay,true); ffbtn.addEventListener("click",ff,true); nplay.addEventListener("click",input,true); nposs.addEventListener("click",input,true); var div = document.createElement("div"); div.setAttribute("style","float: right"); div.style.marginRight = "10px"; div.style.marginTop = "15px"; var area = document.getElementById("replay_area"); area.style.width = "520px"; area.style.height = "1160px"; var fimg = area.style.backgroundImage; area.style.backgroundImage = "none"; var img = document.createElement("img"); if (fimg.toString().indexOf('url("') == 0) { console.log("firefox >3.6"); img.src = fimg.slice(fimg.indexOf("/"),fimg.indexOf('")')); } else if (fimg.toString().indexOf('url(') == 0) { console.log("firefox <3.6"); img.src = fimg.slice(fimg.indexOf("/"),fimg.indexOf(")")); } else { console.log("what firefox version is this?"); console.log(fimg.toString()); img.src = fimg.slice(fimg.indexOf("/"),fimg.indexOf(")")); } img.id = "field_image"; img.style.zIndex = 0; area.appendChild(img); inp = document.createElement("input"); inp.id = "use_vision"; inp.type = "checkbox"; var data = "0"; if (GM_getValue) { data = GM_getValue("use_vision",1); if (data == "1") { inp.checked = true; } showVision = (data == "1"); } var vs = document.getElementById("use_hidden_qb_vision"); if (vs != null) { vs.parentNode.insertBefore(inp,vs); vs.parentNode.removeChild(vs); inp.nextSibling.textContent = " Show QB Vision"; } else { var text = document.createElement("text"); text.textContent = " Show QB Vision"; var options = document.getElementById("options_popup"); options.appendChild(inp); options.appendChild(text); options.appendChild(document.createElement("br")); } inp.addEventListener("click",visionClicked,false); var br = document.createElement("br"); inp = document.createElement("input"); inp.id = "variable_framerate"; inp.type = "checkbox"; var data = "0"; if (GM_getValue) { data = GM_getValue("variable_framerate",0); if (data == "1") { inp.checked = true; } ihavearealoperatingsystem = (data == "1"); } var text = document.createElement("text"); text.textContent = " Variable Framerate"; var options = document.getElementById("options_popup"); options.appendChild(br); options.appendChild(inp); options.appendChild(text); inp.addEventListener("click",framerateChanged,false); var inp = document.getElementById("use_hidden_icons"); if (inp == null) { inp = document.createElement("input"); inp.id = "use_hidden_icons"; inp.type = "checkbox"; text = document.createElement("text"); text.textContent = " Hide Popup Icons"; var options = document.getElementById("options_popup"); options.appendChild(br); options.appendChild(inp); options.appendChild(text); } showIcons = !inp.checked; inp.addEventListener("click",iconsClicked,false); options.style.top = "575px";//parseInt(options.style.top)-100+"px"; options.style.height = "150px"; if (document.getElementById("rrframe") == null) { var div = document.createElement("input"); div.type = "hidden"; div.id = "rrframe"; div.value = 0; document.getElementById("footer").appendChild(div); } var page = new Object(); page.responseText = window.document.body.innerHTML; addPlayInfo(page); } function framerateChanged(e) { if (e.target.checked == false) { if (GM_setValue) { GM_setValue("variable_framerate",0); } ihavearealoperatingsystem = false; frameSpeed = 925/frameRate; } else { if (GM_setValue) { GM_setValue("variable_framerate",1); } ihavearealoperatingsystem = true; } } function iconsClicked(e) { if (e.target.checked == true) { showIcons = false; } else { showIcons = true; } } function visionClicked(e) { if (e.target.checked == false) { if (GM_setValue) { GM_setValue("use_vision",0); } showVision = true; var vis = document.getElementById("vision"); if (vis != null) { vis.parentNode.removeChild(vis); } } else { if (GM_setValue) { GM_setValue("use_vision",1); } showVision = false; } } function pbpSetup() { var pbptag = document.createElement("div"); pbptag.setAttribute("id","pbp"); var pbp = document.getElementById("pbp"); if (pbp == null) { document.body.appendChild(pbptag); var href = window.location.toString(); href = href.replace("replay.pl","game.pl"); var idx = href.indexOf("&pbp_id"); href = href.slice(0,idx) + "&mode=pbp"; getInetPage(href, importPBP); setTimeout(pbpSetup, 300); return; } else if (pbp.childNodes.length == 0) { setTimeout(pbpSetup, 300); return; } var page = new Object(); page.responseText = pbp.innerHTML; if (plays == null) { loadPBPSimple(page); } resetPlay(); buttonSetup(); if (alwaysPause == false) { play(); } } function addPlayInfo(page) { if (document.getElementById("use_playcall").checked == true) return; var odesc = null; try { odesc = page.responseText.split("Offense Play:
")[1].split("<")[0]; } catch (e) { console.log("first play? : "+e); return; } if (odesc != null) { var ddesc = null; try { ddesc = page.responseText.split("Defense Play:
")[1].split("<")[0]; } catch (e) { console.log("no AI access? : "+e); } if (ddesc == null) { ddesc = "Unknown"; if (odesc == "Field Goal") ddesc = "Field Goal Block"; else if (odesc == "Kickoff Return") ddesc = "Kickoff"; else if (odesc == "Punt") ddesc = "Punt Return"; else { var dl = 0; var lb = 0; var cb = 0; var s = 0; for (p in unsafeWindow.players) { var pos = unsafeWindow.players[p].position; console.log(pos); switch (pos) { case "LDE": case "DT": case "NT": case "RDE": dl++; break; case "LOLB": case "LILB": case "MLB": case "RILB": case "ROLB" : lb++; break; case "CB1": case "CB2": case "CB3": case "CB4": case "CB5" : cb++; break; case "FS": case "SS": s++; } } console.log(dl+" : "+lb+" : "+cb+" : "+s); if (lb == 4) { if (dl == 3) ddesc = "3-4"; else ddesc = "4-4"; } else if (cb == 5) ddesc = "3-1-7 Quarter"; else if (cb == 4) { if (lb == 1) ddesc = "4-1-6 Dime"; else ddesc = "3-2-6 Dime"; } else if (cb == 3) { if (lb == 2) ddesc = "4-2-5 Nickel"; else ddesc = "3-3-5 Nickel"; } else if (lb == 3) ddesc = "4-3"; else if (cb == 2) ddesc = "Goalline Small"; else ddesc = "Goalline"; } } var diff = 4; if (goingUp(unsafeWindow.play_data) == true) { diff += 456; } while (document.getElementsByClassName("play_container").length > 0) { var pc = document.getElementsByClassName("play_container"); pc[0].parentNode.removeChild(pc[0]); } console.log(odesc+" : "+ddesc); var odiv = document.createElement("div"); odiv.setAttribute("class","play_container"); odiv.setAttribute("id","play_container"); odiv.setAttribute("style","top:"+diff+"px; left:4px"); odiv.innerHTML = "Offense Play:
"+odesc; document.getElementById("replay_container").appendChild(odiv); var ddiv = document.createElement("div"); ddiv.setAttribute("class","play_container"); ddiv.setAttribute("id","play_container"); ddiv.setAttribute("style","top:"+diff+"px; left:269px;"); ddiv.innerHTML = "Defense Play:
"+ddesc; document.getElementById("replay_container").appendChild(ddiv); } } function buttonSetup(play) { var currentPlay = -1; if (play == null) { var addr = document.getElementById("rrplay").value; for (var i=0; i 0) { list[0].parentNode.removeChild(list[0]); list = area.getElementsByClassName("player_icon_overlay"); } list = area.getElementsByClassName("player_icon"); while (list.length > 0) { list[0].parentNode.removeChild(list[0]); list = area.getElementsByClassName("player_icon"); } list = area.getElementsByClassName("player_popup_icon"); while (list.length > 0) { list[0].parentNode.removeChild(list[0]); list = area.getElementsByClassName("player_popup_icon"); } } //var diffarray = new Array(); var startTime = 0; var endTime = 0; var adj = [0,0]; function render() { //console.log("render: pP="+playPaused+" : pFT="+(playFinishedTimer != null)+" : cF="+currentFrame+" / "+play_data.length); //console.log(playPaused); //console.log(playFinishedTimer == null); if (playPaused == true) { return; } if (playFinishedTimer != null) { return; } if (lastTime == -1) { lastTime = new Date().getTime(); if (alwaysPause == true) { playPaused = true; return; } else { frameTimer = setTimeout(render,preDelay); return; } } if (currentFrame == 0) { startTime = new Date().getTime(); } //console.log("a "+currentFrame+" --- "+(play_data.length)); if (currentFrame < play_data.length) { var newTime = new Date().getTime(); var diff = newTime - lastTime; if (ihavearealoperatingsystem == true) { //diffarray.push(diff); if (diff < frameSpeed) { frameTimer = setTimeout(render,frameSpeed-diff); return; } //draw frame here drawFrame(); currentFrame++; if ((1000/(newTime-lastTime)) < (frameRate-0.5)) { frameSpeed = frameSpeed * 0.95; adj[0]++; } else if ((1000/(newTime-lastTime)) > (frameRate+0.5)) { frameSpeed = frameSpeed * 1.05; adj[1]++; } lastTime = newTime; } else { //diffarray.push(diff); if (diff < frameSpeed) { frameTimer = setTimeout(render,5); return; } //draw frame here drawFrame(); currentFrame++; lastTime = newTime; } } //console.log("b "+currentFrame+" --- "+(play_data.length)); if (currentFrame > play_data.length-1) { endTime = new Date().getTime(); console.log(startTime+" - "+endTime+" = "+(endTime-startTime)+" | "+play_data.length+" | "+(play_data.length/((endTime-startTime)/1000)).toFixed(2)+" - "+frameSpeed.toFixed(2)+" | "+frameRate+"["+adj[0]+"/"+adj[1]+"]"); clearTimeout(frameTimer); frameTimer = null; adj = [0,0]; var p = document.getElementById("play_outcome"); p.style.display = "block"; p.style.visibility = "visible"; currentFrame = 0; playDone = true; if (parseInt(thisScore) != 0) { var sdiv = null; if (scoreUpdate == "O") { sdiv = document.getElementById("off_score"); } else { sdiv = document.getElementById("def_score"); } sdiv.innerHTML = parseInt(sdiv.innerHTML) + parseInt(thisScore); sdiv.style.outlineStyle = "solid"; sdiv.style.outlineColor = "white"; sdiv.style.color = "gold"; thisScore = 0; } if (playFinishedTimer == null) { //console.log("setting playIsFinished"); playFinishedTimer = setTimeout(playIsFinished,postDelay); } else { console.log("not setting playIsFinished"); } //console.log(diffarray); //diffarray = new Array(); } else { frameTimer = setTimeout(render,5);//frameSpeed>>2); } } function play() { if (frameTimer != null) { clearTimeout(frameTimer); frameTimer = null; } var div = document.getElementById("rrplay"); if (div.childNodes.length > 0) { //console.log("waiting ("+div.childNodes.length+") ..."); setTimeout(play, 200); return; } playPaused = false; render(); } function pauseReplay() { // console.log("pauseReplay"); if (playDone == true) { if (postPlayTimer != null) { clearTimeout(postPlayTimer); postPlayTimer = null; } playPaused = true; playDone = false; } else { playPaused = !playPaused; } // console.log("playDone is "+playDone); if (playPaused == true) { clearTimeout(frameTimer); frameTimer = null; } else { if (playDone == false) { play(); } } } function findPlayer(player, arr) { //console.log("findPlayer"); var output = -1; for (var i=0; i "+arr[output].id); //console.log(" : returning "+output); if (output == -1) { console.log("this is -1 : "+player.id); } return output; } function bortFix() { if (firstRun == true) { for (var f=0; f= pd[0][i].y) { count++; } else { count--; } } return count > 0; } var rotation = null; function fixFrames() { //console.log("fixFrames"); var stime = new Date(); var uwpd = new Array(); for (var i=0; i 0) || (u.mo > 0)) { var li = document.getElementById("player_link_"+u.id); if (li != null) { var brdiv = document.createElement("div"); brdiv.setAttribute("id","breathcon_"+u.id); brdiv.setAttribute("style","margin: 0px; padding: 0px; position: relative; top: -5px; left: 20px; width: 100px; height: 3px; text-align: left; visibility: visible; background-color: rgb(0, 0, 0);"); var brimg = document.createElement("img"); brimg.setAttribute("id","breath_"+u.id); brimg.setAttribute("src","/images/spacer.gif"); brimg.setAttribute("style","position: relative; top: -9px; width: 100px; height: 3px;"); brdiv.appendChild(brimg); li.parentNode.appendChild(brdiv); var modiv = document.createElement("div"); modiv.setAttribute("id","morcon_"+u.id); modiv.setAttribute("style","margin: 0px; padding: 0px; position: relative; top: -8px; left: 125px; width: 100px; height: 3px; text-align: left; visibility: visible; background-color: rgb(0, 0, 0);"); var moimg = document.createElement("img"); moimg.setAttribute("id","morale_"+u.id); moimg.setAttribute("src","/images/spacer.gif"); moimg.setAttribute("style","position: relative; top: -9px; width: 100px; height: 3px;"); modiv.appendChild(moimg); li.parentNode.appendChild(modiv); } var div = document.getElementById("breathcon_"+u.id); div.addEventListener("mouseover",function (e) { unsafeWindow.set_tip("Energy: "+parseInt(this.firstChild.style.width), 0, 1, 1, 1); },false); div.addEventListener("mouseout",function (e) { unsafeWindow.unset_tip(); },false); var div = document.getElementById("morcon_"+u.id); div.addEventListener("mouseover",function (e) { unsafeWindow.set_tip("Morale: "+parseInt(this.firstChild.style.width), 0, 1, 1, 1); },false); div.addEventListener("mouseout",function (e) { unsafeWindow.unset_tip(); },false); } } var time = new Date() - stime; console.log("breath/morale : "+time.toFixed(0)+"ms"); var stime = new Date(); if (uwpd[0] != null) { for (var f=0; f ball.tx) { var temp = x1; x1 = x2; x2 = temp; temp = y1; y1 = y2; y2 = temp; } // console.log("("+x1+","+y1+") -2-to ("+x2+","+y2+")"); div.style.left = (x1-1)+"px"; div.style.top = (y1-1)+"px"; div.style.width = Math.abs(x2-x1+2)+"px"; // console.log(y2+"-"+y1+"+2 = "+(y2-y1+2)); div.style.height = Math.abs(y2-y1+2)+"px"; div.style.zIndex = 750; // console.log("("+(ball.x-x1)+","+(ball.y-y1)+") -3-to ("+(ball.tx-x1)+","+(ball.ty-y1)+")"); drawLine(div, parseInt(ball.x-x1), parseInt(ball.y-y1), parseInt(ball.tx-x1), parseInt(ball.ty-y1)); vision_data[f] = div; } } } var time = new Date() - stime; console.log("vision : "+time.toFixed(0)+"ms"); var stime = new Date(); poss_data = new Array(); if (pd[0] != null) { for (var f=0; f ballTop) { top = ballTop-75; } var val = 0 - top; val = Math.min(0, val); val = Math.max(val, -660); cam_data[i] = parseInt(val); } } } var time = new Date() - stime; console.log("cam : "+time.toFixed(0)+"ms"); var stime = new Date(); var j=0; rotation = null; for (var i=0; i 1.07) { j=i; rotation = pd[i][0]; rotation.start = i; for (var j=i; j exp="+expire+") "+data.icon); if (playerExtrasOut[expire] == null) { playerExtrasOut[expire] = new Array(); } playerExtrasOut[expire].push([data.id, data.icon]); } } } var time = new Date() - stime; console.log("extras : "+time.toFixed(0)+"ms"); var stime = new Date(); var t = 0; var brskip = 0; var moskip = 0; for (var i=1; i "+x1+","+y1); var gstep = 0; var slope = Math.abs(y1 - y0) > Math.abs(x1 - x0); if (slope) { var temp = x0; x0 = y0; y0 = temp; temp = x1; x1 = y1; y1 = temp; } if (x0 > x1) { var temp = x0; x0 = x1; x1 = temp; temp = y0; y0 = y1; y1 = temp; } var deltax = x1 - x0; var deltay = Math.abs(y1 - y0); var error = deltax << 1; var ystep; var y = y0; if (y0 < y1) { ystep = 1; } else { ystep = -1; } for (var x=x0; x= rotation.stop) || (currentFrame == 0)) { playerDiv["ball"].src = ballImage; playerDiv["ball"].setAttribute("style",playerDiv["ball"].getAttribute("style").split(";",2)[1]); playerDiv["ball"].style.width = 10 + 'px'; playerDiv["ball"].style.height = 17 + 'px'; playerDiv["ball"].style.zIndex = playerLayerZ + 1; } if (isNaN(z) == false) { playerDiv["ball"].style.width = parseInt(10 * z) + 'px'; playerDiv["ball"].style.height = parseInt(17 * z) + 'px'; } playerDiv["ball"].style.left = x+'px'; playerDiv["ball"].style.top = y+'px'; } else { playerDiv[id].style.left = x + 'px'; playerDiv[id].style.top = y + 'px'; if (br) { document.getElementById("breath_"+id).style.width = br+"px"; document.getElementById("breath_"+id).style.background = gradient[br]; } if (mo) { document.getElementById("morale_"+id).style.width = mo+"px"; document.getElementById("morale_"+id).style.background = gradient[mo]; } } } function playerShrink(id, x, y, z, p) { if (p == null) { if (playerDiv[id].style.width == "13px") { var bgc = playerDiv[id].style.backgroundColor; playerDiv[id].parentNode.removeChild(playerDiv[id]); playerDiv[id] = null; createPlayerDot(id, x, y, z, p); playerDiv[id].style.backgroundColor = bgc; } } else { if (playerDiv[id].style.width != "13px") { var bgc = playerDiv[id].style.backgroundColor; playerDiv[id].parentNode.removeChild(playerDiv[id]); playerDiv[id] = null; createPlayerDot(id, x, y, z, p); playerDiv[id].style.backgroundColor = bgc; } } } function playerTrim(id, x, y, z, p) { if (p == null) { if (playerDiv[id].src.toString().indexOf("spacer") != -1) { var bgc = playerDiv[id].style.backgroundColor; playerDiv[id].parentNode.removeChild(playerDiv[id]); playerDiv[id] = null; createPlayerDot(id, x, y, z, p); playerDiv[id].style.backgroundColor = bgc; } } else { if (playerDiv[id].src.toString().indexOf("spacer") == -1) { var bgc = playerDiv[id].style.backgroundColor; playerDiv[id].parentNode.removeChild(playerDiv[id]); playerDiv[id] = null; createPlayerDot(id, x, y, z, p); playerDiv[id].style.backgroundColor = bgc; } } } function ff() { //console.log("ff"); if (playPaused == true) { var pdl = play_data.length; currentFrame = (pdl+currentFrame+1)%pdl; drawFrame(); } else { frameRate += 3; frameSpeed = frameSpeed/2; } //console.log("ff: "+frameSpeed); } function rew() { //console.log("rew"); if (playPaused == true) { var pdl = play_data.length; currentFrame = (pdl+currentFrame-1)%pdl; drawFrame(); } else { frameRate -= 3; frameSpeed = frameSpeed*2; } //console.log("rew: "+frameSpeed); } function reset() { //console.log("reset"); playPaused = true; currentFrame = 0; drawFrame(); } function beginPlay() { //console.log("beginPlay is not done"); if (postPlayTimer != null) { clearTimeout(postPlayTimer); postPlayTimer = null; } if (playPaused == true) { return; } resetBall(); play(); } function playIsFinished() { //console.log("pIF"); if (playFinishedTimer != null) { clearTimeout(playFinishedTimer); playFinishedTimer = null; } if (postPlayTimer != null) { clearTimeout(postPlayTimer); postPlayTimer = null; } if (playPaused == true) { return; } playDone = false; if (document.getElementById("use_continuous").checked == false) { currentFrame = 0; while (document.getElementById("replay_area").getElementsByClassName("player_popup_icon").length > 0) { var e = document.getElementById("replay_area").getElementsByClassName("player_popup_icon")[0]; e.parentNode.removeChild(e); } beginPlay(); } else { var button = document.getElementsByClassName("nplaybtn")[0]; if (document.getElementById("rrplay").getAttribute("index") == button.id) { currentFrame = 0; beginPlay(); } else { var evt = []; evt.target = button.firstChild; input(evt); } } } function input(evt) { if (postPlayTimer != null) { clearTimeout(postPlayTimer); postPlayTimer = null; } if (playFinishedTimer != null) { clearTimeout(playFinishedTimer); playFinishedTimer = null; } if (prePlayTimer != null) { clearTimeout(prePlayTimer); prePlayTimer = null; } if (playPaused != true) { pauseReplay(); } var id = evt.target.parentNode.getAttribute("id")+""; lastPlay = currentPlay; currentPlay = parseFloat(id); document.getElementById("rrplay").setAttribute("index",currentPlay); //console.log("lastPlay="+lastPlay+" -- currentPlay="+currentPlay); if (currentPlay == plays.length) { console.log("do something about last play of the game"); return; } var address = plays[currentPlay].replay+""; if (address == "[object XPCNativeWrapper [object Text]]") { buttonSetup(currentPlay); handleFieldGoal(currentPlay); } else { //console.log("next address = "+address); evt.target.innerHTML = "Loading ."; httpRequest = getInetPage(address, change, evt.target); } } function change(address, page) { clearTimeout(frameTimer); frameTimer = null; clearTimeout(postPlayTimer); postPlayTimer = null; clearTimeout(prePlayTimer); prePlayTimer = null; changeInfo(page); changePlays(page); buttonSetup(currentPlay); addPlayInfo(page); resetPlay(); var rrplay = document.getElementById("rrplay"); rrplay.value = address; var evt = document.createEvent("HTMLEvents"); evt.initEvent("change", true, true); rrplay.dispatchEvent(evt); var a = document.createElement("a"); a.style.color = "white"; a.innerHTML = "Share this play"; a.href = address; var cont = document.getElementById("share_play"); cont.removeChild(cont.firstChild); for (var i=0; i","Next Poss >>"]; for (var i=0; i"; } var offContainer = document.getElementById("offense_container"); var defContainer = document.getElementById("defense_container"); offContainer.style.visibility = "hidden"; offContainer.style.display = "none"; defContainer.style.visibility = "hidden"; defContainer.style.display = "none"; var containers = document.getElementsByClassName("primary_container"); var new_containers = div.getElementsByClassName("primary_container"); for (var i=0; i 0) { if (poss_data[currentFrame-1] == poss_data[currentFrame]) { return; } } resetBall(); playerId = poss_data[currentFrame]; var l = document.getElementById("pos_dot_"+playerId); if (l != null) { l.parentNode.id = "pbrball"; l.style.backgroundRepeat = "no-repeat"; l.style.backgroundImage = "url(\"/images/ball.gif\")"; } } } function findPoss(idx, direction) { var play = plays[idx]; var currTeam = play.team; if (direction > 0) { for (var i=idx+1; i