summaryrefslogtreecommitdiff
path: root/smarttv-client
diff options
context:
space:
mode:
authorthlo <smarttv640@gmail.com>2013-07-24 20:32:03 +0200
committerthlo <t.lohmar@gmx.de>2013-07-24 20:32:03 +0200
commit0ecc9a2ca4c3604ef2590fef5b3072417689a7d3 (patch)
tree3e8d88ad1c84e9f537d1fa8853ddd00f200760d0 /smarttv-client
parentd8688559455cc3cd86f41e816568d099f07f3800 (diff)
downloadvdr-plugin-smarttvweb-0ecc9a2ca4c3604ef2590fef5b3072417689a7d3.tar.gz
vdr-plugin-smarttvweb-0ecc9a2ca4c3604ef2590fef5b3072417689a7d3.tar.bz2
Widget updates:
- Multi-Server Support - Number key personalization for recordings - Timezone fix - Fix in YouTube Handling - Fix in Helpbar - Other misc fixes
Diffstat (limited to 'smarttv-client')
-rwxr-xr-xsmarttv-client/CSS/Main.css11
-rw-r--r--smarttv-client/Javascript/Buttons.js34
-rw-r--r--smarttv-client/Javascript/Comm.js15
-rwxr-xr-xsmarttv-client/Javascript/Config.js233
-rwxr-xr-xsmarttv-client/Javascript/Data.js35
-rw-r--r--smarttv-client/Javascript/DirectAccess.js14
-rwxr-xr-xsmarttv-client/Javascript/Display.js8
-rw-r--r--smarttv-client/Javascript/Epg.js36
-rw-r--r--smarttv-client/Javascript/Helpbar.js48
-rwxr-xr-xsmarttv-client/Javascript/Main.js124
-rwxr-xr-xsmarttv-client/Javascript/Options.js175
-rw-r--r--smarttv-client/Javascript/OverlayMenu.js218
-rwxr-xr-xsmarttv-client/Javascript/Player.js72
-rwxr-xr-xsmarttv-client/Javascript/Server.js61
-rwxr-xr-xsmarttv-client/config.xml3
-rwxr-xr-xsmarttv-client/index.html17
16 files changed, 938 insertions, 166 deletions
diff --git a/smarttv-client/CSS/Main.css b/smarttv-client/CSS/Main.css
index 70c01d9..7eaae7a 100755
--- a/smarttv-client/CSS/Main.css
+++ b/smarttv-client/CSS/Main.css
@@ -72,6 +72,11 @@ body {
#selectNow{
text-align: left;
}
+
+#selectTitle{
+ text-align: right;
+}
+
#selectDisk{
text-align: right;
}
@@ -245,19 +250,19 @@ body {
#logoNow {
text-align: left;
font-size:18px;
- width: 35%;
+ width: 25%;
}
#logoTitle {
text-align: center;
font-size:25px;
- width: 30%;
+ width: 50%;
}
#logoDisk {
text-align: right;
font-size:18px;
- width: 35%;
+ width: 25%;
}
/* Right Half */
#rightHalf {
diff --git a/smarttv-client/Javascript/Buttons.js b/smarttv-client/Javascript/Buttons.js
index b881975..2e293fd 100644
--- a/smarttv-client/Javascript/Buttons.js
+++ b/smarttv-client/Javascript/Buttons.js
@@ -31,6 +31,7 @@ Buttons.init = function (){
this.ynButton = new ButtonHandler();
this.ynButton.hndlName = "ynButtons";
this.ynButton.enterCallback = Buttons.ynEnterCallback;
+ this.ynButton.returnCallback = Buttons.ynReturnCallback;
this.ynButton.btnMax = 1;
this.ynButton.elmName = "#yn-btn-";
this.ynButton.masterElm = "#yn-buttons";
@@ -41,6 +42,16 @@ Buttons.init = function (){
// $("#prc-buttons-anchor").attr("onkeydown", "Button.prButton.onInput();");
}
};
+Buttons.ynReturnCallback = function () {
+ switch (Main.state) {
+ case Main.eOPT:
+ Options.drawServerList();
+ break;
+ default:
+ break;
+ }
+
+};
Buttons.ynEnterCallback = function () {
Main.log("Buttons.ynEnterCallback btnSelected= " + Buttons.ynButton.btnSelected);
@@ -58,8 +69,13 @@ Buttons.ynEnterCallback = function () {
case Main.eURLS:
Server.deleteUrls(Data.getCurrentItem().childs[Main.selectedVideo].payload.guid);
break;
+ case Main.eOPT:
+ Config.deletedFromContext((Options.selectedLine -1)); // 0 is reserved for the input field
+ Options.drawServerList();
+
+ break;
}
-
+
break;
}
Buttons.ynHide();
@@ -103,6 +119,7 @@ Buttons.show = function () {
Buttons.hide = function () {
this.prButton.hide();
// $("#prc-buttons-anchor").blur();
+
Main.enableKeys();
};
@@ -126,7 +143,10 @@ Buttons.ynShow = function () {
Buttons.ynHide = function () {
this.ynButton.hide();
- Main.enableKeys();
+ if (Main.state == Main.eOPT)
+ $("#optionsViewAnchor").focus();
+ else
+ Main.enableKeys();
};
Buttons.createStyleSheet = function () {
@@ -219,8 +239,16 @@ Buttons.createYnButtons= function () {
table.append(tbody);
var row = $("<tr>", {style: "width:100%; align:center"});
+ var cell = $("<td>", {style :"height:80%; width:100%", colspan:"3" });
+ cell.css("align","center");
+ var txt_div = $("<div>", {text: "Delete ?"});
+ cell.append(txt_div);
+ row.append(cell);
+ tbody.append(row);
- var cell = $("<td>", {style :"height:80%; width:50%"});
+ row = $("<tr>", {style: "width:100%; align:center"});
+ cell = $("<td>", {style :"height:80%; width:50%"});
+
cell.css("align","right");
$("<button>", {id : "yn-btn-1", text: "Yes", class: "pr-btn"}).appendTo(cell);
row.append(cell);
diff --git a/smarttv-client/Javascript/Comm.js b/smarttv-client/Javascript/Comm.js
index 8c87af6..eb548a2 100644
--- a/smarttv-client/Javascript/Comm.js
+++ b/smarttv-client/Javascript/Comm.js
@@ -1,10 +1,16 @@
var Comm = {
+ created: false,
customMgr : {},
deviceInstance : []
};
Comm.init = function () {
+ if (this.created == true) {
+ return;
+ }
+
+ this.created = true;
// >> Register custom manager callback to receive device connect and disconnect events
Comm.customMgr = webapis.customdevice || {};
@@ -16,6 +22,8 @@ Comm.init = function () {
Main.logToServer("curWidget.id= (" + curWidget.id+")");
};
+//TODO: I should ensure that I take only events from the selected VDR server
+
Comm.onDeviceStatusChange = function (sParam) {
switch( Number(sParam.eventType) ) {
case Comm.customMgr.MGR_EVENT_DEV_CONNECT:
@@ -32,10 +40,10 @@ Comm.onDeviceStatusChange = function (sParam) {
};
Comm.onCustomObtained = function (customs) {
- Main.logToServer("onCustomObtained - found " + customs.length + " custom device(s)");
+// Main.logToServer("onCustomObtained - found " + customs.length + " custom device(s)");
for(var i=0; i<customs.length; i++) {
if(customs[i]!=null && customs[i].getType() == Comm.customMgr.DEV_SMART_DEVICE) {
- Main.logToServer("onCustomObtained - is Comm.custom.DEV_SMART_DEVICE: i=" + i);
+// Main.logToServer("onCustomObtained - is Comm.custom.DEV_SMART_DEVICE: i=" + i);
Comm.deviceInstance[i] = customs[i];
Comm.deviceInstance[i].registerDeviceCallback(Comm.onDeviceEvent);
}
@@ -138,6 +146,9 @@ Comm.onMessageReceived = function(message, context) {
}
break;
+ case "MESG":
+ Notify.showNotify(msg.payload, true);
+ break;
}; // switch
diff --git a/smarttv-client/Javascript/Config.js b/smarttv-client/Javascript/Config.js
index 8f0d898..2d4cf52 100755
--- a/smarttv-client/Javascript/Config.js
+++ b/smarttv-client/Javascript/Config.js
@@ -2,8 +2,10 @@ var Config = {
cfgFileName : "",
XHRObj : null,
xmlDocument : null,
+ vdrServers : null,
serverUrl : "", // Will become the main URL for contacting the server. Form "http://<server>:port"
serverAddr : "",
+ serverName : "",
serverAddrDefault: "192.168.1.122:8000",
format :"has",
tgtBufferBitrate : 6000, // kbps
@@ -19,7 +21,10 @@ var Config = {
uploadJsFile : "",
directAcessTimeout : 1500,
preferredQuality : 2,
- widgetVersion : "unknown",
+ widgetVersion : "unknown",
+ tzCorrection : 0,
+ recSortType : 0,
+ playKeyBehavior : 0,
deviceType : 0 // Used to differentiate between browsers and platforms
// 0: Samsung
@@ -43,17 +48,22 @@ Config.init = function () {
Main.logToServer ("modelName= " + deviceapis.tv.info.getModel());
Main.logToServer ("productType= " + deviceapis.tv.info.getProduct());
*/
+
+ this.vdrServers = new VdrServers();
+ this.vdrServers.instanceName = " MyObj";
+ if (this.serverUrl != "") {
+ // Hardcoded server URL. Done with config
+ Main.log ("Hardcoded server URL. Done with config");
+ Config.fetchConfig();
+ return;
+ }
+
- if (this.deviceType == 0) {
+// if (this.deviceType == 0)
+ switch (this.deviceType){
+ case 0:
// This is a Samsung Smart TV
-
- if (this.serverUrl != "") {
- // Hardcoded server URL. Done with config
- Main.log ("Hardcoded server URL. Done with config");
- Config.fetchConfig();
- return;
- }
-
+
try {
this.cfgFileName = curWidget.id + "/config.dta";
}
@@ -82,8 +92,11 @@ Config.init = function () {
return;
}
else {
+ // ok, there should be some config info
Config.readContext();
- }
+ return; //thlo: TODO
+ }
+ break;
}
Server.notifyServer("started");
Config.fetchConfig();
@@ -136,6 +149,12 @@ Config.fetchConfig = function () {
Config.uploadJsFile = $(data).find('uploadJsFile').text();
Config.directAcessTimeout = $(data).find('directAcessTimeout').text();
Config.preferredQuality = $(data).find('preferredQuality').text();
+ Config.sortType= parseInt($(data).find('sortType').text());
+ if ((Config.sortType < 0) || (Config.sortType > Data.maxSort) || isNaN(Config.sortType)) {
+ Config.sortType = 0;
+ }
+ Config.playKeyBehavior = parseInt($(data).find('playKeyBehavior').text());
+ Config.playKeyBehavior = isNaN(Config.playKeyBehavior) ? 0 : Config.playKeyBehavior;
Player.skipDuration = Config.skipDuration;
if (Config.directAcessTimeout != "") {
@@ -153,6 +172,8 @@ Config.fetchConfig = function () {
Main.log("liveChannels= " + Config.liveChannels);
Main.log("debug= " + Config.debug);
Main.log("usePdlForRecordings= " + Config.usePdlForRecordings);
+ Main.log("sortType= " + Config.sortType);
+ Main.log("playKeyBehavior= " + Config.playKeyBehavior);
Main.log("**** /Config ****");
Main.init();
@@ -170,40 +191,99 @@ Config.fetchConfig = function () {
};
-Config.writeContext = function (addr) {
+
+Config.deletedFromContext = function(idx) {
+ Main.log("Config.deletedFromContext: idx= " + idx);
+ Config.vdrServers.serverUrlList.splice(idx, 1);
+
+ Config.writeServerUrlList();
+};
+
+Config.updateContext = function (addr) {
+ Main.log("Config.updateContext with ("+addr+")");
+ Main.logToServer("Config.updateContext with ("+addr+")");
+
+ var found = false;
+
+ for (var i = 0; i < Config.vdrServers.serverUrlList.length; i++) {
+ if (Config.vdrServers.serverUrlList[i] == addr) {
+ found = true;
+ break;
+ }
+
+ }
+ if (found == true) {
+ // don't overwrite, if the address is already there.
+ Main.log("Config.updateContext: don't overwrite -> return");
+ Notify.showNotify("Server already included -> Ignoring", true);
+
+ 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
+// 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 == "") {
+ // only change the server, when needed.
+ Config.serverAddr = addr;
+ Config.serverUrl = "http://" + Config.serverAddr;
+ Config.fetchConfig();
+ }
};
-Config.updateContext = function (addr) {
- Main.log("Config.updateContext with ("+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();
- Config.serverAddr = addr;
- Config.serverUrl = "http://" + Config.serverAddr;
- Config.fetchConfig();
+ var fd = fileSystemObj.openCommonFile(Config.cfgFileName,"w");
+
+ 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]);
+ fd.writeLine('serverAddr ' + Config.vdrServers.serverUrlList[i]);
+ }
+
+ fileSystemObj.closeCommonFile(fd);
+
};
Config.readContext = function () {
+ // readConfig is only called once, at start-up.
+ // an array of server addresses should be read.
var fileSystemObj = new FileSystem();
+
try {
var fd = fileSystemObj.openCommonFile(Config.cfgFileName, "r");
-
var line = "";
while (line = fd.readLine()) {
var avp = line.split(" ");
if (avp.length > 1) {
+ Config.vdrServers.serverUrlList.push(avp[1]);
+ Main.log("Config.readContext avp[1]= " + avp[1]);
Config.serverAddr = avp[1];
Config.serverUrl = "http://" + Config.serverAddr;
}
@@ -215,6 +295,7 @@ Config.readContext = function () {
}
}
fileSystemObj.closeCommonFile(fd);
+
}
catch (e) {
Main.log("Config.readContext: Error while reading: e= " +e);
@@ -235,6 +316,16 @@ Config.readContext = function () {
Config.doFirstLaunch();
}
+
+// Config.vdrServers.serverUrlList.push("192.168.1.142:8000");
+ this.vdrServers.checkServers();
+ if (Config.vdrServers.serverUrlList.length > 1) {
+ // Now I should show the popup to select the server.
+ // 1: Check whether more than one server is active
+ // - I need a new plugin method (getServerName)
+ // 2: If more than one server is active, show server menu
+ }
+
};
@@ -243,3 +334,107 @@ Config.reset = function () {
var fileSystemObj = new FileSystem();
fileSystemObj.deleteCommonFile(curWidget.id + "/config.dta");
};
+
+//**************************************************
+function VdrServers() {
+ this.serverUrlList = [];
+ this.activeServers = [];
+ this.responses = 0;
+ this.instanceName = "";
+};
+
+VdrServers.prototype.checkServers = function () {
+
+ Main.log ("check active VDR servers " );
+ this.responses = 0;
+ this.activeServers = [];
+
+ for (var i = 0; i < this.serverUrlList.length; i++) {
+ var obj = new VdrServerChecker(this, i);
+ obj.checkServer(this.serverUrlList[i]);
+ }
+};
+
+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);
+ switch (this.activeServers.length) {
+ case 0:
+ Display.showPopup("Please start your VDR server");
+ break;
+ case 1:
+ Config.serverAddr = this.activeServers[0].addr;
+ Config.serverUrl = "http://" + Config.serverAddr;
+ Config.serverName = this.activeServers[0].name;
+ Notify.showNotify("Only " + Config.serverName + " found", true);
+
+ $("#selectTitle").text(Config.serverName );
+ $("#logoTitle").text(Config.serverName );
+
+ Config.fetchConfig();
+ break;
+ default:
+ OverlayMenu.menu = [];
+ for (var i = 0; i < this.activeServers.length; i++) {
+ var self = this;
+ OverlayMenu.menu.push ({title: this.activeServers[i].name, func : function (idx) { self.selectCallback(idx); } });
+ }
+ OverlayMenu.show();
+
+ break;
+ }
+ }
+
+};
+
+
+VdrServers.prototype.selectCallback = function (idx) {
+ Config.serverAddr = this.activeServers[idx].addr;
+ Config.serverUrl = "http://" + Config.serverAddr;
+ Config.serverName = this.activeServers[idx].name;
+
+ Main.log ("vdrServers.selectCallback idx= " + idx + " Config.serverUrl= " + Config.serverUrl);
+
+ $("#selectTitle").text(Config.serverName );
+ $("#logoTitle").text(Config.serverName );
+
+ Config.fetchConfig();
+
+
+};
+
+//**************************************************
+function VdrServerChecker(parent, i) {
+ this.ipaddr = "";
+ this.idx = i;
+ this.parent = parent;
+};
+
+VdrServerChecker.prototype.checkServer = function (addr) {
+ this.ipaddr = addr;
+ var url ="http://"+ addr + "/serverName.xml";
+ $.ajax({
+ url: url,
+ type : "GET",
+ context : this,
+ timeout : 400,
+ success : function(data, status, XHR ) {
+ var name = $(data).find('hostname').text();
+ var ip = $(data).find('ipaddress').text();
+ Main.log ("checkServer Success Inst= " + this.ipaddr + " " + name + " " + ip);
+ this.parent.activeServers.push({name : name, addr : ip});
+ this.parent.handleResponse();
+ },
+ error : function (XHR, status, error) {
+ Main.log ("checkServer Error Inst= " + this.ipaddr +" status: " + ((status != null) ? status : "null"));
+ if (status != null)
+ if (status == "error") {
+ this.parent.activeServers.push({name : "Unnamed " + this.idx, addr : this.ipaddr});
+ }
+ this.parent.handleResponse();
+ }
+ });
+
+};
diff --git a/smarttv-client/Javascript/Data.js b/smarttv-client/Javascript/Data.js
index 5eee3f2..d2673fe 100755
--- a/smarttv-client/Javascript/Data.js
+++ b/smarttv-client/Javascript/Data.js
@@ -4,7 +4,8 @@ var Data =
folderList : [],
createAccessMap : false,
directAccessMap : {},
- sortType : 0
+ sortType : 0,
+ maxSort : 3
};
Array.prototype.remove = function(from, to) {
@@ -18,7 +19,7 @@ Data.reset = function() {
this.assets = new Item;
this.folderList = [];
this.createAccessMap = false;
- this.sortType = 0;
+ this.sortType = Config.sortType;
// this.folderList.push({item : this.assets, id: 0});
Main.log("Data.reset: folderList.push. this.folderList.length= " + this.folderList.length);
};
@@ -38,7 +39,7 @@ Data.completed= function(sort) {
};
Data.nextSortType = function () {
- Data.sortType = (Data.sortType +1) %3;
+ Data.sortType = (Data.sortType +1) % Data.maxSort;
this.assets.sortPayload(Data.sortType);
};
@@ -252,23 +253,6 @@ Item.prototype.print = function(level) {
}
};
-/*
-Item.prototype.sortPayload = function() {
- for (var i = 0; i < this.childs.length; i++) {
- if (this.childs[i].isFolder == true) {
- this.childs[i].sortPayload();
- }
- }
- this.childs.sort(function(a,b) {
- if (a.title == b.title) {
- return (b.payload.start - a.payload.start);
- }
- else {
- return ((a.title < b.title) ? -1 : 1);
- }
- });
-};
-*/
Item.prototype.sortPayload = function(sel) {
for (var i = 0; i < this.childs.length; i++) {
if (this.childs[i].isFolder == true) {
@@ -299,6 +283,17 @@ Item.prototype.sortPayload = function(sel) {
}
});
break;
+ case 3:
+ this.childs.sort(function(a,b) {
+ if (a.title == b.title) {
+ return (b.payload.start -a.payload.start);
+ }
+ else {
+ return ((a.title < b.title) ? -1 : 1);
+
+ }
+ });
+ break;
case 0:
default:
this.childs.sort(function(a,b) {
diff --git a/smarttv-client/Javascript/DirectAccess.js b/smarttv-client/Javascript/DirectAccess.js
index 2406f89..b274498 100644
--- a/smarttv-client/Javascript/DirectAccess.js
+++ b/smarttv-client/Javascript/DirectAccess.js
@@ -15,6 +15,13 @@ Main.selectedVideo needs to point to the selected video of that current folder
*/
+DirectAccess.init = function (){
+ if (this.created == false) {
+ DirectAccess.createStyleSheet();
+ $("#directChanAccess").hide();
+ this.created = true;
+ }
+};
DirectAccess.selectNewChannel = function (num) {
Main.log("DirectAccess.selectNewChannel: val= (" + num + ")");
@@ -74,13 +81,6 @@ DirectAccess.selectNewChannel = function (num) {
//
};
-DirectAccess.init = function (){
- if (this.created == false) {
- DirectAccess.createStyleSheet();
- $("#directChanAccess").hide();
- this.created = true;
- }
-};
DirectAccess.show = function (val) {
Main.log("DirectAccess.show " + val);
diff --git a/smarttv-client/Javascript/Display.js b/smarttv-client/Javascript/Display.js
index 94743bd..6246406 100755
--- a/smarttv-client/Javascript/Display.js
+++ b/smarttv-client/Javascript/Display.js
@@ -102,12 +102,12 @@ Display.GetEpochTime = function() {
// Samsung specific UTC time function
// res = Display.pluginTime.GetEpochTime();
var now_millis = ((new Date).getTime());
- res = (now_millis /1000.0);
+ res = ((now_millis /1000.0) - (Config.tzCorrection * 60));
break;
default:
var now_millis = ((new Date).getTime());
- res = (now_millis /1000.0);
+ res = ((now_millis /1000.0) - (Config.tzCorrection * 60));
break;
}
@@ -949,7 +949,7 @@ Display.handlerShowProgress = function() {
$("#olTimeInfo").text(Player.curPlayTimeStr + " / " + Player.getDurationStr());
var Digital=new Date();
- var hours=Digital.getHours();
+ var hours= (Digital.getHours()- Config.tzCorrection ) ;
var minutes=Digital.getMinutes();
if (minutes<=9)
minutes='0'+minutes;
@@ -974,7 +974,7 @@ ClockHandler.start = function(elm){
ClockHandler.update = function() {
var date = new Date();
- var hours= date.getHours();
+ var hours= (date.getHours() - Config.tzCorrection);
var minutes= date.getMinutes();
if (minutes<=9)
minutes='0'+minutes;
diff --git a/smarttv-client/Javascript/Epg.js b/smarttv-client/Javascript/Epg.js
index e6bfdd6..87325a8 100644
--- a/smarttv-client/Javascript/Epg.js
+++ b/smarttv-client/Javascript/Epg.js
@@ -161,6 +161,7 @@ Epg.parseResponse = function (message,text, XHR) {
entry.prog = $(this).find("title").text();
entry.desc = $(this).find("desc").text();
entry.start = parseInt($(this).find("start").text());
+ entry.eventid= parseInt($(this).find("eventid").text());
entry.dur = (parseInt($(this).find("end").text()) - parseInt($(this).find("start").text()));
Main.log("Epg.parseResponse : Guid= "+ guid + " title= " + entry.prog+ " start= " +entry.start + " dur= " + entry.dur);
@@ -188,4 +189,39 @@ Epg.parseResponse = function (message,text, XHR) {
});
};
+Epg.getCurrentEvent4Rec = function (guid) {
+ var url = Config.serverUrl + "/epg.xml?id=" + guid;
+
+ Main.log("Epg.getCurrentEpg: guid= " + guid + " and url= " + url);
+ $.ajax({
+ type: "GET",
+ async: true,
+ url: url,
+ success: function(data, status, XHR ) {
+ $(message).find("programme").each(function(){
+ var guid = $(this).find("guid").text();
+ if (guid != Epg.curGuid) {
+ Main.logToServer("ERROR in Epg.parseResponse : Guid (="+ guid + ") != Epg.curGuid (=" + Epg.curGuid+ ") " );
+ }
+
+ entry={};
+ entry.prog = $(this).find("title").text();
+ entry.desc = $(this).find("desc").text();
+ entry.start = parseInt($(this).find("start").text());
+ entry.eventid= parseInt($(this).find("eventid").text());
+ entry.dur = (parseInt($(this).find("end").text()) - parseInt($(this).find("start").text()));
+
+ Main.log("Epg.getCurrentEpg : Guid= "+ guid + " title= " + entry.prog+ " start= " +entry.start + " dur= " + entry.dur);
+
+ // thlo: here I should invoke the rec command
+ // then I should switch to recording playback (new state?).
+
+ });
+
+ },
+ error: function (jqXHR, status, error) {
+
+ }
+ });
+};
diff --git a/smarttv-client/Javascript/Helpbar.js b/smarttv-client/Javascript/Helpbar.js
index 61e51bf..7511e09 100644
--- a/smarttv-client/Javascript/Helpbar.js
+++ b/smarttv-client/Javascript/Helpbar.js
@@ -6,6 +6,7 @@ Helpbar.init = function () {
if (this.isInited == false) {
Helpbar.createHelpbar();
Helpbar.hide();
+ Helpbar.hideOptSrv();
}
};
@@ -17,35 +18,52 @@ Helpbar.hide = function () {
$("#helpbar").hide();
};
+Helpbar.showOptSrv = function () {
+ $("#helpbarOptSrv").show();
+};
+
+Helpbar.hideOptSrv = function () {
+ $("#helpbarOptSrv").hide();
+};
+
Helpbar.createHelpbar = function() {
this.isInited = true;
var sheet = $("<style>");
sheet.attr({type : 'text/css',
innerHTML : '\
- .hb-bg {left:0px; top:480px; width:960px; height:40px; position: absolute; font-size:18px; background: darkblue;background: -webkit-linear-gradient(top, #1e5799 0%,#7db9e8 50%,#1e5799 100%);}\
+ .hb-bg {left:0px; top:480px; width:960px; height:40px; position: absolute; z-index:40; font-size:18px; background: darkblue;background: -webkit-linear-gradient(top, #1e5799 0%,#7db9e8 50%,#1e5799 100%);}\
}'});
$('body').append(sheet);
-// $('<div>', { id: "helpbar", class: "hb-bg"}).appendTo ($("body"));
-// $('<div>', {id: "hb-row"}).appendTo("#helpbar");
$("<table>", {id:"helpbar", class: "hb-bg"}).appendTo ($("body"));
- $("<tr>", {id: "hb-row", align:"center", valign:"middle"}).appendTo("#helpbar");
+ var row = $("<tr>", {id: "hb-row", align:"center", valign:"middle"});
+ row.appendTo("#helpbar");
- Helpbar.addItem("Images/helpbar/help_lr.png", "Move Cursor");
- Helpbar.addItem("Images/helpbar/help_back.png", "Cancel");
+ Helpbar.addItem("Images/helpbar/help_joy.png", "Move Cursor", row);
+ Helpbar.addItem("Images/helpbar/help_back.png", "Cancel", row);
- Helpbar.addItem("Images/helpbar/help_enter.png", "Done");
- Helpbar.addItem("Images/helpbar/help_red.png", "Clear all");
- Helpbar.addItem("Images/helpbar/help_green.png", "Clear Char");
- Helpbar.addItem("Images/helpbar/help_yellow.png", "Dot (.)");
- Helpbar.addItem("Images/helpbar/help_blue.png", "Colon (:)");
+ Helpbar.addItem("Images/helpbar/help_enter.png", "Done", row);
+ Helpbar.addItem("Images/helpbar/help_red.png", "Clear all", row);
+ Helpbar.addItem("Images/helpbar/help_green.png", "Clear Char", row);
+ Helpbar.addItem("Images/helpbar/help_yellow.png", "Dot (.)", row);
+ Helpbar.addItem("Images/helpbar/help_blue.png", "Colon (:)", row);
+
+ //--------------------------------------------
+
+ $("<table>", {id:"helpbarOptSrv", class: "hb-bg"}).appendTo ($("body"));
+ row = $("<tr>", {id: "hb-row-opt-srv", align:"center", valign:"middle"});
+ row.appendTo("#helpbarOptSrv");
+
+ Helpbar.addItem("Images/helpbar/help_ud.png", "Move Cursor", row);
+ Helpbar.addItem("Images/helpbar/help_back.png", "Cancel", row);
+ Helpbar.addItem("Images/helpbar/help_yellow.png", "Delete", row);
};
-Helpbar.addItem = function(url, msg) {
+Helpbar.addItem = function(url, msg, row) {
var hb_elm = $("<td>");
-// var hb_elm = $("<div>");
-// hb_elm.css({"display":"inline-block"});
- hb_elm.appendTo("#hb-row");
+
+ //hb_elm.appendTo("#hb-row");
+ hb_elm.appendTo(row);
var tab = $("<table>");
tab.appendTo(hb_elm);
diff --git a/smarttv-client/Javascript/Main.js b/smarttv-client/Javascript/Main.js
index aa33217..241666c 100755
--- a/smarttv-client/Javascript/Main.js
+++ b/smarttv-client/Javascript/Main.js
@@ -52,7 +52,8 @@ var Main = {
eREC : 2, // State Recording Select Screen / Video Playing
eMED : 3, // State Media Select Screen / Video Playing
eURLS : 4, // State Urls
- eOPT : 5, // Options
+ eSRVR : 5, // State Select Server
+ eOPT : 6, // Options
defKeyHndl : null,
selectMenuKeyHndl : null,
@@ -101,6 +102,7 @@ Main.onLoad = function() {
Spinner.init();
Helpbar.init();
Options.init();
+ OverlayMenu.init();
this.defKeyHndl = new cDefaulKeyHndl;
this.playStateKeyHndl = new cPlayStateKeyHndl(this.defKeyHndl);
@@ -108,6 +110,9 @@ Main.onLoad = function() {
this.menuKeyHndl = new cMenuKeyHndl(this.defKeyHndl);
this.selectMenuKeyHndl = new cSelectMenuKeyHndl(this.defKeyHndl);
+ ClockHandler.start("#selectNow");
+ Config.getWidgetVersion();
+
Config.init();
};
@@ -136,6 +141,8 @@ Main.init = function () {
};
}
+ this.state = Main.eMAIN;
+
Main.log("Main.init()");
Buttons.init();
@@ -162,25 +169,28 @@ Main.init = function () {
Spinner.hide();
Display.show();
};
-
-
- // Enable key event processing
- this.enableKeys();
}
else {
Main.log("Failed to initialise");
}
- ClockHandler.start("#selectNow");
+ // Enable key event processing
+ this.enableKeys();
+
+ Server.updateVdrStatus();
+
HeartbeatHandler.start();
- Server.updateVdrStatus();
DirectAccess.init();
- Config.getWidgetVersion();
+
Comm.init();
+// window.setTimeout(function() {Config.updateContext("192.168.1.142:8000"); }, (10*1000));
+
+
+
// DirectAccess.show();
// Timers.init();
// Display.initOlForRecordings();
@@ -295,16 +305,16 @@ Main.changeState = function (state) {
Main.selectedVideo = 0;
Main.urlsSelected();
-// window.setTimeout(function() {Main.testUrls (); }, (5*1000));
-
break;
-
+ case Main.eSRVR:
+ Config.vdrServers.checkServers();
+ break;
case Main.eOPT:
// Options
// Options.init();
$("#selectScreen").hide();
Options.show();
- Main.optionsSelected();
+// Main.optionsSelected();
break;
}
};
@@ -515,7 +525,7 @@ Main.playItem = function (url) {
if ((now - (start_time + duration)) < 0) {
// still recording
Main.log("*** Still Recording! ***");
- Main.logToServer("*** Still Recording! ***");
+ Main.logToServer("*** Still Recording!: now= " + now + " start_time= " + start_time + " dur= " + duration +" ***");
Player.isRecording = true;
Player.startTime = start_time;
Player.duration = duration; // EpgDuration
@@ -678,48 +688,57 @@ cPlayStateKeyHndl.prototype.handleKeyDown = function (event) {
{
case tvKey.KEY_1:
Main.log("KEY_1 pressed");
- Display.showProgress();
- Player.jumpToVideo(10);
+// Display.showProgress();
+// Player.jumpToVideo(10);
+ Player.numKeyJump(1);
break;
case tvKey.KEY_2:
Main.log("KEY_2 pressed");
- Display.showProgress();
- Player.jumpToVideo(20);
+// Display.showProgress();
+// Player.jumpToVideo(20);
+ Player.numKeyJump(2);
break;
case tvKey.KEY_3:
Main.log("KEY_3 pressed");
- Display.showProgress();
- Player.jumpToVideo(30);
+// Display.showProgress();
+// Player.jumpToVideo(30);
+ Player.numKeyJump(3);
break;
case tvKey.KEY_4:
Main.log("KEY_4 pressed");
- Display.showProgress();
- Player.jumpToVideo(40);
+// Display.showProgress();
+// Player.jumpToVideo(40);
+ Player.numKeyJump(4);
break;
case tvKey.KEY_5:
Main.log("KEY_5 pressed");
- Display.showProgress();
- Player.jumpToVideo(50);
+// Display.showProgress();
+// Player.jumpToVideo(50);
+ Player.numKeyJump(5);
break;
case tvKey.KEY_6:
Main.log("KEY_6 pressed");
- Display.showProgress();
- Player.jumpToVideo(60);
+// Display.showProgress();
+// Player.jumpToVideo(60);
+ Player.numKeyJump(6);
break;
case tvKey.KEY_7:
Main.log("KEY_7 pressed");
- Display.showProgress();
- Player.jumpToVideo(70);
+// Display.showProgress();
+// Player.jumpToVideo(70);
+ Player.numKeyJump(7);
break;
case tvKey.KEY_8:
Main.log("KEY_8 pressed");
- Display.showProgress();
- Player.jumpToVideo(80);
+// Display.showProgress();
+// Player.jumpToVideo(80);
+ Player.numKeyJump(8);
break;
case tvKey.KEY_9:
Main.log("KEY_9 pressed");
- Display.showProgress();
- Player.jumpToVideo(90);
+// Display.showProgress();
+// Player.jumpToVideo(90);
+ Player.numKeyJump(9);
break;
case tvKey.KEY_RIGHT:
@@ -916,6 +935,16 @@ cLivePlayStateKeyHndl.prototype.handleKeyDown = function (event) {
Main.playItem();
break;
+ case tvKey.KEY_RIGHT:
+ Main.log("Right: Skip Forward");
+ Display.showProgress();
+ if (Player.trickPlaySpeed != 1) {
+ Notify.showNotify("Trickplay!", true);
+ }
+ else
+ Player.skipForwardVideo();
+ break;
+
// case tvKey.KEY_4:
case tvKey.KEY_DOWN:
case tvKey.KEY_CH_DOWN:
@@ -949,6 +978,10 @@ cLivePlayStateKeyHndl.prototype.handleKeyDown = function (event) {
Main.log("ENTER");
Display.hide();
Display.showProgress();
+ if(Player.getState() == Player.PAUSED) {
+ Player.resumeVideo();
+ }
+
break;
case tvKey.KEY_LEFT:
case tvKey.KEY_RETURN:
@@ -972,8 +1005,27 @@ cLivePlayStateKeyHndl.prototype.handleKeyDown = function (event) {
widgetAPI.blockNavigation(event);
break;
+ case tvKey.KEY_REC:
+ case 73:
+
+ Main.log("KEY_REC with guid= Data.getCurrentItem().childs[Main.selectedVideo].payload.guid");
+ var timer_req = new addTimer(Data.getCurrentItem().childs[Main.selectedVideo].payload.guid);
+ // use the guid and request the epg.
+ // use the event id then issue the rec command
+// Data.getCurrentItem().childs[Main.selectedVideo].payload.guid
+
case tvKey.KEY_PAUSE:
- Main.log("PAUSE");
+ Main.log("REC / PAUSE");
+ if(Player.getState() == Player.PAUSED) {
+ Player.resumeVideo();
+ }
+ else {
+ Player.pauseVideo();
+ }
+
+ // use the guid and request the epg.
+ // use the event id then issue the rec command
+// Data.getCurrentItem().childs[Main.selectedVideo].payload.
break;
case tvKey.KEY_INFO:
Display.showInfo(Main.selectedVideo);
@@ -1167,7 +1219,7 @@ function cSelectMenuKeyHndl (def_hndl) {
Main.log(this.handlerName + " created");
this.select = 1;
- this.selectMax = 5; // Highest Select Entry
+ this.selectMax = 6; // Highest Select Entry
};
cSelectMenuKeyHndl.prototype.handleKeyDown = function (event) {
@@ -1204,6 +1256,12 @@ cSelectMenuKeyHndl.prototype.handleKeyDown = function (event) {
Main.changeState (this.select);
break;
+ case tvKey.KEY_6:
+ Main.log("KEY_6 pressed");
+ this.select = 6;
+ Main.changeState (this.select);
+ break;
+
case tvKey.KEY_ENTER:
case tvKey.KEY_PLAY:
case tvKey.KEY_PANEL_ENTER:
diff --git a/smarttv-client/Javascript/Options.js b/smarttv-client/Javascript/Options.js
index 55eebf9..efa5a63 100755
--- a/smarttv-client/Javascript/Options.js
+++ b/smarttv-client/Javascript/Options.js
@@ -4,8 +4,14 @@ var Options = {
jqInputElm : "#widgetServerAddr",
cursor : "_",
cursorPos : 0,
- isCreated : false
+ isCreated : false,
+ selectedLine : 0,
+ maxSelect : -1,
+ state : 0,
+
+ sEnter : 0,
+ sSelect : 1
};
Options.init = function() {
@@ -24,8 +30,9 @@ Options.init = function() {
};
Options.show = function() {
-// document.getElementById("optionsScreen").style.display="block";
+ Main.log("Options.show");
$("#optionsScreen").show();
+ this.selectedLine = 0;
if (Config.firstLaunch == true)
document.getElementById(Options.inputElm).value = Config.serverAddrDefault ;
@@ -34,9 +41,10 @@ Options.show = function() {
Options.cursorPos = document.getElementById(Options.inputElm).value.length;
- $(this.jqInputElm).focus();
// document.getElementById(Options.inputElm).focus();
+ Options.drawServerList();
+
Helpbar.init();
Helpbar.show();
};
@@ -45,9 +53,38 @@ Options.hide = function() {
$("#optionsScreen").hide();
// document.getElementById("optionsScreen").style.display="none";
Helpbar.hide();
+ Helpbar.hideSrv();
+
Main.enableKeys();
};
+Options.drawServerList = function () {
+ //delete all chiilds below optionsList
+ $("#optionsList").children().remove();
+
+ for (var i = 0; i < Config.vdrServers.serverUrlList.length; i++) {
+ var line = $("<div>", {id: ("optl-" + (i+1))}).text("Server "+ i + ": " + Config.vdrServers.serverUrlList[i]);
+ $("#optionsList").append(line);
+ }
+
+ this.maxSelect = Config.vdrServers.serverUrlList.length;
+ Main.log("Options.show - this.maxSelect= " + this.maxSelect);
+
+ if (this.selectedLine > this.maxSelect)
+ this.selectedLine = this.maxSelect;
+
+ if (this.selectedLine == 0) {
+ $(this.jqInputElm).focus();
+ this.state = Options.sEnter;
+ }
+ else {
+ this.state = Options.sSelect;
+ $("#optionsViewAnchor").focus();
+ var elm = document.getElementById("optl-"+this.selectedLine);
+ Display.selectItem(elm);
+ }
+
+};
Options.createKeypad = function () {
var sheet = $("<style>");
@@ -96,7 +133,6 @@ Options.insertChar = function(char) {
var res = "";
if (Options.cursorPos == 0) {
res = char;
-// document.getElementById(Options.inputElm).value = char + Options.cursor;
}
else {
if (Options.cursorPos == txt.length) {
@@ -104,7 +140,6 @@ Options.insertChar = function(char) {
}
else {
res = txt.slice(0, Options.cursorPos) + char + txt.slice(Options.cursorPos);
-// document.getElementById(Options.inputElm).value = txt.slice(0, Options.cursorPos) + char + txt.slice(Options.cursorPos);
}
}
document.getElementById(Options.inputElm).value = res;
@@ -117,13 +152,10 @@ Options.deleteAll = function () {
document.getElementById(Options.inputElm).value = '';
Options.cursorPos = 0;
Options.setCursor(Options.cursorPos);
-// document.getElementById(Options.inputElm).value = "" +Options.cursor;
};
Options.deleteChar = function() {
var txt = document.getElementById(Options.inputElm).value;
-// alert("Options.cursorPos= " +Options.cursorPos);
-// alert("txt.length= " +txt.length);
document.getElementById(Options.inputElm).value = txt.slice(0, (Options.cursorPos-1)) + txt.slice(Options.cursorPos);
Options.cursorPos = Options.cursorPos -1;
Options.setCursor(Options.cursorPos);
@@ -135,45 +167,27 @@ Options.moveCursorLeft = function() {
return;
Options.cursorPos = Options.cursorPos -1;
Options.setCursor(Options.cursorPos);
-// document.getElementById(Options.inputElm).setSelectionRange(Options.cursorPos, Options.cursorPos);
- /*
- if (Options.cursorPos == 0)
- return;
- var txt = document.getElementById(Options.inputElm).value;
- var tgt = txt.slice(0, (Options.cursorPos-1)) + Options.cursor +txt.slice((Options.cursorPos-1), Options.cursorPos) + txt.slice(Options.cursorPos+1);
-
- document.getElementById(Options.inputElm).value = tgt;
- Options.cursorPos = Options.cursorPos -1;
- */
};
Options.moveCursorRight = function() {
if (Options.cursorPos == document.getElementById(Options.inputElm).value.length)
return;
Options.cursorPos = Options.cursorPos +1;
-// document.getElementById(Options.inputElm).setSelectionRange(Options.cursorPos, Options.cursorPos);
Options.setCursor(Options.cursorPos);
- /*
- var txt = document.getElementById(Options.inputElm).value;
- if (Options.cursorPos == txt.length-1)
- return;
-
- var tgt = txt.slice(0, Options.cursorPos) +txt.slice((Options.cursorPos+1), (Options.cursorPos+2)) + Options.cursor + txt.slice(Options.cursorPos+2);
-
- document.getElementById(Options.inputElm).value = tgt;
- Options.cursorPos = Options.cursorPos +1;
- */
};
Options.onInput = function () {
var keyCode = event.keyCode;
+ Main.log("Options.onInput Key= " + keyCode);
switch(keyCode) {
case tvKey.KEY_1:
Main.log("KEY_1 pressed");
+ if (Options.state != Options.sEnter )
+ return;
Options.insertChar("1");
$("#kb-btn-1").removeClass('ui-btn').addClass('ui-btn-pressed');
@@ -184,6 +198,8 @@ Options.onInput = function () {
break;
case tvKey.KEY_2:
Main.log("KEY_2 pressed");
+ if (Options.state != Options.sEnter )
+ return;
Options.insertChar("2");
$("#kb-btn-2").removeClass('ui-btn').addClass('ui-btn-pressed');
setTimeout(function() {
@@ -193,6 +209,8 @@ Options.onInput = function () {
break;
case tvKey.KEY_3:
Main.log("KEY_3 pressed");
+ if (Options.state != Options.sEnter )
+ return;
Options.insertChar("3");
$("#kb-btn-3").removeClass('ui-btn').addClass('ui-btn-pressed');
@@ -202,6 +220,8 @@ Options.onInput = function () {
break;
case tvKey.KEY_4:
Main.log("KEY_4 pressed");
+ if (Options.state != Options.sEnter )
+ return;
Options.insertChar("4");
document.getElementById("kb-btn-4").click();
@@ -214,6 +234,8 @@ Options.onInput = function () {
break;
case tvKey.KEY_5:
Main.log("KEY_5 pressed");
+ if (Options.state != Options.sEnter )
+ return;
Options.insertChar("5");
$("#kb-btn-5").removeClass('ui-btn').addClass('ui-btn-pressed');
@@ -224,6 +246,8 @@ Options.onInput = function () {
break;
case tvKey.KEY_6:
Main.log("KEY_6 pressed");
+ if (Options.state != Options.sEnter )
+ return;
Options.insertChar("6");
$("#kb-btn-6").removeClass('ui-btn').addClass('ui-btn-pressed');
@@ -234,6 +258,8 @@ Options.onInput = function () {
break;
case tvKey.KEY_7:
Main.log("KEY_7 pressed");
+ if (Options.state != Options.sEnter )
+ return;
Options.insertChar("7");
$("#kb-btn-7").removeClass('ui-btn').addClass('ui-btn-pressed');
@@ -244,6 +270,8 @@ Options.onInput = function () {
break;
case tvKey.KEY_8:
Main.log("KEY_8 pressed");
+ if (Options.state != Options.sEnter )
+ return;
Options.insertChar("8");
$("#kb-btn-8").removeClass('ui-btn').addClass('ui-btn-pressed');
setTimeout(function() {
@@ -253,6 +281,8 @@ Options.onInput = function () {
break;
case tvKey.KEY_9:
Main.log("KEY_9 pressed");
+ if (Options.state != Options.sEnter )
+ return;
Options.insertChar("9");
$("#kb-btn-9").removeClass('ui-btn').addClass('ui-btn-pressed');
@@ -263,6 +293,10 @@ Options.onInput = function () {
break;
case tvKey.KEY_0:
Main.log("KEY_0 pressed");
+
+ if (Options.state != Options.sEnter )
+ return;
+
Options.insertChar("0");
$("#kb-btn-0").removeClass('ui-btn').addClass('ui-btn-pressed');
setTimeout(function() {
@@ -271,12 +305,75 @@ Options.onInput = function () {
break;
case tvKey.KEY_LEFT:
+ if (Options.state != Options.sEnter )
+ return;
+
Options.moveCursorLeft();
break;
case tvKey.KEY_RIGHT:
+ if (Options.state != Options.sEnter )
+ return;
Options.moveCursorRight();
break;
+ case tvKey.KEY_UP:
+ if (this.selectedLine != 0) {
+ var elm = document.getElementById("optl-"+this.selectedLine);
+ Display.unselectItem(elm);
+ }
+ this.selectedLine --;
+ if (this.selectedLine < 0) {
+ this.selectedLine = this.maxSelect;
+ $("#optionsViewAnchor").focus();
+ Options.state = Options.sSelect;
+ Helpbar.showOptSrv();
+ Helpbar.hide();
+ $("#ime_keypad").hide();
+
+ }
+ if (this.selectedLine == 0) {
+ $(this.jqInputElm).focus();
+ Options.state = Options.sEnter;
+ Helpbar.show();
+ Helpbar.hideOptSrv();
+ $("#ime_keypad").show();
+ }
+ Main.log("Up: this.selectedLine= " + this.selectedLine);
+
+ if (Options.state == Options.sSelect) {
+ var elm = document.getElementById("optl-"+this.selectedLine);
+ Display.selectItem(elm);
+ }
+
+ break;
+ case tvKey.KEY_DOWN:
+ if (this.selectedLine != 0) {
+ var elm = document.getElementById("optl-"+this.selectedLine);
+ Display.unselectItem(elm);
+ }
+ this.selectedLine ++ ;
+ if (this.selectedLine > this.maxSelect) {
+ this.selectedLine = 0;
+ $(this.jqInputElm).focus();
+ Options.state = Options.sEnter;
+ Helpbar.show();
+ Helpbar.hideOptSrv();
+ $("#ime_keypad").show();
+ }
+ if (this.selectedLine == 1) {
+ $("#optionsViewAnchor").focus();
+ Options.state = Options.sSelect;
+ Helpbar.showOptSrv();
+ Helpbar.hide();
+ $("#ime_keypad").hide();
+ }
+ Main.log("Down: this.selectedLine= " + this.selectedLine);
+ if (Options.state == Options.sSelect) {
+ var elm = document.getElementById("optl-"+this.selectedLine);
+ Display.selectItem(elm);
+ }
+
+ break;
case tvKey.KEY_RETURN:
Main.log("Return pressed");
Options.hide();
@@ -288,6 +385,11 @@ Options.onInput = function () {
// Done
// Options.cursorPos = Options.cursorPos +1;
// Options.deleteChar(); //
+ if (Options.state == Options.sSelect) {
+ Buttons.ynShow();
+ return;
+ }
+
Main.log("Enter pressed -> Done Val= ("+ document.getElementById(Options.inputElm).value+")");
Config.updateContext(document.getElementById(Options.inputElm).value);
@@ -304,12 +406,16 @@ Options.onInput = function () {
case tvKey.KEY_RED:
// Clear All
Main.log("Red pressed");
+ if (Options.state != Options.sEnter )
+ return;
Options.deleteAll();
break;
case tvKey.KEY_GREEN:
// Clear Char
Main.log("Green pressed");
+ if (Options.state != Options.sEnter )
+ return;
Options.deleteChar();
break;
@@ -317,13 +423,22 @@ Options.onInput = function () {
case tvKey.KEY_YELLOW:
// Dot
Main.log("Yellow pressed");
+ if (Options.state == Options.sSelect) {
+ Buttons.ynShow();
+ return;
+ }
+
+ if (Options.state == Options.sEnter ) {
+ Options.insertChar(".");
+ }
- Options.insertChar(".");
break;
case tvKey.KEY_PRECH:
case tvKey.KEY_BLUE:
Main.log("Blue pressed");
+ if (Options.state != Options.sEnter )
+ return;
// Colon
Options.insertChar(":");
break;
diff --git a/smarttv-client/Javascript/OverlayMenu.js b/smarttv-client/Javascript/OverlayMenu.js
new file mode 100644
index 0000000..14d237a
--- /dev/null
+++ b/smarttv-client/Javascript/OverlayMenu.js
@@ -0,0 +1,218 @@
+var OverlayMenu = {
+ menu : []
+};
+
+OverlayMenu.init = function () {
+ // initiate the overlay menue
+
+ // should get an Array with Title and Command as input
+// OverlayMenu.menu.push ({title: "Teefax", func : undefined});
+// OverlayMenu.menu.push ({title: "Verleihnix", func : undefined});
+
+ OverlayMenu.createStyleSheet();
+
+
+ this.elmName = "#olm-";
+ this.masterElm = "#overlayMenu";
+ this.inputElm = "#overlayMenu-anchor";
+ this.btnSelected = 0;
+
+ var elem = document.getElementById('overlayMenu-anchor');
+ elem.setAttribute('onkeydown', 'OverlayMenu.onInput();');
+
+ $("#overlayMenu").hide();
+};
+
+
+OverlayMenu.show = function() {
+ Main.log("***** OverlayMenu.show *****");
+ OverlayMenu.createMenu();
+// this.menuHandler.show();
+
+ Main.log("OverlayMenu.show(): masterElm= " +this.masterElm + " inputElm= " + this.inputElm);
+ $(this.masterElm).show();
+ $(this.inputElm).focus();
+ this.reset ();
+
+};
+
+OverlayMenu.hide = function() {
+ Main.log("OverlayMenu.hide(): masterElm= " +this.masterElm + " inputElm= " + this.inputElm);
+
+ $(this.masterElm).hide();
+ $(this.inputElm).blur();
+ $("#ovlTable").remove();
+ Main.enableKeys();
+
+};
+
+OverlayMenu.createStyleSheet = function () {
+ var sheet = $("<style>");
+ sheet.attr({type : 'text/css',
+ innerHTML : '\
+ #overlayMenu { width:40%; height: 30%; position: absolute; text-align:center; border-width:1px;\
+ background:rgba(0,0,139, 0.8);border-style:solid;border-width:1px;border-radius:15px;\
+ -webkit-box-shadow:3px 3px 7px 4px rgba(0,0,0, 0.5);z-index:50;}\
+ .ovl-itm { margin-left: 10px; \
+ padding: 10px 10px 10px 10px;\
+ border-radius:10px; \
+ font-size:16px;\
+ border-style:solid;\
+ border-width:1px;\
+ background: transparent;}\
+ .ovlmn-itm-selected {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%)";\
+ }\
+ }'});
+
+ $('body').append(sheet);
+};
+
+OverlayMenu.createMenu= function () {
+ var p_width = $("body").outerWidth();
+ var p_height = $("body").outerHeight();
+
+
+ var table = $("<table>", {style:"height:100%;width:100%;", id:"ovlTable"});
+ $("#overlayMenu").append(table);
+
+ var tbody = $("<tbody>", {style:"height:100%;width:100%;"});
+ table.append(tbody);
+
+ for (var i = 0; i < OverlayMenu.menu.length; i++) {
+ var row = OverlayMenu.createEntry(OverlayMenu.menu[i].title, i);
+ tbody.append(row);
+ }
+
+ var row = OverlayMenu.createHelpbarRow();
+ tbody.append(row);
+
+ $("#overlayMenu").css({"left": ((p_width - $("#overlayMenu").outerWidth()) /2) +"px", "top": ((p_height - $("#overlayMenu").outerHeight()) /2) +"px" });
+};
+
+
+
+OverlayMenu.createEntry = function(name, id) {
+ var row = $("<tr>", {style: "width:100%; align:center"});
+
+ var cell = $("<td>", {style: "width:100%; align:center"});
+// cell.css("align","center");
+ Main.log("OverlayMenu.createEntry: " +"olm-"+id);
+ $("<button>", {id : "olm-"+id, text: name, class: "ovl-itm"}).appendTo(cell);
+// $("<button>", {id : this.elmName +id, text: name, class: "ovl-itm"}).appendTo(cell);
+
+
+ row.append(cell);
+
+ return row;
+};
+
+OverlayMenu.createHelpbarRow = function() {
+ var res = $("<tr>", {style: "width:100%; align:center"});
+ var outer_cell = $("<td>", {style: "width:100%; align:center"});
+
+ var h_table = $("<table>", {style:"height:100%;width:100%;"});
+
+ var tbody = $("<tbody>", {style:"height:100%;width:100%;"});
+ h_table.append(tbody);
+ var row = $("<tr>", {style: "width:100%; align:center"});
+ tbody.append(row);
+
+ var cell = OverlayMenu.createHelpItem("Images/helpbar/help_ud.png", "Select");
+ row.append(cell);
+ cell = OverlayMenu.createHelpItem("Images/helpbar/help_enter.png", "OK");
+ row.append(cell);
+
+ cell = OverlayMenu.createHelpItem("Images/helpbar/help_back.png", "Cancel");
+ row.append(cell);
+
+ outer_cell.append(h_table);
+ res.append(outer_cell);
+
+ return res;
+};
+
+OverlayMenu.createHelpItem = function(url, msg) {
+
+ var cell = $("<td>", {style: "align:center"});
+// cell.css("align","center");
+
+ var hb_elm = $("<div>");
+ hb_elm.css({"display":"inline-block", "padding-right":"10px"});
+ cell.append(hb_elm);
+
+ hb_elm.append($("<img>", { src: url, style: "display:inline-block"}));
+ hb_elm.append($("<div>", { text: msg, style: "display:inline-block; padding-bottom:10px"}));
+
+ return cell;
+};
+
+
+OverlayMenu.reset = function () {
+ this.btnSelected = 0;
+ for (var i =0; i <= OverlayMenu.menu.length; i++) {
+ $(this.elmName + i).removeClass('ovlmn-itm-selected').addClass('ovl-itm');
+ }
+ $(this.elmName+"0").removeClass('ovl-itm').addClass('ovlmn-itm-selected');
+};
+
+
+OverlayMenu.selectBtnUp = function () {
+ var btnname = this.elmName+this.btnSelected;
+ Main.log(this.hndlName + "-BtnLeft: Old: " +this.btnSelected + " btn= "+btnname);
+ $(btnname).removeClass('ovlmn-itm-selected').addClass('ovl-itm');
+ if (this.btnSelected == 0)
+ this.btnSelected = (OverlayMenu.menu.length-1);
+ else
+ this.btnSelected--;
+ $(this.elmName + this.btnSelected).removeClass('ovl-itm').addClass('ovlmn-itm-selected');
+ Main.log(this.hndlName+"-BtnUp: New: " +this.btnSelected);
+};
+
+OverlayMenu.selectBtnDown = function () {
+ $(this.elmName + this.btnSelected).removeClass('ovlmn-itm-selected').addClass('ovl-itm');
+ if (this.btnSelected == (OverlayMenu.menu.length-1))
+ this.btnSelected = 0;
+ else
+ this.btnSelected++;
+ $(this.elmName + this.btnSelected).removeClass('ovl-itm').addClass('ovlmn-itm-selected');
+};
+
+OverlayMenu.onInput = function () {
+ var keyCode = event.keyCode;
+ Main.log(this.hndlName+" key= " + keyCode);
+ switch(keyCode) {
+ case tvKey.KEY_UP:
+ Main.log(this.hndlName+"-Select Up");
+ this.selectBtnUp();
+ break;
+ case tvKey.KEY_DOWN:
+ Main.log(this.hndlName+"-Select Down");
+ this.selectBtnDown();
+ break;
+ case tvKey.KEY_ENTER:
+ if (OverlayMenu.menu[this.btnSelected].func != undefined)
+ OverlayMenu.menu[this.btnSelected].func(this.btnSelected);
+ else
+ Main.log("OverlayMenu.Enter: enterCallback is NULL");
+ OverlayMenu.hide();
+
+ break;
+ case tvKey.KEY_RETURN:
+ case tvKey.KEY_EXIT:
+ OverlayMenu.hide();
+ if (this.returnCallback != null)
+ this.returnCallback();
+ break;
+
+ }
+ widgetAPI.blockNavigation(event);
+ };
+
+
diff --git a/smarttv-client/Javascript/Player.js b/smarttv-client/Javascript/Player.js
index b6986f5..dc677eb 100755
--- a/smarttv-client/Javascript/Player.js
+++ b/smarttv-client/Javascript/Player.js
@@ -58,6 +58,31 @@ var Player =
requestStartTime :0
};
+Player.init = function() {
+
+ if (this.AVPlayerObj != null)
+ return false; // that prevents Main.init to overwrite the callbacks.
+
+ var success = true;
+ Main.log("success vale : " + success);
+ this.state = this.STOPPED;
+
+ try {
+ var custom = webapis.avplay;
+ Main.logToServer("webapis.ver= " + webapis.ver);
+ custom.getAVPlay(Player.onAVPlayObtained, Player.onGetAVPlayError);
+ }
+ catch(exp) {
+ Main.log('Player.init: getAVplay Exception :[' +exp.code + '] ' + exp.message);
+ }
+
+
+ this.skipDuration = Config.skipDuration; // Use Config default also here
+
+ Main.log("success= " + success);
+ return success;
+};
+
// This function is called when Stop was pressed
Player.resetAtStop = function () {
// the default is for plain on-demand recording
@@ -202,26 +227,6 @@ Player.onGetAVPlayError = function (error) {
};
-Player.init = function() {
- var success = true;
- Main.log("success vale : " + success);
- this.state = this.STOPPED;
-
- try {
- var custom = webapis.avplay;
- Main.logToServer("webapis.ver= " + webapis.ver);
- custom.getAVPlay(Player.onAVPlayObtained, Player.onGetAVPlayError);
- }
- catch(exp) {
- Main.log('Player.init: getAVplay Exception :[' +exp.code + '] ' + exp.message);
- }
-
-
- this.skipDuration = Config.skipDuration; // Use Config default also here
-
- Main.log("success= " + success);
- return success;
-};
Player.deinit = function() {
Main.log("Player deinit !!! " );
@@ -242,14 +247,17 @@ Player.getNumOfSubtitleTracks = function () {
Player.nextAudioTrack = function () {
- Player.curAudioTrack = (Player.curAudioTrack +1 ) % Player.AVPlayerObj.totalNumOfAudio;
+ var new_track = (Player.curAudioTrack +1 ) % Player.AVPlayerObj.totalNumOfAudio;
+// Player.curAudioTrack = (Player.curAudioTrack +1 ) % Player.AVPlayerObj.totalNumOfAudio;
try {
- if (Player.AVPlayerObj.setAudioStreamID(Player.curAudioTrack) == false) {
- Main.logToServer("Player.nextAudioTrack: Failed to set audio track to " + Player.curAudioTrack);
- Display.showPopup("Player.nextAudioTrack: Failed to set audio track to " + Player.curAudioTrack);
+// if (Player.AVPlayerObj.setAudioStreamID(Player.curAudioTrack) == false) {
+ if (Player.AVPlayerObj.setAudioStreamID(new_track) == false) {
+ Main.logToServer("Player.nextAudioTrack: Failed to set audio track to " + new_track);
+ Display.showPopup("Player.nextAudioTrack: Failed to set audio track to " + new_track);
}
else {
+ Player.curAudioTrack = new_track;
Main.logToServer("Player.nextAudioTrack: Track= " + Player.curAudioTrack);
Notify.showNotify("Audio Track " + Player.curAudioTrack, true);
}
@@ -463,6 +471,22 @@ Player.resumeVideo = function() {
// pluginObj.setOffScreenSaver();
};
+Player.numKeyJump = function (key) {
+ Display.showProgress();
+
+ switch (Config.playKeyBehavior) {
+ case 1:
+ var cur_skip_duration = this.skipDuration;
+ this.skipDuration = key * 60;
+ this.skipForwardVideo();
+ this.skipDuration = cur_skip_duration;
+ break;
+ default:
+ Player.jumpToVideo(key * 10);
+ break;
+ }
+};
+
Player.jumpToVideo = function(percent) {
Spinner.show();
if (this.isLive == true) {
diff --git a/smarttv-client/Javascript/Server.js b/smarttv-client/Javascript/Server.js
index fae4e83..660230a 100755
--- a/smarttv-client/Javascript/Server.js
+++ b/smarttv-client/Javascript/Server.js
@@ -4,6 +4,7 @@ var Server = {
doSort : false,
retries : 0,
curGuid : "",
+ tzCorrection : 0,
XHRObj : null
};
@@ -163,6 +164,27 @@ Server.updateVdrStatus = function (){
url: Config.serverUrl + "/vdrstatus.xml",
type : "GET",
success : function(data, status, XHR){
+ var ts_vdr = $(data).find('vdrTime').text();
+
+ try {
+ var ts = ts_vdr.split("T")[1];
+ var s = ts.split(":");
+ if (s.length == 3) {
+ var now = ((new Date).getHours());
+ Config.tzCorrection = now - s[0];
+ // if Config.tzCorrection larger zero, then TV is ahead
+ // thus, I need to substract Config.tzCorrection from the TV time
+// Config.tzCorrection = 1;
+ Main.logToServer("Server.updateVdrStatu: tzCor= " + Config.tzCorrection);
+ }
+ else
+ Main.logToServer("tzCor WARNING");
+
+ }
+ catch (e) {
+ Main.log ("ERROR in tzCor (Old plugin?): " + e);
+ }
+
var free = $(data).find('free').text() / 1024.0;
// var used = $(data).find('used').text() / 1024.0;
// var percent = $(data).find('percent').text();
@@ -176,7 +198,8 @@ Server.updateVdrStatus = function (){
}
$("#logoDisk").text("Free: " +free_str + unit);
$("#selectDisk").text("Free: " +free_str + unit);
- },
+
+ },
error: function(jqXHR, status, error){
Main.log("VdrStatus: Error");
}
@@ -296,6 +319,7 @@ Server.notifyServer = function (state) {
});
};
+
var HeartbeatHandler = {
timeoutObj : null,
isActive : false
@@ -322,3 +346,38 @@ HeartbeatHandler.stop = function(){
window.clearTimeout(this.timeoutObj);
this.isActive = false;
};
+
+function addTimer(guid) {
+ this.successCallback = null;
+ this.errorCallback = null;
+ this.guid = guid;
+ this.request();
+};
+
+addTimer.prototype.request = function () {
+ var url =Config.serverUrl + "/addTimer.xml?guid="+this.guid;
+ Main.log("addTimer request url= " + url);
+
+ $.ajax({
+ url: url,
+ type : "GET",
+ context : this,
+ timeout : 400,
+ success : function(data, status, XHR ) {
+ Main.log ("addTimer for Inst= " + this.guid +" status: " + ((status != null) ? status : "null"));
+ },
+ error : function (XHR, status, error) {
+ Main.log ("addTimer for Error Inst= " + this.guid+" status: " + ((status != null) ? status : "null"));
+ if (XHR.status == 400) {
+
+ Display.showPopup("Timer creation failed channel= "+this.guid + " Text= " + XHR.responseText, true);
+ }
+ else
+ Display.showPopup("Timer creation failed channel= "+this.guid + " code= " + XHR.status, true);
+
+ }
+ });
+
+};
+
+
diff --git a/smarttv-client/config.xml b/smarttv-client/config.xml
index f075f63..9eddd2c 100755
--- a/smarttv-client/config.xml
+++ b/smarttv-client/config.xml
@@ -9,7 +9,7 @@
<BigThumbIcon>Images/icon/SmartTvWeb_115.png</BigThumbIcon>
<ListIcon>Images/icon/SmartTvWeb_85.png</ListIcon>
<BigListIcon>Images/icon/SmartTvWeb_95.png</BigListIcon>
- <ver>0.94</ver>
+ <ver>0.95.0721</ver>
<mgrver></mgrver>
<fullwidget>y</fullwidget>
<movie>y</movie>
@@ -20,6 +20,7 @@
<videomute>n</videomute>
<dcont>y</dcont>
<widgetname>VDR on TV</widgetname>
+ <network>n</network>
<description></description>
<width>960</width>
<height>540</height>
diff --git a/smarttv-client/index.html b/smarttv-client/index.html
index 5172cac..d39b109 100755
--- a/smarttv-client/index.html
+++ b/smarttv-client/index.html
@@ -38,6 +38,7 @@
<script language="javascript" type="text/javascript" src="Javascript/Lang.js"></script>
<script language="javascript" type="text/javascript" src="Javascript/Urls.js"></script>
<script language="javascript" type="text/javascript" src="Javascript/Comm.js"></script>
+ <script language="javascript" type="text/javascript" src="Javascript/OverlayMenu.js"></script>
<!-- Style sheets -->
<link rel="stylesheet" href="CSS/Main.css" type="text/css">
@@ -77,8 +78,9 @@
<div id="widgetVersion" style="font-size:10px"></div>
<div id="selectView">
<table id="selectStatus" width="100%" padding-bottom="15px">
- <tr align="justify">
+ <tr align="center">
<td id="selectNow">0:0</td>
+ <td id="selectTitle"> </td>
<td id="selectDisk">Free: 1Gb</td>
</tr>
</table>
@@ -86,14 +88,18 @@
<div id="selectItem2">2: Recordings</div>
<div id="selectItem3">3: Media</div>
<div id="selectItem4">4: YouTube</div>
- <div id="selectItem5">5: Options</div>
+ <div id="selectItem5">5: Select Server</div>
+ <div id="selectItem6">6: Options</div>
</div>
</div>
<div id="optionsScreen">
<div id="optionsView">
+ <a href='javascript:void(0);' id='optionsViewAnchor' onkeydown='Options.onInput();' ></a>
+
<b>Server Configurations</b><br><br>
Address (host:port) http://<input type="text" id="widgetServerAddr" onkeydown='Options.onInput();' maxlength="25">
-
+ <br><br>
+ <div id="optionsList"></div>
</div>
</div>
@@ -103,7 +109,7 @@
<tr >
<td id="logoNow" >0:0</td>
<td id="logoTitle">VDR on SmartTV</td>
- <td id="logoDisk">Free 1Gb</td>
+ <td id="logoDisk">Free 0Gb</td>
</tr>
</table>
</center>
@@ -206,5 +212,8 @@
</td></tr>
</table>
</div>
+ <div id="overlayMenu">
+ <a href='javascript:void(0);' id='overlayMenu-anchor' ></a>
+ </div>
</body>
</html>