1/* 2 Multiple Counter 1.1 3 Copyright 2006-2007 popKorn 4 [email protected] 5*/ 6 7var timerIDs = new Array(), 8 timerRunnings = new Array(), 9 episodeIDs = new Array(), 10 bigDays = new Array(), 11 foundCounters = new Array(), 12 foundCountersTimerID = null, 13 foundCountersRunning = false, 14 pageLoaded = false; 15 16window.onload = function() { pageLoaded = true; } 17 18function runMC() { 19 for(var i = 0; i < episodesDatesTimes.length; i++) { 20 foundCounters[i] = false; 21 } 22 foundCounters[episodesDatesTimes.length] = 0; 23 24 stopFindingCounters(); 25 findingCounters(); 26 27} 28 29function stopFindingCounters() { 30 if (foundCountersRunning) { 31 clearTimeout(foundCountersTimerID); 32 } 33 foundCountersRunning = false; 34} 35 36function findingCounters() { 37 38 checkAndRun(); 39 40 if ((pageLoaded)||(foundCounters[episodesDatesTimes.length] == episodesDatesTimes.length)) { 41 stopFindingCounters(); 42 checkAndRun(); 43 } else { 44 foundCountersTimerID = setTimeout("findingCounters()", 10); 45 } 46} 47 48function checkAndRun() { 49 for(var i = 0; i < episodesDatesTimes.length; i++) { 50 if (foundCounters[i]) { 51 continue; 52 } 53 54 var o1 = "countdownepisode" + (i + 1); 55 var o2 = "countdown" + (i + 1); 56 var obj1 = getRefTo(o1); 57 var obj2 = getRefTo(o2); 58 59 if ((obj1 != null)&&(obj2 != null)) { 60 foundCounters[i] = true; 61 foundCounters[episodesDatesTimes.length]++; 62 startCountdown(i); 63 } 64 } 65} 66 67function getRefTo(objID) { 68 var objRef = null; 69 var bbdc = document; 70 71 if ((bbdc.getElementById)&&(bbdc.getElementById(objID) != null)) { 72 objRef = bbdc.getElementById(objID); 73 } else { 74 if ((bbdc.layers)&&(bbdc.layers[objID] != null)) { 75 objRef = bbdc.layers[objID]; 76 } else if (bbdc.all) { 77 objRef = bbdc.all[objID]; 78 } 79 } 80 81 return objRef; 82} 83 84function prepareCountdown(id) { 85 var thisIsTheEpisode = null; 86 var tmpToday = new Date(); 87 var tmpbigDay = new Date(); 88 89 timerIDs[id] = null; 90 timerRunnings[id] = false; 91 bigDays[id] = null; 92 episodeIDs[id] = "0x00"; 93
94 var tmpEpisodesDatesTimes = episodesDatesTimes[id]; 95 for(var i = 0; i < tmpEpisodesDatesTimes.length; i++) { 96 var ep = tmpEpisodesDatesTimes[i]; 97 98 tmpbigDay = new Date(Date.UTC(ep[1], ep[2] - 1, ep[3], ep[4], ep[5], ep[6])); 99 100 if (tmpToday.getTime() < tmpbigDay.getTime()) { 101 thisIsTheEpisode = tmpEpisodesDatesTimes[i]; 102 break; 103 } 104 } 105 if (thisIsTheEpisode != null) { 106 bigDays[id] = tmpbigDay; 107 episodeIDs[id] = thisIsTheEpisode[0]; 108 var o = "countdownepisode" + (id + 1); 109 var obj = getRefTo(o); 110 obj.innerHTML = episodeIDs[id]; 111 } else { 112 if (tmpEpisodesDatesTimes.length != 0) { 113 episodeIDs[id] = tmpEpisodesDatesTimes[tmpEpisodesDatesTimes.length - 1][0]; 114 var o = "countdownepisode" + (id + 1); 115 var obj = getRefTo(o); 116 obj.innerHTML = episodeIDs[id]; 117 } 118 bigDays[id] = null; 119 } 120} 121 122function startCountdown(id) { 123 prepareCountdown(id); 124 125 if (bigDays[id] != null) { 126 startclock(id); 127 } else { 128 stopclock(id); 129 } 130} 131 132function showtime(id) { 133 var today = new Date(); 134 135 var msPerSec = 1000, 136 secPerMin = 60, 137 minPerHr = 60, 138 hrsPerDay = 24; 139 140 var tmpbigDay = bigDays[id]; 141 142 var timeLeft = (tmpbigDay.getTime() - today.getTime()); 143 timeLeft = (timeLeft < 0) ? 0 : timeLeft; 144 timeLeft = Math.floor(timeLeft / msPerSec); 145 146 var secLeft = timeLeft % secPerMin; 147 timeLeft = Math.floor(timeLeft / secPerMin); 148 149 var minsLeft = timeLeft % minPerHr; 150 timeLeft = Math.floor(timeLeft / minPerHr); 151 152 var hrsLeft = timeLeft % hrsPerDay; 153 var daysLeft = Math.floor(timeLeft / hrsPerDay); 154 155 var showText = daysLeft + "d " + checkZero(hrsLeft) + ":" 156 + checkZero(minsLeft) + ":" + checkZero(secLeft); 157 158 var o = "countdown" + (id + 1); 159 var obj = getRefTo(o); 160 obj.innerHTML = showText; 161 162 if ((daysLeft <= 0)&&(hrsLeft <= 0)&&(minsLeft <= 0)&&(secLeft <= 0)) { 163 stopclock(id); 164 timerIDs[id] = setTimeout("startCountdown(" + id + ")", secPerMin * msPerSec); 165 } else { 166 timerIDs[id] = setTimeout("showtime(" + id + ")", msPerSec); 167 } 168 timerRunnings[id] = true; 169} 170 171function stopclock(id) { 172 if (timerRunnings[id]) { 173 clearTimeout(timerIDs[id]); 174 } 175 timerRunnings[id] = false; 176} 177 178function startclock(id) { 179 stopclock(id); 180 showtime(id); 181} 182 183function checkZero(number) { 184 return ((number < 10) ? ("0" + number) : number); 185}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.