From f92e97207c9f6fc740bf4960049758a5a36d6898 Mon Sep 17 00:00:00 2001 From: thlo Date: Sun, 13 Jan 2013 21:28:52 +0100 Subject: Various changes: Folder Support for Live, Spinner, Keyboard, etc --- smarttv-client/CSS/Main.css | 17 +- smarttv-client/Images/leftHalf-bg.png | Bin 138277 -> 155643 bytes smarttv-client/Images/rightHalf-bg.png | Bin 124624 -> 140790 bytes smarttv-client/Javascript/Config.js | 45 ++-- smarttv-client/Javascript/Data.js | 32 +++ smarttv-client/Javascript/Display.js | 75 ++++--- smarttv-client/Javascript/Epg.js | 41 ++++ smarttv-client/Javascript/Helpbar.js | 58 ++++++ smarttv-client/Javascript/Main.js | 170 +++++++-------- smarttv-client/Javascript/Options.js | 367 ++++++++++++++++++++++++++++----- smarttv-client/Javascript/Player.js | 40 ++-- smarttv-client/Javascript/Server.js | 49 +++-- smarttv-client/Javascript/Spinner.js | 51 +++++ smarttv-client/config.xml | 2 +- smarttv-client/index.html | 23 ++- 15 files changed, 742 insertions(+), 228 deletions(-) create mode 100644 smarttv-client/Javascript/Epg.js create mode 100644 smarttv-client/Javascript/Helpbar.js create mode 100644 smarttv-client/Javascript/Spinner.js diff --git a/smarttv-client/CSS/Main.css b/smarttv-client/CSS/Main.css index e3ebaca..ccc6714 100755 --- a/smarttv-client/CSS/Main.css +++ b/smarttv-client/CSS/Main.css @@ -66,7 +66,6 @@ body { position: absolute; left: 0px; top: 0px; width: 960px; height: 540px; - display: none; background: url("../Images/selectScreen-bg.png"); 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%); } @@ -226,6 +225,9 @@ body { background: -webkit-linear-gradient(-45deg, #1e5799 0%,#2989d8 41%,#7db9e8 100%); } +.style_videoitem { + display: inline-block; +} .style_videoList { color:#FFFFFF; @@ -383,3 +385,16 @@ body { text-align:center; font-size:14px; } + + +#Spinning { + position:absolute; + left:401px; top:196px; + width:158px; height:147px; + background-image:url("../Images/spinner/loadingBG.png"); + background-repeat:no-repeat; + opacity:0.5; + display:none; + z-index:20; +} + diff --git a/smarttv-client/Images/leftHalf-bg.png b/smarttv-client/Images/leftHalf-bg.png index 0be1542..d91b9b6 100644 Binary files a/smarttv-client/Images/leftHalf-bg.png and b/smarttv-client/Images/leftHalf-bg.png differ diff --git a/smarttv-client/Images/rightHalf-bg.png b/smarttv-client/Images/rightHalf-bg.png index 824f3a8..9cb89ac 100644 Binary files a/smarttv-client/Images/rightHalf-bg.png and b/smarttv-client/Images/rightHalf-bg.png differ diff --git a/smarttv-client/Javascript/Config.js b/smarttv-client/Javascript/Config.js index 1aa2f75..a950641 100755 --- a/smarttv-client/Javascript/Config.js +++ b/smarttv-client/Javascript/Config.js @@ -64,17 +64,14 @@ Config.init = function () { // should switch to the config screen here var res = fileSystemObj.createCommonDir(curWidget.id); if (res == true) { - Config.firstLaunch = true; - - Main.init(); // Obsolete? - - Main.changeState(4); + Config.doFirstLaunch(); return; } else { - Main.init(); - Display.showPopup ("ERROR: Cannot create widget folder"); - Main.logToServer("ERROR: Cannot create widget folder curWidget.id= " +curWidget.id); + Config.doFirstLaunch(); +// Main.init(); + Display.showPopup ("WARNING: Cannot create widget folder. Try Config"); +// Main.logToServer("ERROR: Cannot create widget folder curWidget.id= " +curWidget.id); } return; } @@ -86,6 +83,13 @@ Config.init = function () { Config.fetchConfig(); }; +Config.doFirstLaunch = function () { + Config.firstLaunch = true; +// Main.init(); // Obsolete? + + Main.changeState(4); +}; + Config.fetchConfig = function () { if (this.XHRObj == null) { this.XHRObj = new XMLHttpRequest(); @@ -114,6 +118,7 @@ Config.writeContext = function (addr) { }; Config.updateContext = function (addr) { + Main.log("Config.updateContext with ("+addr+")"); var fileSystemObj = new FileSystem(); var fd = fileSystemObj.openCommonFile(Config.cfgFileName,"w"); @@ -123,6 +128,7 @@ Config.updateContext = function (addr) { Config.serverAddr = addr; Config.serverUrl = "http://" + Config.serverAddr; + Config.fetchConfig(); }; Config.readContext = function () { @@ -141,29 +147,28 @@ Config.readContext = function () { Config.serverUrl = "http://" + Config.serverAddr; } else { - Display.showPopup ("WARNING: Error in Config File. Try widget restart."); + Display.showPopup ("ERROR: Error in Config File. Try widget re-install."); // TODO: I should re-write the config file } } fileSystemObj.closeCommonFile(fd); - } catch (e) { - Main.logToServer("Config.readContext: Error while reading: e= " +e); + Main.log("Config.readContext: Error while reading: e= " +e); var res = fileSystemObj.createCommonDir(curWidget.id); if (res == true) { - Main.logToServer("Config.readContext: Widget Folder created"); - Display.showPopup ("Config Read Error: Try widget restart"); + Main.log("WARNING: ConfigRead Error. Launching Config-Menu from here"); + // Display.showPopup ("Config Read Error: Try widget restart"); + } else { - Main.logToServer("Config.readContext: Widget Folder creation failed"); - Display.showPopup ("Config Read Error: Try re-installing the widget"); - Main.log("-------------- Error: res = false ------------------------"); + Main.log("Config.readContext: Widget Folder creation failed"); + + Display.showPopup ("WARNING: ConfigRead Error and WidgetFolder creation failed.
Launching Config-Menu from here"); +// Main.log("-------------- Error: res = false ------------------------"); } + Config.doFirstLaunch(); - Config.firstLaunch = true; - Main.init(); - Main.changeState(4); } }; @@ -219,6 +224,8 @@ Config.processConfig = function () { return; } else { + Config.firstLaunch = false; + Main.log ("Parsing config XML now"); Main.logToServer("Parsing config XML now"); this.format = Config.getXmlString("format"); diff --git a/smarttv-client/Javascript/Data.js b/smarttv-client/Javascript/Data.js index e7049ee..2b95fa7 100755 --- a/smarttv-client/Javascript/Data.js +++ b/smarttv-client/Javascript/Data.js @@ -48,6 +48,10 @@ Data.dumpFolderStruct = function(){ Main.log("---------- dumpFolderStruct Done -------"); }; +Data.findEpgUpdateTime = function() { + return this.assets.findEpgUpdateTime(Display.GetEpochTime() + 10000, "", 0); + // min, guid, level +}; Data.getCurrentItem = function () { return this.folderList[this.folderList.length-1].item; }; @@ -123,6 +127,34 @@ Item.prototype.addChild = function (key, pyld, level) { } }; +Item.prototype.findEpgUpdateTime = function (min, guid, level) { + var prefix= ""; + for (var i = 0; i < level; i++) + prefix += "-"; + + for (var i = 0; i < this.childs.length; i++) { + if (this.childs[i].isFolder == true) { + var res = this.childs[i].findEpgUpdateTime(min, guid, level+1); + min = res.min; + guid = res.guid; + } + else { + var digi =new Date(this.childs[i].payload['start'] * 1000); + var str = digi.getHours() + ":" + digi.getMinutes(); + + Main.log(prefix + "min= " + min+ " start= " + this.childs[i].payload['start'] + " (" + str+ ") title= " + this.childs[i].title); + + if ((this.childs[i].payload['start'] != 0) && ((this.childs[i].payload['start'] + this.childs[i].payload['dur']) < min)) { + min = this.childs[i].payload['start'] + this.childs[i].payload['dur']; + guid = this.childs[i].payload['guid'] ; + Main.log(prefix + "New Min= " + min + " new id= " + guid + " title= " + this.childs[i].title); + } + } + } + + return { "min": min, "guid" : guid}; +}; + Item.prototype.print = function(level) { var prefix= ""; for (var i = 0; i < level; i++) diff --git a/smarttv-client/Javascript/Display.js b/smarttv-client/Javascript/Display.js index 483a141..218f942 100755 --- a/smarttv-client/Javascript/Display.js +++ b/smarttv-client/Javascript/Display.js @@ -49,10 +49,22 @@ Display.init = function() } for (var i = 0; i <= this.LASTIDX; i++) { - var elm = document.getElementById("video"+i); + var elm = $("#video"+i); + $(elm).css({"width" : "100%", "text-align": "left" }); + $(elm).append($("
").css({ "display": "inline-block", "padding-top": "4px", "padding-bottom": "6px", "width":"20%"})); + $(elm).append($("
").css({ "display": "inline-block", "padding-top": "4px", "padding-bottom": "6px", "width":"70%"})); + $(elm).append($("
").css({ "display": "inline-block", "padding-top": "4px", "padding-bottom": "6px", "width":"5%"})); + +/* $(elm).children("div").eq(0).text ("Hallo1"); + $(elm).children("div").eq(1).text ("Hallo2"); + $(elm).children("div").eq(2).text ("Hallo3"); +*/ +/* + * var elm = document.getElementById("video"+i); elm.style.paddingLeft = "10px"; elm.style.paddingTop = "4px"; elm.style.paddingBottom = "6px"; + */ } var done = false; @@ -76,8 +88,15 @@ Display.init = function() return success; }; +Display.setVideoItem = function (elm, cnt) { + // cnt + $(elm).children("div").eq(0).text (cnt.c1); + $(elm).children("div").eq(1).text (cnt.c2); + $(elm).children("div").eq(2).text (cnt.c3); +}; + Display.putInnerHTML = function (elm, val) { - + alert(Config.deviceType + " " +elm + " " + val); switch (Config.deviceType) { case 0: // Samsung specific handling of innerHtml @@ -133,7 +152,7 @@ Display.resetVideoList = function () { break; } Display.unselectItem(elm); - Display.putInnerHTML(elm, ""); + Display.setVideoItem(elm, {c1: "", c2: "", c3: ""}); } }; @@ -276,7 +295,6 @@ Display.handleDescription =function (selected) { var min = Display.getNumString (digi.getMinutes(), 2); var d_str =""; -// Main.log("handleDescription: " +Data.getCurrentItem().childs[selected].payload.desc); var msg = ""; if (Main.state == 1) { // Live @@ -326,19 +344,24 @@ Display.getNumString =function(num, fmt) { }; Display.getDisplayTitle = function(item) { - var res = ""; + var res = {c1:"", c2:"", c3:""}; switch (Main.state) { case 1: // Live - res = item.title; + if (item.isFolder == true) { + res.c2 = item.title; + res.c3 = "<" + Display.getNumString(item.childs.length, 2) +">"; + } + else { + res.c2 = item.title; + } break; case 2: case 3: // Recordings if (item.isFolder == true) { -// res = "<" + Display.getNumString(item.childs.length, 3) + ">-------- " + item.title; - res = "<" + Display.getNumString(item.childs.length, 3) + ">       - " + item.title; - + res.c1 = "<" + Display.getNumString(item.childs.length, 3) + ">"; + res.c2 = item.title; } else { var digi = new Date(parseInt(item.payload.start*1000)); @@ -348,7 +371,8 @@ Display.getDisplayTitle = function(item) { var min = Display.getNumString (digi.getMinutes(), 2); var d_str = mon + "/" + day + " " + hour + ":" + min; - res = d_str + " - " + item.title; + res.c1 = d_str; + res.c2 = item.title; } break; default: @@ -361,7 +385,9 @@ Display.getDisplayTitle = function(item) { Display.setVideoList = function(selected, first) { // var listHTML = ""; - var first_item = selected; + var res = {}; +// var first_item = selected; + var first_item = first; //thlo var i=0; Main.log("Display.setVideoList title= " +Data.getCurrentItem().childs[selected].title + " selected= " + selected + " first_item= " + first_item); @@ -369,15 +395,14 @@ Display.setVideoList = function(selected, first) { for (i = 0; i <= this.LASTIDX; i++) { if ((first_item+i) >= Data.getVideoCount()) { - listHTML = ""; + res = {c1: "", c2: "", c3: ""}; } else { - listHTML = Display.getDisplayTitle (Data.getCurrentItem().childs[first_item+i]); -// Main.log(" - title[first_item+i]= " +Data.getCurrentItem().childs[(first_item +i)].title + " i= " + i + " listHTML= " + listHTML); -// Main.log(" - listHTML= " + listHTML); + res = Display.getDisplayTitle (Data.getCurrentItem().childs[first_item+i]); } this.videoList[i] = document.getElementById("video"+i); - Display.putInnerHTML(this.videoList[i], listHTML); + + Display.setVideoItem(this.videoList[i], res); this.unselectItem(this.videoList[i]); } @@ -414,6 +439,7 @@ Display.unselectItem = function (item) { Display.setVideoListPosition = function(position, move) { var listHTML = ""; +// var res = {}; //thlo: unused? Main.log ("Display.setVideoListPosition title= " +Data.getCurrentItem().childs[position].title + " move= " +move); this.handleDescription(position); @@ -454,9 +480,7 @@ Display.setVideoListPosition = function(position, move) this.currentWindow = this.FIRSTIDX; for(i = 0; i <= this.LASTIDX; i++) { - listHTML = Display.getDisplayTitle (Data.getCurrentItem().childs[i]); -// listHTML = Data.getCurrentItem().childs[i].title; - Display.putInnerHTML(this.videoList[i], listHTML); + Display.setVideoItem(this.videoList[i], Display.getDisplayTitle (Data.getCurrentItem().childs[i])); if(i == this.currentWindow) this.selectItem(this.videoList[i]); @@ -466,9 +490,7 @@ Display.setVideoListPosition = function(position, move) } else { for(i = 0; i <= this.LASTIDX; i++) { - listHTML = Display.getDisplayTitle (Data.getCurrentItem().childs[i + position - this.currentWindow]); -// listHTML = Data.getCurrentItem().childs[i + position - this.currentWindow].title; - Display.putInnerHTML(this.videoList[i], listHTML); + Display.setVideoItem(this.videoList[i], Display.getDisplayTitle (Data.getCurrentItem().childs[i + position - this.currentWindow])); } } } @@ -479,10 +501,7 @@ Display.setVideoListPosition = function(position, move) this.currentWindow = this.LASTIDX; for(i = 0; i <= this.LASTIDX; i++) { - listHTML = Display.getDisplayTitle (Data.getCurrentItem().childs[i + position - this.currentWindow]); -// listHTML = Data.getCurrentItem().childs[i + position - this.currentWindow].title; - Display.putInnerHTML(this.videoList[i], listHTML); - + Display.setVideoItem(this.videoList[i], Display.getDisplayTitle (Data.getCurrentItem().childs[i + position - this.currentWindow])); if(i == this.currentWindow) this.selectItem(this.videoList[i]); else @@ -491,9 +510,7 @@ Display.setVideoListPosition = function(position, move) } else { for(i = 0; i <= this.LASTIDX; i++) { - listHTML = Display.getDisplayTitle (Data.getCurrentItem().childs[i + position]); -// listHTML = Data.getCurrentItem().childs[i + position].title; - Display.putInnerHTML(this.videoList[i], listHTML); + Display.setVideoItem(this.videoList[i], Display.getDisplayTitle (Data.getCurrentItem().childs[i + position])); } } } diff --git a/smarttv-client/Javascript/Epg.js b/smarttv-client/Javascript/Epg.js new file mode 100644 index 0000000..c400e0e --- /dev/null +++ b/smarttv-client/Javascript/Epg.js @@ -0,0 +1,41 @@ +/* + * Principle: One monitor for each channel + * Nur max 20 + * Oder einer: + * Search once through all entries and look for the lowest expiry. + * Set a timer to update the entry + * check, whether the entry is "on screen" + * +*/ + +var Epg = { + restfulUrl : "" + +}; + +// Should be called after initial config +Epg.init = function () { + if (Config.serverUrl == "") + return; + if (Config.serverUrl.indexOf(':') != -1) { + Main.log ("Epg: Serverurl= " + Config.serverUrl); + this.restfulUrl = Config.serverUrl.splice(0, Config.serverUrl.indexOf(':')) + ":8002"; + } + + Main.log ("Restful API Url= "+ this.restfulUrl); + + $.ajax({ + type: "HEAD", + async: true, + url: this.restfulUrl + "channels.xml", + success: function(message,text,response){ + Main.log("AJAX Response: MSG= " + message + " txt= " + text + " resp= " + response); + } + }); +}; + +Epg.startEpgUpdating = function() { + + var res = Data.findEpgUpdateTime(); + Main.log("GUID= " + res.guid + " Min= " + res.min); +}; \ No newline at end of file diff --git a/smarttv-client/Javascript/Helpbar.js b/smarttv-client/Javascript/Helpbar.js new file mode 100644 index 0000000..0196d78 --- /dev/null +++ b/smarttv-client/Javascript/Helpbar.js @@ -0,0 +1,58 @@ + +var Helpbar = { + isInited : false +}; + +Helpbar.init = function () { + if (this.isInited == false) { + Helpbar.createHelpbar(); + Helpbar.hide(); + } +}; + +Helpbar.show = function () { + $("#helpbar").show(); +}; + +Helpbar.hide = function () { + $("#helpbar").hide(); +}; + +Helpbar.createHelpbar = function() { + this.isInited = true; + var sheet = $("