From 752587bccad186db28df673f84690eb265ecd991 Mon Sep 17 00:00:00 2001 From: thlo Date: Sun, 1 Sep 2013 16:53:29 +0200 Subject: Timer menu entry, which gives an overview of the timers and allows deletion of timers. widget.conf configurable InfoOverlay timeout (new widget.conf entry ) YouTube entry becomes optional. Add true to your widget.conf Improved server error feedback through widget GUI Bug Fixes. --- smarttv-client/CSS/Main.css | 87 +++++++++ smarttv-client/Javascript/Buttons.js | 26 ++- smarttv-client/Javascript/Comm.js | 3 + smarttv-client/Javascript/Config.js | 14 +- smarttv-client/Javascript/Display.js | 6 +- smarttv-client/Javascript/Main.js | 66 ++++--- smarttv-client/Javascript/Options.js | 2 +- smarttv-client/Javascript/Player.js | 4 +- smarttv-client/Javascript/SelectScreen.js | 40 ++-- smarttv-client/Javascript/Server.js | 32 +++ smarttv-client/Javascript/Timers.js | 315 +++++++++++++++++++++++++----- smarttv-client/index.html | 6 + 12 files changed, 510 insertions(+), 91 deletions(-) diff --git a/smarttv-client/CSS/Main.css b/smarttv-client/CSS/Main.css index 9478ad8..5ee123c 100755 --- a/smarttv-client/CSS/Main.css +++ b/smarttv-client/CSS/Main.css @@ -39,6 +39,93 @@ body { background-color: rgba(0,0,139,0.8); } +.style_menuItem { + color : white; + padding-bottom:3px; + margin-top:5px; + margin-bottom : 5px; + text-align: center; + background : transparent; + border-radius: 0px; +} + +.style_menuItemSelected{ + color : black; + padding-bottom:3px; + margin-top:5px; + margin-bottom : 5px; + text-align: center; + border-radius: 3px; + background : white; + background : -webkit-linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1) 100%); + -webkit-box-shadow : 2px 2px 1px 2px rgba(0,0,0, 0.5); +} + +.style-roundItem { + margin-left: 10px; + padding: 10px 10px 10px 10px; + border-radius:10px; + font-size:16px; + border-style:solid; + border-width:1px; + background: transparent; +} + +.style-roundItemSelected { + margin-left: 10px; + padding: 10px 10px 10px 10px; + border-radius:10px; + font-size:16px; + border-style:solid; + border-width:1px; + background-color: white; + background-color: "-webkit-linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1) 100%)"; +} + +.style_overflow { + overflow: hidden; + white-space : nowrap; +} +.style_timerRec { + width :8px; + height:8px; + border-radius: 4px; + background: red; +} +.style_timerNone { + width :8px; +} + +#timerScreen { + position: absolute; + left: 0px; top: 0px; + width: 960px; height: 540px; + z-index:10; + + background: radial-gradient(ellipse at 80% 80%, #c5deea 0%,#8abbd7 31%,#066dab 100%); + background: -webkit-radial-gradient(80% 80%, ellipse cover, rgba(197,222,234,1) 0%,rgba(138,187,215,1) 31%,rgba(6,109,171,1) 100%); + } +#timerView { + position: absolute; + left: 240px; top: 135px; + width: 480px; height: 270px; + margin-top:3px; + margin-bottom:3px; + border-style:solid; + border-width:2px; + font-size:16px; + border-radius: 7px; + -webkit-border-radius: 7px; + padding-top:5px; + padding-bottom:5px; + padding-left:20px; + padding-right:20px; + background: rgba(6,109,171,1) 100%; + background: linear-gradient(135deg, #1e5799 0%,#2989d8 41%,#7db9e8 100%); + background: -webkit-linear-gradient(-45deg, #1e5799 0%,#2989d8 41%,#7db9e8 100%); + -webkit-box-shadow:3px 3px 7px 4px rgba(0,0,0, 0.5); +} + #selectScreen { position: absolute; left: 0px; top: 0px; diff --git a/smarttv-client/Javascript/Buttons.js b/smarttv-client/Javascript/Buttons.js index 2e293fd..5791aec 100644 --- a/smarttv-client/Javascript/Buttons.js +++ b/smarttv-client/Javascript/Buttons.js @@ -47,6 +47,10 @@ Buttons.ynReturnCallback = function () { case Main.eOPT: Options.drawServerList(); break; + case Main.eTMR: + Buttons.ynHide(); + Timers.focus(); + break; default: break; } @@ -74,9 +78,14 @@ Buttons.ynEnterCallback = function () { Options.drawServerList(); break; + case Main.eTMR: + Timers.deleteTimer(); + break; + } break; + } Buttons.ynHide(); }; @@ -143,10 +152,17 @@ Buttons.ynShow = function () { Buttons.ynHide = function () { this.ynButton.hide(); - if (Main.state == Main.eOPT) + switch (Main.state) { + case Main.eOPT: $("#optionsViewAnchor").focus(); - else + break; + case Main.eTMR: + Timers.focus(); + break; + default: Main.enableKeys(); + break; + }; }; Buttons.createStyleSheet = function () { @@ -382,6 +398,10 @@ ButtonHandler.prototype.onInput = function () { break; } - widgetAPI.blockNavigation(event); + try { + widgetAPI.blockNavigation(event); + } + catch (e) { + } }; diff --git a/smarttv-client/Javascript/Comm.js b/smarttv-client/Javascript/Comm.js index b6e216f..d732fca 100644 --- a/smarttv-client/Javascript/Comm.js +++ b/smarttv-client/Javascript/Comm.js @@ -12,6 +12,9 @@ Comm.init = function () { this.created = true; // >> Register custom manager callback to receive device connect and disconnect events + if (Config.deviceType != 0) + return; + Comm.customMgr = webapis.customdevice || {}; Comm.customMgr.registerManagerCallback(Comm.onDeviceStatusChange); diff --git a/smarttv-client/Javascript/Config.js b/smarttv-client/Javascript/Config.js index e32b74a..0583262 100755 --- a/smarttv-client/Javascript/Config.js +++ b/smarttv-client/Javascript/Config.js @@ -20,11 +20,13 @@ var Config = { usePdlForRecordings : true, uploadJsFile : "", directAcessTimeout : 1500, + infoTimeout : 3000, preferredQuality : 2, widgetVersion : "unknown", tzCorrection : 0, recSortType : 0, playKeyBehavior : 0, + haveYouTube : false, deviceType : 0 // Used to differentiate between browsers and platforms // 0: Samsung @@ -148,6 +150,10 @@ Config.fetchConfig = function () { Config.usePdlForRecordings = ($(data).find('usePdlForRecordings').text() == "false") ? false : true; Config.uploadJsFile = $(data).find('uploadJsFile').text(); Config.directAcessTimeout = $(data).find('directAcessTimeout').text(); + + Config.infoTimeout = parseInt( $(data).find('infoTimeout').text()); + Config.infoTimeout = isNaN(Config.infoTimeout) ? 3000 : Config.infoTimeout; + Config.preferredQuality = $(data).find('preferredQuality').text(); Config.sortType= parseInt($(data).find('sortType').text()); if ((Config.sortType < 0) || (Config.sortType > Data.maxSort) || isNaN(Config.sortType)) { @@ -155,7 +161,8 @@ Config.fetchConfig = function () { } Config.playKeyBehavior = parseInt($(data).find('playKeyBehavior').text()); Config.playKeyBehavior = isNaN(Config.playKeyBehavior) ? 0 : Config.playKeyBehavior; - + Config.haveYouTube = ($(data).find('youtubemenu').text() == "true") ? true : false + Player.skipDuration = Config.skipDuration; if (Config.directAcessTimeout != "") { DirectAccess.delay = Config.directAcessTimeout; @@ -360,7 +367,10 @@ VdrServers.prototype.handleResponse = function () { Main.log ("handle responses: Response " + this.responses + " of " + this.serverUrlList.length); this.responses ++; if (this.responses == this.serverUrlList.length) { - Main.log ("handle responses: Done. Active Servers= " + this.activeServers.length); + Main.log ("handle responses: Done. Active Servers= " + this.activeServers.length); + + SelectScreen.resetElements(); + switch (this.activeServers.length) { case 0: this.retries ++; diff --git a/smarttv-client/Javascript/Display.js b/smarttv-client/Javascript/Display.js index a8eb758..c0b1093 100755 --- a/smarttv-client/Javascript/Display.js +++ b/smarttv-client/Javascript/Display.js @@ -46,6 +46,7 @@ Display.init = function() this.volOlHandler.init(Display.handlerShowVolume, Display.handlerHideVolume); this.popupOlHandler.init(Display.handlerShowPopup, Display.handlerHidePopup); this.infoOlHandler.init(Display.handlerShowInfo, Display.handlerHideInfo); + this.infoOlHandler.olDelay = Config.infoTimeout; if (!this.statusDiv) { success = false; @@ -173,15 +174,16 @@ Display.selectItem = function (item) { item.style.background = "-webkit-linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1) 100%)"; item.style.borderRadius= "3px"; item.style["-webkit-box-shadow"] = "2px 2px 1px 2px rgba(0,0,0, 0.5)"; - // item.style.backgroundColor = "white"; + }; Display.unselectItem = function (item) { item.style.color = "white"; - item.style.backgroundColor = "transparent"; +// item.style.backgroundColor = "transparent"; item.style.background = "transparent"; item.style.borderRadius= "0px"; item.style["-webkit-box-shadow"] = ""; + }; Display.jqSelectItem = function (item) { diff --git a/smarttv-client/Javascript/Main.js b/smarttv-client/Javascript/Main.js index e7c06ae..1d62d74 100755 --- a/smarttv-client/Javascript/Main.js +++ b/smarttv-client/Javascript/Main.js @@ -52,9 +52,10 @@ var Main = { eLIVE : 1, // State Live Select Screen / Video Playing eREC : 2, // State Recording Select Screen / Video Playing eMED : 3, // State Media Select Screen / Video Playing - eURLS : 4, // State Urls - eSRVR : 5, // State Select Server - eOPT : 6, // Options + eTMR : 4, // State Timer Screen + eURLS : 5, // State Urls + eSRVR : 6, // State Select Server + eOPT : 7, // Options defKeyHndl : null, selectMenuKeyHndl : null, @@ -90,6 +91,7 @@ Main.onLoad = function() { Config.deviceType = 1; tvKey = Main.tvKeys; + Config.serverUrl = "http://" + Config.serverAddrDefault; Main.log("Not a Samsung Smart TV" ); // Display.showPopup("Not a Samsung Smart TV. Lets see, how far we come"); } @@ -183,18 +185,21 @@ Main.init = function () { Server.updateVdrStatus(); - HeartbeatHandler.start(); - - - DirectAccess.init(); + HeartbeatHandler.start(); + DirectAccess.init(); Comm.init(); + Timers.init(); +// Timers.show(); + + + if (Config.deviceType == 0){ Main.log("ProductInfo= " + deviceapis.tv.info.getProduct()); Main.logToServer("ProductInfo= " + deviceapis.tv.info.getProduct()); Main.logToServer("isBdPlayer= " + Main.isBdPlayer()); Main.logToServer("TimeZone= " + deviceapis.tv.info.getTimeZone()); - + } // TestHandler.showMenu(20); // window.setTimeout(function() {Config.updateContext("192.168.1.142:8000"); }, (10*1000)); @@ -321,6 +326,11 @@ Main.changeState = function (state) { Main.urlsSelected(); break; + case Main.eTMR: + $("#selectScreen").hide(); + ClockHandler.start("#logoNow"); + Timers.show(); + break; case Main.eSRVR: Config.vdrServers.checkServers(); break; @@ -437,23 +447,28 @@ Main.enableKeys = function() { document.getElementById("anchor").focus(); }; -Main.keyDown = function(event) { -event = event || window.event; +Main.keyDown = function() { + var ev = event || window.event; + var keyCode = ev.keyCode; + + Main.logToServer("State= " + this.state + ": Key pressed: " + Main.getKeyCode(keyCode)); + Main.log("State= " + this.state + ": Key pressed: " + Main.getKeyCode(keyCode)); + switch (this.state) { case 0: // selectView - this.selectMenuKeyHndl.handleKeyDown(event); + this.selectMenuKeyHndl.handleKeyDown(keyCode); break; case Main.eLIVE: // Live Main.log("Live - Main.keyDown PlayerState= " + Player.getState()); if(Player.getState() == Player.STOPPED) { // Menu Key - this.menuKeyHndl.handleKeyDown(event); + this.menuKeyHndl.handleKeyDown(keyCode); } else { // Live State Keys - this.livePlayStateKeyHndl.handleKeyDown(event); + this.livePlayStateKeyHndl.handleKeyDown(keyCode); }; break; @@ -464,11 +479,11 @@ event = event || window.event; // Main.log("Recordings - Main.keyDown PlayerState= " + Player.getState()); if(Player.getState() == Player.STOPPED) { // Menu Key - this.menuKeyHndl.handleKeyDown(event); + this.menuKeyHndl.handleKeyDown(keyCode); } else { // Play State Keys - this.playStateKeyHndl.handleKeyDown(event); + this.playStateKeyHndl.handleKeyDown(keyCode); }; break; @@ -688,16 +703,16 @@ function cPlayStateKeyHndl(def_hndl) { }; -cPlayStateKeyHndl.prototype.handleKeyDown = function (event) { - var keyCode = event.keyCode; +cPlayStateKeyHndl.prototype.handleKeyDown = function (keyCode) { +// var keyCode = event.keyCode; if(Player.getState() == Player.STOPPED) { Main.log("ERROR: Wrong state - STOPPED"); return; } - Main.log(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode)); - Main.logToServer(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode)); +// Main.log(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode)); +// Main.logToServer(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode)); switch(keyCode) { @@ -884,15 +899,15 @@ function cLivePlayStateKeyHndl(def_hndl) { }; -cLivePlayStateKeyHndl.prototype.handleKeyDown = function (event) { - var keyCode = event.keyCode; +cLivePlayStateKeyHndl.prototype.handleKeyDown = function (keyCode) { +// var keyCode = event.keyCode; if(Player.getState() == Player.STOPPED) { Main.log("ERROR: Wrong state - STOPPED"); return; } - Main.log(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode)); +// Main.log(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode)); switch(keyCode) { case tvKey.KEY_ASPECT: @@ -1076,8 +1091,8 @@ function cMenuKeyHndl (def_hndl) { }; -cMenuKeyHndl.prototype.handleKeyDown = function (event) { - var keyCode = event.keyCode; +cMenuKeyHndl.prototype.handleKeyDown = function (keyCode) { +// var keyCode = event.keyCode; switch(keyCode) { case tvKey.KEY_0: @@ -1589,8 +1604,11 @@ Main.tvKeys = { KEY_RIGHT :39, KEY_ENTER :13, + KEY_RETURN :27, KEY_STOP :27, // ESC // KEY_MUTE :27, + KEY_RED :82, + KEY_1 :49, KEY_2 :50, KEY_3 :51, diff --git a/smarttv-client/Javascript/Options.js b/smarttv-client/Javascript/Options.js index efa5a63..9964a00 100755 --- a/smarttv-client/Javascript/Options.js +++ b/smarttv-client/Javascript/Options.js @@ -53,7 +53,7 @@ Options.hide = function() { $("#optionsScreen").hide(); // document.getElementById("optionsScreen").style.display="none"; Helpbar.hide(); - Helpbar.hideSrv(); +// Helpbar.hideSrv(); Main.enableKeys(); }; diff --git a/smarttv-client/Javascript/Player.js b/smarttv-client/Javascript/Player.js index a21c933..e6fdf59 100755 --- a/smarttv-client/Javascript/Player.js +++ b/smarttv-client/Javascript/Player.js @@ -95,8 +95,10 @@ Player.resetAtStop = function () { return; } this.aspectRatio = this.eASP16to9; + if (this.effectMode != 0) { + Player.screenObj.Set3DEffectMode(0); + } this.effectMode = 0; - this.bufferState = 0; Player.ResetTrickPlay(); // is the GUI resetted as well? diff --git a/smarttv-client/Javascript/SelectScreen.js b/smarttv-client/Javascript/SelectScreen.js index 2d985c6..f7cb631 100644 --- a/smarttv-client/Javascript/SelectScreen.js +++ b/smarttv-client/Javascript/SelectScreen.js @@ -8,27 +8,31 @@ SelectScreen.init = function() { Main.logToServer("Config.getWidgetVersion= " + Config.widgetVersion) ; var parent = $("#selectView"); var idx = 0; - - this.keyToStateMap[idx] = Main.eMAIN; + $("#selectScreen").show(); + + this.keyToStateMap[idx] = Main.eMAIN; // State of this view this.keyToStateMap[++idx] = Main.eLIVE; - parent.append($("
", {id : "selectItem"+idx, text:idx+": Live", style : "padding-bottom:3px; margin-top:5px; margin-bottom : 5px; text-align: center"})); - + parent.append($("
", {id : "selectItem"+idx, text:idx+": Live", class : "style_menuItem"})); + this.keyToStateMap[++idx] = Main.eREC; - parent.append($("
", {id : "selectItem"+idx, text:idx+": Recordings", style : "padding-bottom:3px; margin-top:5px; margin-bottom : 5px; text-align: center"})); + parent.append($("
", {id : "selectItem"+idx, text:idx+": Recordings", class : "style_menuItem"})); this.keyToStateMap[++idx] = Main.eMED; - parent.append($("
", {id : "selectItem"+idx, text:idx+": Media", style : "padding-bottom:3px; margin-top:5px; margin-bottom : 5px; text-align: center"})); + parent.append($("
", {id : "selectItem"+idx, text:idx+": Media", class : "style_menuItem"})); + + this.keyToStateMap[++idx] = Main.eTMR; + parent.append($("
", {id : "selectItem"+idx, text:idx+": Timers", class : "style_menuItem"})); if (Config.haveYouTube) { this.keyToStateMap[++idx] = Main.eURLS; - parent.append($("
", {id : "selectItem"+idx, text:idx+": You Tube", style : "padding-bottom:3px; margin-top:5px; margin-bottom : 5px; text-align: center"})); - selectMenuKeyHndl.selectMax++; + parent.append($("
", {id : "selectItem"+idx, text:idx+": You Tube", class : "style_menuItem"})); +// Main.selectMenuKeyHndl.selectMax++; } this.keyToStateMap[++idx] = Main.eSRVR; - parent.append($("
", {id : "selectItem"+idx, text:idx+": Select Server", style : "padding-bottom:3px; margin-top:5px; margin-bottom : 5px; text-align: center"})); + parent.append($("
", {id : "selectItem"+idx, text:idx+": Select Server", class : "style_menuItem"})); this.keyToStateMap[++idx] = Main.eOPT; - parent.append($("
", {id : "selectItem"+idx, text:idx+": Options", style : "padding-bottom:3px; margin-top:5px; margin-bottom : 5px; text-align: center"})); + parent.append($("
", {id : "selectItem"+idx, text:idx+": Options", class : "style_menuItem"})); /* var done = false; @@ -50,12 +54,22 @@ SelectScreen.init = function() { } */ + Main.selectMenuKeyHndl.selectMax = idx; Display.selectItem(document.getElementById("selectItem1")); // Display.jqSelectItem($("#selectItem1")); Main.log("SelectScreen.init - done"); }; +SelectScreen.resetElements = function () { + $('.style_menuItem').remove(); + this.keyToStateMap = []; +// Main.selectMenuKeyHndl.selectMax = 5; + Main.selectMenuKeyHndl.select =1; +// Main.selectedVideo = 0; + +}; + SelectScreen.keyToState = function (key) { }; @@ -72,9 +86,9 @@ function cSelectMenuKeyHndl (def_hndl) { // this.selectMax = 6; // Highest Select Entry }; -cSelectMenuKeyHndl.prototype.handleKeyDown = function (event) { - var keyCode = event.keyCode; - Main.log(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode)); +cSelectMenuKeyHndl.prototype.handleKeyDown = function (keyCode) { +// var keyCode = event.keyCode; +// Main.log(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode)); switch(keyCode) { case tvKey.KEY_1: diff --git a/smarttv-client/Javascript/Server.js b/smarttv-client/Javascript/Server.js index 8c696b7..fd8959c 100755 --- a/smarttv-client/Javascript/Server.js +++ b/smarttv-client/Javascript/Server.js @@ -376,6 +376,38 @@ Server.execRecCmd = function (cmd, guid) { }); }; +Server.getErrorText = function (status, input) { + var errno = parseInt(input.slice(0, 3)); + + var res = ""; + switch (status) { + case 400: // Bad Request + switch (errno) { + case 10: + res = "No Timer found."; + break; + default: + res = "Unhandled Errno - Status= " + status + " Errno= "+ errno; + break; + } + break; + case 503: // Service unavailable + switch (errno) { + case 1: + res = "Timers are being edited."; + break; + default: + res = "Unhandled Errno - Status= " + status + " Errno= "+ errno; + break; + } + break; + default: + res = "Unhandled Status - Status= " + status + " Errno= "+ errno; + break; + }; + return res; +}; + var HeartbeatHandler = { timeoutObj : null, isActive : false diff --git a/smarttv-client/Javascript/Timers.js b/smarttv-client/Javascript/Timers.js index c7110c7..29db55c 100644 --- a/smarttv-client/Javascript/Timers.js +++ b/smarttv-client/Javascript/Timers.js @@ -1,64 +1,289 @@ var Timers = { - haveRapi : false, - timerList : {} + timerList : [], + scrollDur : 300, + scrollFlip : 100 + }; Timers.init = function() { - var url = "http://192.168.1.122:8002/info.xml"; + /* + div with scrolling property + defualt: left ad right half + Line has "RecOngoing" "Channel" "Start" "Stop" "Title" + */ + + this.btnSelected = 0; + this.scrolling = false; + + var elem = document.getElementById('timerScreen-anchor'); + elem.setAttribute('onkeydown', 'Timers.onInput();'); + + $("#timerScreen").hide(); +}; + +Timers.show = function() { + Main.log("Timers.show"); + $("#timerScreen").show(); + this.btnSelected = 0; + + Timers.focus(); + Timers.readTimers(); +// Timers.debug(); +}; + +Timers.focus = function () { + Main.log("Timers.focus"); + + $("#timerScreen-anchor").focus(); +}; + +Timers.debug = function () { + for (var i = 0; i < 20; i++) { + Timers.timerList.push( {title: "Timer One two three VZGTTTTTTGFDDD GHGZG"+i, isSingleEvent: true, printday:"", weekdays:0, + day: 0, start:2015, stop:2013, starttime: 0, stoptime: 0, channelid: "", channelname : "Hello Channel", flags: 0, + index: i, isrec: false, eventid: 0 }); + + } + Timers.createMenu(); +}; + +Timers.hide = function() { + + $("#timerScreen").hide(); + Main.changeState(Main.eMAIN); + Main.enableKeys(); + + Timers.timerList = []; + $("#timerTable").remove(); + +}; + +Timers.insertColon = function (t) { +// insert the collon before the last two digits + var len = t.length; + + var o = t; + if (len >= 2) { + o = t.substr(0, (len-2)) + ":" + t.substr(len-2); + switch (o.length) { + case 3: + o = "00" +o; + break; + case 4: + o = "0" + o; + break; + }; + } + return o; +}; + +Timers.readTimers = function () { + var url = Config.serverUrl + "/timers.xml"; $.ajax({ url: url, type : "GET", success : function(data, status, XHR ) { - Timers.haveRapi = true; Main.log ("Timers: Got response"); - Timers.readTimers(); - + $(data).find("timer").each(function () { + var title = $(this).find('file').text(); + var isSingleEvent = ($(data).find('issingleevent').text() == "true") ? true : false; + + var printday = $(this).find('printday').text(); + var weekdays = parseInt($(this).find('weekdays').text()); + var day = parseInt($(this).find('day').text()); + var start = $(this).find('start').text(); + var stop = $(this).find('stop').text(); + var starttime = parseInt($(this).find('starttime').text()); + var stoptime = parseInt($(this).find('stoptime').text()); + var channelid = $(this).find('channelid').text(); + var channelname = $(this).find('channelname').text(); + var flags = parseInt($(this).find('flags').text()); + var index = parseInt($(this).find('index').text()); + var isrec = ($(this).find('isrec').text() == "true") ? true: false; + var eventid = parseInt($(this).find('eventid').text()); + + Timers.timerList.push( {title: title, isSingleEvent: isSingleEvent, printday:printday, weekdays:weekdays, + day: day, start: Timers.insertColon(start), stop: Timers.insertColon(stop), starttime: starttime, stoptime: stoptime, channelid: channelid, channelname : channelname, + flags: flags, index: index, isrec: isrec, eventid: eventid }); + }); + + Timers.createMenu(); }, error : function (jqXHR, status, error) { - Timers.haveRapi = false; - Main.log ("Timers: Not found!!!"); + Main.logToServer ("Timers: Not found!!!"); } - }); + }); }; -Timers.readTimers = function () { - if (Timers.haveRapi == false) { - Main.log ("Timers.readTimers: no restful API!!!"); - return; +Timers.createMenu= function () { + var p_width = $("body").outerWidth(); + var p_height = $("body").outerHeight(); + + var table = $("
", {id : "timerTable", style :"overflow-y: scroll;margin-top:3px;margin-bottom:3px;height:100%;"}); + $("#timerView").append(table); + + $("#timerScreen").show(); + for (var i = 0; i < Timers.timerList.length; i++) { + Main.log("Timers: " + Timers.timerList[i].title); + table.append(Timers.createEntry(i, $("#timerTable").width())); + } + + this.btnSelected = 0; + $("#tmr-0").removeClass('style_menuItem').addClass('style_menuItemSelected'); + + +}; + +Timers.createEntry= function (i, w) { + Main.log("width= " +w); + var row = $("
", {id: "tmr-"+i, class : "style_menuItem", style : "text-align:left;overflow-x: hidden;white-space : nowrap;"}); //, style : "text-overflow: ellipsis;white-space : nowrap;" + +// row.append($("
", {class : ((Timers.timerList[i].isrec ==true) ? "style_timerRec" : ""), style : "display: inline-block;"})); + row.append($("
", {class : ((Timers.timerList[i].isrec ==true) ? "style_timerRec" : "style_timerNone"), style : "display: inline-block;"})); // + row.append($("
", {text : Timers.timerList[i].channelname, style : "padding-left:5px;width:12%; display: inline-block;", class : "style_overflow"})); + row.append($("
", {text : Timers.timerList[i].start, style : "padding-left:5px; width:9%; display: inline-block;", class : "style_overflow"})); + row.append($("
", {text : Timers.timerList[i].stop, style : "padding-left:5px; width:9%; display: inline-block;", class : "style_overflow"})); + row.append($("
", {text : Timers.timerList[i].title, style : "padding-left:5px; width:68%;display: inline-block;", class : "style_overflow"})); + + return row; +}; + +Timers.resetBtns = function () { + this.btnSelected = 0; + for (var i =0; i <= Timers.timerList.length; i++) { + $("#tmr-" + i).removeClass('style_menuItemSelected').addClass('style_menuItem'); } - var url = "http://192.168.1.122:8002/timers.xml"; + $("#tmr-0").removeClass('style_menuItem').addClass('style_menuItemSelected'); +}; + +Timers.resetView = function () { + Timers.timerList = []; + $("#timerTable").remove(); + + Timers.readTimers(); + + +}; + +Timers.deleteTimer = function () { +// delete the current timer + Main.log("****** Delete Timer: " + Timers.timerList[this.btnSelected].title); + + var del_req = new DeleteTimerReq (Timers.timerList[this.btnSelected].index); +// var del_req = new DeleteTimerReq (10); + +} + +Timers.selectBtnUp = function () { + var btnname = "#tmr-"+this.btnSelected; + Main.log( "Timers-BtnUp: Old: " +this.btnSelected + " btn= "+btnname); + $(btnname).removeClass('style_menuItemSelected').addClass('style_menuItem'); + if (this.btnSelected == 0) { + this.btnSelected = (Timers.timerList.length-1); + $("#timerTable").animate ({scrollTop: $("#tmr-" + this.btnSelected).position().top}, this.scrollFlip); + } + else { + this.btnSelected--; + var pos = $("#tmr-" + this.btnSelected).position().top; + Main.log("pos= " + pos + " ovlBodyHeight= " + $("#timerTable").height() + " scrollTop= " + $("#timerTable").scrollTop()); + if (pos < 0) { + $("#timerTable").animate ({scrollTop: $("#timerTable").scrollTop() + pos}, this.scrollDur); + Main.log("New scrollTop= " +$("#timerTable").scrollTop() +" new pos= " + $("#tmr-" + this.btnSelected).position().top); + } + + } + $("#tmr-" + this.btnSelected).removeClass('style_menuItem').addClass('style_menuItemSelected'); + Main.log("Timers-BtnUp: New: " +this.btnSelected); +}; + +Timers.selectBtnDown = function () { + var btnname = "#tmr-"+this.btnSelected; + $("#tmr-" + this.btnSelected).removeClass('style_menuItemSelected').addClass('style_menuItem'); + Main.log( "Timers-BtnDown: Old: " +this.btnSelected + " btn= "+btnname); + if (this.btnSelected == (Timers.timerList.length-1)) { + this.btnSelected = 0; + $("#timerTable").animate ({scrollTop: 0}, this.scrollFlip); + } + else { + this.btnSelected++; + var pos = $("#tmr-" + this.btnSelected).position().top; + var height = $("#tmr-" + this.btnSelected).outerHeight() +10; + Main.log("pos= " + pos + " height= " + height + " ovlBodyHeight= " + $("#timerTable").height() + " scrollTop= " + $("#timerTable").scrollTop()); + if ((pos + height) > $("#timerTable").height()) { + $("#timerTable").animate ({scrollTop: $("#timerTable").scrollTop() + (pos + height) - $("#timerTable").height()}, this.scrollDur); + Main.log("New scrollTop= " +$("#timerTable").scrollTop() +" new pos= " + $("#tmr-" + this.btnSelected).position().top); + } + + } + Main.log( "Timers-BtnDown: New: " +this.btnSelected ); + + $("#tmr-" + this.btnSelected).removeClass('style_menuItem').addClass('style_menuItemSelected'); +}; + +Timers.onInput = function () { + var keyCode = event.keyCode; + Main.log(" Timers key= " + keyCode); + switch(keyCode) { + case tvKey.KEY_UP: + Main.log("Timers-Select Up"); + this.selectBtnUp(); + break; + case tvKey.KEY_DOWN: + Main.log("Timers-Select Down"); + this.selectBtnDown(); + break; + case tvKey.KEY_ENTER: + Buttons.ynShow(); +// Timers.hide(); + + break; + case tvKey.KEY_RETURN: + case tvKey.KEY_EXIT: + Timers.hide(); + + if (this.returnCallback != null) + this.returnCallback(); + break; + + } + try { + widgetAPI.blockNavigation(event); + } + catch (e) { + }; +}; + + + +function DeleteTimerReq (idx) { + this.index = idx; + this.exec(); +}; + +DeleteTimerReq.prototype.exec = function () { + Main.log("Sending delete request for idx= " + this.index); $.ajax({ - url: url, + url: Config.serverUrl + "/deleteTimer?index=" +this.index, type : "GET", + context : this, success : function(data, status, XHR ) { - Main.log ("Timers.readTimer: Success"); - Main.log(" Count= " + $(data).find("count").text()); - $(data).find("timer").each(function () { - Main.log("timer: "); - Timers.curItem = {}; - $(this).find("param").each(function () { - Main.log(" + " + $(this).attr("name") + " val= " +$(this).text()); - Timers.curItem[$(this).attr("name")] = $(this).text(); - }); -/* for (var prop in Timers.curItem) { - Main.log (" -" + prop + " : " + Timers.curItem[prop]); - } - */ - Main.log("Adding id " +Timers.curItem["id"]); - Timers.timerList[Timers.curItem["id"]] = Timers.curItem; - Timers.curItem = {}; - }); - Main.log("Summary"); - for (var id in Timers.timerList) { - Main.log (id + " : "); - for (var prop in Timers.timerList[id]) { - Main.log (" - " + prop + " : " + Timers.timerList[id][prop]); - } - - } - }, - error : function (jqXHR, status, error) { - Main.log ("Timers.readTimer: Failure"); + Main.logToServer("Timers.deleteTimer: Success" ); + Main.log("Timers.deleteTimer: Success" ); + + Timers.resetView(); + // remove index from database + }, + error : function (XHR, status, error) { + Main.logToServer("Timers.deleteTimer: ERROR " + XHR.status + ": " + XHR.responseText ); + Main.log("Timers.deleteTimer: ERROR (" + XHR.status + ": " + XHR.responseText +")"); + + var res = Server.getErrorText(XHR.status, XHR.responseText); +// var res = parseInt(XHR.responseText.slice(0, 3)); + Main.log("Timers.deleteTimer: res(" + res +") for idx= " + this.index); + + Notify.showNotify( res, true); + } - }); -}; \ No newline at end of file + }); + +}; diff --git a/smarttv-client/index.html b/smarttv-client/index.html index 3ec5c46..8575cd8 100755 --- a/smarttv-client/index.html +++ b/smarttv-client/index.html @@ -210,5 +210,11 @@
+
+ + +
+
+ -- cgit v1.2.3