diff options
Diffstat (limited to 'smarttv-client/Javascript/Options.js')
-rwxr-xr-x | smarttv-client/Javascript/Options.js | 367 |
1 files changed, 315 insertions, 52 deletions
diff --git a/smarttv-client/Javascript/Options.js b/smarttv-client/Javascript/Options.js index d066c00..06d9ad0 100755 --- a/smarttv-client/Javascript/Options.js +++ b/smarttv-client/Javascript/Options.js @@ -1,83 +1,346 @@ var Options = {
- imeBox : null
+ imeBox : null,
+ inputElm : "widgetServerAddr",
+ jqInputElm : "#widgetServerAddr",
+ cursor : "_",
+ cursorPos : 0,
+ isCreated : false
+
};
Options.init = function() {
- _g_ime.Recog_use_YN = false;
- _g_ime.keySet = '12key';
+ if (this.isCreated == true)
+ return;
- this.imeBox = new IMEShell("widgetServerAddr", Options.onImeCreated, 'de');
-};
+ this.isCreated = true;
-Options.onComplete = function () {
- Main.log("Completed");
-};
+ document.getElementById(Options.inputElm).value = Config.serverAddrDefault;
+ Options.cursorPos = Config.serverAddrDefault.length;
+
+ Options.createKeypad ();
+ $("#optionsScreen").hide();
-Options.onEnter = function () {
- Main.log("Enter: " + document.getElementById("widgetServerAddr").value );
+ document.getElementById(Options.inputElm).style.color="black";
+};
- Config.updateContext(document.getElementById("widgetServerAddr").value);
+Options.show = function() {
+// document.getElementById("optionsScreen").style.display="block";
+ $("#optionsScreen").show();
+ if (Config.firstLaunch == true)
+ document.getElementById(Options.inputElm).value = Config.serverAddrDefault ;
+ else
+ document.getElementById(Options.inputElm).value = Config.serverAddr;
- document.getElementById('widgetServerAddr').blur();
-
- document.getElementById("optionsScreen").style.display="none";
+ Options.cursorPos = document.getElementById(Options.inputElm).value.length;
- if (Config.firstLaunch == true)
- Main.state = 1;
- Main.changeState(0);
-
- Config.fetchConfig();
- if(_g_ime.pluginMouse_use_YN){
- this.imeBox._blur();
- };
+ $(this.jqInputElm).focus();
+// document.getElementById(Options.inputElm).focus();
- // Main.enableKeys();
+ Helpbar.init();
+ Helpbar.show();
};
-Options.onBlue = function () {
- var val = document.getElementById("widgetServerAddr").value + ".";
- Options.imeBox.setString(val);
+Options.hide = function() {
+ $("#optionsScreen").hide();
+// document.getElementById("optionsScreen").style.display="none";
+ Helpbar.hide();
+ Main.enableKeys();
};
-Options.onImeCreated = function(obj) {
-// _g_ime.keySet ("12key");
-// obj.setKeySetFunc('12key');
- Main.logToServer ("Options.onImeCreated()");
- Main.logToServer ("[IME] ============================================ imeobj.IsSupportXT9:"+obj.IsSupportXT9);
- var strKeySet = obj.getKeySet();
- Main.logToServer ("[IME] ============================================ strKeySet:"+strKeySet);
+Options.createKeypad = function () {
+ var sheet = $("<style>");
+ sheet.attr({type : 'text/css',
+ innerHTML : '\
+ .ui-btn {width:70px; height: 48px; display:inline-block, font-size:20px;background:url("Images/keypad/kp-button.png");}\
+ .ui-btn-pressed {width:70px; height: 48px; display:inline-blockfont-size:20px;background:url("Images/keypad/kp-button-inv.png");}\
+ .ui-keypad {left:650px; top:135px; width: 220px; text-align:center; border-width:1px; background: #1e5799; border-style:solid;\
+ }'});
+ $('body').append(sheet);
-
- obj.setKeyFunc(tvKey.KEY_RETURN, function(keyCode) { widgetAPI.sendReturnEvent(); return false; } );
- obj.setKeyFunc(tvKey.KEY_EXIT, function(keyCode) { widgetAPI.sendExitEvent(); return false; } );
+/* var domNode = $('<div>');
+ domNode.attr({id : 'ime_keypad',
+ innerHTML : '<table class="ui-keypad"> \
+ <tr><td><button id="kb-btn-1" class="ui-btn">1</button></td><td><button id="kb-btn-2" class="ui-btn">2</button></td><td><button id="kb-btn-3" class="ui-btn">3</button></td></tr>\
+ <tr><td><button id="kb-btn-4" class="ui-btn">4</button></td><td><button id="kb-btn-5" class="ui-btn">5</button></td><td><button id="kb-btn-6" class="ui-btn">6</button></td></tr>\
+ <tr><td><button id="kb-btn-7" class="ui-btn">7</button></td><td><button id="kb-btn-8" class="ui-btn">8</button></td><td><button id="kb-btn-9" class="ui-btn">9</button></td></tr>\
+ <tr><td><button id="kb-btn-dot" class="ui-btn">.</button></td><td><button id="kb-btn-0" class="ui-btn">0</button></td><td><button id="kb-btn-col" class="ui-btn">:</button></td></tr>\
+ </table>'});
+*/
+ var domNode = $('<div>', { id: "ime_keypad", class: "ui-keypad"});
+ var row = $('<div>');
+ $("<button>", {id : "kb-btn-1", text: "1", class: "ui-btn"}).appendTo(row);
+ $("<button>", {id : "kb-btn-2", text: "2", class: "ui-btn"}).appendTo(row);
+ $("<button>", {id : "kb-btn-3", text: "3", class: "ui-btn"}).appendTo(row);
+ row.appendTo(domNode);
+
+ row = $('<div>');
+ $("<button>", {id : "kb-btn-4", text: "4", class: "ui-btn"}).appendTo(row);
+ $("<button>", {id : "kb-btn-5", text: "5", class: "ui-btn"}).appendTo(row);
+ $("<button>", {id : "kb-btn-6", text: "6", class: "ui-btn"}).appendTo(row);
+ row.appendTo(domNode);
- obj.setKeypadPos(650, 135);
- obj.setWordBoxPos(18, 6);
- obj.setKeyFunc(tvKey.KEY_BLUE, Options.onBlue);
+ row = $('<div>');
+ $("<button>", {id : "kb-btn-7", text: "7", class: "ui-btn"}).appendTo(row);
+ $("<button>", {id : "kb-btn-8", text: "8", class: "ui-btn"}).appendTo(row);
+ $("<button>", {id : "kb-btn-9", text: "9", class: "ui-btn"}).appendTo(row);
+ row.appendTo(domNode);
+
+ row = $('<div>');
+ $("<button>", {id : "kb-btn-dot", text: ".", class: "ui-btn"}).appendTo(row);
+ $("<button>", {id : "kb-btn-0", text: "0", class: "ui-btn"}).appendTo(row);
+ $("<button>", {id : "kb-btn-col", text: ":", class: "ui-btn"}).appendTo(row);
+ row.appendTo(domNode);
+
+ $("#optionsScreen").append(domNode);
+};
- obj.setString(Config.serverAddrDefault);
- obj.setEnterFunc(Options.onEnter);
+Options.setCursor = function (pos) {
+ document.getElementById(Options.inputElm).setSelectionRange(pos, pos);
+};
- if (obj.setMode("_num") == false) {
- Main.logToServer("obj.setMode(\"_num\") returns false");
+Options.insertChar = function(char) {
+ var txt = document.getElementById(Options.inputElm).value;
+ var res = "";
+ if (Options.cursorPos == 0) {
+ res = char;
+// document.getElementById(Options.inputElm).value = char + Options.cursor;
+ }
+ else {
+ if (Options.cursorPos == txt.length) {
+ res = txt + 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;
+ Options.cursorPos = Options.cursorPos +1;
+ Options.setCursor(Options.cursorPos);
+
+};
+
+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);
+};
- Options.imeBox.setOnCompleteFunc(Options.onComplete);
- if(_g_ime.pluginMouse_use_YN){
- obj._focus();
- };
- document.getElementById('widgetServerAddr').focus();
- Main.logToServer ("Options.onReady()");
- Main.logToServer ("KeySet= " + Options.imeBox.getKeySet());
+Options.moveCursorLeft = function() {
+ if (Options.cursorPos == 0)
+ 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);
- Options.onReady ();
+ document.getElementById(Options.inputElm).value = tgt;
+ Options.cursorPos = Options.cursorPos -1;
+ */
};
-Options.onReady = function () {
+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;
+
+ switch(keyCode) {
+ case tvKey.KEY_1:
+ Main.log("KEY_1 pressed");
+ Options.insertChar("1");
+
+ $("#kb-btn-1").removeClass('ui-btn').addClass('ui-btn-pressed');
+ setTimeout(function() {
+ $("#kb-btn-1").removeClass('ui-btn-pressed').addClass('ui-btn');
+ }, 80);
+
+ break;
+ case tvKey.KEY_2:
+ Main.log("KEY_2 pressed");
+ Options.insertChar("2");
+ $("#kb-btn-2").removeClass('ui-btn').addClass('ui-btn-pressed');
+ setTimeout(function() {
+ $("#kb-btn-2").removeClass('ui-btn-pressed').addClass('ui-btn');
+ }, 80);
+
+ break;
+ case tvKey.KEY_3:
+ Main.log("KEY_3 pressed");
+ Options.insertChar("3");
+
+ $("#kb-btn-3").removeClass('ui-btn').addClass('ui-btn-pressed');
+ setTimeout(function() {
+ $("#kb-btn-3").removeClass('ui-btn-pressed').addClass('ui-btn');
+ }, 80);
+ break;
+ case tvKey.KEY_4:
+ Main.log("KEY_4 pressed");
+ Options.insertChar("4");
+
+ document.getElementById("kb-btn-4").click();
+
+ $("#kb-btn-4").removeClass('ui-btn').addClass('ui-btn-pressed');
+ setTimeout(function() {
+ $("#kb-btn-4").removeClass('ui-btn-pressed').addClass('ui-btn');
+ }, 80);
+
+ break;
+ case tvKey.KEY_5:
+ Main.log("KEY_5 pressed");
+ Options.insertChar("5");
+
+ $("#kb-btn-5").removeClass('ui-btn').addClass('ui-btn-pressed');
+ setTimeout(function() {
+ $("#kb-btn-5").removeClass('ui-btn-pressed').addClass('ui-btn');
+ }, 80);
+
+ break;
+ case tvKey.KEY_6:
+ Main.log("KEY_6 pressed");
+ Options.insertChar("6");
+
+ $("#kb-btn-6").removeClass('ui-btn').addClass('ui-btn-pressed');
+ setTimeout(function() {
+ $("#kb-btn-6").removeClass('ui-btn-pressed').addClass('ui-btn');
+ }, 80);
+
+ break;
+ case tvKey.KEY_7:
+ Main.log("KEY_7 pressed");
+ Options.insertChar("7");
+
+ $("#kb-btn-7").removeClass('ui-btn').addClass('ui-btn-pressed');
+ setTimeout(function() {
+ $("#kb-btn-7").removeClass('ui-btn-pressed').addClass('ui-btn');
+ }, 80);
+
+ break;
+ case tvKey.KEY_8:
+ Main.log("KEY_8 pressed");
+ Options.insertChar("8");
+ $("#kb-btn-8").removeClass('ui-btn').addClass('ui-btn-pressed');
+ setTimeout(function() {
+ $("#kb-btn-8").removeClass('ui-btn-pressed').addClass('ui-btn');
+ }, 80);
+
+ break;
+ case tvKey.KEY_9:
+ Main.log("KEY_9 pressed");
+ Options.insertChar("9");
+
+ $("#kb-btn-9").removeClass('ui-btn').addClass('ui-btn-pressed');
+ setTimeout(function() {
+ $("#kb-btn-9").removeClass('ui-btn-pressed').addClass('ui-btn');
+ }, 80);
+
+ break;
+ case tvKey.KEY_0:
+ Main.log("KEY_0 pressed");
+ Options.insertChar("0");
+ $("#kb-btn-0").removeClass('ui-btn').addClass('ui-btn-pressed');
+ setTimeout(function() {
+ $("#kb-btn-0").removeClass('ui-btn-pressed').addClass('ui-btn');
+ }, 80);
+
+ break;
+ case tvKey.KEY_LEFT:
+ Options.moveCursorLeft();
+ break;
+ case tvKey.KEY_RIGHT:
+ Options.moveCursorRight();
+ break;
+
+ case tvKey.KEY_RETURN:
+ Main.log("Return pressed");
+ Options.hide();
+ Main.changeState(0);
+ widgetAPI.blockNavigation(event);
+
+ break;
+ case tvKey.KEY_ENTER:
+ // Done
+// Options.cursorPos = Options.cursorPos +1;
+// Options.deleteChar(); //
+ Main.log("Enter pressed -> Done Val= ("+ document.getElementById(Options.inputElm).value+")");
+
+ Config.updateContext(document.getElementById(Options.inputElm).value);
+ if (Config.firstLaunch == true)
+ Main.state = 1;
+
+ Main.enableKeys();
+ Options.hide();
+ Main.changeState(0);
+
+ Config.fetchConfig();
+
+ break;
+ case tvKey.KEY_RED:
+ // Clear All
+ Main.log("Red pressed");
+ Options.deleteAll();
+ break;
+
+ case tvKey.KEY_GREEN:
+ // Clear Char
+ Main.log("Green pressed");
+ Options.deleteChar();
+ break;
+
+ case tvKey.KEY_TTX_MIX:
+ case tvKey.KEY_YELLOW:
+ // Dot
+ Main.log("Yellow pressed");
+
+ Options.insertChar(".");
+ break;
+
+ case tvKey.KEY_PRECH:
+ case tvKey.KEY_BLUE:
+ Main.log("Blue pressed");
+ // Colon
+ Options.insertChar(":");
+ break;
+ }
+ widgetAPI.blockNavigation(event);
+
+};
+
+
+
+
|