From 0e6de3bdde26492255b6840670affe11068babf0 Mon Sep 17 00:00:00 2001 From: thlo Date: Sat, 14 Sep 2013 18:14:06 +0200 Subject: Show Key Bindings (help overlay) when pressing the tools key. Timer Activation and Deactivation. Verbose start for debugging. Scrolling popup for Debugging. ImageViewer improvements. --- smarttv-client/CSS/Main.css | 34 +- smarttv-client/Images/helpbar/help_pause.png | Bin 0 -> 206 bytes smarttv-client/Images/helpbar/help_play.png | Bin 0 -> 236 bytes smarttv-client/Images/helpbar/help_rec.png | Bin 0 -> 320 bytes smarttv-client/Images/helpbar/help_stop.png | Bin 0 -> 214 bytes smarttv-client/Javascript/Buttons.js | 20 +- smarttv-client/Javascript/Config.js | 92 +++-- smarttv-client/Javascript/Helpbar.js | 192 ++++++++- smarttv-client/Javascript/ImgViewer.js | 131 +++++- smarttv-client/Javascript/Main.js | 30 +- smarttv-client/Javascript/Network.js | 3 - smarttv-client/Javascript/Options.js | 9 +- smarttv-client/Javascript/Server.js | 592 +++++++++++++++++++++++---- smarttv-client/Javascript/Timers.js | 69 +++- smarttv-client/config.xml | 2 +- 15 files changed, 1033 insertions(+), 141 deletions(-) create mode 100644 smarttv-client/Images/helpbar/help_pause.png create mode 100644 smarttv-client/Images/helpbar/help_play.png create mode 100644 smarttv-client/Images/helpbar/help_rec.png create mode 100644 smarttv-client/Images/helpbar/help_stop.png (limited to 'smarttv-client') diff --git a/smarttv-client/CSS/Main.css b/smarttv-client/CSS/Main.css index aea87a6..93aba17 100755 --- a/smarttv-client/CSS/Main.css +++ b/smarttv-client/CSS/Main.css @@ -94,18 +94,50 @@ body { border-radius: 4px; background: red; } + +.style_timerAct { + width :8px; + height:8px; + border-radius: 4px; + background: green; +} + .style_timerNone { width :8px; } .style_headline { color : black; + font-size:14px; background : linear-gradient(0deg, #1e5799 0%,#2989d8 41%,#7db9e8 100%); background : -webkit-linear-gradient(top, #1e5799 0%,#2989d8 41%,#7db9e8 100%); border-radius: 3px; -webkit-box-shadow: 2px 2px 1px 2px rgba(0,0,0, 0.5); } + +.style_hbOverlay { + position: absolute; + z-index:70; + border-radius: 7px; + border-width:1px; + background:rgba(0,0,139, 0.8); + border-style:solid; + border-width:1px; + -webkit-box-shadow:3px 3px 7px 4px rgba(0,0,0, 0.5); +} + +.style_hbOverlayRow { + padding-left : 5px; + padding-right: 5px; +} + +.style_hbOverlayLElm { +} +.style_hbOverlayRElm { +} + + #timerScreen { position: absolute; left: 0px; top: 0px; @@ -302,7 +334,7 @@ body { position: absolute; display: none; left: 120px; top: 10px; - width: 720px; height: 100px; + width: 720px; height: 200px; border-style:solid; border-width:2px; -webkit-border-radius: 7px; diff --git a/smarttv-client/Images/helpbar/help_pause.png b/smarttv-client/Images/helpbar/help_pause.png new file mode 100644 index 0000000..f3214c7 Binary files /dev/null and b/smarttv-client/Images/helpbar/help_pause.png differ diff --git a/smarttv-client/Images/helpbar/help_play.png b/smarttv-client/Images/helpbar/help_play.png new file mode 100644 index 0000000..c21cd7a Binary files /dev/null and b/smarttv-client/Images/helpbar/help_play.png differ diff --git a/smarttv-client/Images/helpbar/help_rec.png b/smarttv-client/Images/helpbar/help_rec.png new file mode 100644 index 0000000..e26ce3e Binary files /dev/null and b/smarttv-client/Images/helpbar/help_rec.png differ diff --git a/smarttv-client/Images/helpbar/help_stop.png b/smarttv-client/Images/helpbar/help_stop.png new file mode 100644 index 0000000..ca5c7b6 Binary files /dev/null and b/smarttv-client/Images/helpbar/help_stop.png differ diff --git a/smarttv-client/Javascript/Buttons.js b/smarttv-client/Javascript/Buttons.js index 5791aec..3b946db 100644 --- a/smarttv-client/Javascript/Buttons.js +++ b/smarttv-client/Javascript/Buttons.js @@ -42,6 +42,7 @@ Buttons.init = function (){ // $("#prc-buttons-anchor").attr("onkeydown", "Button.prButton.onInput();"); } }; + Buttons.ynReturnCallback = function () { switch (Main.state) { case Main.eOPT: @@ -50,6 +51,10 @@ Buttons.ynReturnCallback = function () { case Main.eTMR: Buttons.ynHide(); Timers.focus(); + break; + case Main.eMED: + Buttons.ynHide(); + break; default: break; @@ -79,9 +84,12 @@ Buttons.ynEnterCallback = function () { break; case Main.eTMR: - Timers.deleteTimer(); + + Timers.timerCallback(); + break; + case Main.eMED: + Server.deleteMedFile(Data.getCurrentItem().childs[Main.selectedVideo].payload.guid); break; - } break; @@ -144,6 +152,11 @@ Buttons.prcHide = function () { Main.enableKeys(); }; +//change the Headline Text of the yn buttons (Default is "Delete ?") +Buttons.ynHeadlineText = function(msg) { + $("#yn-btn-text").text(msg); +}; + Buttons.ynShow = function () { Main.log("Buttons.ynShow()"); this.ynButton.show(); @@ -151,6 +164,7 @@ Buttons.ynShow = function () { }; Buttons.ynHide = function () { + $("#yn-btn-text").text("Delete ?"); this.ynButton.hide(); switch (Main.state) { case Main.eOPT: @@ -257,7 +271,7 @@ Buttons.createYnButtons= function () { var row = $("", {style: "width:100%; align:center"}); var cell = $("", {style :"height:80%; width:100%", colspan:"3" }); cell.css("align","center"); - var txt_div = $("
", {text: "Delete ?"}); + var txt_div = $("
", {text: "Delete ?", id : "yn-btn-text"}); cell.append(txt_div); row.append(cell); tbody.append(row); diff --git a/smarttv-client/Javascript/Config.js b/smarttv-client/Javascript/Config.js index 0583262..08c4cf5 100755 --- a/smarttv-client/Javascript/Config.js +++ b/smarttv-client/Javascript/Config.js @@ -27,9 +27,9 @@ var Config = { recSortType : 0, playKeyBehavior : 0, haveYouTube : false, + verboseStart : false, // Debug Messages during start (before widget.conf is loaded) deviceType : 0 // Used to differentiate between browsers and platforms // 0: Samsung - }; @@ -56,12 +56,11 @@ Config.init = function () { if (this.serverUrl != "") { // Hardcoded server URL. Done with config Main.log ("Hardcoded server URL. Done with config"); + Display.showPopup ("Hardcoded server URL. Done with config"); Config.fetchConfig(); return; } - -// if (this.deviceType == 0) switch (this.deviceType){ case 0: // This is a Samsung Smart TV @@ -71,13 +70,22 @@ Config.init = function () { } catch (e) { Main.log("curWidget.id does not exists. Is that really a Samsung?"); + Display.showPopup ("curWidget.id does not exists. Is that really a Samsung?"); return; }; var fileSystemObj = new FileSystem(); - if (fileSystemObj.isValidCommonPath(curWidget.id) == 0){ +// if (fileSystemObj.isValidCommonPath(curWidget.id) == 0){ + if (fileSystemObj.isValidCommonPath(curWidget.id) != 1){ +// isValidCommonPath returns: +// 0 : JS function failed +// 1 : valid +// 2 : invalid + Main.log("First Launch of the Widget"); + if (Config.verboseStart == true) + Display.showPopup ("First Launch of the Widget"); // should switch to the config screen here var res = fileSystemObj.createCommonDir(curWidget.id); if (res == true) { @@ -85,8 +93,8 @@ Config.init = function () { return; } else { + Display.showPopup ("WARNING: Cannot create widget folder. Ignoring and trying to configure"); Config.doFirstLaunch(); - Display.showPopup ("WARNING: Cannot create widget folder. Try Config"); // Display.showPopup (Lang[Lang.sel].configInit); // Main.logToServer("ERROR: Cannot create widget folder curWidget.id= " +curWidget.id); @@ -94,17 +102,28 @@ Config.init = function () { return; } else { - // ok, there should be some config info + // ok, there should be some config info + if (Config.verboseStart == true) + Display.showPopup ("Reading Context Now"); + Config.readContext(); + // async check of available VDR servers. Will continue from a different place return; //thlo: TODO } break; + default: + // another TV set. + break; } + + //the function is likely never executed to the end. Check! Server.notifyServer("started"); Config.fetchConfig(); }; Config.doFirstLaunch = function () { + if (Config.verboseStart == true) + Display.showPopup("OK: First Launch. Configure now"); Config.firstLaunch = true; Main.changeState(Main.eOPT); @@ -129,10 +148,15 @@ Config.getWidgetVersion = function () { Config.fetchConfig = function () { + if (Config.verboseStart == true) + Display.showPopup ("Fetching widget.conf..."); + $.ajax({ url: this.serverUrl + "/widget.conf", type : "GET", success : function(data, status, XHR ) { + if (Config.verboseStart == true) + Display.showPopup ("Processing widget.conf..."); Main.log ("Parsing config XML now"); Main.logToServer("Parsing config XML now"); @@ -188,7 +212,7 @@ Config.fetchConfig = function () { }, error : function (XHR, status, error) { Main.log ("Config Server Error"); - Display.showPopup("Config Server Error " + XHR.status + " " + status); + Display.showPopup("ERROR while fetching widget.conf " + XHR.status + " " + status); // Display.showPopup(Lang[Lang.sel].configNoServer + " "+ XHR.status + " " + status); Main.logToServer("Config Server Error " + XHR.status + " " + status); @@ -209,7 +233,10 @@ Config.deletedFromContext = function(idx) { Config.updateContext = function (addr) { Main.log("Config.updateContext with ("+addr+")"); Main.logToServer("Config.updateContext with ("+addr+")"); - + + if ((Config.verboseStart == true) && (Config.firstLaunch == true)) + Display.showPopup("Config.updateContext with ("+addr+")"); + var found = false; for (var i = 0; i < Config.vdrServers.serverUrlList.length; i++) { @@ -223,27 +250,15 @@ Config.updateContext = function (addr) { // don't overwrite, if the address is already there. Main.log("Config.updateContext: don't overwrite -> return"); Notify.showNotify("Server already included -> Ignoring", true); - + if ((Config.verboseStart == true) && (Config.firstLaunch == true)) + Display.showPopup("Config.updateContext: don't overwrite -> return"); return; } Config.vdrServers.serverUrlList.push(addr); Config.writeServerUrlList(); - /* - var fileSystemObj = new FileSystem(); - var fd = fileSystemObj.openCommonFile(Config.cfgFileName,"w"); - -// fd.writeLine('serverAddr ' + addr); // SHould be overwritten by Options menue - for (var i = 0; i < Config.vdrServers.serverUrlList.length; i++) { - Main.log ("Config.updateContext itm= " + Config.vdrServers.serverUrlList[i]); - Main.logToServer ("Config.updateContext itm= " + Config.vdrServers.serverUrlList[i]); - fd.writeLine('serverAddr ' + Config.vdrServers.serverUrlList[i]); - } - - fileSystemObj.closeCommonFile(fd); -*/ - if (Config.serverAddr == "") { + if (Config.serverAddr == "") { // only change the server, when needed. Config.serverAddr = addr; Config.serverUrl = "http://" + Config.serverAddr; @@ -251,16 +266,6 @@ Config.updateContext = function (addr) { } }; -/* -Config.writeContext = function (addr) { - var fileSystemObj = new FileSystem(); - - var fd = fileSystemObj.openCommonFile(Config.cfgFileName,"w"); - - fd.writeLine('serverAddr ' + addr); // SHould be overwritten by Options menue - fileSystemObj.closeCommonFile(fd); -}; -*/ Config.writeServerUrlList = function () { var fileSystemObj = new FileSystem(); @@ -269,11 +274,15 @@ Config.writeServerUrlList = function () { for (var i = 0; i < Config.vdrServers.serverUrlList.length; i++) { Main.log ("Config.writeServerUrlList itm= " + Config.vdrServers.serverUrlList[i]); Main.logToServer ("Config.writeServerUrlList itm= " + Config.vdrServers.serverUrlList[i]); + if (Config.verboseStart == true) + Display.showPopup ("Config.writeServerUrlList: writing VdrServer= " + Config.vdrServers.serverUrlList[i]); + fd.writeLine('serverAddr ' + Config.vdrServers.serverUrlList[i]); } fileSystemObj.closeCommonFile(fd); - + if (Config.verboseStart == true) + Display.showPopup ("Config.writeServerUrlList done "); }; Config.readContext = function () { @@ -291,7 +300,10 @@ Config.readContext = function () { if (avp.length > 1) { Config.vdrServers.serverUrlList.push(avp[1]); Main.log("Config.readContext avp[1]= " + avp[1]); - Config.serverAddr = avp[1]; + if (Config.verboseStart == true) + Display.showPopup ("Config.readContext: serverAddr= " + avp[1]); + + Config.serverAddr = avp[1]; Config.serverUrl = "http://" + Config.serverAddr; } else { @@ -306,10 +318,12 @@ Config.readContext = function () { } catch (e) { Main.log("Config.readContext: Error while reading: e= " +e); + Display.showPopup("Config.readContext: Error while reading: e= " +e); + Display.showPopup("Trying to create now the local config file" ); var res = fileSystemObj.createCommonDir(curWidget.id); if (res == true) { Main.log("WARNING: ConfigRead Error. Launching Config-Menu from here"); - // Display.showPopup ("Config Read Error: Try widget restart"); + Display.showPopup ("Config Read Error: Try widget restart"); } else { @@ -318,13 +332,13 @@ Config.readContext = function () { Display.showPopup ("WARNING: ConfigRead Error and WidgetFolder creation failed.
Launching Config-Menu from here"); // Display.showPopup (Lang[Lang.sel].configRead2); -// Main.log("-------------- Error: res = false ------------------------"); } Config.doFirstLaunch(); } - -// Config.vdrServers.serverUrlList.push("192.168.1.142:8000"); + + // Now, I read at least one VDR server address from Config file + this.vdrServers.checkServers(); if (Config.vdrServers.serverUrlList.length > 1) { // Now I should show the popup to select the server. diff --git a/smarttv-client/Javascript/Helpbar.js b/smarttv-client/Javascript/Helpbar.js index 7511e09..ccff0f9 100644 --- a/smarttv-client/Javascript/Helpbar.js +++ b/smarttv-client/Javascript/Helpbar.js @@ -4,6 +4,10 @@ var Helpbar = { Helpbar.init = function () { if (this.isInited == false) { + this.helpbarOlHandler = new OverlayHandler("HelpbarHndl"); + this.helpbarOlHandler.init(Helpbar.showHelpbarOverlay, Helpbar.hideHelpbarOverlay); + this.helpbarOlHandler.olDelay = 5000; + Helpbar.createHelpbar(); Helpbar.hide(); Helpbar.hideOptSrv(); @@ -72,4 +76,190 @@ Helpbar.addItem = function(url, msg, row) { $("").append($("", { src: url})).appendTo(row); $("").append($("

", { text: msg})).appendTo(row); -}; \ No newline at end of file +}; + +//-------------------------------------------------------- + +Helpbar.showHelpbar = function () { + Main.log ("Helpbar.showHelpbar"); + this.helpbarOlHandler.show(); +}; + +Helpbar.showHelpbarOverlay = function() { + + $("

", {id:"helpbarOverlay", class: "style_hbOverlay"}).appendTo ($("body")); + $("#helpbarOverlay").append($("
", {text: "RC Keys", style : "padding-left : 5px; padding-right: 5px;"})); + + + switch (Main.state) { + case Main.eMAIN: + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_lr.png", "Page Up / Down")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_enter.png", "Tune in / Select Group")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_back.png", "Exit")); + + break; + case Main.eLIVE: + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_0_9.png", "Direct Channel Access")); + + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_ud.png", "Change Channel")); +// $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_ff_rw.png", "Trickplay (if supported)")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_enter.png", "Show Progress")); + + + + if(Player.getState() == Player.STOPPED) { + // Menu Key + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_enter.png", "Tune in / Select Group")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_back.png", "Group Up / Exit")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_lr.png", "Page Up / Down")); + + } + else { + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_rec.png", "Start Recording")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_pause.png", "Pause (Experimental)")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_green.png", "3D")); +// $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_yellow.png", "Next Subtitle")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_blue.png", "Next Audio Track")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_size.png", "Change Picture Size")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_info.png", "Recording Info")); + }; + + break; + case Main.eREC: + if(Player.getState() == Player.STOPPED) { + // Menu Key + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_ud.png", "Cursor up / down")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_lr.png", "Page Up / Down")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_enter.png", "Start Playback / Select Folder")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_back.png", "Folder Up / Exit")); + + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_red.png", "Recording Commands Menu")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_blue.png", "Change Sorting [by date, ...]")); + } + else { + // while playing + var num_key_text = ""; + switch (Config.playKeyBehavior) { + case 1: + num_key_text = " * 1min"; + break; + default: + num_key_text = "/10 * RecDuration"; + break; + } + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_0_9.png", num_key_text)); // depends on config + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_lr.png", "Skip")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_ud.png", "Change Skip Duration")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_ff_rw.png", "Trickplay (if supported)")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_enter.png", "Show Progress")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_pause.png", "Pause / Play")); + + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_size.png", "Change Picture Size")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_info.png", "Recording Info")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_green.png", "3D")); +// $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_yellow.png", "Next Subtitle")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_blue.png", "Next Audio Track")); + }; + + break; + case Main.eMED: + if(Player.getState() == Player.STOPPED) { + if (ImgViewer.isActive == true) { + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_lr.png", "Next / Prev Image")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_yellow.png", "Delete Image")); + } + else { + // Menu Key + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_ud.png", "Cursor up / down")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_lr.png", "Page Up / Down")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_enter.png", "Start Playback / Select Folder")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_back.png", "Folder Up / Exit")); + + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_red.png", "Recording Commands Menu")); +// $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_blue.png", "Change Sorting [by date, ...]")); + } // else + } + else { + // while playing + var num_key_text = ""; + switch (Config.playKeyBehavior) { + case 1: + num_key_text = " * 1min"; + break; + default: + num_key_text = "/10 * RecDuration"; + break; + } + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_0_9.png", num_key_text)); // depends on config + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_lr.png", "Skip")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_ud.png", "Change Skip Duration")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_ff_rw.png", "Trickplay (if supported)")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_enter.png", "Show Progress")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_pause.png", "Pause / Play")); + + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_size.png", "Change Picture Size")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_info.png", "Recording Info")); + + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_green.png", "3D")); +// $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_yellow.png", "Next Subtitle")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_blue.png", "Next Audio Track")); + }; + + break; + case Main.eTMR: + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_red.png", "Toggle Activation")); + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_yellow.png", "Delete Timer")); + break; + case Main.eURLS: + $("#helpbarOverlay").append(Helpbar.createRow("Images/helpbar/help_yellow.png", "Delete Entry")); + break; + case Main.eSRVR: + break; + case Main.eOPT: + break; + default: + break; + } + + var p_width = $("body").outerWidth(); + var p_height = $("body").outerHeight(); + + + Helpbar.maxWidth = 0; + // I also need to find the max of the r_elms + $("#helpbarOverlay").find('img').each(function () { + if ($(this).outerWidth() > Helpbar.maxWidth) + Helpbar.maxWidth = $(this).outerWidth(); + }); + Helpbar.maxRElmWidth = 0; + $("#helpbarOverlay").find('.style_hbOverlayRElm').each(function () { + if ($(this).outerWidth() > Helpbar.maxRElmWidth) + Helpbar.maxRElmWidth = $(this).outerWidth(); + }); + + $(".style_hbOverlayLElm").css ('width', Helpbar.maxWidth+10+"px"); + $(".style_hbOverlayRow").css ('width', Helpbar.maxRElmWidth+Helpbar.maxWidth+40+"px"); + + $("#helpbarOverlay").css({"left": ((p_width - $("#helpbarOverlay").outerWidth()) -40) +"px", + "top": ((p_height - $("#helpbarOverlay").outerHeight()) /2) +"px"}); + +}; + +Helpbar.createRow = function (url, msg) { + var row = $("
", {class : "style_hbOverlayRow"}); + + var l_elm = $("
", {style : "display: inline-block;", class : "style_hbOverlayLElm"}); + var r_elm = $("
", {style : "display: inline-block;", class : "style_hbOverlayRElm"}); + + l_elm.append($("", { src: url})); + r_elm.append($("
", { text: msg})); + + row.append(l_elm); + row.append(r_elm); + + return row; +}; + +Helpbar.hideHelpbarOverlay = function() { + $("#helpbarOverlay").remove(); +}; diff --git a/smarttv-client/Javascript/ImgViewer.js b/smarttv-client/Javascript/ImgViewer.js index ea8739f..af7495b 100644 --- a/smarttv-client/Javascript/ImgViewer.js +++ b/smarttv-client/Javascript/ImgViewer.js @@ -6,11 +6,24 @@ ImgViewer.init = function () { var elem = document.getElementById('iv-anchor'); elem.setAttribute('onkeydown', 'ImgViewer.onInput();'); + this.isActive = false; + + this.eFullScreen = 0; + this.eMedIcons = 1; + + this.screenMode = this.eFullScreen; + + $("#imageViewer").hide(); }; ImgViewer.show = function () { Display.hide(); + this.isActive = true; + this.screenMode = this.eFullScreen; + this.imgList = []; + this.curImg = 0; + $("#imageViewer").show(); $("#iv-anchor").focus(); @@ -18,22 +31,55 @@ ImgViewer.show = function () { Main.log ("URL= " + Data.getCurrentItem().childs[Main.selectedVideo].payload.link); Spinner.show(); + ImgViewer.createImgArray(); + + if (this.imgList.length == 0) { + Notify.showNotify("No Image Found", true); + ImgViewer.hide(); + return; + } + ImgViewer.showImage(); + /* if (ImgViewer.isImage() == true) { ImgViewer.showImage(); } else { ImgViewer.showNextImage(); } + */ }; ImgViewer.hide = function () { + this.isActive = false; + this.screenMode = this.eFullScreen; Display.show(); $("#imageViewer").hide(); Spinner.hide(); + + Display.setVideoList(Main.selectedVideo, (Main.selectedVideo - Display.currentWindow)); + Main.enableKeys(); }; +ImgViewer.createImgArray = function () { + var max = Data.getVideoCount(); + for (var i = 0; i < Data.getVideoCount() ; i ++) { + if (ImgViewer.isImage( (Main.selectedVideo + i) % max) == true) { + this.imgList.push((Main.selectedVideo + i) % max); + } + } + +}; + +ImgViewer.isImage = function(no) { + if ((Data.getCurrentItem().childs[no].payload.mime == "image/jpeg") || + (Data.getCurrentItem().childs[no].payload.mime == "image/png")) + return true; + else + return false; +}; + ImgViewer.isImage = function() { if ((Data.getCurrentItem().childs[Main.selectedVideo].payload.mime == "image/jpeg") || (Data.getCurrentItem().childs[Main.selectedVideo].payload.mime == "image/png")) @@ -44,6 +90,13 @@ ImgViewer.isImage = function() { }; ImgViewer.showNextImage = function () { + this.curImg++; + if (this.curImg >= this.imgList.length) + this.curImg = 0; + + ImgViewer.showImage(); + + /* Main.logToServer("ImgViewer.showNextImage curIdx= " +Main.selectedVideo); var start_ts = new Date().getTime(); @@ -70,9 +123,17 @@ ImgViewer.showNextImage = function () { Notify.showNotify("No Image Found", true); ImgViewer.hide(); } + */ }; ImgViewer.showPrevImage = function () { + this.curImg--; + if (this.curImg <0) + this.curImg = this.imgList.length-1; + + ImgViewer.showImage(); + +/* Main.log("ImgViewer.showPrevImage curIdx= " +Main.selectedVideo); var start_ts = new Date().getTime(); @@ -99,10 +160,12 @@ ImgViewer.showPrevImage = function () { Notify.showNotify("No Image Found", true); ImgViewer.hide(); } + */ }; ImgViewer.showImage = function () { - Main.logToServer("showImage: "+ Data.getCurrentItem().childs[Main.selectedVideo].payload.link); +// Main.logToServer("showImage: "+ Data.getCurrentItem().childs[Main.selectedVideo].payload.link); + Main.logToServer("showImage: "+ Data.getCurrentItem().childs[this.imgList[this.curImg]].payload.link); $("#ivImage") .error(function() { @@ -120,7 +183,48 @@ ImgViewer.showImage = function () { else { $(this).css({"width": "100%", "height" : "auto"}); }}) - .attr('src', Data.getCurrentItem().childs[Main.selectedVideo].payload.link +"?"+Math.random()); + .attr('src', Data.getCurrentItem().childs[this.imgList[this.curImg]].payload.link +"?"+Math.random()); +// .attr('src', Data.getCurrentItem().childs[Main.selectedVideo].payload.link +"?"+Math.random()); +}; + +function ImgLoader (url, elm) { + this.url = url; + this.elm = elm; + + this.elm + .error(function() { + Main.log("ERROR"); + ImgViewer.hide(); + Spinner.hide(); + Notify.showNotify("Error while loading image.", true); + }) + .load(function () { + Main.logToServer("showImage Loaded"); + Spinner.hide(); + if($(this).height() > $(this).width()) { + $(this).css({"height": "100%", "width" : "auto"}); + } + else { + $(this).css({"width": "100%", "height" : "auto"}); + }}) + .attr('src', this.url +"?"+Math.random()); + + }; + + +ImgViewer.showImageGrid = function () { + +}; + +ImgViewer.showGridRow = function (no) { + var p_width = $("body").outerWidth(); + var elms = p_width / no; + + var row = $("
"); + + var l_elm = $("
", {style : "display: inline-block; ", class : "style_hbOverlayLElm"}); + var r_elm = $("
", {style : "display: inline-block;"}); + }; ImgViewer.onInput = function () { @@ -140,18 +244,37 @@ ImgViewer.onInput = function () { ImgViewer.showNextImage(); break; case tvKey.KEY_ENTER: -// Buttons.ynShow(); + if (this.screenMode == this.eFullScreen) { + this.screenMode = this.eMedIcons; + } + else { + this.screenMode = this.eFullScreen; + } + ; + + // Buttons.ynShow(); // Show overlay info break; case tvKey.KEY_RETURN: case tvKey.KEY_EXIT: case tvKey.KEY_STOP: + Main.selectedVideo = this.imgList[this.curImg]; + ImgViewer.hide(); - if (this.returnCallback != null) this.returnCallback(); break; + case tvKey.KEY_BLUE: + break; + case tvKey.KEY_YELLOW: + Main.log("Delete YE Button"); + Buttons.ynShow(); +// Server.deleteMedFile(Data.getCurrentItem().childs[Main.selectedVideo].payload.guid); + break; + case tvKey.KEY_TOOLS: + Helpbar.showHelpbar(); + break; } try { diff --git a/smarttv-client/Javascript/Main.js b/smarttv-client/Javascript/Main.js index 0743604..55c2fa2 100755 --- a/smarttv-client/Javascript/Main.js +++ b/smarttv-client/Javascript/Main.js @@ -88,6 +88,7 @@ Main.onLoad = function() { } catch (e) { + // Not a TV set. Use Config.serverAddrDefault as server address Config.deviceType = 1; tvKey = Main.tvKeys; @@ -135,8 +136,13 @@ showHandler = function() { // Called by Config, when done Main.init = function () { Main.log("Main.init()"); + if (Config.verboseStart == true) + Display.showPopup ("Config done: Main.init() now" ); if (Config.debug == true) { + if (Config.verboseStart == true) + Display.showPopup ("Main.init: widgetdebug is true. Logging to (" + Config.serverUrl + ")"); + Main.logToServer = function (msg) { if (Config.serverUrl == "" ) return; @@ -193,7 +199,13 @@ Main.init = function () { Timers.init(); ImgViewer.init(); // Timers.show(); + + //set popup to normal timeout duration + Display.popupOlHandler.olDelay = 3*1000; + Config.verboseStart = false; + Display.scrollPopup (); + // end if (Config.deviceType == 0){ Main.log("ProductInfo= " + deviceapis.tv.info.getProduct()); @@ -719,8 +731,10 @@ cPlayStateKeyHndl.prototype.handleKeyDown = function (keyCode) { // Main.log(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode)); // Main.logToServer(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode)); - switch(keyCode) - { + switch(keyCode) { + case tvKey.KEY_TOOLS: + Helpbar.showHelpbar(); + break; case tvKey.KEY_1: Main.log("KEY_1 pressed"); // Display.showProgress(); @@ -917,6 +931,10 @@ cLivePlayStateKeyHndl.prototype.handleKeyDown = function (keyCode) { // Main.log(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode)); switch(keyCode) { + case tvKey.KEY_TOOLS: + Helpbar.showHelpbar(); + break; + case tvKey.KEY_ASPECT: Player.toggleAspectRatio(); break; @@ -1108,6 +1126,10 @@ cMenuKeyHndl.prototype.handleKeyDown = function (keyCode) { // var keyCode = event.keyCode; switch(keyCode) { + case tvKey.KEY_TOOLS: + Helpbar.showHelpbar(); + break; + case tvKey.KEY_0: if (Main.state == Main.eLIVE) { Main.log("cMenu DirectAccess: keyCode= " + keyCode); @@ -1178,6 +1200,10 @@ cMenuKeyHndl.prototype.handleKeyDown = function (keyCode) { if (Main.state == Main.eURLS) { Buttons.ynShow(); } + if (Main.state == Main.eMED) { + Main.log("Delete YE Button"); + Buttons.ynShow(); + } break; case tvKey.KEY_BLUE: if (Main.state == Main.eREC) { diff --git a/smarttv-client/Javascript/Network.js b/smarttv-client/Javascript/Network.js index 314dcca..23b0307 100755 --- a/smarttv-client/Javascript/Network.js +++ b/smarttv-client/Javascript/Network.js @@ -15,9 +15,6 @@ Network.init = function () { this.ownGw = this.plugin.GetGateway(nw_type); this.ownIp = this.plugin.GetIP(nw_type); } - Main.log( "ownMac= " + this.ownMac); - Main.log ("ownGw= " + this.ownGw); - Main.log ("ownIp= " + this.ownIp); this.isInited = true; } catch (e) { diff --git a/smarttv-client/Javascript/Options.js b/smarttv-client/Javascript/Options.js index 9964a00..cf44270 100755 --- a/smarttv-client/Javascript/Options.js +++ b/smarttv-client/Javascript/Options.js @@ -59,7 +59,7 @@ Options.hide = function() { }; Options.drawServerList = function () { - //delete all chiilds below optionsList + //delete all childs below optionsList $("#optionsList").children().remove(); for (var i = 0; i < Config.vdrServers.serverUrlList.length; i++) { @@ -182,6 +182,8 @@ Options.moveCursorRight = function() { Options.onInput = function () { var keyCode = event.keyCode; + if (Config.verboseStart == true) + Display.showPopup(""); Main.log("Options.onInput Key= " + keyCode); switch(keyCode) { case tvKey.KEY_1: @@ -385,6 +387,8 @@ Options.onInput = function () { // Done // Options.cursorPos = Options.cursorPos +1; // Options.deleteChar(); // + if (Config.verboseStart == true) + Display.showPopup("Options.onInput: Enter Pressed - Val= " + document.getElementById(Options.inputElm).value); if (Options.state == Options.sSelect) { Buttons.ynShow(); return; @@ -398,8 +402,7 @@ Options.onInput = function () { Main.enableKeys(); Options.hide(); - Main.changeState(0); - + Main.changeState(0); Config.fetchConfig(); break; diff --git a/smarttv-client/Javascript/Server.js b/smarttv-client/Javascript/Server.js index 97da591..4213dcf 100755 --- a/smarttv-client/Javascript/Server.js +++ b/smarttv-client/Javascript/Server.js @@ -241,6 +241,7 @@ Server.getResume = function (guid) { }); }; +/* Server.saveResume = function() { var msg = ""; msg += "filename:" + Data.getCurrentItem().childs[Main.selectedVideo].payload.guid + "\n"; @@ -252,59 +253,7 @@ Server.saveResume = function() { }; -Server.deleteRecording = function(guid) { - Main.log("Server.deleteRecording guid=" + guid); - Main.logToServer("Server.deleteRecording guid=" + guid); - Notify.handlerShowNotify("Deleting...", false); - - $.ajax({ - url: Config.serverUrl + "/deleteRecording.xml?id=" +guid, - type : "POST", - success : function(data, status, XHR ) { - Notify.showNotify("Deleted", true); - Data.deleteElm(Main.selectedVideo); - if (Main.selectedVideo >= Data.getVideoCount()) - Main.selectedVideo = Data.getVideoCount() -1; - Server.updateVdrStatus(); - Display.setVideoList(Main.selectedVideo, (Main.selectedVideo - Display.currentWindow)); - Main.logToServer("Server.deleteRecording: Success" ); - }, - error : function (XHR, status, error) { - Main.logToServer("Server.deleteRecording: Error" ); - - // show popup - Notify.showNotify("Error", true); - } - }); -}; - -Server.deleteUrls = function (guid) { - Main.log("Server.deleteUrls"); - Main.logToServer("Server.deleteUrls guid=" + guid); - Notify.handlerShowNotify("Deleting...", false); - - $.ajax({ - url: Config.serverUrl + "/deleteYtUrl?guid=" +guid, - type : "POST", - success : function(data, status, XHR ) { - Notify.showNotify("Deleted", true); - Data.deleteElm(Main.selectedVideo); - if (Main.selectedVideo >= Data.getVideoCount()) - Main.selectedVideo = Data.getVideoCount() -1; - Server.updateVdrStatus(); - Display.setVideoList(Main.selectedVideo, (Main.selectedVideo - Display.currentWindow)); - Main.logToServer("Server.deleteUrls: Success" ); - }, - error : function (XHR, status, error) { - Main.logToServer("Server.deleteUrls: Error" ); - Notify.showNotify(status, true); - - // show popup -// Notify.showNotify("Error", true); - } - }); - -}; +*/ Server.notifyServer = function (state) { Main.log("Server.notifyServer state="+state +"&mac=" + Network.ownMac + "&ip=" + Network.ownIp); @@ -360,6 +309,7 @@ Server.fetchRecCmdsList = function() { }); }; +/* Server.execRecCmd = function (cmd, guid) { var url = Config.serverUrl + "/execreccmd?cmd="+cmd+"&guid=" + guid; @@ -376,21 +326,96 @@ Server.execRecCmd = function (cmd, guid) { } }); }; - +*/ Server.getErrorText = function (status, input) { - var errno = parseInt(input.slice(0, 3)); +// var errno_str = input.slice(0, 3); +// var errno = parseInt(errno_str, 10); + var errno = Number(input.slice(0, 3)); var res = ""; + + Main.logToServer("Server.getErrorText status= " + status + " Errno= " + errno + " input= " + input ); switch (status) { case 400: // Bad Request switch (errno) { + case 1: + res = "Mandatory Line attribute not present."; + break; + case 2: + res= "No guid in query line"; + break; + case 3: + res = "Entry not found. Deletion failed"; + break; + case 6: + // set resume data + res = "Failed to find the recording."; + break; + case 7: + // get resume data + res = "Failed to find the recording."; + break; + case 8: + res = "File is new."; + break; + case 9: + res = "No id in query line"; + break; case 10: - res = "No Timer found."; + res = "No Timer found."; + break; + + case 15: + res = "Mandatory cmd attribute not present."; + break; + case 16: + res = "Command (cmd) value out of range."; + break; + case 17: + res = "Execreccmd disabled."; + break; + case 18: + res = "No such file or directory."; + break; + case 19: + res = "Permission Denied."; + break; + case 20: + res = "Is a directory."; + break; + case 21: + res = "Deletion failed (for some reason)."; + break; + + default: + res = "Unhandled Errno - Status= " + status + " Errno= "+ errno; + break; + } + break; + case 404: // File not found + switch (errno) { + case 1: + res = "Recording not found. Deletion failed."; + break; + case 2: + res = "Media Folder likely not configured."; + break; + case 3: + res = "File not found."; + break; + default: + res = "Unhandled Errno - Status= " + status + " Errno= "+ errno; + break; + }; + case 500: // Internal Server Error + switch (errno) { + case 6: + res = "deletion failed!"; break; default: res = "Unhandled Errno - Status= " + status + " Errno= "+ errno; break; - } + }; break; case 503: // Service unavailable switch (errno) { @@ -409,33 +434,425 @@ Server.getErrorText = function (status, input) { return res; }; -var HeartbeatHandler = { - timeoutObj : null, - isActive : false +Server.deleteRecording = function(guid) { + var obj = new execRestCmd(RestCmds.CMD_DelRec, guid); + + /* + + Main.log("Server.deleteRecording guid=" + guid); + Main.logToServer("Server.deleteRecording guid=" + guid); + Notify.handlerShowNotify("Deleting...", false); + + $.ajax({ + url: Config.serverUrl + "/deleteRecording.xml?id=" +guid, + type : "POST", + success : function(data, status, XHR ) { + Notify.showNotify("Deleted", true); + Data.deleteElm(Main.selectedVideo); + if (Main.selectedVideo >= Data.getVideoCount()) + Main.selectedVideo = Data.getVideoCount() -1; + Server.updateVdrStatus(); + Display.setVideoList(Main.selectedVideo, (Main.selectedVideo - Display.currentWindow)); + Main.logToServer("Server.deleteRecording: Success" ); + }, + error : function (XHR, status, error) { + Main.logToServer("Server.deleteRecording: Error" ); + + // show popup + Notify.showNotify("Error", true); + } + }); + */ }; -HeartbeatHandler.start = function(){ - if (this.isActive ==true) - window.clearTimeout(this.timeoutObj); - - this.isActive = true; - HeartbeatHandler.update(); +Server.deleteUrls = function (guid) { + + var obj = new execRestCmd(RestCmds.CMD_DelYtUrl, guid); + +/* + Main.log("Server.deleteUrls"); + Main.logToServer("Server.deleteUrls guid=" + guid); + Notify.handlerShowNotify("Deleting...", false); + + $.ajax({ + url: Config.serverUrl + "/deleteYtUrl?guid=" +guid, + type : "POST", + success : function(data, status, XHR ) { + Notify.showNotify("Deleted", true); + Data.deleteElm(Main.selectedVideo); + if (Main.selectedVideo >= Data.getVideoCount()) + Main.selectedVideo = Data.getVideoCount() -1; + Server.updateVdrStatus(); + Display.setVideoList(Main.selectedVideo, (Main.selectedVideo - Display.currentWindow)); + Main.logToServer("Server.deleteUrls: Success" ); + }, + error : function (XHR, status, error) { + Main.logToServer("Server.deleteUrls: Error" ); + Notify.showNotify(status, true); + + // show popup +// Notify.showNotify("Error", true); + } + }); +*/ }; -HeartbeatHandler.update = function() { - Server.notifyServer("running"); - this.timeoutObj = window.setTimeout(function() {HeartbeatHandler.update(); }, (60*1000)); // once every 1min + +Server.getResume = function (guid) { + Main.log ("***** getResume *****"); + var obj = new execRestCmd(RestCmds.CMD_GetResume, guid); +/* + $.ajax({ + url: Config.serverUrl + "/getResume.xml", + type : "POST", + data : "filename:" + guid +"\n", + success : function(data, status, XHR ) { + Main.log("**** Resome Success Response - status= " + status + " mime= " + XHR.responseType + " data= "+ data); + + var resume_str = $(data).find("resume").text(); + if (resume_str != "") { + var resume_val = parseFloat(resume_str); + Main.log("resume val= " + resume_val ); + Main.logToServer("resume val= " + resume_val ); + Player.resumePos = resume_val; + Player.playVideo( resume_val); + } + else { + Display.hide(); + Display.showProgress(); + Player.playVideo(-1); + } + + }, + error : function (jqXHR, status, error) { + Main.log("**** Resome Error Response - status= " + status + " error= "+ error); + Display.hide(); + Display.showProgress(); + Player.playVideo(-1); + } + }); + */ }; -HeartbeatHandler.stop = function(){ - if (this.isActive == false ) - return; +Server.saveResume = function() { + var obj = new execRestCmd(RestCmds.CMD_SetResume, Data.getCurrentItem().childs[Main.selectedVideo].payload.guid); +/* + var msg = ""; + msg += "filename:" + Data.getCurrentItem().childs[Main.selectedVideo].payload.guid + "\n"; + msg += "resume:"+ (Player.curPlayTime/1000) + "\n" ; + + $.post(Config.serverUrl + "/setResume.xml", msg, function(data, textStatus, XHR) { + Main.logToServer("SaveResume Status= " + XHR.status ); + }, "text"); +*/ +}; + +Server.execRecCmd = function (cmd, guid) { + var obj = new execRestCmd(RestCmds.CMD_ExecRecCmd, guid, { cmd:cmd }); + +}; + +Server.deleteMedFile = function(guid) { + var obj = new execRestCmd(RestCmds.CMD_DelMedFile, guid); +}; + +var RestCmds = { + CMD_AddTimer : 0, + CMD_DelMedFile : 1, + CMD_DelYtUrl : 2, + CMD_DelRec : 3, + CMD_SetResume : 4, + CMD_GetResume : 5, + CMD_GetRecCmds : 6, + CMD_ExecRecCmd : 7, + CMD_ActTimer : 8, + CMD_DelTimer : 9 +}; + + +//-------------------------------------------------------------------- +//-------------------------------------------------------------------- +//----------------- execRestCmd -------------------------------------- +//-------------------------------------------------------------------- +//-------------------------------------------------------------------- +function execRestCmd(cmd, guid, parms) { + this.successCallback = null; + this.errorCallback = null; + this.guid = guid; + this.parms = parms; + + this.url = ""; + this.cmd = -1; + this.method = ""; + + switch(cmd) { + case RestCmds.CMD_AddTimer: + // add a timer + + this.url =Config.serverUrl + "/addTimer.xml?guid="+this.guid; + this.cmd = cmd; + this.method = "GET"; + + this.successCallback = function(data, status, XHR ) { + Notify.showNotify("Timer added", true); + Main.log ("addTimer for Inst= " + this.guid +" status: " + ((status != null) ? status : "null")); + }; + break; + case RestCmds.CMD_DelMedFile: + // delete a file from media folder + + Main.log("Server.deleteMedFile guid=" + guid); + Main.logToServer("Server.deleteMedFile guid=" + guid); + + this.url =Config.serverUrl + "/deleteFile?guid=" +guid; + this.cmd = cmd; + this.method = "GET"; + + this.successCallback = function(data, status, XHR ) { + Notify.showNotify("Deleted", true); + Data.deleteElm(Main.selectedVideo); + if (Main.selectedVideo >= Data.getVideoCount()) + Main.selectedVideo = Data.getVideoCount() -1; + }; + break; + case RestCmds.CMD_DelYtUrl: + // delete a YouTube URL + + Main.log("Server.deleteUrls"); + Main.logToServer("Server.deleteUrls guid=" + guid); + Notify.handlerShowNotify("Deleting...", false); + + this.url =Config.serverUrl + "/deleteYtUrl?guid=" +guid; + this.cmd = cmd; + this.method = "POST"; + + this.successCallback = function(data, status, XHR ) { + Notify.showNotify("Deleted", true); + Data.deleteElm(Main.selectedVideo); + if (Main.selectedVideo >= Data.getVideoCount()) + Main.selectedVideo = Data.getVideoCount() -1; + Server.updateVdrStatus(); + Display.setVideoList(Main.selectedVideo, (Main.selectedVideo - Display.currentWindow)); + Main.logToServer("Server.deleteUrls: Success" ); + + }; + break; + case RestCmds.CMD_DelRec: + // Delete a Recording + + Main.log("Server.deleteRecording guid=" + guid); + Main.logToServer("Server.deleteRecording guid=" + guid); + Notify.handlerShowNotify("Deleting...", false); + + this.url =Config.serverUrl + "/deleteRecording.xml?id=" +guid; + this.cmd = cmd; + this.method = "POST"; + + this.successCallback = function(data, status, XHR ) { + Notify.showNotify("Deleted", true); + Data.deleteElm(Main.selectedVideo); + if (Main.selectedVideo >= Data.getVideoCount()) + Main.selectedVideo = Data.getVideoCount() -1; + Server.updateVdrStatus(); + Display.setVideoList(Main.selectedVideo, (Main.selectedVideo - Display.currentWindow)); + Main.logToServer("Server.deleteRecording: Success" ); + }; + + break; + + case RestCmds.CMD_SetResume : + // Send Resume Data + + Main.log("Server.GetResume guid=" + guid); + Main.logToServer("Server.GetResume guid=" + guid); + this.url =Config.serverUrl + "/setResume.xml?guid=" +guid + "&resume=" + (Player.curPlayTime/1000); + this.cmd = cmd; + this.method = "POST"; + this.successCallback = function(data, status, XHR ) { + Main.logToServer("SaveResume Status= " + XHR.status ); + }; + + break; + case RestCmds.CMD_GetResume : + // Request Resume Data from VDR + + Main.log("Server.GetResume guid=" + guid); + Main.logToServer("Server.GetResume guid=" + guid); + + this.url =Config.serverUrl + "/getResume.xml?guid=" +guid; + this.cmd = cmd; + this.method = "POST"; + + this.successCallback = function(data, status, XHR ) { + Main.log("**** Resome Success Response - status= " + status + " mime= " + XHR.responseType + " data= "+ data); + + var resume_str = $(data).find("resume").text(); + if (resume_str != "") { + var resume_val = parseFloat(resume_str); + Main.log("resume val= " + resume_val ); + Main.logToServer("resume val= " + resume_val ); + Player.resumePos = resume_val; + Player.playVideo( resume_val); + } + else { + Main.logToServer("ERROR: No resume data in response " ); + + Display.hide(); + Display.showProgress(); + Player.playVideo(-1); + } + }; + + this.errorCallback = function() { + Display.hide(); + Display.showProgress(); + Player.playVideo(-1); + }; + + + break; + + case RestCmds.CMD_ExecRecCmd : + // Execute a recording command + + Main.logToServer("Server.execRecCmd cmd="+parms.cmd+" guid=" + guid ); + + this.url = Config.serverUrl + "/execreccmd?cmd="+parms.cmd+"&guid=" + guid; + this.cmd = cmd; + this.method = "GET"; + + this.successCallback = function(data, status, XHR ) { + Main.logToServer("Server.execRecCmd OK" ) ; + Display.handleDescription(Main.selectedVideo); + }; + break; + + case RestCmds.CMD_ActTimer : + // Activate or Deactivate a timer + + Main.logToServer("Server.ActTimer index=" + guid + " setActive= " + ((parms.setActive == true) ? "true" : "false" )); + + this.url = Config.serverUrl + "/activateTimer?index=" +guid + "&activate=" + ((parms.setActive == true) ? "true" : "false"), + this.cmd = cmd; + this.method = "GET"; + + this.successCallback = function(data, status, XHR ) { + Main.logToServer("Timers.activateTimer: Success" ); + Main.log("Timers.activateTimer: Success" ); + + Timers.resetView(); + }; + break; + + case RestCmds.CMD_DelTimer : + // Delete a timer + + Main.logToServer("Server.DelTimer index=" + guid ); + + this.url = Config.serverUrl + "/deleteTimer?index=" +guid, + this.cmd = cmd; + this.method = "GET"; + + this.successCallback = function(data, status, XHR ) { + Main.logToServer("Timers.deleteTimer: Success" ); + Main.log("Timers.deleteTimer: Success" ); + + Timers.resetView(); + // remove index from database + }; + break; + + default: + Main.log("execRestCmd - ERROR: CMD= " + cmd + " is not supported"); + Main.logToServer("execRestCmd - ERROR: CMD= " + cmd + " is not supported"); + break; + }; + + if (this.cmd > 0) + this.request(); + else { + Main.logToServer("execRestCmd - CMD (" + cmd + ") Not found"); + } - window.clearTimeout(this.timeoutObj); - this.isActive = false; }; +execRestCmd.prototype.request = function () { + Main.log("execRestCmd request url= " + this.url); + + $.ajax({ + url: this.url, + type : this.method, + context : this, + timeout : 500, + success : this.successCallback, +/* function(data, status, XHR ) { + if (this.successCallback != null) + this.successCallback(); + switch (this.cmd) { + case RestCmds.CMD_AddTimer: + Notify.showNotify("Timer added", true); + Main.log ("addTimer for Inst= " + this.guid +" status: " + ((status != null) ? status : "null")); + break; + + case RestCmds.CMD_DelMedFile: + Notify.showNotify("Deleted", true); + Data.deleteElm(Main.selectedVideo); + if (Main.selectedVideo >= Data.getVideoCount()) + Main.selectedVideo = Data.getVideoCount() -1; + + break; + + case RestCmds.CMD_DelYtUrl: + Notify.showNotify("Deleted", true); + Data.deleteElm(Main.selectedVideo); + if (Main.selectedVideo >= Data.getVideoCount()) + Main.selectedVideo = Data.getVideoCount() -1; + Server.updateVdrStatus(); + Display.setVideoList(Main.selectedVideo, (Main.selectedVideo - Display.currentWindow)); + Main.logToServer("Server.deleteUrls: Success" ); + break; + + case RestCmds.CMD_DelRec: + Notify.showNotify("Deleted", true); + Data.deleteElm(Main.selectedVideo); + if (Main.selectedVideo >= Data.getVideoCount()) + Main.selectedVideo = Data.getVideoCount() -1; + Server.updateVdrStatus(); + Display.setVideoList(Main.selectedVideo, (Main.selectedVideo - Display.currentWindow)); + Main.logToServer("Server.deleteRecording: Success" ); + + break; + + default: + Main.logToServer("execRestCmd - Success for cmd= " + this.cmd); + }; + },*/ + error : function (XHR, status, error) { + + Main.logToServer("ERROR received for guid= " + this.guid + " status= " + status); + if (status == "timeout") { + Notify.showNotify( "Timeout.", true); + + } + else { + Main.log("ERROR= " + XHR.status + " text= " + XHR.responseText); + var res = Server.getErrorText(XHR.status, XHR.responseText); + Main.log ("execRestCmd for Error Inst= " + this.guid+ " res= " + res); + Notify.showNotify( res, true); + + if (this.errorCallback != null) + this.errorCallback(); + + } + + } + }); + +}; + + + function addTimer(guid) { this.successCallback = null; this.errorCallback = null; @@ -469,4 +886,31 @@ addTimer.prototype.request = function () { }; +var HeartbeatHandler = { + timeoutObj : null, + isActive : false +}; + + +HeartbeatHandler.start = function(){ + if (this.isActive ==true) + window.clearTimeout(this.timeoutObj); + + this.isActive = true; + HeartbeatHandler.update(); +}; + +HeartbeatHandler.update = function() { + Server.notifyServer("running"); + this.timeoutObj = window.setTimeout(function() {HeartbeatHandler.update(); }, (60*1000)); // once every 1min +}; + +HeartbeatHandler.stop = function(){ + if (this.isActive == false ) + return; + + window.clearTimeout(this.timeoutObj); + this.isActive = false; +}; + diff --git a/smarttv-client/Javascript/Timers.js b/smarttv-client/Javascript/Timers.js index 53c9d4e..c00e9e7 100644 --- a/smarttv-client/Javascript/Timers.js +++ b/smarttv-client/Javascript/Timers.js @@ -1,8 +1,11 @@ var Timers = { timerList : [], scrollDur : 300, - scrollFlip : 100 - + scrollFlip : 100, + btnMode : 0 + // 0 nothing + // 1: delete + // 2: }; Timers.init = function() { @@ -145,8 +148,8 @@ Timers.createMenu= function () { }; Timers.getPrintDate = function (day) { - var day = new Date (day * 1000); - return day.getDate() + "." + (day.getMonth() +1) + "." + day.getFullYear() + var d = new Date (day * 1000); + return d.getDate() + "." + (d.getMonth() +1) + "." + d.getFullYear(); }; Timers.getWeekdays = function (wd) { @@ -170,7 +173,10 @@ Timers.createEntry= function (i, 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($("
", {class : ((Timers.timerList[i].isrec ==true) ? "style_timerRec" : ((Timers.timerList[i].flags & 1) != 0) ? "style_timerAct" : "style_timerNone"), style : "display: inline-block;"})); + if ( Timers.timerList[i].isSingleEvent == true) { } else { @@ -199,14 +205,16 @@ Timers.resetView = function () { }; -Timers.deleteTimer = function () { +Timers.timerCallback = 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); +// var del_req = new DeleteTimerReq (Timers.timerList[this.btnSelected].index); + + var obj = new execRestCmd(RestCmds.CMD_DelTimer, Timers.timerList[this.btnSelected].index); + // var del_req = new DeleteTimerReq (10); +}; -} Timers.selectBtnUp = function () { var btnname = "#tmr-"+this.btnSelected; @@ -271,6 +279,46 @@ Timers.onInput = function () { // Timers.hide(); break; + case tvKey.KEY_YELLOW: + + Timers.timerCallback = function () { + // delete the current timer + Main.log("Timers.timerCallback: " + Timers.timerList[this.btnSelected].title); + var obj = new execRestCmd(RestCmds.CMD_DelTimer, Timers.timerList[this.btnSelected].index); + // var del_req = new DeleteTimerReq (10); + }; + + Buttons.ynShow(); +// Timers.hide(); + + break; + case tvKey.KEY_RED: + if ((Timers.timerList[this.btnSelected].flags & 1) != 0) { + // Timer is currently active + Buttons.ynHeadlineText ("Deactivate Timer ?"); + Timers.timerCallback = function () { + Main.log("Timers.timerCallback Deactivate Timer: " + Timers.timerList[this.btnSelected].title); + var obj = new execRestCmd(RestCmds.CMD_ActTimer, Timers.timerList[this.btnSelected].index, {setActive : false}); + }; + + } + else { + // Timer is currently deactive + Buttons.ynHeadlineText ("Activate Timer ?"); + Timers.timerCallback = function () { + Main.log("Timers.timerCallback Activate Timer: " + Timers.timerList[this.btnSelected].title); + var obj = new execRestCmd(RestCmds.CMD_ActTimer, Timers.timerList[this.btnSelected].index, {setActive : true}); + }; + } + + Buttons.ynShow(); +// Timers.hide(); + + break; + case tvKey.KEY_TOOLS: + Helpbar.showHelpbar(); + break; + case tvKey.KEY_RETURN: case tvKey.KEY_EXIT: Timers.hide(); @@ -288,7 +336,7 @@ Timers.onInput = function () { }; - +/* function DeleteTimerReq (idx) { this.index = idx; this.exec(); @@ -321,3 +369,4 @@ DeleteTimerReq.prototype.exec = function () { }); }; +*/ \ No newline at end of file diff --git a/smarttv-client/config.xml b/smarttv-client/config.xml index 85c7537..6f34c49 100755 --- a/smarttv-client/config.xml +++ b/smarttv-client/config.xml @@ -9,7 +9,7 @@ Images/icon/SmartTvWeb_115.png Images/icon/SmartTvWeb_85.png Images/icon/SmartTvWeb_95.png - 0.95.0827 + 0.95.0914 y y -- cgit v1.2.3