diff options
author | thlo <smarttv640@gmail.com> | 2013-03-03 21:42:04 +0100 |
---|---|---|
committer | thlo <t.lohmar@gmx.de> | 2013-03-03 21:42:04 +0100 |
commit | 026e7f57858e873f2f81ecd6c3fbe1ee0f0d7203 (patch) | |
tree | 370047071a9bf415580aa984e8186ed4acf8e18f /smarttv-client/Javascript/DirectAccess.js | |
parent | 65255cd25a87509c0a75c4e09ebd33977e54ed9c (diff) | |
download | vdr-plugin-smarttvweb-026e7f57858e873f2f81ecd6c3fbe1ee0f0d7203.tar.gz vdr-plugin-smarttvweb-026e7f57858e873f2f81ecd6c3fbe1ee0f0d7203.tar.bz2 |
Version 0.91.
Direct Channel Access added for Live and Channel Numbers.
Folder Headlines.
Cropped Picture Size.
Diffstat (limited to 'smarttv-client/Javascript/DirectAccess.js')
-rw-r--r-- | smarttv-client/Javascript/DirectAccess.js | 220 |
1 files changed, 220 insertions, 0 deletions
diff --git a/smarttv-client/Javascript/DirectAccess.js b/smarttv-client/Javascript/DirectAccess.js new file mode 100644 index 0000000..73d9fdf --- /dev/null +++ b/smarttv-client/Javascript/DirectAccess.js @@ -0,0 +1,220 @@ +DirectAccess = {
+ created: false,
+ returnCallback : null,
+ timeout : 0,
+ timeoutObj : null,
+ delay : 1500
+};
+
+/*
+There is the Data.directAccessMap which contains an array for each channel number
+
+When I do a direct access, then I first need to "go down to root" and then apply the positions from the array.
+
+Main.selectedVideo needs to point to the selected video of that current folder
+
+
+*/
+
+DirectAccess.selectNewChannel = function (num) {
+ Main.log("DirectAccess.selectNewChannel: val= (" + num + ")");
+ if (!(num in Data.directAccessMap)){
+ Main.log("DirectAccess.selectNewChannel: val= (" + num +") not found!");
+ Notify.showNotify("Not Found", true);
+
+/* Player.stopVideo();
+ Main.changeState(0);
+ widgetAPI.blockNavigation(event);
+*/
+ return;
+ }
+
+ Main.log("DirectAccess.selectNewChannel num= " + num + " Data.directAccessMap[num]= " +Data.directAccessMap[num] );
+ if (Data.isRootFolder() != true) {
+ var itm = Data.folderUp();
+ Main.selectedVideo = itm.id;
+ }
+ // now I should be in root
+ switch(Data.directAccessMap[num].length) {
+ case 1:
+ Main.selectedVideo= Data.directAccessMap[num][0];
+ Main.log("DirectAccess.selectNewChannel num=" + num +" - Case 1: Main.selectedVideo= "+ Main.selectedVideo);
+ break;
+ case 2:
+ Main.log("DirectAccess.selectNewChannel num=" + num +" - Case 2: Data.directAccessMap[num][0]= "+ Data.directAccessMap[num][0] + " Data.directAccessMap[num][1]= " + Data.directAccessMap[num][1]);
+ if (Data.getCurrentItem().childs[Data.directAccessMap[num][0]].isFolder == true) {
+ Data.selectFolder(Data.directAccessMap[num][0], Data.directAccessMap[num][0]);
+ Main.selectedVideo= Data.directAccessMap[num][1];
+ }
+ else {
+ // Error: Should be a folder, if there is two elms in directAccessMap
+ Display.showPopup("directAccess Failed: Inconsistency in directAccessMap");
+ Main.log("ERROR in selectNewChannel num=" + num +"- Case 2: Data.directAccessMap[num][0]= "+ Data.directAccessMap[num][0] + " Data.directAccessMap[num][1]= " + Data.directAccessMap[num][1]);
+
+ Player.stopVideo();
+ Main.changeState(0);
+ widgetAPI.blockNavigation(event);
+ }
+ break;
+ default:
+ Display.showPopup("directAccess Failed: Inconsistency in directAccessMap. More than 2 elms");
+ Main.log("ERROR in selectNewChannel num=" + num +" - Data.directAccessMap[num].length= "+ Data.directAccessMap[num].length);
+ Player.stopVideo();
+ Main.changeState(0);
+ widgetAPI.blockNavigation(event);
+
+ return;
+ break;
+ }
+
+ Player.stopVideo();
+ Main.playItem();
+
+
+ //
+};
+
+DirectAccess.init = function (){
+ if (this.created == false) {
+ DirectAccess.createStyleSheet();
+ $("#directChanAccess").hide();
+ this.created = true;
+ }
+};
+
+DirectAccess.show = function () {
+ $("#directChanAccess").show();
+ $("#directAccessAnchor").focus();
+ DirectAccess.timeout = Display.GetEpochTime() + (DirectAccess.delay / 1000.0);
+ DirectAccess.timeoutObj = window.setTimeout( function() {DirectAccess.handleTimeout();}, DirectAccess.delay);
+ Main.log("DirectAccess.show: now= "+ Display.GetEpochTime() +" timeout= " + DirectAccess.timeout +" delta= " + (DirectAccess.timeout -Display.GetEpochTime()));
+ };
+
+
+DirectAccess.hide = function () {
+ Main.log("DirectAccess.hide: timeout= " + DirectAccess.timeout);
+ if (DirectAccess.timeoutObj != null) {
+ window.clearTimeout(DirectAccess.timeoutObj);
+ DirectAccess.timeoutObj = null;
+ };
+ $("#directAccessAnchor").val("");
+
+ $("#directChanAccess").hide();
+ $("#directAccessAnchor").blur();
+ Main.enableKeys();
+};
+
+DirectAccess.handleTimeout = function () {
+ Main.log("DirectAccess.handleTimeout");
+ DirectAccess.timeoutObj = null;
+ if (Display.GetEpochTime() < DirectAccess.timeout) {
+ var delta = (DirectAccess.timeout -Display.GetEpochTime()) *1000.0;
+ DirectAccess.timeoutObj = window.setTimeout( DirectAccess.handleTimeout, delta);
+ DirectAccess.timeout = Display.GetEpochTime() + (delta / 1000.0);
+ Main.log("DirectAccess.timeout: " + DirectAccess.timeout);
+ }
+ else {
+ Main.log("DirectAccess.timeout: handleEnter");
+ DirectAccess.handleEnter();
+ };
+};
+
+DirectAccess.extendTimer = function () {
+ DirectAccess.timeout = Display.GetEpochTime() + (DirectAccess.delay / 1000.0);
+ Main.log("DirectAccess.extendTimer: " + DirectAccess.timeout);
+};
+
+DirectAccess.cancel = function () {
+ DirectAccess.hide();
+};
+
+DirectAccess.handleEnter = function () {
+ Main.log("DirectAccess.handleEnter val= " +$("#directAccessAnchor").val() );
+ DirectAccess.selectNewChannel($("#directAccessAnchor").val());
+ DirectAccess.hide();
+
+ // find entry according to number
+};
+
+DirectAccess.createStyleSheet = function () {
+ var sheet = $("<style>");
+ sheet.attr({type : 'text/css',
+ innerHTML : '\
+ #directChanAccess { left: 70%; top: 10px; width:10%; height: 10%; position: absolute; \
+ text-align:center; \
+ background:rgba(0,0,139, 0.8);\
+ border-width:1px;border-style:solid;border-width:1px;border-radius:15px;\
+ -webkit-box-shadow:3px 3px 7px 4px rgba(0,0,0, 0.5);z-index:15;}\
+ #directAccessAnchor {background-color:transparent;text-align: right;font-size:20px}\
+ '});
+
+ $('body').append(sheet);
+};
+
+DirectAccess.onInput = function () {
+ var keyCode = event.keyCode;
+ var input ="";
+ if (input.length == 4)
+ input= $("#directAccessAnchor").val().slice(1);
+ else
+ input= $("#directAccessAnchor").val();
+// $("#directAccessAnchor").val(input.slice(1));
+ Main.log("DirectAccess.onInput: " + keyCode + " Val= " + $("#directAccessAnchor").val());
+ DirectAccess.extendTimer();
+ switch(keyCode) {
+ case tvKey.KEY_0:
+ $("#directAccessAnchor").val(input + "0");
+ widgetAPI.blockNavigation(event);
+
+ break;
+ case tvKey.KEY_1:
+ $("#directAccessAnchor").val(input + "1");
+ widgetAPI.blockNavigation(event);
+ break;
+ case tvKey.KEY_2:
+ $("#directAccessAnchor").val(input + "2");
+ widgetAPI.blockNavigation(event);
+ break;
+ case tvKey.KEY_3:
+ $("#directAccessAnchor").val(input + "3");
+ widgetAPI.blockNavigation(event);
+ break;
+ case tvKey.KEY_4:
+ $("#directAccessAnchor").val(input + "4");
+ widgetAPI.blockNavigation(event);
+ break;
+ case tvKey.KEY_5:
+ $("#directAccessAnchor").val(input + "5");
+ widgetAPI.blockNavigation(event);
+ break;
+ case tvKey.KEY_6:
+ $("#directAccessAnchor").val(input + "6");
+ widgetAPI.blockNavigation(event);
+ break;
+ case tvKey.KEY_7:
+ $("#directAccessAnchor").val(input + "7");
+ widgetAPI.blockNavigation(event);
+ break;
+ case tvKey.KEY_8:
+ $("#directAccessAnchor").val(input + "8");
+ widgetAPI.blockNavigation(event);
+ break;
+ case tvKey.KEY_9:
+ $("#directAccessAnchor").val(input + "9");
+ widgetAPI.blockNavigation(event);
+ break;
+ case tvKey.KEY_ENTER:
+ //Search channel
+ DirectAccess.handleEnter ();
+ widgetAPI.blockNavigation(event);
+ break;
+ case tvKey.KEY_RETURN:
+ case tvKey.KEY_EXIT:
+ DirectAccess.hide();
+ if (this.returnCallback != null)
+ this.returnCallback();
+ widgetAPI.blockNavigation(event);
+ break;
+ };
+ widgetAPI.blockNavigation(event);
+};
\ No newline at end of file |