| 1 | let Globalx = {}; |
|---|
| 2 | let GlobalxInitValue = { |
|---|
| 3 | editor: null, |
|---|
| 4 | key_indicate_file: false, |
|---|
| 5 | key: '/' |
|---|
| 6 | }; |
|---|
| 7 | |
|---|
| 8 | function main() { |
|---|
| 9 | restore_info_to_globalx() |
|---|
| 10 | |
|---|
| 11 | editor_func("data"); |
|---|
| 12 | make_ul_for_menu('data' , '#data-side') |
|---|
| 13 | menux( "data" ) |
|---|
| 14 | |
|---|
| 15 | editor_func("setting"); |
|---|
| 16 | make_ul_for_menu("setting" , '#setting-side') |
|---|
| 17 | |
|---|
| 18 | editor_func("output"); |
|---|
| 19 | make_ul_for_menu("output" , '#output-side') |
|---|
| 20 | |
|---|
| 21 | tab_init() |
|---|
| 22 | topmenu_init() |
|---|
| 23 | |
|---|
| 24 | rebuild_bookmark_menu("data") |
|---|
| 25 | |
|---|
| 26 | // LocalStorageにまだ保存していない場合を想定して、ここで保存しておく |
|---|
| 27 | console.log("call save_info_from_globalx()") |
|---|
| 28 | save_info_from_globalx() |
|---|
| 29 | |
|---|
| 30 | part = "data" |
|---|
| 31 | $('#down-download').on('click', {part: part}, handleDownload) |
|---|
| 32 | $( Globalx['data'].textarea_sel ).val(""); |
|---|
| 33 | $( '#bookmark_displayname' ).prop( 'maxlength' , Globalx[part].bookmark_displayname_max_length) |
|---|
| 34 | $('#bookmarkDlg').dialog({ |
|---|
| 35 | autoOpen: false, |
|---|
| 36 | modal: true, |
|---|
| 37 | buttons: { |
|---|
| 38 | "OK": function() { |
|---|
| 39 | part = Globalx.parts[ Globalx.index ] |
|---|
| 40 | path = $( '#bookmark_path' ).val() |
|---|
| 41 | displayname = $( '#bookmark_displayname' ).val() |
|---|
| 42 | register_bookmark_( part , path, displayname ) |
|---|
| 43 | $(this).dialog("close")}, |
|---|
| 44 | "Cancel": function() { |
|---|
| 45 | bookmark_cb.prop('checked', false) |
|---|
| 46 | $(this).dialog("close") |
|---|
| 47 | } |
|---|
| 48 | } |
|---|
| 49 | }) |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | function init_globalx() { |
|---|
| 53 | Globalx.num = 0; |
|---|
| 54 | Globalx.index = 0; |
|---|
| 55 | Globalx.parts = ["data", "output", "setting"] |
|---|
| 56 | |
|---|
| 57 | Globalx.parts.map( function( part ){ |
|---|
| 58 | console.log("init_globalx part=" + part ) |
|---|
| 59 | set_globalx_editor(part) |
|---|
| 60 | } ) |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | function set_globalx_editor(part) { |
|---|
| 64 | Globalx[part] = { |
|---|
| 65 | editor_id: `${part}-editor`, |
|---|
| 66 | editor: null, |
|---|
| 67 | textarea_sel: `textarea[name=${part}-editor-t`, |
|---|
| 68 | /**/ |
|---|
| 69 | menu_id: `${part}-menu2`, |
|---|
| 70 | bookmark_id: `${part}-bookmark`, |
|---|
| 71 | bookmark_op_id: `${part}-bookmark_op`, |
|---|
| 72 | item_name: "", |
|---|
| 73 | /**/ |
|---|
| 74 | bookmarks: [], |
|---|
| 75 | bookmark_displayname_max_length: 18, |
|---|
| 76 | key_indicate_file: false, |
|---|
| 77 | key: '/', |
|---|
| 78 | key_sel: `#${part}-filelist_key`, |
|---|
| 79 | download_sel: `#${part}-download_sel` |
|---|
| 80 | } |
|---|
| 81 | Globalx[part].menu_sel = `#${Globalx[part].menu_id}` |
|---|
| 82 | Globalx[part].bookmark_sel = `#${Globalx[part].bookmark_id}` |
|---|
| 83 | Globalx[part].bookmark_op_sel = `#${Globalx[part].bookmark_op_id}` |
|---|
| 84 | Globalx[part].bookmark_mgr = new BookmarkMgr( Globalx[part].bookmark_displayname_max_length ) |
|---|
| 85 | |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | function editor_func(part) { |
|---|
| 89 | let editor = ace.edit( Globalx[part].editor_id ) |
|---|
| 90 | editor.setTheme("ace/theme/monokai"); |
|---|
| 91 | editor.setFontSize(14); |
|---|
| 92 | editor.getSession().setMode("ace/mode/markdown"); |
|---|
| 93 | editor.getSession().setUseWrapMode(true); |
|---|
| 94 | editor.getSession().setTabSize(2); |
|---|
| 95 | Globalx[part].editor = editor; |
|---|
| 96 | let textarea = $( Globalx[part].textarea_sel ); |
|---|
| 97 | Globalx[part].textarea = textarea; |
|---|
| 98 | editor.getSession().on("change", function () { |
|---|
| 99 | Globalx[part].textarea.val(editor.getSession().getValue()); |
|---|
| 100 | }); |
|---|
| 101 | } |
|---|
| 102 | |
|---|