Commit 4d29dbff authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

bite the bullet and use double quotes consistently

parent 30532771
'use strict'; "use strict";
var nw = require('nw.gui'); var nw = require("nw.gui");
console.log(nw.App.argv); console.log(nw.App.argv);
var pdgui = require('./pdgui.js'); var pdgui = require("./pdgui.js");
var port_no = nw.App.argv[0]; // fed to us by the Pd process var port_no = nw.App.argv[0]; // fed to us by the Pd process
var pwd = process.env.PWD; var pwd = process.env.PWD;
pdgui.set_port(port_no); pdgui.set_port(port_no);
...@@ -36,7 +36,7 @@ document.getElementById("dsp_control").addEventListener("click", ...@@ -36,7 +36,7 @@ document.getElementById("dsp_control").addEventListener("click",
} }
); );
var find_bar = document.getElementById('console_find_text'); var find_bar = document.getElementById("console_find_text");
find_bar.addEventListener("keydown", find_bar.addEventListener("keydown",
function(e) { function(e) {
return console_find_keydown(this, e); return console_find_keydown(this, e);
...@@ -101,13 +101,13 @@ function console_unwrap_tag(console_elem, tag_name) { ...@@ -101,13 +101,13 @@ function console_unwrap_tag(console_elem, tag_name) {
} }
function console_find_text(elem, evt, callback) { function console_find_text(elem, evt, callback) {
var console_text = document.getElementById('p1'), var console_text = document.getElementById("p1"),
wrap_tag = 'mark', wrap_tag = "mark",
wrapper_count; wrapper_count;
// Check the input for default text before the event happens // Check the input for default text before the event happens
if (console_find_check_default(elem)) { if (console_find_check_default(elem)) {
// if so, erase it // if so, erase it
elem.value = ''; elem.value = "";
// put this in css and use class here // put this in css and use class here
elem.style.color = "#000"; elem.style.color = "#000";
} }
...@@ -116,11 +116,11 @@ function console_find_text(elem, evt, callback) { ...@@ -116,11 +116,11 @@ function console_find_text(elem, evt, callback) {
// Check after the event if the value is empty, and if // Check after the event if the value is empty, and if
// so set it to default value // so set it to default value
if (elem.value === undefined || elem.value === '') { if (elem.value === undefined || elem.value === "") {
console_find_set_default(elem); console_find_set_default(elem);
} else if (!console_find_check_default(elem)) { } else if (!console_find_check_default(elem)) {
window.findAndReplaceDOMText(console_text, { window.findAndReplaceDOMText(console_text, {
//preset: 'prose', //preset: "prose",
find: elem.value.toLowerCase(), find: elem.value.toLowerCase(),
wrap: wrap_tag wrap: wrap_tag
}); });
...@@ -129,9 +129,9 @@ function console_find_text(elem, evt, callback) { ...@@ -129,9 +129,9 @@ function console_find_text(elem, evt, callback) {
// counting the wrappers! // counting the wrappers!
wrapper_count = console_text.getElementsByTagName(wrap_tag).length; wrapper_count = console_text.getElementsByTagName(wrap_tag).length;
if (wrapper_count < 1) { if (wrapper_count < 1) {
elem.style.setProperty('background', 'red'); elem.style.setProperty("background", "red");
} else { } else {
elem.style.setProperty('background', 'white'); elem.style.setProperty("background", "white");
} }
} }
if (callback) { if (callback) {
...@@ -142,7 +142,7 @@ function console_find_text(elem, evt, callback) { ...@@ -142,7 +142,7 @@ function console_find_text(elem, evt, callback) {
// start at top and highlight the first result after a search // start at top and highlight the first result after a search
function console_find_callback() { function console_find_callback() {
var highlight_checkbox = document.getElementById('console_find_highlight'); var highlight_checkbox = document.getElementById("console_find_highlight");
console_find_highlight_all(highlight_checkbox); console_find_highlight_all(highlight_checkbox);
console_find_traverse.set_index(0); console_find_traverse.set_index(0);
console_find_traverse.next(); console_find_traverse.next();
...@@ -154,10 +154,10 @@ function console_find_keypress(elem, e) { ...@@ -154,10 +154,10 @@ function console_find_keypress(elem, e) {
function console_find_highlight_all(elem) { function console_find_highlight_all(elem) {
var matches, var matches,
highlight_tag = 'console_find_highlighted', highlight_tag = "console_find_highlighted",
state = elem.checked, state = elem.checked,
i, len; i, len;
matches = document.getElementById('p1') matches = document.getElementById("p1")
.getElementsByClassName(highlight_tag); .getElementsByClassName(highlight_tag);
// remember-- matches is a _live_ collection, not an array. // remember-- matches is a _live_ collection, not an array.
// If you remove the highlight_tag from an element, it is // If you remove the highlight_tag from an element, it is
...@@ -169,7 +169,7 @@ function console_find_highlight_all(elem) { ...@@ -169,7 +169,7 @@ function console_find_highlight_all(elem) {
matches[i].classList.remove(highlight_tag); matches[i].classList.remove(highlight_tag);
} }
if (state) { if (state) {
matches = document.getElementById('p1').getElementsByTagName('mark'); matches = document.getElementById("p1").getElementsByTagName("mark");
for (i = 0; i < matches.length; i++) { for (i = 0; i < matches.length; i++) {
matches[i].classList.add(highlight_tag); matches[i].classList.add(highlight_tag);
} }
...@@ -178,20 +178,20 @@ function console_find_highlight_all(elem) { ...@@ -178,20 +178,20 @@ function console_find_highlight_all(elem) {
var console_find_traverse = (function() { var console_find_traverse = (function() {
var count = 0, var count = 0,
console_text = document.getElementById('p1'), console_text = document.getElementById("p1"),
wrap_tag = 'mark'; wrap_tag = "mark";
return { return {
next: function() { next: function() {
var i, last, next, var i, last, next,
elements = console_text.getElementsByTagName(wrap_tag); elements = console_text.getElementsByTagName(wrap_tag);
if (elements.length > 0) { if (elements.length > 0) {
i = count % elements.length; i = count % elements.length;
elements[i].classList.add('console_find_current'); elements[i].classList.add("console_find_current");
if (elements.length > 1) { if (elements.length > 1) {
last = i === 0 ? elements.length - 1 : i - 1; last = i === 0 ? elements.length - 1 : i - 1;
next = (i + 1) % elements.length; next = (i + 1) % elements.length;
elements[last].classList.remove('console_find_current'); elements[last].classList.remove("console_find_current");
elements[next].classList.remove('console_find_current'); elements[next].classList.remove("console_find_current");
} }
// adjust the scrollbar to make sure the element is visible, // adjust the scrollbar to make sure the element is visible,
// but only if necessary. // but only if necessary.
...@@ -296,7 +296,7 @@ function pdmenu_irc () { ...@@ -296,7 +296,7 @@ function pdmenu_irc () {
function nw_create_pd_window_menus () { function nw_create_pd_window_menus () {
// Window menu // Window menu
var windowMenu = new nw.Menu({ var windowMenu = new nw.Menu({
type: 'menubar' type: "menubar"
}); });
// File menu // File menu
...@@ -304,78 +304,78 @@ function nw_create_pd_window_menus () { ...@@ -304,78 +304,78 @@ function nw_create_pd_window_menus () {
// Add to window menu // Add to window menu
windowMenu.append(new nw.MenuItem({ windowMenu.append(new nw.MenuItem({
label: l('menu.file'), label: l("menu.file"),
submenu: fileMenu submenu: fileMenu
})); }));
// File sub-entries // File sub-entries
fileMenu.append(new nw.MenuItem({ fileMenu.append(new nw.MenuItem({
label: l('menu.new'), label: l("menu.new"),
click: pdgui.menu_new, click: pdgui.menu_new,
key: 'n', key: "n",
modifiers: 'ctrl', modifiers: "ctrl",
tooltip: l('menu.new.tt') tooltip: l("menu.new.tt")
})); }));
fileMenu.append(new nw.MenuItem({ fileMenu.append(new nw.MenuItem({
label: l('menu.open'), label: l("menu.open"),
key: 'o', key: "o",
modifiers: "ctrl", modifiers: "ctrl",
tooltip: l('menu.open.tt'), tooltip: l("menu.open.tt"),
click: function (){ click: function (){
var chooser = document.querySelector('#fileDialog'); var chooser = document.querySelector("#fileDialog");
chooser.click(); chooser.click();
} }
})); }));
if (pdgui.k12_mode == 1) { if (pdgui.k12_mode == 1) {
fileMenu.append(new nw.MenuItem({ fileMenu.append(new nw.MenuItem({
label: l('menu.k12.demos'), label: l("menu.k12.demos"),
tooltip: l('menu.k12.demos_tt'), tooltip: l("menu.k12.demos_tt"),
click: pdgui.menu_k12_open_demos click: pdgui.menu_k12_open_demos
})); }));
} }
fileMenu.append(new nw.MenuItem({ fileMenu.append(new nw.MenuItem({
type: 'separator' type: "separator"
})); }));
// Note: this must be different for the main Pd window // Note: this must be different for the main Pd window
fileMenu.append(new nw.MenuItem({ fileMenu.append(new nw.MenuItem({
label: l('menu.save'), label: l("menu.save"),
click: function () {}, click: function () {},
enabled: false, enabled: false,
key: 's', key: "s",
tooltip: l('menu.save.tt'), tooltip: l("menu.save.tt"),
modifiers: "ctrl" modifiers: "ctrl"
})); }));
fileMenu.append(new nw.MenuItem({ fileMenu.append(new nw.MenuItem({
label: l('menu.saveas'), label: l("menu.saveas"),
click: function (){}, click: function (){},
enabled: false, enabled: false,
key: 'S', key: "S",
tooltip: l('menu.saveas_tt'), tooltip: l("menu.saveas_tt"),
modifiers: "ctrl" modifiers: "ctrl"
})); }));
if (pdgui.k12_mode == 0) { if (pdgui.k12_mode == 0) {
fileMenu.append(new nw.MenuItem({ fileMenu.append(new nw.MenuItem({
type: 'separator' type: "separator"
})); }));
} }
fileMenu.append(new nw.MenuItem({ fileMenu.append(new nw.MenuItem({
label: l('menu.message'), label: l("menu.message"),
click: pdgui.menu_send, click: pdgui.menu_send,
key: 'm', key: "m",
modifiers: "ctrl", modifiers: "ctrl",
tooltip: l('menu.message_tt') tooltip: l("menu.message_tt")
})); }));
if (pdgui.k12_mode == 0) { if (pdgui.k12_mode == 0) {
fileMenu.append(new nw.MenuItem({ fileMenu.append(new nw.MenuItem({
type: 'separator' type: "separator"
})); }));
} }
...@@ -385,18 +385,18 @@ function nw_create_pd_window_menus () { ...@@ -385,18 +385,18 @@ function nw_create_pd_window_menus () {
// Note: there's no good reason to have this here // Note: there's no good reason to have this here
fileMenu.append(new nw.MenuItem({ fileMenu.append(new nw.MenuItem({
label: l('menu.close'), label: l("menu.close"),
click: function () {}, click: function () {},
enabled: false, enabled: false,
})); }));
// Quit Pd // Quit Pd
fileMenu.append(new nw.MenuItem({ fileMenu.append(new nw.MenuItem({
label: l('menu.quit'), label: l("menu.quit"),
click: pdgui.menu_quit, click: pdgui.menu_quit,
key: 'q', key: "q",
modifiers: "ctrl", modifiers: "ctrl",
tooltip: l('menu.quit_tt') tooltip: l("menu.quit_tt")
})); }));
...@@ -405,25 +405,25 @@ function nw_create_pd_window_menus () { ...@@ -405,25 +405,25 @@ function nw_create_pd_window_menus () {
// Add to window menu // Add to window menu
windowMenu.append(new nw.MenuItem({ windowMenu.append(new nw.MenuItem({
label: l('menu.edit'), label: l("menu.edit"),
submenu: editMenu submenu: editMenu
})); }));
// Edit sub-entries // Edit sub-entries
editMenu.append(new nw.MenuItem({ editMenu.append(new nw.MenuItem({
label: l('menu.copy'), label: l("menu.copy"),
click: function() { click: function() {
document.execCommand('copy'); document.execCommand("copy");
}, },
key: 'c', key: "c",
modifiers: 'ctrl', modifiers: "ctrl",
tooltip: l('menu.copy_tt') tooltip: l("menu.copy_tt")
})); }));
editMenu.append(new nw.MenuItem({ editMenu.append(new nw.MenuItem({
label: l('menu.selectall'), label: l("menu.selectall"),
click: function () { click: function () {
var container_id = 'p1', range; var container_id = "p1", range;
// This should work across browsers // This should work across browsers
if (document.selection) { if (document.selection) {
range = document.body.createTextRange(); range = document.body.createTextRange();
...@@ -442,71 +442,71 @@ function nw_create_pd_window_menus () { ...@@ -442,71 +442,71 @@ function nw_create_pd_window_menus () {
window.getSelection().addRange(range); window.getSelection().addRange(range);
} }
}, },
key: 'a', key: "a",
modifiers: "ctrl", modifiers: "ctrl",
tooltip: l('menu.selectall_tt') tooltip: l("menu.selectall_tt")
})); }));
editMenu.append(new nw.MenuItem({ editMenu.append(new nw.MenuItem({
type: 'separator' type: "separator"
})); }));
editMenu.append(new nw.MenuItem({ editMenu.append(new nw.MenuItem({
label: l('menu.zoomin'), label: l("menu.zoomin"),
click: function () { click: function () {
nw.Window.get().zoomLevel += 1; nw.Window.get().zoomLevel += 1;
pdgui.gui_post("zoom level is " + nw.Window.get().zoomLevel); pdgui.gui_post("zoom level is " + nw.Window.get().zoomLevel);
}, },
key: '=', key: "=",
modifiers: "ctrl", modifiers: "ctrl",
tooltip: l('menu.zoomin_tt') tooltip: l("menu.zoomin_tt")
})); }));
editMenu.append(new nw.MenuItem({ editMenu.append(new nw.MenuItem({
label: l('menu.zoomout'), label: l("menu.zoomout"),
click: function () { click: function () {
nw.Window.get().zoomLevel -= 1; nw.Window.get().zoomLevel -= 1;
pdgui.gui_post("zoom level is " + nw.Window.get().zoomLevel); pdgui.gui_post("zoom level is " + nw.Window.get().zoomLevel);
}, },
key: '-', key: "-",
modifiers: "ctrl", modifiers: "ctrl",
tooltip: l('menu.zoomout_tt') tooltip: l("menu.zoomout_tt")
})); }));
editMenu.append(new nw.MenuItem({ editMenu.append(new nw.MenuItem({
type: 'separator' type: "separator"
})); }));
editMenu.append(new nw.MenuItem({ editMenu.append(new nw.MenuItem({
label: l('menu.find'), label: l("menu.find"),
click: function () { click: function () {
var find_bar = document.getElementById('console_find'), var find_bar = document.getElementById("console_find"),
find_bar_text = document.getElementById('console_find_text'), find_bar_text = document.getElementById("console_find_text"),
text_container = document.getElementById('console_bottom'), text_container = document.getElementById("console_bottom"),
state = find_bar.style.getPropertyValue('display'); state = find_bar.style.getPropertyValue("display");
if (state === 'none') { if (state === "none") {
text_container.style.setProperty('bottom', '1em'); text_container.style.setProperty("bottom", "1em");
find_bar.style.setProperty('display', 'inline'); find_bar.style.setProperty("display", "inline");
find_bar.style.setProperty('height', '1em'); find_bar.style.setProperty("height", "1em");
text_container.scrollTop = text_container.scrollHeight; text_container.scrollTop = text_container.scrollHeight;
find_bar_text.focus(); find_bar_text.focus();
find_bar_text.select(); find_bar_text.select();
} else { } else {
text_container.style.setProperty('bottom', '0px'); text_container.style.setProperty("bottom", "0px");
find_bar.style.setProperty('display', 'none'); find_bar.style.setProperty("display", "none");
} }
}, },
key: 'f', key: "f",
modifiers: "ctrl", modifiers: "ctrl",
tooltip: l('menu.find_tt') tooltip: l("menu.find_tt")
})); }));
editMenu.append(new nw.MenuItem({ editMenu.append(new nw.MenuItem({
label: l('menu.preferences'), label: l("menu.preferences"),
click: pdgui.open_prefs, click: pdgui.open_prefs,
key: 'p', key: "p",
modifiers: "ctrl", modifiers: "ctrl",
tooltip: l('menu.preferences_tt') tooltip: l("menu.preferences_tt")
})); }));
...@@ -516,45 +516,45 @@ function nw_create_pd_window_menus () { ...@@ -516,45 +516,45 @@ function nw_create_pd_window_menus () {
// Add to windows menu // Add to windows menu
windowMenu.append(new nw.MenuItem({ windowMenu.append(new nw.MenuItem({
label: l('menu.windows'), label: l("menu.windows"),
submenu: winmanMenu submenu: winmanMenu
})); }));
// Winman sub-entries // Winman sub-entries
winmanMenu.append(new nw.MenuItem({ winmanMenu.append(new nw.MenuItem({
label: l('menu.nextwin'), label: l("menu.nextwin"),
click: pdmenu_next_win, click: pdmenu_next_win,
//key: 'c', //key: "c",
//modifiers: "ctrl", //modifiers: "ctrl",
tooltip: l('menu.nextwin_tt') tooltip: l("menu.nextwin_tt")
})); }));
winmanMenu.append(new nw.MenuItem({ winmanMenu.append(new nw.MenuItem({
label: l('menu.prevwin'), label: l("menu.prevwin"),
click: pdmenu_previous_win, click: pdmenu_previous_win,
//key: 'a', //key: "a",
//modifiers: "ctrl", //modifiers: "ctrl",
tooltip: l('menu.prevwin_tt') tooltip: l("menu.prevwin_tt")
})); }));
winmanMenu.append(new nw.MenuItem({ winmanMenu.append(new nw.MenuItem({
type: 'separator' type: "separator"
})); }));
winmanMenu.append(new nw.MenuItem({ winmanMenu.append(new nw.MenuItem({
label: l('menu.parentwin'), label: l("menu.parentwin"),
click: pdmenu_parent_win, click: pdmenu_parent_win,
//key: 'a', //key: "a",
//modifiers: "ctrl", //modifiers: "ctrl",
tooltip: l('menu.parentwin_tt') tooltip: l("menu.parentwin_tt")
})); }));
winmanMenu.append(new nw.MenuItem({ winmanMenu.append(new nw.MenuItem({
label: l('menu.pdwin'), label: l("menu.pdwin"),
click: pdmenu_console_win, click: pdmenu_console_win,
//key: 'a', //key: "a",
//modifiers: "ctrl",