From c1cd5732df8626658ecf1a3aa105e64e62700838 Mon Sep 17 00:00:00 2001 From: Gunjan Yadu Date: Sun, 14 Mar 2021 19:29:48 +0000 Subject: [PATCH 1/3] Update README.md --- emscripten/project/purr-data/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emscripten/project/purr-data/README.md b/emscripten/project/purr-data/README.md index d7978a47d..a1e38768a 100644 --- a/emscripten/project/purr-data/README.md +++ b/emscripten/project/purr-data/README.md @@ -107,7 +107,7 @@ Method 2 - Fix graphical arrays being opened if the patch font size changes. - Ask for saving the patch when the user closes an edited patch. - Make the GUI(e.g. bang, toggle) property dialog window work. -- Make the dialog windows(e.g. property, text) appear in the right side of the patch instead of the left side bar. +- Make the dialog windows(e.g. property, text) appear in the right side of the patch instead of the left sidebar. - Merge patch menu into the global menu and make it work depending on the focus of patches. - Style the patch window menu bar so it can show the focus state and add some buttons (e.g. close) for convenience. - Make the patch window resizable by dragging its border. -- GitLab From 599dfe61984c6d95e819a576475df5c56f6132eb Mon Sep 17 00:00:00 2001 From: Gunjan Yadu Date: Thu, 18 Mar 2021 11:54:51 +0530 Subject: [PATCH 2/3] Indentation problems resolved --- .../project/purr-data/components/menu/menu.js | 1344 ++++++++--------- 1 file changed, 672 insertions(+), 672 deletions(-) diff --git a/emscripten/project/purr-data/components/menu/menu.js b/emscripten/project/purr-data/components/menu/menu.js index fecd9a7fe..6d8f89eed 100644 --- a/emscripten/project/purr-data/components/menu/menu.js +++ b/emscripten/project/purr-data/components/menu/menu.js @@ -1,727 +1,727 @@ -"use strict"; +'use strict'; -var l = pdbundle.pdgui.get_local_string; // For menu names -var prev_menu_clicked; +const l = pdbundle.pdgui.get_local_string; // For menu names +let prev_menu_clicked; function menu_section_click(id) { - // Hide previous menu clicked - if (prev_menu_clicked !== undefined) { - var prev = document.getElementById(prev_menu_clicked); - if (prev) { - prev.querySelectorAll("ul")[0].style.display = "none"; - } + // Hide previous menu clicked + if (prev_menu_clicked !== undefined) { + const prev = document.getElementById(prev_menu_clicked); + if (prev) { + prev.querySelectorAll('ul')[0].style.display = 'none'; } + } - // Show the current menu options - var m_option = document.getElementById(id); - m_option.querySelectorAll("ul")[0].style.display = "block"; + // Show the current menu options + const m_option = document.getElementById(id); + m_option.querySelectorAll('ul')[0].style.display = 'block'; - // Listen to clicks on the page so can close the menu - document.onclick = function (e) { - if (e.target.id !== id) { - m_option.querySelectorAll("ul")[0].style.display = "none"; - prev_menu_clicked = undefined; - } + // Listen to clicks on the page so can close the menu + document.onclick = function (e) { + if (e.target.id !== id) { + m_option.querySelectorAll('ul')[0].style.display = 'none'; + prev_menu_clicked = undefined; } + }; - // Update the previous menu clicked - prev_menu_clicked = id; + // Update the previous menu clicked + prev_menu_clicked = id; } function menu_section_move(id) { - if (prev_menu_clicked !== undefined) { - if (prev_menu_clicked !== id) { - menu_section_click(id); - } + if (prev_menu_clicked !== undefined) { + if (prev_menu_clicked !== id) { + menu_section_click(id); } + } } function menu_options(type, w, cid) { - if (cid === undefined) cid = ""; - tmp_cid = cid; - - var file_base = { - // File section - "menu-file": { - label: l("menu.file"), - action: { - onclick: function () { menu_section_click("menu-file" + cid) }, - onmousemove: function () { menu_section_move("menu-file" + cid) } - } - }, - - "file-message": { - label: l("menu.message"), - key: pdbundle.shortcuts.menu.message_web.key, - modifiers: pdbundle.shortcuts.menu.message_web.modifiers, - tooltip: l("menu.message_tt"), - bottom_hr: {} - }, + if (cid === undefined) cid = ''; + tmp_cid = cid; + + const file_base = { + // File section + 'menu-file': { + label: l('menu.file'), + action: { + onclick() { menu_section_click('menu-file' + cid); }, + onmousemove() { menu_section_move('menu-file' + cid); }, + }, + }, + + 'file-message': { + label: l('menu.message'), + key: pdbundle.shortcuts.menu.message_web.key, + modifiers: pdbundle.shortcuts.menu.message_web.modifiers, + tooltip: l('menu.message_tt'), + bottom_hr: {}, + }, + }; + + const edit_base = { + + // Edit section + 'menu-edit': { + label: l('menu.edit'), + action: { + onclick() { menu_section_click('menu-edit' + cid); }, + onmousemove() { menu_section_move('menu-edit' + cid); }, + }, + }, + + // Edit entries + 'edit-copy': { + label: l('menu.copy'), + key: pdbundle.shortcuts.menu.copy_web.key, + modifiers: pdbundle.shortcuts.menu.copy_web.modifiers, + tooltip: l('menu.copy_tt'), + }, + 'edit-selectall': { + label: l('menu.selectall'), + key: pdbundle.shortcuts.menu.selectall_web.key, + modifiers: pdbundle.shortcuts.menu.selectall_web.modifiers, + tooltip: l('menu.selectall_tt'), + }, + 'edit-find': { + label: l('menu.find'), + key: pdbundle.shortcuts.menu.find_web.key, + modifiers: pdbundle.shortcuts.menu.find_web.modifiers, + tooltip: l('menu.find_tt'), + }, + + }; + + const view_base = { + // View section + 'menu-view': { + label: l('menu.view'), + action: { + onclick() { menu_section_click('menu-view' + cid); }, + onmousemove() { menu_section_move('menu-view' + cid); }, + }, + }, + + // View entries + 'view-zoomin': { + label: l('menu.zoomin'), + key: pdbundle.shortcuts.menu.zoomin_web.key, + modifiers: pdbundle.shortcuts.menu.zoomin_web.modifiers, + tooltip: l('menu.zoomin_tt'), + }, + 'view-zoomout': { + label: l('menu.zoomout'), + key: pdbundle.shortcuts.menu.zoomout_web.key, + modifiers: pdbundle.shortcuts.menu.zoomout_web.modifiers, + tooltip: l('menu.zoomout_tt'), + }, + 'view-zoomreset': { + label: l('menu.zoomreset'), + key: pdbundle.shortcuts.menu.zoomreset_web.key, + modifiers: pdbundle.shortcuts.menu.zoomreset_web.modifiers, + tooltip: l('menu.zoomreset_tt'), + top_hr: {}, + }, + 'view-fullscreen': { + label: l('menu.fullscreen'), + key: pdbundle.shortcuts.menu.fullscreen_web.key, + modifiers: pdbundle.shortcuts.menu.fullscreen_web.modifiers, + tooltip: l('menu.fullscreen_tt'), + top_hr: {}, + }, + }; + + const window_base = { + // Window section + 'menu-window': { + label: l('menu.windows'), + action: { + onclick() { menu_section_click('menu-window' + cid); }, + onmousemove() { menu_section_move('menu-window' + cid); }, + }, + }, + + // Window entries + 'window-nextwin': { + action: { onclick() { pdbundle.pdgui.raise_next('pd_window'); } }, + label: l('menu.nextwin'), + key: pdbundle.shortcuts.menu.nextwin_web.key, + modifiers: pdbundle.shortcuts.menu.nextwin_web.modifiers, + tooltip: l('menu.nextwin_tt'), + }, + 'window-prevwin': { + action: { onclick() { pdbundle.pdgui.raise_prev('pd_window'); } }, + label: l('menu.prevwin'), + key: pdbundle.shortcuts.menu.prevwin_web.key, + modifiers: pdbundle.shortcuts.menu.prevwin_web.modifiers, + tooltip: l('menu.prevwin_tt'), + }, + }; + + const console_menu_base = { + // File + ...file_base, + + // File entries + 'file-new': { + action: { onclick: pdbundle.pdgui.menu_new }, + label: l('menu.new'), + key: pdbundle.shortcuts.menu.new_web.key, + modifiers: pdbundle.shortcuts.menu.new_web.modifiers, + tooltip: l('menu.new_tt'), + }, + + 'file-open': { + label: l('menu.open'), + key: pdbundle.shortcuts.menu.open_web.key, + modifiers: pdbundle.shortcuts.menu.open_web.modifiers, + tooltip: l('menu.open_tt'), + }, + + // Edit + ...edit_base, + // Edit entries + 'edit-clear-console': { + action: { onclick: pdbundle.pdgui.clear_console }, + label: l('menu.clear_console'), + tooltip: l('menu.clear_console'), + key: pdbundle.shortcuts.menu.clear_console_web.key, + modifiers: pdbundle.shortcuts.menu.clear_console_web.modifiers, + top_hr: {}, + bottom_hr: {}, + }, + 'edit-preferences': { + action: { onclick: pdbundle.pdgui.open_prefs }, + label: l('menu.preferences'), + key: pdbundle.shortcuts.menu.preferences_web.key, + modifiers: pdbundle.shortcuts.menu.preferences_web.modifiers, + tooltip: l('menu.preferences_tt'), + }, + + // View + ...view_base, + + // Media section + 'menu-media': { + label: l('menu.media'), + action: { + onclick() { menu_section_click('menu-media' + cid); }, + onmousemove() { menu_section_move('menu-media' + cid); }, + }, + }, + + // Media entries + 'media-audio-on': { + action: { onclick() { pdbundle.pdgui.pdsend('pd dsp 1'); } }, + label: l('menu.audio_on'), + key: pdbundle.shortcuts.menu.audio_on_web.key, + modifiers: pdbundle.shortcuts.menu.audio_on_web.modifiers, + tooltip: l('menu.audio_on_tt'), + }, + 'media-audio-off': { + action: { onclick() { pdbundle.pdgui.pdsend('pd dsp 0'); } }, + label: l('menu.audio_off'), + key: pdbundle.shortcuts.menu.audio_off_web.key, + modifiers: pdbundle.shortcuts.menu.audio_off_web.modifiers, + tooltip: l('menu.audio_off_tt'), + bottom_hr: {}, + }, + 'media-test': { + action: { onclick() { pdbundle.pdgui.pd_doc_open('doc/7.stuff/tools', 'testtone.pd'); } }, + label: l('menu.test'), + tooltip: l('menu.test_tt'), + }, + 'media-loadmeter': { + action: { onclick() { pdbundle.pdgui.pd_doc_open('doc/7.stuff/tools', 'load-meter.pd'); } }, + label: l('menu.loadmeter'), + tooltip: l('menu.loadmeter_tt'), + }, + + // Window + ...window_base, + + // Help section + 'menu-help': { + label: l('menu.help'), + action: { + onclick() { menu_section_click('menu-help' + cid); }, + onmousemove() { menu_section_move('menu-help' + cid); }, + }, + }, + + // Help entries + 'help-about': { + action: { onclick() { pdbundle.pdgui.web_pd_doc_open('doc/about', 'about.pd'); } }, + label: l('menu.about'), + tooltip: l('menu.about_tt'), + }, + 'help-manual': { + action: { onclick() { pdbundle.pdgui.pd_doc_open('doc/1.manual', 'index.htm'); } }, + label: l('menu.manual'), + tooltip: l('menu.manual_tt'), + }, + 'help-browser': { + action: { onclick: pdbundle.pdgui.open_search }, + label: l('menu.browser'), + key: pdbundle.shortcuts.menu.browser_web.key, + modifiers: pdbundle.shortcuts.menu.browser_web.modifiers, + tooltip: l('menu.browser_tt'), + }, + 'help-intro': { + action: { onclick() { pdbundle.pdgui.pd_doc_open('doc/5.reference', 'help-intro.pd'); } }, + label: l('menu.intro'), + tooltip: l('menu.intro_tt'), + bottom_hr: {}, + }, + 'help-l2ork-list': { + action: { onclick() { pdbundle.pdgui.external_doc_open('http://disis.music.vt.edu/listinfo/l2ork-dev'); } }, + label: l('menu.l2ork_list'), + tooltip: l('menu.l2ork_list_tt'), + }, + 'help-pd-list': { + action: { onclick() { pdbundle.pdgui.external_doc_open('http://puredata.info/community/lists'); } }, + label: l('menu.pd_list'), + tooltip: l('menu.pd_list_tt'), + }, + 'help-forums': { + action: { onclick() { pdbundle.pdgui.external_doc_open('http://forum.pdpatchrepo.info/'); } }, + label: l('menu.forums'), + tooltip: l('menu.forums_tt'), + }, + 'help-irc': { + action: { onclick() { pdbundle.pdgui.external_doc_open('http://puredata.info/community/IRC'); } }, + label: l('menu.irc'), + tooltip: l('menu.irc_tt'), + }, + }; + + const console_menu = { + ...console_menu_base, + + 'file-recent-files': { + recent_files: w.document.getElementById('file-recent-files'), //pass the recent files element holder + label: l('menu.recent_files'), + tooltip: l('menu.recent_files_tt'), + bottom_hr: {}, + }, + + // Help entries + 'help-devtools': { + label: l('menu.devtools'), + tooltip: l('menu.devtools_tt'), + }, + + }; + + const canvas_menu_base = { + // File section + ...file_base, + // File entries + 'file-save': { + label: l('menu.save'), + key: pdbundle.shortcuts.menu.save_web.key, + modifiers: pdbundle.shortcuts.menu.save_web.modifiers, + tooltip: l('menu.save_tt'), + }, + 'file-saveas': { + label: l('menu.saveas'), + key: pdbundle.shortcuts.menu.saveas_web.key, + modifiers: pdbundle.shortcuts.menu.saveas_web.modifiers, + tooltip: l('menu.saveas_tt'), + }, + 'file-print': { + label: l('menu.print'), + key: pdbundle.shortcuts.menu.print_web.key, + modifiers: pdbundle.shortcuts.menu.print_web.modifiers, + tooltip: l('menu.print_tt'), + bottom_hr: {}, + }, + 'file-close': { + label: l('menu.close'), + key: pdbundle.shortcuts.menu.close_web.key, + modifiers: pdbundle.shortcuts.menu.close_web.modifiers, + tooltip: l('menu.close_tt'), + }, + + // Edit section + ...edit_base, + + // Edit entries + 'edit-undo': { + label: l('menu.undo'), + tooltip: l('menu.undo_tt'), + key: pdbundle.shortcuts.menu.undo_web.key, + modifiers: pdbundle.shortcuts.menu.undo_web.modifiers, + }, + 'edit-redo': { + label: l('menu.redo'), + tooltip: l('menu.redo_tt'), + key: pdbundle.shortcuts.menu.redo_web.key, + modifiers: pdbundle.shortcuts.menu.redo_web.modifiers, + bottom_hr: {}, + }, + 'edit-cut': { + label: l('menu.cut'), + key: pdbundle.shortcuts.menu.cut_web.key, + modifiers: pdbundle.shortcuts.menu.cut_web.modifiers, + tooltip: l('menu.cut_tt'), + }, + 'edit-paste': { + label: l('menu.paste'), + key: pdbundle.shortcuts.menu.paste_web.key, + modifiers: pdbundle.shortcuts.menu.paste_web.modifiers, + tooltip: l('menu.paste_tt'), + }, + 'edit-paste-clipboard': { + label: l('menu.paste_clipboard'), + key: pdbundle.shortcuts.menu.paste_clipboard_web.key, + modifiers: pdbundle.shortcuts.menu.paste_clipboard_web.modifiers, + tooltip: l('menu.paste_clipboard_tt'), + }, + 'edit-duplicate': { + label: l('menu.duplicate'), + key: pdbundle.shortcuts.menu.duplicate_web.key, + modifiers: pdbundle.shortcuts.menu.duplicate_web.modifiers, + tooltip: l('menu.duplicate_tt'), + }, + 'edit-reselect': { + label: l('menu.reselect'), + key: pdbundle.shortcuts.menu.reselect_web.key, + modifiers: pdbundle.shortcuts.menu.reselect_web.modifiers, + tooltip: l('menu.reselect_tt'), + }, + 'edit-tidyup': { + label: l('menu.tidyup'), + key: pdbundle.shortcuts.menu.tidyup_web.key, + modifiers: pdbundle.shortcuts.menu.tidyup_web.modifiers, + tooltip: l('menu.tidyup_tt'), + }, + 'edit-font': { + label: l('menu.font'), + tooltip: l('menu.font_tt'), + }, + 'edit-cordinspector': { + label: l('menu.cordinspector'), + key: pdbundle.shortcuts.menu.cordinspector_web.key, + modifiers: pdbundle.shortcuts.menu.cordinspector_web.modifiers, + tooltip: l('menu.cordinspector_tt'), + bottom_hr: {}, + }, + 'edit-findagain': { + label: l('menu.findagain'), + key: pdbundle.shortcuts.menu.findagain_web.key, + modifiers: pdbundle.shortcuts.menu.findagain_web.modifiers, + tooltip: l('menu.findagain'), + }, + 'edit-finderror': { + action: { onclick() { pdbundle.pdgui.pdsend('pd finderror'); } }, + label: l('menu.finderror'), + tooltip: l('menu.finderror_tt'), + bottom_hr: {}, + }, + + 'edit-editmode': { + label: l('menu.editmode'), + key: pdbundle.shortcuts.menu.editmode_web.key, + modifiers: pdbundle.shortcuts.menu.editmode_web.modifiers, + tooltip: l('menu.editmode_tt'), + bottom_hr: {}, + }, + + // View section + ...view_base, + + // View entries + 'view-optimalzoom': { + label: l('menu.zoomoptimal'), + key: pdbundle.shortcuts.menu.zoomoptimal_web.key, + modifiers: pdbundle.shortcuts.menu.zoomoptimal_web.modifiers, + tooltip: l('menu.zoomoptimal_tt'), + }, + 'view-horizzoom': { + label: l('menu.zoomhoriz'), + key: pdbundle.shortcuts.menu.zoomhoriz_web.key, + modifiers: pdbundle.shortcuts.menu.zoomhoriz_web.modifiers, + tooltip: l('menu.zoomhoriz_tt'), + }, + 'view-vertzoom': { + label: l('menu.zoomvert'), + key: pdbundle.shortcuts.menu.zoomvert_web.key, + modifiers: pdbundle.shortcuts.menu.zoomvert_web.modifiers, + tooltip: l('menu.zoomvert_tt'), + }, + + // Put section + 'menu-put': { + label: l('menu.put'), + action: { + onclick() { menu_section_click('menu-put' + cid); }, + onmousemove() { menu_section_move('menu-put' + cid); }, + }, + }, + + // Put entries + 'put-object': { + label: l('menu.object'), + key: pdbundle.shortcuts.menu.object_web.key, + modifiers: pdbundle.shortcuts.menu.object_web.modifiers, + tooltip: l('menu.object_tt'), + }, + 'put-msgbox': { + label: l('menu.msgbox'), + key: pdbundle.shortcuts.menu.msgbox_web.key, + modifiers: pdbundle.shortcuts.menu.msgbox_web.modifiers, + tooltip: l('menu.msgbox_tt'), + }, + 'put-number': { + label: l('menu.number'), + key: pdbundle.shortcuts.menu.number_web.key, + modifiers: pdbundle.shortcuts.menu.number_web.modifiers, + tooltip: l('menu.number_tt'), + }, + 'put-symbol': { + label: l('menu.symbol'), + key: pdbundle.shortcuts.menu.symbol_web.key, + modifiers: pdbundle.shortcuts.menu.symbol_web.modifiers, + tooltip: l('menu.symbol_tt'), + }, + 'put-comment': { + label: l('menu.comment'), + key: pdbundle.shortcuts.menu.comment_web.key, + modifiers: pdbundle.shortcuts.menu.comment_web.modifiers, + tooltip: l('menu.comment_tt'), + }, + 'put-dropdown': { + label: l('menu.dropdown'), + key: pdbundle.shortcuts.menu.dropdown_web.key, + modifiers: pdbundle.shortcuts.menu.dropdown_web.modifiers, + tooltip: l('menu.dropdown_tt'), + bottom_hr: {}, + }, + 'put-bang': { + label: l('menu.bang'), + key: pdbundle.shortcuts.menu.bang_web.key, + modifiers: pdbundle.shortcuts.menu.bang_web.modifiers, + tooltip: l('menu.bang_tt'), + }, + 'put-toggle': { + label: l('menu.toggle'), + key: pdbundle.shortcuts.menu.toggle_web.key, + modifiers: pdbundle.shortcuts.menu.toggle_web.modifiers, + tooltip: l('menu.toggle_tt'), + }, + 'put-number2': { + label: l('menu.number2'), + key: pdbundle.shortcuts.menu.number2_web.key, + modifiers: pdbundle.shortcuts.menu.number2_web.modifiers, + tooltip: l('menu.number2'), + }, + 'put-vslider': { + label: l('menu.vslider'), + key: pdbundle.shortcuts.menu.vslider_web.key, + modifiers: pdbundle.shortcuts.menu.vslider_web.modifiers, + tooltip: l('menu.vslider_tt'), + }, + 'put-hslider': { + label: l('menu.hslider'), + key: pdbundle.shortcuts.menu.hslider_web.key, + modifiers: pdbundle.shortcuts.menu.hslider_web.modifiers, + tooltip: l('menu.hslider_tt'), + }, + 'put-vradio': { + label: l('menu.vradio'), + key: pdbundle.shortcuts.menu.vradio_web.key, + modifiers: pdbundle.shortcuts.menu.vradio_web.modifiers, + tooltip: l('menu.vradio_tt'), + }, + 'put-hradio': { + label: l('menu.hradio'), + key: pdbundle.shortcuts.menu.hradio_web.key, + modifiers: pdbundle.shortcuts.menu.hradio_web.modifiers, + tooltip: l('menu.hradio_tt'), + }, + 'put-vu': { + label: l('menu.vu'), + key: pdbundle.shortcuts.menu.vu_web.key, + modifiers: pdbundle.shortcuts.menu.vu_web.modifiers, + tooltip: l('menu.vu_tt'), + }, + 'put-cnv': { + label: l('menu.cnv'), + key: pdbundle.shortcuts.menu.cnv_web.key, + modifiers: pdbundle.shortcuts.menu.cnv_web.modifiers, + tooltip: l('menu.cnv_tt'), + bottom_hr: {}, + }, + 'put-array': { + label: l('menu.array'), + tooltip: l('menu.array_tt'), + }, + + // Window section + ...window_base, + + // Window entries + 'window-parentwin': { + label: l('menu.parentwin'), + tooltip: l('menu.parentwin_tt'), + top_hr: {}, + }, + 'window-visible-ancestor': { + label: l('menu.visible_ancestor'), + tooltip: l('menu.visible_ancestor_tt'), + }, + 'window-pdwin': { + action: { onclick() { pdbundle.pdgui.raise_pd_window(); } }, + label: l('menu.pdwin'), + tooltip: l('menu.pdwin_tt'), + key: pdbundle.shortcuts.menu.pdwin_web.key, + modifiers: pdbundle.shortcuts.menu.pdwin_web.modifiers, + }, + }; + + const canvas_menu = { + ...console_menu, + ...canvas_menu_base, + }; + + const web_menu = { + ...console_menu_base, + }; + + const web_canvas = { + ...canvas_menu_base, + 'file-download': { + label: l('menu.download'), + }, + }; + + + const entries = { + 'console': console_menu, + 'canvas': canvas_menu, + 'web': web_menu, + 'web-canvas': web_canvas, + }; + + // Iteracting over the menu options to set it's args and make it visible + const menu = entries[type]; + + if (cid != '') { + window.shortkeys[cid] = { ...window.shortkeys[''] }; + } else { + window.shortkeys[cid] = {}; + } + + for (const id in menu) { + const menu_item = w.document.getElementById(id + cid); + visible(menu_item); + remove_select_text(menu_item); + for (const option in menu[id]) { + window[option](menu_item, menu[id][option]); } + } - var edit_base = { - - // Edit section - "menu-edit": { - label: l("menu.edit"), - action: { - onclick: function () { menu_section_click("menu-edit" + cid) }, - onmousemove: function () { menu_section_move("menu-edit" + cid) } - }, - }, - - // Edit entries - "edit-copy": { - label: l("menu.copy"), - key: pdbundle.shortcuts.menu.copy_web.key, - modifiers: pdbundle.shortcuts.menu.copy_web.modifiers, - tooltip: l("menu.copy_tt") - }, - "edit-selectall": { - label: l("menu.selectall"), - key: pdbundle.shortcuts.menu.selectall_web.key, - modifiers: pdbundle.shortcuts.menu.selectall_web.modifiers, - tooltip: l("menu.selectall_tt") - }, - "edit-find": { - label: l("menu.find"), - key: pdbundle.shortcuts.menu.find_web.key, - modifiers: pdbundle.shortcuts.menu.find_web.modifiers, - tooltip: l("menu.find_tt") - }, - - } - - var view_base = { - // View section - "menu-view": { - label: l("menu.view"), - action: { - onclick: function () { menu_section_click("menu-view" + cid) }, - onmousemove: function () { menu_section_move("menu-view" + cid) } - } - }, - - // View entries - "view-zoomin": { - label: l("menu.zoomin"), - key: pdbundle.shortcuts.menu.zoomin_web.key, - modifiers: pdbundle.shortcuts.menu.zoomin_web.modifiers, - tooltip: l("menu.zoomin_tt") - }, - "view-zoomout": { - label: l("menu.zoomout"), - key: pdbundle.shortcuts.menu.zoomout_web.key, - modifiers: pdbundle.shortcuts.menu.zoomout_web.modifiers, - tooltip: l("menu.zoomout_tt") - }, - "view-zoomreset": { - label: l("menu.zoomreset"), - key: pdbundle.shortcuts.menu.zoomreset_web.key, - modifiers: pdbundle.shortcuts.menu.zoomreset_web.modifiers, - tooltip: l("menu.zoomreset_tt"), - top_hr: {} - }, - "view-fullscreen": { - label: l("menu.fullscreen"), - key: pdbundle.shortcuts.menu.fullscreen_web.key, - modifiers: pdbundle.shortcuts.menu.fullscreen_web.modifiers, - tooltip: l("menu.fullscreen_tt"), - top_hr: {} - } - } - - var window_base = { - // Window section - "menu-window": { - label: l("menu.windows"), - action: { - onclick: function () { menu_section_click("menu-window" + cid) }, - onmousemove: function () { menu_section_move("menu-window" + cid) } - } - }, - - // Window entries - "window-nextwin": { - action: { onclick: function () { pdbundle.pdgui.raise_next("pd_window") } }, - label: l("menu.nextwin"), - key: pdbundle.shortcuts.menu.nextwin_web.key, - modifiers: pdbundle.shortcuts.menu.nextwin_web.modifiers, - tooltip: l("menu.nextwin_tt") - }, - "window-prevwin": { - action: { onclick: function () { pdbundle.pdgui.raise_prev("pd_window") } }, - label: l("menu.prevwin"), - key: pdbundle.shortcuts.menu.prevwin_web.key, - modifiers: pdbundle.shortcuts.menu.prevwin_web.modifiers, - tooltip: l("menu.prevwin_tt") - } - } - - var console_menu_base = { - // File - ...file_base, - - // File entries - "file-new": { - action: { onclick: pdbundle.pdgui.menu_new }, - label: l("menu.new"), - key: pdbundle.shortcuts.menu.new_web.key, - modifiers: pdbundle.shortcuts.menu.new_web.modifiers, - tooltip: l("menu.new_tt") - }, - - "file-open": { - label: l("menu.open"), - key: pdbundle.shortcuts.menu.open_web.key, - modifiers: pdbundle.shortcuts.menu.open_web.modifiers, - tooltip: l("menu.open_tt") - }, - - // Edit - ...edit_base, - // Edit entries - "edit-clear-console": { - action: { onclick: pdbundle.pdgui.clear_console }, - label: l("menu.clear_console"), - tooltip: l("menu.clear_console"), - key: pdbundle.shortcuts.menu.clear_console_web.key, - modifiers: pdbundle.shortcuts.menu.clear_console_web.modifiers, - top_hr: {}, - bottom_hr: {} - }, - "edit-preferences": { - action: { onclick: pdbundle.pdgui.open_prefs }, - label: l("menu.preferences"), - key: pdbundle.shortcuts.menu.preferences_web.key, - modifiers: pdbundle.shortcuts.menu.preferences_web.modifiers, - tooltip: l("menu.preferences_tt") - }, - - // View - ...view_base, - - // Media section - "menu-media": { - label: l("menu.media"), - action: { - onclick: function () { menu_section_click("menu-media" + cid) }, - onmousemove: function () { menu_section_move("menu-media" + cid) } - } - }, - - // Media entries - "media-audio-on": { - action: { onclick: function () { pdbundle.pdgui.pdsend("pd dsp 1") } }, - label: l("menu.audio_on"), - key: pdbundle.shortcuts.menu.audio_on_web.key, - modifiers: pdbundle.shortcuts.menu.audio_on_web.modifiers, - tooltip: l("menu.audio_on_tt") - }, - "media-audio-off": { - action: { onclick: function () { pdbundle.pdgui.pdsend("pd dsp 0") } }, - label: l("menu.audio_off"), - key: pdbundle.shortcuts.menu.audio_off_web.key, - modifiers: pdbundle.shortcuts.menu.audio_off_web.modifiers, - tooltip: l("menu.audio_off_tt"), - bottom_hr: {} - }, - "media-test": { - action: { onclick: function () { pdbundle.pdgui.pd_doc_open("doc/7.stuff/tools", "testtone.pd") } }, - label: l("menu.test"), - tooltip: l("menu.test_tt") - }, - "media-loadmeter": { - action: { onclick: function () { pdbundle.pdgui.pd_doc_open("doc/7.stuff/tools", "load-meter.pd") } }, - label: l("menu.loadmeter"), - tooltip: l("menu.loadmeter_tt") - }, - - // Window - ...window_base, - - // Help section - "menu-help": { - label: l("menu.help"), - action: { - onclick: function () { menu_section_click("menu-help" + cid) }, - onmousemove: function () { menu_section_move("menu-help" + cid) } - } - }, - - // Help entries - "help-about": { - action: { onclick: function () { pdbundle.pdgui.web_pd_doc_open("doc/about", "about.pd") } }, - label: l("menu.about"), - tooltip: l("menu.about_tt") - }, - "help-manual": { - action: { onclick: function () { pdbundle.pdgui.pd_doc_open("doc/1.manual", "index.htm") } }, - label: l("menu.manual"), - tooltip: l("menu.manual_tt") - }, - "help-browser": { - action: { onclick: pdbundle.pdgui.open_search }, - label: l("menu.browser"), - key: pdbundle.shortcuts.menu.browser_web.key, - modifiers: pdbundle.shortcuts.menu.browser_web.modifiers, - tooltip: l("menu.browser_tt") - }, - "help-intro": { - action: { onclick: function () { pdbundle.pdgui.pd_doc_open("doc/5.reference", "help-intro.pd") } }, - label: l("menu.intro"), - tooltip: l("menu.intro_tt"), - bottom_hr: {} - }, - "help-l2ork-list": { - action: { onclick: function () { pdbundle.pdgui.external_doc_open("http://disis.music.vt.edu/listinfo/l2ork-dev") } }, - label: l("menu.l2ork_list"), - tooltip: l("menu.l2ork_list_tt") - }, - "help-pd-list": { - action: { onclick: function () { pdbundle.pdgui.external_doc_open("http://puredata.info/community/lists") } }, - label: l("menu.pd_list"), - tooltip: l("menu.pd_list_tt") - }, - "help-forums": { - action: { onclick: function () { pdbundle.pdgui.external_doc_open("http://forum.pdpatchrepo.info/") } }, - label: l("menu.forums"), - tooltip: l("menu.forums_tt") - }, - "help-irc": { - action: { onclick: function () { pdbundle.pdgui.external_doc_open("http://puredata.info/community/IRC") } }, - label: l("menu.irc"), - tooltip: l("menu.irc_tt") - }, - } - - var console_menu = { - ...console_menu_base, - - "file-recent-files": { - recent_files: w.document.getElementById("file-recent-files"), //pass the recent files element holder - label: l("menu.recent_files"), - tooltip: l("menu.recent_files_tt"), - bottom_hr: {} - }, - - // Help entries - "help-devtools": { - label: l("menu.devtools"), - tooltip: l("menu.devtools_tt") - } - - } - - var canvas_menu_base = { - // File section - ...file_base, - // File entries - "file-save": { - label: l("menu.save"), - key: pdbundle.shortcuts.menu.save_web.key, - modifiers: pdbundle.shortcuts.menu.save_web.modifiers, - tooltip: l("menu.save_tt") - }, - "file-saveas": { - label: l("menu.saveas"), - key: pdbundle.shortcuts.menu.saveas_web.key, - modifiers: pdbundle.shortcuts.menu.saveas_web.modifiers, - tooltip: l("menu.saveas_tt") - }, - "file-print": { - label: l("menu.print"), - key: pdbundle.shortcuts.menu.print_web.key, - modifiers: pdbundle.shortcuts.menu.print_web.modifiers, - tooltip: l("menu.print_tt"), - bottom_hr: {} - }, - "file-close": { - label: l("menu.close"), - key: pdbundle.shortcuts.menu.close_web.key, - modifiers: pdbundle.shortcuts.menu.close_web.modifiers, - tooltip: l("menu.close_tt") - }, - - // Edit section - ...edit_base, - - // Edit entries - "edit-undo": { - label: l("menu.undo"), - tooltip: l("menu.undo_tt"), - key: pdbundle.shortcuts.menu.undo_web.key, - modifiers: pdbundle.shortcuts.menu.undo_web.modifiers - }, - "edit-redo": { - label: l("menu.redo"), - tooltip: l("menu.redo_tt"), - key: pdbundle.shortcuts.menu.redo_web.key, - modifiers: pdbundle.shortcuts.menu.redo_web.modifiers, - bottom_hr: {} - }, - "edit-cut": { - label: l("menu.cut"), - key: pdbundle.shortcuts.menu.cut_web.key, - modifiers: pdbundle.shortcuts.menu.cut_web.modifiers, - tooltip: l("menu.cut_tt") - }, - "edit-paste": { - label: l("menu.paste"), - key: pdbundle.shortcuts.menu.paste_web.key, - modifiers: pdbundle.shortcuts.menu.paste_web.modifiers, - tooltip: l("menu.paste_tt") - }, - "edit-paste-clipboard": { - label: l("menu.paste_clipboard"), - key: pdbundle.shortcuts.menu.paste_clipboard_web.key, - modifiers: pdbundle.shortcuts.menu.paste_clipboard_web.modifiers, - tooltip: l("menu.paste_clipboard_tt") - }, - "edit-duplicate": { - label: l("menu.duplicate"), - key: pdbundle.shortcuts.menu.duplicate_web.key, - modifiers: pdbundle.shortcuts.menu.duplicate_web.modifiers, - tooltip: l("menu.duplicate_tt") - }, - "edit-reselect": { - label: l("menu.reselect"), - key: pdbundle.shortcuts.menu.reselect_web.key, - modifiers: pdbundle.shortcuts.menu.reselect_web.modifiers, - tooltip: l("menu.reselect_tt") - }, - "edit-tidyup": { - label: l("menu.tidyup"), - key: pdbundle.shortcuts.menu.tidyup_web.key, - modifiers: pdbundle.shortcuts.menu.tidyup_web.modifiers, - tooltip: l("menu.tidyup_tt") - }, - "edit-font": { - label: l("menu.font"), - tooltip: l("menu.font_tt") - }, - "edit-cordinspector": { - label: l("menu.cordinspector"), - key: pdbundle.shortcuts.menu.cordinspector_web.key, - modifiers: pdbundle.shortcuts.menu.cordinspector_web.modifiers, - tooltip: l("menu.cordinspector_tt"), - bottom_hr: {} - }, - "edit-findagain": { - label: l("menu.findagain"), - key: pdbundle.shortcuts.menu.findagain_web.key, - modifiers: pdbundle.shortcuts.menu.findagain_web.modifiers, - tooltip: l("menu.findagain") - }, - "edit-finderror": { - action: { onclick: function () { pdbundle.pdgui.pdsend("pd finderror") } }, - label: l("menu.finderror"), - tooltip: l("menu.finderror_tt"), - bottom_hr: {} - }, - - "edit-editmode": { - label: l("menu.editmode"), - key: pdbundle.shortcuts.menu.editmode_web.key, - modifiers: pdbundle.shortcuts.menu.editmode_web.modifiers, - tooltip: l("menu.editmode_tt"), - bottom_hr: {} - }, - - // View section - ...view_base, - - // View entries - "view-optimalzoom": { - label: l("menu.zoomoptimal"), - key: pdbundle.shortcuts.menu.zoomoptimal_web.key, - modifiers: pdbundle.shortcuts.menu.zoomoptimal_web.modifiers, - tooltip: l("menu.zoomoptimal_tt") - }, - "view-horizzoom": { - label: l("menu.zoomhoriz"), - key: pdbundle.shortcuts.menu.zoomhoriz_web.key, - modifiers: pdbundle.shortcuts.menu.zoomhoriz_web.modifiers, - tooltip: l("menu.zoomhoriz_tt") - }, - "view-vertzoom": { - label: l("menu.zoomvert"), - key: pdbundle.shortcuts.menu.zoomvert_web.key, - modifiers: pdbundle.shortcuts.menu.zoomvert_web.modifiers, - tooltip: l("menu.zoomvert_tt") - }, - - // Put section - "menu-put": { - label: l("menu.put"), - action: { - onclick: function () { menu_section_click("menu-put" + cid) }, - onmousemove: function () { menu_section_move("menu-put" + cid) } - } - }, - - // Put entries - "put-object": { - label: l("menu.object"), - key: pdbundle.shortcuts.menu.object_web.key, - modifiers: pdbundle.shortcuts.menu.object_web.modifiers, - tooltip: l("menu.object_tt") - }, - "put-msgbox": { - label: l("menu.msgbox"), - key: pdbundle.shortcuts.menu.msgbox_web.key, - modifiers: pdbundle.shortcuts.menu.msgbox_web.modifiers, - tooltip: l("menu.msgbox_tt") - }, - "put-number": { - label: l("menu.number"), - key: pdbundle.shortcuts.menu.number_web.key, - modifiers: pdbundle.shortcuts.menu.number_web.modifiers, - tooltip: l("menu.number_tt") - }, - "put-symbol": { - label: l("menu.symbol"), - key: pdbundle.shortcuts.menu.symbol_web.key, - modifiers: pdbundle.shortcuts.menu.symbol_web.modifiers, - tooltip: l("menu.symbol_tt") - }, - "put-comment": { - label: l("menu.comment"), - key: pdbundle.shortcuts.menu.comment_web.key, - modifiers: pdbundle.shortcuts.menu.comment_web.modifiers, - tooltip: l("menu.comment_tt") - }, - "put-dropdown": { - label: l("menu.dropdown"), - key: pdbundle.shortcuts.menu.dropdown_web.key, - modifiers: pdbundle.shortcuts.menu.dropdown_web.modifiers, - tooltip: l("menu.dropdown_tt"), - bottom_hr: {} - }, - "put-bang": { - label: l("menu.bang"), - key: pdbundle.shortcuts.menu.bang_web.key, - modifiers: pdbundle.shortcuts.menu.bang_web.modifiers, - tooltip: l("menu.bang_tt") - }, - "put-toggle": { - label: l("menu.toggle"), - key: pdbundle.shortcuts.menu.toggle_web.key, - modifiers: pdbundle.shortcuts.menu.toggle_web.modifiers, - tooltip: l("menu.toggle_tt") - }, - "put-number2": { - label: l("menu.number2"), - key: pdbundle.shortcuts.menu.number2_web.key, - modifiers: pdbundle.shortcuts.menu.number2_web.modifiers, - tooltip: l("menu.number2") - }, - "put-vslider": { - label: l("menu.vslider"), - key: pdbundle.shortcuts.menu.vslider_web.key, - modifiers: pdbundle.shortcuts.menu.vslider_web.modifiers, - tooltip: l("menu.vslider_tt") - }, - "put-hslider": { - label: l("menu.hslider"), - key: pdbundle.shortcuts.menu.hslider_web.key, - modifiers: pdbundle.shortcuts.menu.hslider_web.modifiers, - tooltip: l("menu.hslider_tt") - }, - "put-vradio": { - label: l("menu.vradio"), - key: pdbundle.shortcuts.menu.vradio_web.key, - modifiers: pdbundle.shortcuts.menu.vradio_web.modifiers, - tooltip: l("menu.vradio_tt") - }, - "put-hradio": { - label: l("menu.hradio"), - key: pdbundle.shortcuts.menu.hradio_web.key, - modifiers: pdbundle.shortcuts.menu.hradio_web.modifiers, - tooltip: l("menu.hradio_tt") - }, - "put-vu": { - label: l("menu.vu"), - key: pdbundle.shortcuts.menu.vu_web.key, - modifiers: pdbundle.shortcuts.menu.vu_web.modifiers, - tooltip: l("menu.vu_tt") - }, - "put-cnv": { - label: l("menu.cnv"), - key: pdbundle.shortcuts.menu.cnv_web.key, - modifiers: pdbundle.shortcuts.menu.cnv_web.modifiers, - tooltip: l("menu.cnv_tt"), - bottom_hr: {} - }, - "put-array": { - label: l("menu.array"), - tooltip: l("menu.array_tt") - }, - - // Window section - ...window_base, - - // Window entries - "window-parentwin": { - label: l("menu.parentwin"), - tooltip: l("menu.parentwin_tt"), - top_hr: {} - }, - "window-visible-ancestor": { - label: l("menu.visible_ancestor"), - tooltip: l("menu.visible_ancestor_tt") - }, - "window-pdwin": { - action: { onclick: function () { pdbundle.pdgui.raise_pd_window() } }, - label: l("menu.pdwin"), - tooltip: l("menu.pdwin_tt"), - key: pdbundle.shortcuts.menu.pdwin_web.key, - modifiers: pdbundle.shortcuts.menu.pdwin_web.modifiers - } - }; - - var canvas_menu = { - ...console_menu, - ...canvas_menu_base, - } - - var web_menu = { - ...console_menu_base, - }; - - var web_canvas = { - ...canvas_menu_base, - "file-download": { - label: l("menu.download"), - }, - } - - - var entries = { - "console": console_menu, - "canvas": canvas_menu, - "web": web_menu, - "web-canvas": web_canvas - } - - // Iteracting over the menu options to set it's args and make it visible - var menu = entries[type]; - - if (cid != "") { - window.shortkeys[cid] = { ...window.shortkeys[""] } - } else { - window.shortkeys[cid] = {} - } - - for (const id in menu) { - var menu_item = w.document.getElementById(id + cid); - visible(menu_item); - remove_select_text(menu_item); - for (const option in menu[id]) { - window[option](menu_item, menu[id][option]) - } - } - - return menu; + return menu; } // Functions set on args function visible(menu_item) { - menu_item.style.display = "block"; + menu_item.style.display = 'block'; } function remove_select_text(menu_item) { - menu_item.onselectstart = function (e) { - e.preventDefault(); - } + menu_item.onselectstart = function (e) { + e.preventDefault(); + }; } window.action = function (menu_item, actions) { - for (var key in actions) { - if (actions.hasOwnProperty(key)) { - menu_item[key] = actions[key]; - } + for (const key in actions) { + if (actions.hasOwnProperty(key)) { + menu_item[key] = actions[key]; } -} + } +}; window.label = function (menu_item, label) { - menu_item.prepend(label); -} + menu_item.prepend(label); +}; // Help vars for shortkey implementation -window.shortkeys = {} -var tmp_key; -var tmp_cid; +window.shortkeys = {}; +let tmp_key; +let tmp_cid; window.key = function (menu_item, shortkey) { - tmp_key = shortkey; -} + tmp_key = shortkey; +}; window.modifiers = function (menu_item, modifiers) { - var shortkey = modifiers + "+" + tmp_key; - window.shortkeys[[tmp_cid]][[shortkey]] = menu_item; + const shortkey = modifiers + '+' + tmp_key; + window.shortkeys[[tmp_cid]][[shortkey]] = menu_item; - var span = document.createElement("span"); - span.append(shortkey) - menu_item.append(span); -} + const span = document.createElement('span'); + span.append(shortkey); + menu_item.append(span); +}; window.tooltip = function (menu_item, tooltip) { - // console.log("NEED TO IMPLEMENT TOOLTIP", tooltip); -} + // console.log("NEED TO IMPLEMENT TOOLTIP", tooltip); +}; window.recent_files = function (elem) { - var holder = document.createElement("ul"); - pdbundle.pdgui.populate_recent_files(holder) - elem.append(holder) -} + const holder = document.createElement('ul'); + pdbundle.pdgui.populate_recent_files(holder); + elem.append(holder); +}; function elem_hr() { - var li = document.createElement("li"); - li.setAttribute("class", "hr"); - var hr = document.createElement("hr"); - li.append(hr) + const li = document.createElement('li'); + li.setAttribute('class', 'hr'); + const hr = document.createElement('hr'); + li.append(hr); - return li + return li; } window.top_hr = function (menu_item, hr) { - var hr = elem_hr(); - visible(hr); - menu_item.before(hr) -} + var hr = elem_hr(); + visible(hr); + menu_item.before(hr); +}; window.bottom_hr = function (menu_item, hr) { - var hr = elem_hr(); - visible(hr); - menu_item.after(hr) -} + var hr = elem_hr(); + visible(hr); + menu_item.after(hr); +}; // Common functions for both menus function open_file(w) { - var input, chooser, - span = w.document.querySelector("#fileDialogSpan"); + let input, chooser, + span = w.document.querySelector('#fileDialogSpan'); // Complicated workaround-- see comment in build_file_dialog_string - input = pdbundle.pdgui.build_file_dialog_string({ - style: "display: none;", - type: "file", - id: "fileDialog", - nwworkingdir: pdbundle.pdgui.get_pd_opendir(), - multiple: null, - // These are copied from pd_filetypes in pdbundle.pdgui.js - accept: ".pd,.pat,.mxt,.mxb,.help" - }); - span.innerHTML = input; - chooser = w.document.querySelector("#fileDialog"); - // Hack-- we have to set the event listener here because we - // changed out the innerHTML above - chooser.onchange = function () { - var file_array = this.value; - // reset value so that we can open the same file twice - this.value = null; - pdbundle.pdgui.menu_open(file_array); - console.log("tried to open something"); - }; - chooser.click(); + input = pdbundle.pdgui.build_file_dialog_string({ + style: 'display: none;', + type: 'file', + id: 'fileDialog', + nwworkingdir: pdbundle.pdgui.get_pd_opendir(), + multiple: null, + // These are copied from pd_filetypes in pdbundle.pdgui.js + accept: '.pd,.pat,.mxt,.mxb,.help', + }); + span.innerHTML = input; + chooser = w.document.querySelector('#fileDialog'); + // Hack-- we have to set the event listener here because we + // changed out the innerHTML above + chooser.onchange = function () { + const file_array = this.value; + // reset value so that we can open the same file twice + this.value = null; + pdbundle.pdgui.menu_open(file_array); + console.log('tried to open something'); + }; + chooser.click(); } \ No newline at end of file -- GitLab From 3b7c4b4f38425094617c714cd8dbff11163e44a1 Mon Sep 17 00:00:00 2001 From: Gunjan Yadu Date: Sat, 20 Mar 2021 06:46:30 +0000 Subject: [PATCH 3/3] 4 space indentation applied --- .../project/purr-data/components/menu/menu.js | 1318 ++++++++--------- 1 file changed, 659 insertions(+), 659 deletions(-) diff --git a/emscripten/project/purr-data/components/menu/menu.js b/emscripten/project/purr-data/components/menu/menu.js index 6d8f89eed..9f4b3e13c 100644 --- a/emscripten/project/purr-data/components/menu/menu.js +++ b/emscripten/project/purr-data/components/menu/menu.js @@ -4,649 +4,649 @@ const l = pdbundle.pdgui.get_local_string; // For menu names let prev_menu_clicked; function menu_section_click(id) { - // Hide previous menu clicked - if (prev_menu_clicked !== undefined) { - const prev = document.getElementById(prev_menu_clicked); - if (prev) { - prev.querySelectorAll('ul')[0].style.display = 'none'; + // Hide previous menu clicked + if (prev_menu_clicked !== undefined) { + const prev = document.getElementById(prev_menu_clicked); + if (prev) { + prev.querySelectorAll('ul')[0].style.display = 'none'; + } } - } - // Show the current menu options - const m_option = document.getElementById(id); - m_option.querySelectorAll('ul')[0].style.display = 'block'; + // Show the current menu options + const m_option = document.getElementById(id); + m_option.querySelectorAll('ul')[0].style.display = 'block'; - // Listen to clicks on the page so can close the menu - document.onclick = function (e) { - if (e.target.id !== id) { - m_option.querySelectorAll('ul')[0].style.display = 'none'; - prev_menu_clicked = undefined; - } - }; + // Listen to clicks on the page so can close the menu + document.onclick = function (e) { + if (e.target.id !== id) { + m_option.querySelectorAll('ul')[0].style.display = 'none'; + prev_menu_clicked = undefined; + } + }; - // Update the previous menu clicked - prev_menu_clicked = id; + // Update the previous menu clicked + prev_menu_clicked = id; } function menu_section_move(id) { - if (prev_menu_clicked !== undefined) { - if (prev_menu_clicked !== id) { - menu_section_click(id); + if (prev_menu_clicked !== undefined) { + if (prev_menu_clicked !== id) { + menu_section_click(id); + } } - } } function menu_options(type, w, cid) { - if (cid === undefined) cid = ''; - tmp_cid = cid; - - const file_base = { - // File section - 'menu-file': { - label: l('menu.file'), - action: { - onclick() { menu_section_click('menu-file' + cid); }, - onmousemove() { menu_section_move('menu-file' + cid); }, - }, - }, - - 'file-message': { - label: l('menu.message'), - key: pdbundle.shortcuts.menu.message_web.key, - modifiers: pdbundle.shortcuts.menu.message_web.modifiers, - tooltip: l('menu.message_tt'), - bottom_hr: {}, - }, - }; - - const edit_base = { - - // Edit section - 'menu-edit': { - label: l('menu.edit'), - action: { - onclick() { menu_section_click('menu-edit' + cid); }, - onmousemove() { menu_section_move('menu-edit' + cid); }, - }, - }, - - // Edit entries - 'edit-copy': { - label: l('menu.copy'), - key: pdbundle.shortcuts.menu.copy_web.key, - modifiers: pdbundle.shortcuts.menu.copy_web.modifiers, - tooltip: l('menu.copy_tt'), - }, - 'edit-selectall': { - label: l('menu.selectall'), - key: pdbundle.shortcuts.menu.selectall_web.key, - modifiers: pdbundle.shortcuts.menu.selectall_web.modifiers, - tooltip: l('menu.selectall_tt'), - }, - 'edit-find': { - label: l('menu.find'), - key: pdbundle.shortcuts.menu.find_web.key, - modifiers: pdbundle.shortcuts.menu.find_web.modifiers, - tooltip: l('menu.find_tt'), - }, - - }; - - const view_base = { - // View section - 'menu-view': { - label: l('menu.view'), - action: { - onclick() { menu_section_click('menu-view' + cid); }, - onmousemove() { menu_section_move('menu-view' + cid); }, - }, - }, - - // View entries - 'view-zoomin': { - label: l('menu.zoomin'), - key: pdbundle.shortcuts.menu.zoomin_web.key, - modifiers: pdbundle.shortcuts.menu.zoomin_web.modifiers, - tooltip: l('menu.zoomin_tt'), - }, - 'view-zoomout': { - label: l('menu.zoomout'), - key: pdbundle.shortcuts.menu.zoomout_web.key, - modifiers: pdbundle.shortcuts.menu.zoomout_web.modifiers, - tooltip: l('menu.zoomout_tt'), - }, - 'view-zoomreset': { - label: l('menu.zoomreset'), - key: pdbundle.shortcuts.menu.zoomreset_web.key, - modifiers: pdbundle.shortcuts.menu.zoomreset_web.modifiers, - tooltip: l('menu.zoomreset_tt'), - top_hr: {}, - }, - 'view-fullscreen': { - label: l('menu.fullscreen'), - key: pdbundle.shortcuts.menu.fullscreen_web.key, - modifiers: pdbundle.shortcuts.menu.fullscreen_web.modifiers, - tooltip: l('menu.fullscreen_tt'), - top_hr: {}, - }, - }; - - const window_base = { - // Window section - 'menu-window': { - label: l('menu.windows'), - action: { - onclick() { menu_section_click('menu-window' + cid); }, - onmousemove() { menu_section_move('menu-window' + cid); }, - }, - }, - - // Window entries - 'window-nextwin': { - action: { onclick() { pdbundle.pdgui.raise_next('pd_window'); } }, - label: l('menu.nextwin'), - key: pdbundle.shortcuts.menu.nextwin_web.key, - modifiers: pdbundle.shortcuts.menu.nextwin_web.modifiers, - tooltip: l('menu.nextwin_tt'), - }, - 'window-prevwin': { - action: { onclick() { pdbundle.pdgui.raise_prev('pd_window'); } }, - label: l('menu.prevwin'), - key: pdbundle.shortcuts.menu.prevwin_web.key, - modifiers: pdbundle.shortcuts.menu.prevwin_web.modifiers, - tooltip: l('menu.prevwin_tt'), - }, - }; - - const console_menu_base = { - // File - ...file_base, - - // File entries - 'file-new': { - action: { onclick: pdbundle.pdgui.menu_new }, - label: l('menu.new'), - key: pdbundle.shortcuts.menu.new_web.key, - modifiers: pdbundle.shortcuts.menu.new_web.modifiers, - tooltip: l('menu.new_tt'), - }, - - 'file-open': { - label: l('menu.open'), - key: pdbundle.shortcuts.menu.open_web.key, - modifiers: pdbundle.shortcuts.menu.open_web.modifiers, - tooltip: l('menu.open_tt'), - }, - - // Edit - ...edit_base, - // Edit entries - 'edit-clear-console': { - action: { onclick: pdbundle.pdgui.clear_console }, - label: l('menu.clear_console'), - tooltip: l('menu.clear_console'), - key: pdbundle.shortcuts.menu.clear_console_web.key, - modifiers: pdbundle.shortcuts.menu.clear_console_web.modifiers, - top_hr: {}, - bottom_hr: {}, - }, - 'edit-preferences': { - action: { onclick: pdbundle.pdgui.open_prefs }, - label: l('menu.preferences'), - key: pdbundle.shortcuts.menu.preferences_web.key, - modifiers: pdbundle.shortcuts.menu.preferences_web.modifiers, - tooltip: l('menu.preferences_tt'), - }, - - // View - ...view_base, - - // Media section - 'menu-media': { - label: l('menu.media'), - action: { - onclick() { menu_section_click('menu-media' + cid); }, - onmousemove() { menu_section_move('menu-media' + cid); }, - }, - }, - - // Media entries - 'media-audio-on': { - action: { onclick() { pdbundle.pdgui.pdsend('pd dsp 1'); } }, - label: l('menu.audio_on'), - key: pdbundle.shortcuts.menu.audio_on_web.key, - modifiers: pdbundle.shortcuts.menu.audio_on_web.modifiers, - tooltip: l('menu.audio_on_tt'), - }, - 'media-audio-off': { - action: { onclick() { pdbundle.pdgui.pdsend('pd dsp 0'); } }, - label: l('menu.audio_off'), - key: pdbundle.shortcuts.menu.audio_off_web.key, - modifiers: pdbundle.shortcuts.menu.audio_off_web.modifiers, - tooltip: l('menu.audio_off_tt'), - bottom_hr: {}, - }, - 'media-test': { - action: { onclick() { pdbundle.pdgui.pd_doc_open('doc/7.stuff/tools', 'testtone.pd'); } }, - label: l('menu.test'), - tooltip: l('menu.test_tt'), - }, - 'media-loadmeter': { - action: { onclick() { pdbundle.pdgui.pd_doc_open('doc/7.stuff/tools', 'load-meter.pd'); } }, - label: l('menu.loadmeter'), - tooltip: l('menu.loadmeter_tt'), - }, - - // Window - ...window_base, - - // Help section - 'menu-help': { - label: l('menu.help'), - action: { - onclick() { menu_section_click('menu-help' + cid); }, - onmousemove() { menu_section_move('menu-help' + cid); }, - }, - }, - - // Help entries - 'help-about': { - action: { onclick() { pdbundle.pdgui.web_pd_doc_open('doc/about', 'about.pd'); } }, - label: l('menu.about'), - tooltip: l('menu.about_tt'), - }, - 'help-manual': { - action: { onclick() { pdbundle.pdgui.pd_doc_open('doc/1.manual', 'index.htm'); } }, - label: l('menu.manual'), - tooltip: l('menu.manual_tt'), - }, - 'help-browser': { - action: { onclick: pdbundle.pdgui.open_search }, - label: l('menu.browser'), - key: pdbundle.shortcuts.menu.browser_web.key, - modifiers: pdbundle.shortcuts.menu.browser_web.modifiers, - tooltip: l('menu.browser_tt'), - }, - 'help-intro': { - action: { onclick() { pdbundle.pdgui.pd_doc_open('doc/5.reference', 'help-intro.pd'); } }, - label: l('menu.intro'), - tooltip: l('menu.intro_tt'), - bottom_hr: {}, - }, - 'help-l2ork-list': { - action: { onclick() { pdbundle.pdgui.external_doc_open('http://disis.music.vt.edu/listinfo/l2ork-dev'); } }, - label: l('menu.l2ork_list'), - tooltip: l('menu.l2ork_list_tt'), - }, - 'help-pd-list': { - action: { onclick() { pdbundle.pdgui.external_doc_open('http://puredata.info/community/lists'); } }, - label: l('menu.pd_list'), - tooltip: l('menu.pd_list_tt'), - }, - 'help-forums': { - action: { onclick() { pdbundle.pdgui.external_doc_open('http://forum.pdpatchrepo.info/'); } }, - label: l('menu.forums'), - tooltip: l('menu.forums_tt'), - }, - 'help-irc': { - action: { onclick() { pdbundle.pdgui.external_doc_open('http://puredata.info/community/IRC'); } }, - label: l('menu.irc'), - tooltip: l('menu.irc_tt'), - }, - }; - - const console_menu = { - ...console_menu_base, - - 'file-recent-files': { - recent_files: w.document.getElementById('file-recent-files'), //pass the recent files element holder - label: l('menu.recent_files'), - tooltip: l('menu.recent_files_tt'), - bottom_hr: {}, - }, - - // Help entries - 'help-devtools': { - label: l('menu.devtools'), - tooltip: l('menu.devtools_tt'), - }, - - }; - - const canvas_menu_base = { - // File section - ...file_base, - // File entries - 'file-save': { - label: l('menu.save'), - key: pdbundle.shortcuts.menu.save_web.key, - modifiers: pdbundle.shortcuts.menu.save_web.modifiers, - tooltip: l('menu.save_tt'), - }, - 'file-saveas': { - label: l('menu.saveas'), - key: pdbundle.shortcuts.menu.saveas_web.key, - modifiers: pdbundle.shortcuts.menu.saveas_web.modifiers, - tooltip: l('menu.saveas_tt'), - }, - 'file-print': { - label: l('menu.print'), - key: pdbundle.shortcuts.menu.print_web.key, - modifiers: pdbundle.shortcuts.menu.print_web.modifiers, - tooltip: l('menu.print_tt'), - bottom_hr: {}, - }, - 'file-close': { - label: l('menu.close'), - key: pdbundle.shortcuts.menu.close_web.key, - modifiers: pdbundle.shortcuts.menu.close_web.modifiers, - tooltip: l('menu.close_tt'), - }, - - // Edit section - ...edit_base, - - // Edit entries - 'edit-undo': { - label: l('menu.undo'), - tooltip: l('menu.undo_tt'), - key: pdbundle.shortcuts.menu.undo_web.key, - modifiers: pdbundle.shortcuts.menu.undo_web.modifiers, - }, - 'edit-redo': { - label: l('menu.redo'), - tooltip: l('menu.redo_tt'), - key: pdbundle.shortcuts.menu.redo_web.key, - modifiers: pdbundle.shortcuts.menu.redo_web.modifiers, - bottom_hr: {}, - }, - 'edit-cut': { - label: l('menu.cut'), - key: pdbundle.shortcuts.menu.cut_web.key, - modifiers: pdbundle.shortcuts.menu.cut_web.modifiers, - tooltip: l('menu.cut_tt'), - }, - 'edit-paste': { - label: l('menu.paste'), - key: pdbundle.shortcuts.menu.paste_web.key, - modifiers: pdbundle.shortcuts.menu.paste_web.modifiers, - tooltip: l('menu.paste_tt'), - }, - 'edit-paste-clipboard': { - label: l('menu.paste_clipboard'), - key: pdbundle.shortcuts.menu.paste_clipboard_web.key, - modifiers: pdbundle.shortcuts.menu.paste_clipboard_web.modifiers, - tooltip: l('menu.paste_clipboard_tt'), - }, - 'edit-duplicate': { - label: l('menu.duplicate'), - key: pdbundle.shortcuts.menu.duplicate_web.key, - modifiers: pdbundle.shortcuts.menu.duplicate_web.modifiers, - tooltip: l('menu.duplicate_tt'), - }, - 'edit-reselect': { - label: l('menu.reselect'), - key: pdbundle.shortcuts.menu.reselect_web.key, - modifiers: pdbundle.shortcuts.menu.reselect_web.modifiers, - tooltip: l('menu.reselect_tt'), - }, - 'edit-tidyup': { - label: l('menu.tidyup'), - key: pdbundle.shortcuts.menu.tidyup_web.key, - modifiers: pdbundle.shortcuts.menu.tidyup_web.modifiers, - tooltip: l('menu.tidyup_tt'), - }, - 'edit-font': { - label: l('menu.font'), - tooltip: l('menu.font_tt'), - }, - 'edit-cordinspector': { - label: l('menu.cordinspector'), - key: pdbundle.shortcuts.menu.cordinspector_web.key, - modifiers: pdbundle.shortcuts.menu.cordinspector_web.modifiers, - tooltip: l('menu.cordinspector_tt'), - bottom_hr: {}, - }, - 'edit-findagain': { - label: l('menu.findagain'), - key: pdbundle.shortcuts.menu.findagain_web.key, - modifiers: pdbundle.shortcuts.menu.findagain_web.modifiers, - tooltip: l('menu.findagain'), - }, - 'edit-finderror': { - action: { onclick() { pdbundle.pdgui.pdsend('pd finderror'); } }, - label: l('menu.finderror'), - tooltip: l('menu.finderror_tt'), - bottom_hr: {}, - }, - - 'edit-editmode': { - label: l('menu.editmode'), - key: pdbundle.shortcuts.menu.editmode_web.key, - modifiers: pdbundle.shortcuts.menu.editmode_web.modifiers, - tooltip: l('menu.editmode_tt'), - bottom_hr: {}, - }, - - // View section - ...view_base, - - // View entries - 'view-optimalzoom': { - label: l('menu.zoomoptimal'), - key: pdbundle.shortcuts.menu.zoomoptimal_web.key, - modifiers: pdbundle.shortcuts.menu.zoomoptimal_web.modifiers, - tooltip: l('menu.zoomoptimal_tt'), - }, - 'view-horizzoom': { - label: l('menu.zoomhoriz'), - key: pdbundle.shortcuts.menu.zoomhoriz_web.key, - modifiers: pdbundle.shortcuts.menu.zoomhoriz_web.modifiers, - tooltip: l('menu.zoomhoriz_tt'), - }, - 'view-vertzoom': { - label: l('menu.zoomvert'), - key: pdbundle.shortcuts.menu.zoomvert_web.key, - modifiers: pdbundle.shortcuts.menu.zoomvert_web.modifiers, - tooltip: l('menu.zoomvert_tt'), - }, - - // Put section - 'menu-put': { - label: l('menu.put'), - action: { - onclick() { menu_section_click('menu-put' + cid); }, - onmousemove() { menu_section_move('menu-put' + cid); }, - }, - }, - - // Put entries - 'put-object': { - label: l('menu.object'), - key: pdbundle.shortcuts.menu.object_web.key, - modifiers: pdbundle.shortcuts.menu.object_web.modifiers, - tooltip: l('menu.object_tt'), - }, - 'put-msgbox': { - label: l('menu.msgbox'), - key: pdbundle.shortcuts.menu.msgbox_web.key, - modifiers: pdbundle.shortcuts.menu.msgbox_web.modifiers, - tooltip: l('menu.msgbox_tt'), - }, - 'put-number': { - label: l('menu.number'), - key: pdbundle.shortcuts.menu.number_web.key, - modifiers: pdbundle.shortcuts.menu.number_web.modifiers, - tooltip: l('menu.number_tt'), - }, - 'put-symbol': { - label: l('menu.symbol'), - key: pdbundle.shortcuts.menu.symbol_web.key, - modifiers: pdbundle.shortcuts.menu.symbol_web.modifiers, - tooltip: l('menu.symbol_tt'), - }, - 'put-comment': { - label: l('menu.comment'), - key: pdbundle.shortcuts.menu.comment_web.key, - modifiers: pdbundle.shortcuts.menu.comment_web.modifiers, - tooltip: l('menu.comment_tt'), - }, - 'put-dropdown': { - label: l('menu.dropdown'), - key: pdbundle.shortcuts.menu.dropdown_web.key, - modifiers: pdbundle.shortcuts.menu.dropdown_web.modifiers, - tooltip: l('menu.dropdown_tt'), - bottom_hr: {}, - }, - 'put-bang': { - label: l('menu.bang'), - key: pdbundle.shortcuts.menu.bang_web.key, - modifiers: pdbundle.shortcuts.menu.bang_web.modifiers, - tooltip: l('menu.bang_tt'), - }, - 'put-toggle': { - label: l('menu.toggle'), - key: pdbundle.shortcuts.menu.toggle_web.key, - modifiers: pdbundle.shortcuts.menu.toggle_web.modifiers, - tooltip: l('menu.toggle_tt'), - }, - 'put-number2': { - label: l('menu.number2'), - key: pdbundle.shortcuts.menu.number2_web.key, - modifiers: pdbundle.shortcuts.menu.number2_web.modifiers, - tooltip: l('menu.number2'), - }, - 'put-vslider': { - label: l('menu.vslider'), - key: pdbundle.shortcuts.menu.vslider_web.key, - modifiers: pdbundle.shortcuts.menu.vslider_web.modifiers, - tooltip: l('menu.vslider_tt'), - }, - 'put-hslider': { - label: l('menu.hslider'), - key: pdbundle.shortcuts.menu.hslider_web.key, - modifiers: pdbundle.shortcuts.menu.hslider_web.modifiers, - tooltip: l('menu.hslider_tt'), - }, - 'put-vradio': { - label: l('menu.vradio'), - key: pdbundle.shortcuts.menu.vradio_web.key, - modifiers: pdbundle.shortcuts.menu.vradio_web.modifiers, - tooltip: l('menu.vradio_tt'), - }, - 'put-hradio': { - label: l('menu.hradio'), - key: pdbundle.shortcuts.menu.hradio_web.key, - modifiers: pdbundle.shortcuts.menu.hradio_web.modifiers, - tooltip: l('menu.hradio_tt'), - }, - 'put-vu': { - label: l('menu.vu'), - key: pdbundle.shortcuts.menu.vu_web.key, - modifiers: pdbundle.shortcuts.menu.vu_web.modifiers, - tooltip: l('menu.vu_tt'), - }, - 'put-cnv': { - label: l('menu.cnv'), - key: pdbundle.shortcuts.menu.cnv_web.key, - modifiers: pdbundle.shortcuts.menu.cnv_web.modifiers, - tooltip: l('menu.cnv_tt'), - bottom_hr: {}, - }, - 'put-array': { - label: l('menu.array'), - tooltip: l('menu.array_tt'), - }, - - // Window section - ...window_base, - - // Window entries - 'window-parentwin': { - label: l('menu.parentwin'), - tooltip: l('menu.parentwin_tt'), - top_hr: {}, - }, - 'window-visible-ancestor': { - label: l('menu.visible_ancestor'), - tooltip: l('menu.visible_ancestor_tt'), - }, - 'window-pdwin': { - action: { onclick() { pdbundle.pdgui.raise_pd_window(); } }, - label: l('menu.pdwin'), - tooltip: l('menu.pdwin_tt'), - key: pdbundle.shortcuts.menu.pdwin_web.key, - modifiers: pdbundle.shortcuts.menu.pdwin_web.modifiers, - }, - }; - - const canvas_menu = { - ...console_menu, - ...canvas_menu_base, - }; - - const web_menu = { - ...console_menu_base, - }; + if (cid === undefined) cid = ''; + tmp_cid = cid; + + const file_base = { + // File section + 'menu-file': { + label: l('menu.file'), + action: { + onclick() { menu_section_click('menu-file' + cid); }, + onmousemove() { menu_section_move('menu-file' + cid); }, + }, + }, + + 'file-message': { + label: l('menu.message'), + key: pdbundle.shortcuts.menu.message_web.key, + modifiers: pdbundle.shortcuts.menu.message_web.modifiers, + tooltip: l('menu.message_tt'), + bottom_hr: {}, + }, + }; + + const edit_base = { + + // Edit section + 'menu-edit': { + label: l('menu.edit'), + action: { + onclick() { menu_section_click('menu-edit' + cid); }, + onmousemove() { menu_section_move('menu-edit' + cid); }, + }, + }, + + // Edit entries + 'edit-copy': { + label: l('menu.copy'), + key: pdbundle.shortcuts.menu.copy_web.key, + modifiers: pdbundle.shortcuts.menu.copy_web.modifiers, + tooltip: l('menu.copy_tt'), + }, + 'edit-selectall': { + label: l('menu.selectall'), + key: pdbundle.shortcuts.menu.selectall_web.key, + modifiers: pdbundle.shortcuts.menu.selectall_web.modifiers, + tooltip: l('menu.selectall_tt'), + }, + 'edit-find': { + label: l('menu.find'), + key: pdbundle.shortcuts.menu.find_web.key, + modifiers: pdbundle.shortcuts.menu.find_web.modifiers, + tooltip: l('menu.find_tt'), + }, + + }; + + const view_base = { + // View section + 'menu-view': { + label: l('menu.view'), + action: { + onclick() { menu_section_click('menu-view' + cid); }, + onmousemove() { menu_section_move('menu-view' + cid); }, + }, + }, + + // View entries + 'view-zoomin': { + label: l('menu.zoomin'), + key: pdbundle.shortcuts.menu.zoomin_web.key, + modifiers: pdbundle.shortcuts.menu.zoomin_web.modifiers, + tooltip: l('menu.zoomin_tt'), + }, + 'view-zoomout': { + label: l('menu.zoomout'), + key: pdbundle.shortcuts.menu.zoomout_web.key, + modifiers: pdbundle.shortcuts.menu.zoomout_web.modifiers, + tooltip: l('menu.zoomout_tt'), + }, + 'view-zoomreset': { + label: l('menu.zoomreset'), + key: pdbundle.shortcuts.menu.zoomreset_web.key, + modifiers: pdbundle.shortcuts.menu.zoomreset_web.modifiers, + tooltip: l('menu.zoomreset_tt'), + top_hr: {}, + }, + 'view-fullscreen': { + label: l('menu.fullscreen'), + key: pdbundle.shortcuts.menu.fullscreen_web.key, + modifiers: pdbundle.shortcuts.menu.fullscreen_web.modifiers, + tooltip: l('menu.fullscreen_tt'), + top_hr: {}, + }, + }; + + const window_base = { + // Window section + 'menu-window': { + label: l('menu.windows'), + action: { + onclick() { menu_section_click('menu-window' + cid); }, + onmousemove() { menu_section_move('menu-window' + cid); }, + }, + }, + + // Window entries + 'window-nextwin': { + action: { onclick() { pdbundle.pdgui.raise_next('pd_window'); } }, + label: l('menu.nextwin'), + key: pdbundle.shortcuts.menu.nextwin_web.key, + modifiers: pdbundle.shortcuts.menu.nextwin_web.modifiers, + tooltip: l('menu.nextwin_tt'), + }, + 'window-prevwin': { + action: { onclick() { pdbundle.pdgui.raise_prev('pd_window'); } }, + label: l('menu.prevwin'), + key: pdbundle.shortcuts.menu.prevwin_web.key, + modifiers: pdbundle.shortcuts.menu.prevwin_web.modifiers, + tooltip: l('menu.prevwin_tt'), + }, + }; + + const console_menu_base = { + // File + ...file_base, + + // File entries + 'file-new': { + action: { onclick: pdbundle.pdgui.menu_new }, + label: l('menu.new'), + key: pdbundle.shortcuts.menu.new_web.key, + modifiers: pdbundle.shortcuts.menu.new_web.modifiers, + tooltip: l('menu.new_tt'), + }, + + 'file-open': { + label: l('menu.open'), + key: pdbundle.shortcuts.menu.open_web.key, + modifiers: pdbundle.shortcuts.menu.open_web.modifiers, + tooltip: l('menu.open_tt'), + }, + + // Edit + ...edit_base, + // Edit entries + 'edit-clear-console': { + action: { onclick: pdbundle.pdgui.clear_console }, + label: l('menu.clear_console'), + tooltip: l('menu.clear_console'), + key: pdbundle.shortcuts.menu.clear_console_web.key, + modifiers: pdbundle.shortcuts.menu.clear_console_web.modifiers, + top_hr: {}, + bottom_hr: {}, + }, + 'edit-preferences': { + action: { onclick: pdbundle.pdgui.open_prefs }, + label: l('menu.preferences'), + key: pdbundle.shortcuts.menu.preferences_web.key, + modifiers: pdbundle.shortcuts.menu.preferences_web.modifiers, + tooltip: l('menu.preferences_tt'), + }, + + // View + ...view_base, + + // Media section + 'menu-media': { + label: l('menu.media'), + action: { + onclick() { menu_section_click('menu-media' + cid); }, + onmousemove() { menu_section_move('menu-media' + cid); }, + }, + }, + + // Media entries + 'media-audio-on': { + action: { onclick() { pdbundle.pdgui.pdsend('pd dsp 1'); } }, + label: l('menu.audio_on'), + key: pdbundle.shortcuts.menu.audio_on_web.key, + modifiers: pdbundle.shortcuts.menu.audio_on_web.modifiers, + tooltip: l('menu.audio_on_tt'), + }, + 'media-audio-off': { + action: { onclick() { pdbundle.pdgui.pdsend('pd dsp 0'); } }, + label: l('menu.audio_off'), + key: pdbundle.shortcuts.menu.audio_off_web.key, + modifiers: pdbundle.shortcuts.menu.audio_off_web.modifiers, + tooltip: l('menu.audio_off_tt'), + bottom_hr: {}, + }, + 'media-test': { + action: { onclick() { pdbundle.pdgui.pd_doc_open('doc/7.stuff/tools', 'testtone.pd'); } }, + label: l('menu.test'), + tooltip: l('menu.test_tt'), + }, + 'media-loadmeter': { + action: { onclick() { pdbundle.pdgui.pd_doc_open('doc/7.stuff/tools', 'load-meter.pd'); } }, + label: l('menu.loadmeter'), + tooltip: l('menu.loadmeter_tt'), + }, + + // Window + ...window_base, + + // Help section + 'menu-help': { + label: l('menu.help'), + action: { + onclick() { menu_section_click('menu-help' + cid); }, + onmousemove() { menu_section_move('menu-help' + cid); }, + }, + }, + + // Help entries + 'help-about': { + action: { onclick() { pdbundle.pdgui.web_pd_doc_open('doc/about', 'about.pd'); } }, + label: l('menu.about'), + tooltip: l('menu.about_tt'), + }, + 'help-manual': { + action: { onclick() { pdbundle.pdgui.pd_doc_open('doc/1.manual', 'index.htm'); } }, + label: l('menu.manual'), + tooltip: l('menu.manual_tt'), + }, + 'help-browser': { + action: { onclick: pdbundle.pdgui.open_search }, + label: l('menu.browser'), + key: pdbundle.shortcuts.menu.browser_web.key, + modifiers: pdbundle.shortcuts.menu.browser_web.modifiers, + tooltip: l('menu.browser_tt'), + }, + 'help-intro': { + action: { onclick() { pdbundle.pdgui.pd_doc_open('doc/5.reference', 'help-intro.pd'); } }, + label: l('menu.intro'), + tooltip: l('menu.intro_tt'), + bottom_hr: {}, + }, + 'help-l2ork-list': { + action: { onclick() { pdbundle.pdgui.external_doc_open('http://disis.music.vt.edu/listinfo/l2ork-dev'); } }, + label: l('menu.l2ork_list'), + tooltip: l('menu.l2ork_list_tt'), + }, + 'help-pd-list': { + action: { onclick() { pdbundle.pdgui.external_doc_open('http://puredata.info/community/lists'); } }, + label: l('menu.pd_list'), + tooltip: l('menu.pd_list_tt'), + }, + 'help-forums': { + action: { onclick() { pdbundle.pdgui.external_doc_open('http://forum.pdpatchrepo.info/'); } }, + label: l('menu.forums'), + tooltip: l('menu.forums_tt'), + }, + 'help-irc': { + action: { onclick() { pdbundle.pdgui.external_doc_open('http://puredata.info/community/IRC'); } }, + label: l('menu.irc'), + tooltip: l('menu.irc_tt'), + }, + }; + + const console_menu = { + ...console_menu_base, + + 'file-recent-files': { + recent_files: w.document.getElementById('file-recent-files'), //pass the recent files element holder + label: l('menu.recent_files'), + tooltip: l('menu.recent_files_tt'), + bottom_hr: {}, + }, + + // Help entries + 'help-devtools': { + label: l('menu.devtools'), + tooltip: l('menu.devtools_tt'), + }, + + }; + + const canvas_menu_base = { + // File section + ...file_base, + // File entries + 'file-save': { + label: l('menu.save'), + key: pdbundle.shortcuts.menu.save_web.key, + modifiers: pdbundle.shortcuts.menu.save_web.modifiers, + tooltip: l('menu.save_tt'), + }, + 'file-saveas': { + label: l('menu.saveas'), + key: pdbundle.shortcuts.menu.saveas_web.key, + modifiers: pdbundle.shortcuts.menu.saveas_web.modifiers, + tooltip: l('menu.saveas_tt'), + }, + 'file-print': { + label: l('menu.print'), + key: pdbundle.shortcuts.menu.print_web.key, + modifiers: pdbundle.shortcuts.menu.print_web.modifiers, + tooltip: l('menu.print_tt'), + bottom_hr: {}, + }, + 'file-close': { + label: l('menu.close'), + key: pdbundle.shortcuts.menu.close_web.key, + modifiers: pdbundle.shortcuts.menu.close_web.modifiers, + tooltip: l('menu.close_tt'), + }, + + // Edit section + ...edit_base, + + // Edit entries + 'edit-undo': { + label: l('menu.undo'), + tooltip: l('menu.undo_tt'), + key: pdbundle.shortcuts.menu.undo_web.key, + modifiers: pdbundle.shortcuts.menu.undo_web.modifiers, + }, + 'edit-redo': { + label: l('menu.redo'), + tooltip: l('menu.redo_tt'), + key: pdbundle.shortcuts.menu.redo_web.key, + modifiers: pdbundle.shortcuts.menu.redo_web.modifiers, + bottom_hr: {}, + }, + 'edit-cut': { + label: l('menu.cut'), + key: pdbundle.shortcuts.menu.cut_web.key, + modifiers: pdbundle.shortcuts.menu.cut_web.modifiers, + tooltip: l('menu.cut_tt'), + }, + 'edit-paste': { + label: l('menu.paste'), + key: pdbundle.shortcuts.menu.paste_web.key, + modifiers: pdbundle.shortcuts.menu.paste_web.modifiers, + tooltip: l('menu.paste_tt'), + }, + 'edit-paste-clipboard': { + label: l('menu.paste_clipboard'), + key: pdbundle.shortcuts.menu.paste_clipboard_web.key, + modifiers: pdbundle.shortcuts.menu.paste_clipboard_web.modifiers, + tooltip: l('menu.paste_clipboard_tt'), + }, + 'edit-duplicate': { + label: l('menu.duplicate'), + key: pdbundle.shortcuts.menu.duplicate_web.key, + modifiers: pdbundle.shortcuts.menu.duplicate_web.modifiers, + tooltip: l('menu.duplicate_tt'), + }, + 'edit-reselect': { + label: l('menu.reselect'), + key: pdbundle.shortcuts.menu.reselect_web.key, + modifiers: pdbundle.shortcuts.menu.reselect_web.modifiers, + tooltip: l('menu.reselect_tt'), + }, + 'edit-tidyup': { + label: l('menu.tidyup'), + key: pdbundle.shortcuts.menu.tidyup_web.key, + modifiers: pdbundle.shortcuts.menu.tidyup_web.modifiers, + tooltip: l('menu.tidyup_tt'), + }, + 'edit-font': { + label: l('menu.font'), + tooltip: l('menu.font_tt'), + }, + 'edit-cordinspector': { + label: l('menu.cordinspector'), + key: pdbundle.shortcuts.menu.cordinspector_web.key, + modifiers: pdbundle.shortcuts.menu.cordinspector_web.modifiers, + tooltip: l('menu.cordinspector_tt'), + bottom_hr: {}, + }, + 'edit-findagain': { + label: l('menu.findagain'), + key: pdbundle.shortcuts.menu.findagain_web.key, + modifiers: pdbundle.shortcuts.menu.findagain_web.modifiers, + tooltip: l('menu.findagain'), + }, + 'edit-finderror': { + action: { onclick() { pdbundle.pdgui.pdsend('pd finderror'); } }, + label: l('menu.finderror'), + tooltip: l('menu.finderror_tt'), + bottom_hr: {}, + }, + + 'edit-editmode': { + label: l('menu.editmode'), + key: pdbundle.shortcuts.menu.editmode_web.key, + modifiers: pdbundle.shortcuts.menu.editmode_web.modifiers, + tooltip: l('menu.editmode_tt'), + bottom_hr: {}, + }, + + // View section + ...view_base, + + // View entries + 'view-optimalzoom': { + label: l('menu.zoomoptimal'), + key: pdbundle.shortcuts.menu.zoomoptimal_web.key, + modifiers: pdbundle.shortcuts.menu.zoomoptimal_web.modifiers, + tooltip: l('menu.zoomoptimal_tt'), + }, + 'view-horizzoom': { + label: l('menu.zoomhoriz'), + key: pdbundle.shortcuts.menu.zoomhoriz_web.key, + modifiers: pdbundle.shortcuts.menu.zoomhoriz_web.modifiers, + tooltip: l('menu.zoomhoriz_tt'), + }, + 'view-vertzoom': { + label: l('menu.zoomvert'), + key: pdbundle.shortcuts.menu.zoomvert_web.key, + modifiers: pdbundle.shortcuts.menu.zoomvert_web.modifiers, + tooltip: l('menu.zoomvert_tt'), + }, + + // Put section + 'menu-put': { + label: l('menu.put'), + action: { + onclick() { menu_section_click('menu-put' + cid); }, + onmousemove() { menu_section_move('menu-put' + cid); }, + }, + }, + + // Put entries + 'put-object': { + label: l('menu.object'), + key: pdbundle.shortcuts.menu.object_web.key, + modifiers: pdbundle.shortcuts.menu.object_web.modifiers, + tooltip: l('menu.object_tt'), + }, + 'put-msgbox': { + label: l('menu.msgbox'), + key: pdbundle.shortcuts.menu.msgbox_web.key, + modifiers: pdbundle.shortcuts.menu.msgbox_web.modifiers, + tooltip: l('menu.msgbox_tt'), + }, + 'put-number': { + label: l('menu.number'), + key: pdbundle.shortcuts.menu.number_web.key, + modifiers: pdbundle.shortcuts.menu.number_web.modifiers, + tooltip: l('menu.number_tt'), + }, + 'put-symbol': { + label: l('menu.symbol'), + key: pdbundle.shortcuts.menu.symbol_web.key, + modifiers: pdbundle.shortcuts.menu.symbol_web.modifiers, + tooltip: l('menu.symbol_tt'), + }, + 'put-comment': { + label: l('menu.comment'), + key: pdbundle.shortcuts.menu.comment_web.key, + modifiers: pdbundle.shortcuts.menu.comment_web.modifiers, + tooltip: l('menu.comment_tt'), + }, + 'put-dropdown': { + label: l('menu.dropdown'), + key: pdbundle.shortcuts.menu.dropdown_web.key, + modifiers: pdbundle.shortcuts.menu.dropdown_web.modifiers, + tooltip: l('menu.dropdown_tt'), + bottom_hr: {}, + }, + 'put-bang': { + label: l('menu.bang'), + key: pdbundle.shortcuts.menu.bang_web.key, + modifiers: pdbundle.shortcuts.menu.bang_web.modifiers, + tooltip: l('menu.bang_tt'), + }, + 'put-toggle': { + label: l('menu.toggle'), + key: pdbundle.shortcuts.menu.toggle_web.key, + modifiers: pdbundle.shortcuts.menu.toggle_web.modifiers, + tooltip: l('menu.toggle_tt'), + }, + 'put-number2': { + label: l('menu.number2'), + key: pdbundle.shortcuts.menu.number2_web.key, + modifiers: pdbundle.shortcuts.menu.number2_web.modifiers, + tooltip: l('menu.number2'), + }, + 'put-vslider': { + label: l('menu.vslider'), + key: pdbundle.shortcuts.menu.vslider_web.key, + modifiers: pdbundle.shortcuts.menu.vslider_web.modifiers, + tooltip: l('menu.vslider_tt'), + }, + 'put-hslider': { + label: l('menu.hslider'), + key: pdbundle.shortcuts.menu.hslider_web.key, + modifiers: pdbundle.shortcuts.menu.hslider_web.modifiers, + tooltip: l('menu.hslider_tt'), + }, + 'put-vradio': { + label: l('menu.vradio'), + key: pdbundle.shortcuts.menu.vradio_web.key, + modifiers: pdbundle.shortcuts.menu.vradio_web.modifiers, + tooltip: l('menu.vradio_tt'), + }, + 'put-hradio': { + label: l('menu.hradio'), + key: pdbundle.shortcuts.menu.hradio_web.key, + modifiers: pdbundle.shortcuts.menu.hradio_web.modifiers, + tooltip: l('menu.hradio_tt'), + }, + 'put-vu': { + label: l('menu.vu'), + key: pdbundle.shortcuts.menu.vu_web.key, + modifiers: pdbundle.shortcuts.menu.vu_web.modifiers, + tooltip: l('menu.vu_tt'), + }, + 'put-cnv': { + label: l('menu.cnv'), + key: pdbundle.shortcuts.menu.cnv_web.key, + modifiers: pdbundle.shortcuts.menu.cnv_web.modifiers, + tooltip: l('menu.cnv_tt'), + bottom_hr: {}, + }, + 'put-array': { + label: l('menu.array'), + tooltip: l('menu.array_tt'), + }, + + // Window section + ...window_base, + + // Window entries + 'window-parentwin': { + label: l('menu.parentwin'), + tooltip: l('menu.parentwin_tt'), + top_hr: {}, + }, + 'window-visible-ancestor': { + label: l('menu.visible_ancestor'), + tooltip: l('menu.visible_ancestor_tt'), + }, + 'window-pdwin': { + action: { onclick() { pdbundle.pdgui.raise_pd_window(); } }, + label: l('menu.pdwin'), + tooltip: l('menu.pdwin_tt'), + key: pdbundle.shortcuts.menu.pdwin_web.key, + modifiers: pdbundle.shortcuts.menu.pdwin_web.modifiers, + }, + }; + + const canvas_menu = { + ...console_menu, + ...canvas_menu_base, + }; + + const web_menu = { + ...console_menu_base, + }; + + const web_canvas = { + ...canvas_menu_base, + 'file-download': { + label: l('menu.download'), + }, + }; + + + const entries = { + 'console': console_menu, + 'canvas': canvas_menu, + 'web': web_menu, + 'web-canvas': web_canvas, + }; + + // Iteracting over the menu options to set it's args and make it visible + const menu = entries[type]; + + if (cid != '') { + window.shortkeys[cid] = { ...window.shortkeys[''] }; + } else { + window.shortkeys[cid] = {}; + } - const web_canvas = { - ...canvas_menu_base, - 'file-download': { - label: l('menu.download'), - }, - }; - - - const entries = { - 'console': console_menu, - 'canvas': canvas_menu, - 'web': web_menu, - 'web-canvas': web_canvas, - }; - - // Iteracting over the menu options to set it's args and make it visible - const menu = entries[type]; - - if (cid != '') { - window.shortkeys[cid] = { ...window.shortkeys[''] }; - } else { - window.shortkeys[cid] = {}; - } - - for (const id in menu) { - const menu_item = w.document.getElementById(id + cid); - visible(menu_item); - remove_select_text(menu_item); - for (const option in menu[id]) { - window[option](menu_item, menu[id][option]); + for (const id in menu) { + const menu_item = w.document.getElementById(id + cid); + visible(menu_item); + remove_select_text(menu_item); + for (const option in menu[id]) { + window[option](menu_item, menu[id][option]); + } } - } - return menu; + return menu; } // Functions set on args function visible(menu_item) { - menu_item.style.display = 'block'; + menu_item.style.display = 'block'; } function remove_select_text(menu_item) { - menu_item.onselectstart = function (e) { - e.preventDefault(); - }; + menu_item.onselectstart = function (e) { + e.preventDefault(); + }; } window.action = function (menu_item, actions) { - for (const key in actions) { - if (actions.hasOwnProperty(key)) { - menu_item[key] = actions[key]; + for (const key in actions) { + if (actions.hasOwnProperty(key)) { + menu_item[key] = actions[key]; + } } - } }; window.label = function (menu_item, label) { - menu_item.prepend(label); + menu_item.prepend(label); }; // Help vars for shortkey implementation @@ -655,73 +655,73 @@ let tmp_key; let tmp_cid; window.key = function (menu_item, shortkey) { - tmp_key = shortkey; + tmp_key = shortkey; }; window.modifiers = function (menu_item, modifiers) { - const shortkey = modifiers + '+' + tmp_key; - window.shortkeys[[tmp_cid]][[shortkey]] = menu_item; + const shortkey = modifiers + '+' + tmp_key; + window.shortkeys[[tmp_cid]][[shortkey]] = menu_item; - const span = document.createElement('span'); - span.append(shortkey); - menu_item.append(span); + const span = document.createElement('span'); + span.append(shortkey); + menu_item.append(span); }; window.tooltip = function (menu_item, tooltip) { - // console.log("NEED TO IMPLEMENT TOOLTIP", tooltip); + // console.log("NEED TO IMPLEMENT TOOLTIP", tooltip); }; window.recent_files = function (elem) { - const holder = document.createElement('ul'); - pdbundle.pdgui.populate_recent_files(holder); - elem.append(holder); + const holder = document.createElement('ul'); + pdbundle.pdgui.populate_recent_files(holder); + elem.append(holder); }; function elem_hr() { - const li = document.createElement('li'); - li.setAttribute('class', 'hr'); - const hr = document.createElement('hr'); - li.append(hr); + const li = document.createElement('li'); + li.setAttribute('class', 'hr'); + const hr = document.createElement('hr'); + li.append(hr); - return li; + return li; } window.top_hr = function (menu_item, hr) { - var hr = elem_hr(); - visible(hr); - menu_item.before(hr); + var hr = elem_hr(); + visible(hr); + menu_item.before(hr); }; window.bottom_hr = function (menu_item, hr) { - var hr = elem_hr(); - visible(hr); - menu_item.after(hr); + var hr = elem_hr(); + visible(hr); + menu_item.after(hr); }; // Common functions for both menus function open_file(w) { - let input, chooser, - span = w.document.querySelector('#fileDialogSpan'); + let input, chooser, + span = w.document.querySelector('#fileDialogSpan'); // Complicated workaround-- see comment in build_file_dialog_string - input = pdbundle.pdgui.build_file_dialog_string({ - style: 'display: none;', - type: 'file', - id: 'fileDialog', - nwworkingdir: pdbundle.pdgui.get_pd_opendir(), - multiple: null, - // These are copied from pd_filetypes in pdbundle.pdgui.js - accept: '.pd,.pat,.mxt,.mxb,.help', - }); - span.innerHTML = input; - chooser = w.document.querySelector('#fileDialog'); - // Hack-- we have to set the event listener here because we - // changed out the innerHTML above - chooser.onchange = function () { - const file_array = this.value; - // reset value so that we can open the same file twice - this.value = null; - pdbundle.pdgui.menu_open(file_array); - console.log('tried to open something'); - }; - chooser.click(); -} \ No newline at end of file + input = pdbundle.pdgui.build_file_dialog_string({ + style: 'display: none;', + type: 'file', + id: 'fileDialog', + nwworkingdir: pdbundle.pdgui.get_pd_opendir(), + multiple: null, + // These are copied from pd_filetypes in pdbundle.pdgui.js + accept: '.pd,.pat,.mxt,.mxb,.help', + }); + span.innerHTML = input; + chooser = w.document.querySelector('#fileDialog'); + // Hack-- we have to set the event listener here because we + // changed out the innerHTML above + chooser.onchange = function () { + const file_array = this.value; + // reset value so that we can open the same file twice + this.value = null; + pdbundle.pdgui.menu_open(file_array); + console.log('tried to open something'); + }; + chooser.click(); +} -- GitLab