var scnr_check = null, delayTimeout = null, onGreen = null, onRed = null, actElement = null; function SetControlValue(controlID, newValue, postback) { document.forms[0].elements[controlID].value = newValue; if (postback) { __doPostBack(controlID, ''); } } function onUnLoad() { input.removeEventListener(input.ON_KEY_DOWN, KeyHandler); } function KeyHandler(event) { switch (event.extendedKeyCode) { case KEY_PORTAL: window.location.reload(true); break; case KEY_GREEN: case KEY_OK: if (onGreen) onGreen(); break; case KEY_BACK: case KEY_RED: if (onRed) onRed(); else return; break; case KEY_YELLOW: if (actElement) actElement.value = actElement.value.substring(0, actElement.value.length - 1); break; default: return; } event.consume(); } function setPlatform(val, overright) { // set to platform id if exists var plat = ""; try { plat = toiEnv.createInformationObject("PLATFORM").getValue(); } catch (ex) { dump(ex); } dump("SAVED PLATFORM=" + plat); if (plat != "") { if (overright && val != null) // regstravimo metu kad ir yra stbid, irasom nauja, kuris ateina. { toiEnv.createInformationObject("PLATFORM_" + plat).setValue(val, 0); // nusettinam stb id toje platformoje return; } var stbId = null; try { stbId = toiEnv.createInformationObject("PLATFORM_" + plat).getValue(); } catch (ex) { dump(ex); } dump("SAVED PLATFORM STB ID=" + stbId); if (stbId != null) return stbId; else if (val != null) { toiEnv.createInformationObject("PLATFORM_" + plat).setValue(val, 0); // nusettinam stb id toje platformoje } } // return null; } function onElChange(el) { var tmp = el.value; el.value = ""; setTimeout(function() {el.value = tmp },0); if (actElement) actElement.parentNode.className = null; el.parentNode.className = "Selected"; actElement = el; } function onLoad() { if (window == window.top) { try { try { block(); toiEnv.getVersion(); } catch (e) { //alert("TOI/JS 1.0 is not available, please check your portalurls.xml and that your boot image supports TOI/JS 1.0"); window.location = 'Error.aspx?block=1'; return; } if (!POST_BACK) { var maxnumber = 0, number, val = null, bversion = "n/a", frmv = "n/a", stbKreatelModel = "n/a", tz = "n/a"; try { bversion = toiEnv.createInformationObject("config.build.version").getValue() } catch (ex) { dump("version: " + ex.message); } try { frmv = toiEnv.createInformationObject("config.firmwareversion").getValue() } catch (ex) { dump("firmwareversion: " + ex.message); } try { stbKreatelModel = toiEnv.createInformationObject("config.productdisplayname").getValue() } catch (ex) { dump("productdisplayname: " + ex.message); } try { tz = toiEnv.createInformationObject("config.timezone").getValue() } catch (ex) { dump("timezone: " + ex.message); } SetControlValue("SerialField", toiEnv.createInformationObject("config.serialnumber").getValue()); SetControlValue("MACField", toiEnv.createInformationObject("config.macaddress").getValue()); SetControlValue("IPField", toiEnv.createInformationObject("config.ipaddress").getValue()); SetControlValue("TypeField", stbKreatelModel); SetControlValue("SCNRField", null); SetControlValue("FirmwareField", frmv); SetControlValue("SoftVersionField", bversion); SetControlValue("TimeZoneField", tz); SetControlValue("STBModelField", stbKreatelModel); try { val = toiEnv.createInformationObject("TCOM_STBID").getValue(); } catch (ex) { dump(ex); } if (!PROD) { var stbIDVal = setPlatform(val); if (stbIDVal != null) val = stbIDVal; } SetControlValue("STBIDField", val); if (document.getElementById("RandomDelay").value.length == 0) number = 0; else { maxnumber = parseInt(document.getElementById("RandomDelay").value); number = Math.round(maxnumber * Math.random()); } delayTimeout = setTimeout("__doPostBack('LinkButton1','')", number * 1000); } else { try { document.getElementById("Wait").style.visibility = "hidden"; } catch (e) { } actElement = document.getElementById("dslIDTextBox"); if (actElement) actElement.focus(); try { toiEnv.browserWindow.setTransparency(255); input.addEventListener(input.ON_KEY_DOWN, KeyHandler); } catch (e) { dump("Input Error: " + e); } } } catch (ex) { dump("Login onLoad: " + ex.message); } } else { if (top.wait) top.wait.hide(); if (top.portalLoaded) top.portalLoaded(); top.document.location.reload(true); } } function GreenPress() { var field = document.getElementById("dslIDTextBox"); if (field.value.length == 9 && field.value[0] == '8') field.value = field.value.substr(1); POST_BACK = false; document.getElementById('Wait').style.visibility = 'visible'; __doPostBack('LinkButton2', ''); } function RedPress() { POST_BACK = false; document.getElementById('Wait').style.visibility = 'visible'; __doPostBack('ErrorBackButton', ''); } function success() { try { document.getElementById('Wait').style.visibility = 'visible'; block(); toiEnv.createInformationObject("TCOM_STBID").setValue(document.forms[0].elements["STBIDField"].value, 0); if (!PROD) { setPlatform(document.forms[0].elements["STBIDField"].value, true); } var userDefinedIndicator = ""; try { userDefinedIndicator = toiEnv.createInformationObject("config.userDefinedTVSettings").getValue() } catch (e) { } //patikrinam ar yra indikatorius, kad atmintyje issaugoti vartotojo nustatymai dump("LOGIN'e userDefinedIndicator = " + userDefinedIndicator); if (userDefinedIndicator != 1) { //emizrk. patikrinam ar indikatorius, kad atmintyje issaugoti vartotojo pasirinkti parametrai lygus 1 try { var tmp = toiEnv.createInformationObject("config.1staudiolanguage").getValue(); if (tmp != 'lit') toiEnv.createInformationObject("config.1staudiolanguage").setValue('lit', 0); //emizrk. Pirmines kalbos nustatymas } catch (e) { error("Default 1st language set:", e); } try { var tmp = toiEnv.createInformationObject("config.2ndaudiolanguage").getValue(); if (tmp != 'eng') toiEnv.createInformationObject("config.2ndaudiolanguage").setValue('eng', 0); //emizkr. Antrines kalbos nustatymas. } catch (e) { error("Default 2nd language set:", e); } try { var tmp = ""; try { tmp = toiEnv.createInformationObject("config.3rdaudiolanguage").getValue(); } catch (e) { error("Getting 3rd default language failed:", e); } if (!tmp || tmp != 'rus') toiEnv.createInformationObject("config.3rdaudiolanguage").setValue('rus', 0); //emizrk. Tretines kalbos nustatymas. } catch (e) { error("Default 3rd language set:", e); } } try { toiEnv.createInformationObject("FB_TOKEN").unsetValue(0); } catch (e) { } try { toiEnv.createInformationObject("FLICKR_TOKEN").unsetValue(0); } catch (e) { } try { toiEnv.createInformationObject("PICASA_TOKEN").unsetValue(0); } catch (e) { } try { toiEnv.createInformationObject("YOUTUBE_TOKEN").unsetValue(0); } catch (e) { } window.location = "Default.aspx"; } catch (ex) { dump(ex.message) } } var _transparency = -1, setTransparencyTimeout, _oW; function setTransparency(a, force) { if (a <= 255 && a >= 0 && (a != _transparency || force)) { _transparency = a; if (setTransparencyTimeout) setTransparencyTimeout = clearTimeout(setTransparencyTimeout); setTransparencyTimeout = setTimeout(function () { setTransparencyTimeout = null; toiEnv.browserWindow.setTransparency(a); }, DETAILED ? 200 : 500); } } function error(msg, e) { try { dump("[ERROR] " + msg + ((e) ? ": " + e.name + " (" + e.message + ")" : "")); if (e) dump("[STACK]\n" + e.stack.replace(/^.*?\n/, '').replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(')); } catch (ex) { } } function trace() { try { (0)() } catch (e) { dump("[STACK]\n" + e.stack.replace(/^.*?\n/, '').replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(')); } } function ToDateString(date, enc) { var y = date.getFullYear() + "", M = date.getMonth() + 1, d = date.getDate(), H = date.getHours(), m = date.getMinutes(), s = date.getSeconds(); return y + "-" + two(M) + "-" + two(d) + (enc ? "%20" : " ") + two(H) + ":" + two(m) + ":" + two(s); } function classet(where, from, to) { var tmp = where.className; if (tmp) { if (from) { tmp = tmp.replace(from, to); if (tmp[tmp.length - 1] == " ") tmp = tmp.substr(0, tmp.length - 1); } else if (tmp.indexOf(to) < 0) tmp = tmp + " " + to; } else tmp = to; where.className = tmp; } function dbg(str) { dump("[DBG] " + str); } function block() { if (!mozilla) _oW = document.body.offsetWidth; } function formatTime(d) { return two(d.getHours()) + ":" + two(d.getMinutes()); } function two(x) { return ((x > 9) ? "" : "0") + x; } function formatDate(t) { return t.getFullYear() + "-" + two(t.getMonth() + 1) + "-" + two(t.getDate()); } function videoClose() { try { if (video && video.getState() != video.STATE_IDLE) video.close(); } catch (e) { } } function trim(a) { if (typeof a == 'string') return a.replace(/^\s+|\s+$/g, "").replace(/\s*$/, ""); return null; } function rtrim(a) { if (typeof a == 'string') return a.replace(/\s+$/, "", "").replace(/\s*$/, ""); return null; } function _extend(dest, source, replace) { for (var prop in source) { if (replace == false && dest[prop] != null) { continue; } dest[prop] = source[prop]; } return dest; } function getDateObject(date, time) { try { var dp = date.split("-"), tp = time.split(":"); return new Date(dp[0], parseInt(dp[1], 10) - 1, dp[2], tp[0], tp[1]); } catch (e) { return null; } } function getTimeFromMilis(milis) { var SEC = 1000, MIN = SEC * 60, HOUR = MIN * 60, result = ""; var h = Math.floor(milis / HOUR); if (h > 0) result += h + ":"; milis -= Math.floor(milis / HOUR) * HOUR; var m = Math.floor(milis / MIN); result += h > 0 ? two(m) : m + ":"; milis -= Math.floor(milis / MIN) * MIN; result += two(Math.floor(milis / SEC)); return result; } function contains(a, obj) { if (a && obj) { var i = a.length; while (i--) { if (a[i] === obj) { return true; } } } return false; } // // Idle Agent, idle time calculation class // function IdleAgent() { this.init = init; this.ResetIdleTime = ResetIdleTime; this.ConfirmYes = ConfirmYes; this.ConfirmNo = ConfirmNo; this.bootCountCB = bootCountCB; this.countBoots = countBoots; this.UpdateIdleTime = UpdateIdleTime; this.bootCount = null; this.idleTime = top.time.GetDate(); // idle time in milliseconds this.timeUntilStandby = -1; this.standbyRequestTime0 = 0; this.countIdleTimeTimeout = null; this.standbyPopup = standbyPopup; this.timeToStandbyCB = timeToStandbyCB; this.WriteStbStandbyLogCB = WriteStbStandbyLogCB; this.countIdleTimeTimeout = null; this.waitUntilStandbyTO = null; this.init(); function timeToStandbyCB(res) { var that = res.context; if (res.error) { dump("err timeToStandbyCB " + res.error.Message); that.timeUntilStandby = -1; return; } var idlePopupAfter = Math.round(res.value / 1000); XHR.WriteStbStandbyLog(that.standbyRequestTime, idlePopupAfter, that.WriteStbStandbyLogCB, that); //dump("restart after: " + res.value); that.timeUntilStandby = res.value; if (that.timeUntilStandby > -1) { if (that.waitUntilStandbyTO != null) clearTimeout(that.waitUntilStandbyTO); that.waitUntilStandbyTO = setTimeout(function () { that.standbyPopup(); }, that.timeUntilStandby); } } function WriteStbStandbyLogCB(res) { if (res.error) { dump("STB standby info was not saved"); } else dump("STB standby info successfully saved"); } function standbyPopup() { var that = this; var timeTo = parseInt(IDLEAGENT_TIME_TO, 10); var timeNow = parseInt(top.time.GetDate().getHours(), 10); if (timeNow < timeTo && that.timeUntilStandby != -1) { dump("Popup countdown show"); var timeTill = 60 * 2 * 1000; this.confirmOnScreen = true; if (this.confirmTimeout) this.confirmTimeout = clearTimeout(this.confirmTimeout); this.confirmTimeout = setTimeout(function () { top.menu.confirm.hide(); that.ConfirmYes() }, timeTill); top.menu.confirm.invoke("Del neaktyvumo, jusu priedelis bus perkrautas po " + timeTill / 1000 + " sekundžiu", function () { that.ConfirmYes() }, function () { that.ConfirmNo() }, "Išjungti dabar", "Atšaukti"); } else if (that.timeUntilStandby != -1) that.timeUntilStandby = -1; } function countBoots() { if (IDLEAGENT_ENABLED) { XHR.GetSTBRebootCount(this.bootCountCB, this); } } function bootCountCB(res) { var that = res.context; if (!res.error) { that.bootCount = res.value; } else { that.bootCount = 0; } var now = top.time.GetDate(); that.confirmOnScreen = false; that.confirmTimeout = null; that.countIdleTimeTimeout = setTimeout(function () { that.UpdateIdleTime(now) }, IDLEAGENT_INTERVAL); } function init() { //dump("IDLEAGENT_ENABLED " + IDLEAGENT_ENABLED); if (IDLEAGENT_ENABLED) { this.countBoots(); } } function UpdateIdleTime(callTime) { var that = this; var now = top.time.GetDate(); var idle = now - this.idleTime; //dump("idle time=" + idle); var justrestarted = this.bootCount; var timeFrom = parseInt(IDLEAGENT_TIME_FROM, 10); var timeNow = parseInt(top.time.GetDate().getHours(), 10); var timeTo = parseInt(IDLEAGENT_TIME_TO, 10); var timeGood = (timeNow >= timeFrom && timeNow < timeTo); if (idle >= IDLEAGENT_TIME_DURATION && !this.confirmOnScreen && justrestarted == 0 && timeGood && this.timeUntilStandby == -1) { this.standbyRequestTime = top.time.GetDate(); XHR.GetStandbyTime(this.timeToStandbyCB, this); } if (this.countIdleTimeTimeout) this.countIdleTimeTimeout = clearTimeout(this.countIdleTimeTimeout); this.countIdleTimeTimeout = setTimeout(function () { that.UpdateIdleTime(now) }, IDLEAGENT_INTERVAL); } function ResetIdleTime() { this.idleTime = top.time.GetDate(); this.timeUntilStandby = -1; } function ConfirmYes() { if (this.confirmTimeout) this.confirmTimeout = clearTimeout(this.confirmTimeout); top.menu.confirm.hide(); try { this.idleTime = top.time.GetDate(); toiEnv.system.setStandbyMode(true); } catch (e) { this.idleTime = top.time.GetDate(); dump("klaida " + e); } } function ConfirmNo() { this.confirmOnScreen = false; if (this.confirmTimeout) this.confirmTimeout = clearTimeout(this.confirmTimeout); } } //Funkcija iš hashTable gaunanti visus to HashTable raktus. function GetKeys(h) { var keys = new Array(); for (var key in h) keys.push(key); return keys; } // //HorizontalScroll //#region function HorizontalScroll() { this.initHorizontalTextScroll = initHorizontalTextScroll; this.horizontalTextScroll = horizontalTextScroll; this.endHorizontalScroll = endHorizontalScroll; this.invoke = invoke; this.invokeTvOsdScroll = invokeTvOsdScroll; this.invokeHScrollByParentObj = invokeHScrollByParentObj; this.invokeEPGChanNameScroll = invokeEPGChanNameScroll; this.divObj = null; this.textSpanObj = null; this.startScrolltDelay = 2000; this.restartScrollDelay = 2000; this.textWidth = 0; this.actualWidth = 0; this.beforeStartTimeout = null; this.beforeRestartTimeout = null; this.horizontalScrollerInterval = null; function invoke(divObj, textSpanObj, startDelay, restartDelay) { if (startDelay != null) this.startScrolltDelay = startDelay; else if (this.startScrolltDelay != 2000) this.startScrolltDelay = 2000; if (restartDelay != null) this.restartScrollDelay = restartDelay; else if (this.restartScrollDelay != 2000) this.restartScrollDelay = 2000; //
this.divObj = divObj; this.textSpanObj = textSpanObj; this.initHorizontalTextScroll(); } function invokeTvOsdScroll() { var nowProgContainer = document.getElementById("nowProgTitleCon"); //emizrk. Reikalingi visi elementai, kuriuose vaizduojama programa. var nowProgTextSpan = document.getElementById("nowProgTitleText"); var nextProgContainer = document.getElementById("nextProgTitleCon"); var nextProgTextSpan = document.getElementById("nextProgTitleText"); if (!nowProgContainer || !nowProgTextSpan || !nextProgContainer || !nextProgTextSpan) { return; } else if (nowProgTextSpan.offsetWidth > nowProgContainer.offsetWidth) { this.invoke(nowProgContainer, nowProgTextSpan); } else if (nextProgTextSpan.offsetWidth > nextProgContainer.offsetWidth) { this.invoke(nextProgContainer, nextProgTextSpan); } } // invokeHScrollByParentObj //emizrk. Paduodamas tevinis objektas, kuriame yra div'as, kuriame yra span'as su tekstu. function invokeHScrollByParentObj(parentObj) { var containerDivObj = parentObj.getElementsByTagName('div')[0]; var textSpanObj = containerDivObj.getElementsByTagName('span')[0]; this.invoke(containerDivObj, textSpanObj, 1000, 1500); } function invokeEPGChanNameScroll(index) { var epgChanNameCon = document.getElementById("epgChanNameCon_" + index); var epgChanNameText = document.getElementById("epgChanNameText_" + index); this.invoke(epgChanNameCon, epgChanNameText, 1000, 1500); } function initHorizontalTextScroll() { var that = this; that.textWidth = that.divObj.offsetWidth; that.actualWidth = that.textSpanObj.offsetWidth; if (that.beforeStartTimeout != null) clearTimeout(that.beforeStartTimeout); if (that.beforeRestartTimeout != null) clearTimeout(that.beforeRestartTimeout); if (that.horizontalScrollerInterval != null) clearInterval(that.horizontalScrollerInterval); if (parseInt(that.textSpanObj.style.left) != 0) that.textSpanObj.style.left = 0 + "px"; if (that.actualWidth > that.textWidth) { that.beforeStartTimeout = setTimeout(function () { that.horizontalScrollerInterval = setInterval(function () { that.horizontalTextScroll(); }, 350); }, this.startScrolltDelay); } } function horizontalTextScroll() { var that = this; if (parseInt(that.textSpanObj.style.left) > (that.actualWidth) * (-1) + (that.textWidth)) { //emizrk. PVZ: jei teksto ilgis bus 500px, o mes programai rodyti turim 416px. (OSD plotis 500px MINUS 84px skirti programos laikui rodyti), tada turim slinkti ta span'a i kaire, LEFT atributa MAZINTI i minusine reiksme 500-416=84px, taigi iki -84px. //emizrk. Padaryta: vidinio teksto span'o LEFT atributo reiksme mazinama iki reiksmes (uzpildyto_Span'o_aukstis)*(-1) + (nustatytas_tam_tekstui_skirtas_ilgis) that.textSpanObj.style.left = parseInt(that.textSpanObj.style.left) - 5 + "px"; } else { clearTimeout(that.beforeStartTimeout); clearTimeout(that.beforeRestartTimeout); clearInterval(that.horizontalScrollerInterval); that.beforeRestartTimeout = setTimeout(function () { that.initHorizontalTextScroll(); }, this.restartScrollDelay); } } function endHorizontalScroll() { if (this.beforeStartTimeout != null) clearTimeout(this.beforeStartTimeout); if (this.beforeRestartTimeout != null) clearTimeout(this.beforeRestartTimeout); if (this.horizontalScrollerInterval != null) clearInterval(this.horizontalScrollerInterval); this.actualWidth = 0; this.textWidth = 0; if (this.textSpanObj && parseInt(this.textSpanObj.style.left, 10) != 0) this.textSpanObj.style.left = 0 + "px"; } } //#endregion