diff --git a/editor/hhkb/MEMO.txt b/editor/hhkb/MEMO.txt index a72f8bb8..b381fb88 100644 --- a/editor/hhkb/MEMO.txt +++ b/editor/hhkb/MEMO.txt @@ -1,5 +1,18 @@ TODO ---- + Better source output + KEYMAP macro + + layer operation + copy, swap, set all, clear... + + X Share URL + X shoten service? 09/07 + + Bootloader jump doesn't work + + Keyobard external line graphic + X test on remote site tmk.github.io/tmk_editor/hhkb/? github pages @@ -20,8 +33,8 @@ TODO a.className = 'TE_link'; a.click() - keyboard key text css - align of wrapped text + X keyboard key text css + X align of wrapped text edit action for FN key action map support @@ -31,10 +44,9 @@ TODO Convert table? UI can use position of elemen placing. UI uses matrix posiotn for ID of element. - P load/save JSON X save hex(binary) - firmware + X firmware P load binary P Mass Storage or HID comm X fixed address for keymaps diff --git a/editor/hhkb/index.html b/editor/hhkb/index.html index 08e50014..879bcead 100644 --- a/editor/hhkb/index.html +++ b/editor/hhkb/index.html @@ -4,7 +4,7 @@ - + @@ -92,6 +92,13 @@ ], no_map(), no_map(), + + /* + no_map(), + no_map(), + no_map(), + no_map(), + */ ]; // TODO: define proper Fn actions: 32actions*2bytes @@ -107,32 +114,32 @@ // layer under editing var editing_layer = 0; + // load keymap on keyboard key buttons + var load_keymap_on_keyobard = function(layer, keymap) { + for (var row in keymap) { + for (var col in keymap[row]) { + var code = keymap[row][col]; + var key = code_display[code]; + $("#key-0" + row + "0" + col).text(key.name); + $("#key-0" + row + "0" + col).attr({ title: key.desc }); + } + } + }; + $(function() { // Title document.title = "TMK Keymap Editor for " + KEYBOARD_ID; $("#page-title").text("TMK Keymap Editor for " + KEYBOARD_ID); - // lost keymap under edting when leave the page - /* TODO: Needed when released - $(window).bind('beforeunload', function(){ - return 'CAUTION: You will lost your change.'; - }); - */ + /* + * load keymap from URL hash + */ + var decoded = decode_keymap(document.location.hash.substring(1)); + if (decoded != null) { + keymaps = decoded['keymaps']; + } - // load keymap on keyboard key buttons - var load_keymap = function(layer, keymap) { - for (var row in keymap) { - for (var col in keymap[row]) { - var code = keymap[row][col]; - var key = code_display[code]; - $("#key-0" + row + "0" + col).text(key.name); - $("#key-0" + row + "0" + col).attr({ title: key.desc }); - } - } - }; - // load default keymap on startup - load_keymap(0, keymaps[0]); /* * Layer selector @@ -143,12 +150,17 @@ $(".layer").click(function(ev, ui) { var layer = parseInt($(this).attr('id').match(/layer-(\d+)/)[1]); editing_layer = layer; - load_keymap(layer, keymaps[layer]); + load_keymap_on_keyobard(layer, keymaps[layer]); }); + + /* - * Keyboard display(key buttons) + * Keyboard(key buttons) */ + // load default keymap on startup + load_keymap_on_keyobard(0, keymaps[0]); + // Select key button to edit $(".key").click(function(ev, ui) { editing_key = $(this).attr('id'); @@ -158,6 +170,8 @@ $(this).addClass("key-editing"); }); + + /* * Keycodes button tab */ @@ -192,10 +206,24 @@ keymaps[editing_layer][row][col] = parseInt(code); }); + /* - * Output options + * Share URL */ - //$("#keymap-output").resizable(); // resizable textarea + // Share URL + $("#keymap-share").click(function(ev, ui) { + var hash = encode_keymap({ keymaps: keymaps }); + $("#share-url").text(document.location.origin + document.location.pathname + "#" + hash); + }); + + // Shorten URL + $("#shorten-url").click(function(ev, ui) { + var hash = encode_keymap({ keymaps: keymaps }); + var editor_url = document.location.origin + document.location.pathname; + window.open("https://bitly.com/shorten/?url=" + encodeURIComponent(editor_url + "#" + hash)); + //window.open("http://tinyurl.com/create.php?url=" + encodeURIComponent(editor_url + "#" + hash)); + }); + // Hex Save $("#keymap-download").click(function(ev, ui) { @@ -214,6 +242,13 @@ hex_link[0].click(); }); + + + /* + * Output options + */ + //$("#keymap-output").resizable(); // resizable textarea + // Hex output $("#keymap-hex-generate").click(function(ev, ui) { var keymap_data = fn_actions.concat(keymaps); @@ -234,6 +269,27 @@ $("#keymap-output").text(keymap_output); }); + // encode keymap + $("#keymap-encode").click(function(ev, ui) { + var keymap_output = encode_keymap({ keymaps: keymaps }); + $("#keymap-output").text(keymap_output); + }); + + // decode keymap + $("#keymap-decode").click(function(ev, ui) { + var hash = $("#keymap-output").text(); + var keymap_output = decode_keymap(hash); + $("#keymap-output").text(JSON.stringify(keymap_output)); + }); + + + + // lost keymap under edting when leave the page + /* TODO: Needed when released + $(window).bind('beforeunload', function(){ + return 'CAUTION: You will lost your change.'; + }); + */ }); @@ -243,34 +299,37 @@