Commit 3dd1a531 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

use double quotes consistently

parent 7b2ba485
...@@ -253,9 +253,9 @@ ...@@ -253,9 +253,9 @@
</div> </div>
<script> <script>
'use strict'; "use strict";
var nw = require('nw.gui'); var nw = require("nw.gui");
var pdgui = require('./pdgui.js'); var pdgui = require("./pdgui.js");
// For translations // For translations
var l = pdgui.get_local_string; var l = pdgui.get_local_string;
...@@ -276,12 +276,12 @@ function ok() { ...@@ -276,12 +276,12 @@ function ok() {
function display_pref(type) { function display_pref(type) {
pdgui.gui_post("here i am with " + type); pdgui.gui_post("here i am with " + type);
var all, i, this_elem; var all, i, this_elem;
all = document.getElementsByTagName('fieldset'); all = document.getElementsByTagName("fieldset");
this_elem = document.getElementById(type); this_elem = document.getElementById(type);
for (i = 0; i < all.length; i++) { for (i = 0; i < all.length; i++) {
all[i].style.setProperty('display', 'none'); all[i].style.setProperty("display", "none");
} }
this_elem.style.setProperty('display', 'inline'); this_elem.style.setProperty("display", "inline");
} }
function gui_preset_change(elem) { function gui_preset_change(elem) {
...@@ -296,13 +296,13 @@ function dev_change(elem) { ...@@ -296,13 +296,13 @@ function dev_change(elem) {
// choose the parameter acoordingly // choose the parameter acoordingly
var type; var type;
id = elem.id; id = elem.id;
direction = id.slice(0,2) === 'in' ? 'in' : 'out'; direction = id.slice(0,2) === "in" ? "in" : "out";
type = id.indexOf('chans') !== -1 ? 'chans' : 'devs'; type = id.indexOf("chans") !== -1 ? "chans" : "devs";
// This would need to change if there could ever be more than // This would need to change if there could ever be more than
// 9 devices // 9 devices
index = +(id.slice(-1)) - 1; index = +(id.slice(-1)) - 1;
pdgui.gui_post("direction is " + direction); pdgui.gui_post("direction is " + direction);
attrs = get_attr('pd-' + direction + type, pd_audio_attrs); attrs = get_attr("pd-" + direction + type, pd_audio_attrs);
attrs[index] = elem.value; attrs[index] = elem.value;
pdgui.gui_post("id is " + elem.id); pdgui.gui_post("id is " + elem.id);
pdgui.gui_post("new chan attrs is " + attrs); pdgui.gui_post("new chan attrs is " + attrs);
...@@ -319,7 +319,7 @@ function attr_change(elem) { ...@@ -319,7 +319,7 @@ function attr_change(elem) {
function get_input(name) { function get_input(name) {
var val = document.getElementsByName(name)[0].value; var val = document.getElementsByName(name)[0].value;
return val === 0 ? '0' : val; return val === 0 ? "0" : val;
} }
// get a value from the garray attr array // get a value from the garray attr array
...@@ -330,7 +330,7 @@ function get_array_value(name, attrs) { ...@@ -330,7 +330,7 @@ function get_array_value(name, attrs) {
// If dev is -1, just change it to 0. Not sure if the Pd audio // If dev is -1, just change it to 0. Not sure if the Pd audio
// backend requires this, but it's how it works currently. // backend requires this, but it's how it works currently.
function kludge_dev(type, attrs, index) { function kludge_dev(type, attrs, index) {
var dev = get_attr('pd-' + type + 'devs', attrs)[index]; var dev = get_attr("pd-" + type + "devs", attrs)[index];
if (dev < 0) { dev = 0; } if (dev < 0) { dev = 0; }
return dev; return dev;
} }
...@@ -340,8 +340,8 @@ function kludge_dev(type, attrs, index) { ...@@ -340,8 +340,8 @@ function kludge_dev(type, attrs, index) {
// this way so you can remember your number of channels even if // this way so you can remember your number of channels even if
// you turn off the device.) // you turn off the device.)
function kludge_chans(type, attrs, index) { function kludge_chans(type, attrs, index) {
var dev = get_attr('pd-' + type + 'devs', attrs)[index], var dev = get_attr("pd-" + type + "devs", attrs)[index],
chans = get_attr('pd-' + type + 'chans', attrs)[index]; chans = get_attr("pd-" + type + "chans", attrs)[index];
if (dev < 0 && chans >= 0) { chans *= -1; } if (dev < 0 && chans >= 0) { chans *= -1; }
return chans; return chans;
} }
...@@ -352,41 +352,41 @@ function apply() { ...@@ -352,41 +352,41 @@ function apply() {
// Audio dialog // Audio dialog
pdgui.pdsend( pdgui.pdsend(
'pd audio-dialog', "pd audio-dialog",
kludge_dev('in', attrs, 0), kludge_dev("in", attrs, 0),
kludge_dev('in', attrs, 1), kludge_dev("in", attrs, 1),
kludge_dev('in', attrs, 2), kludge_dev("in", attrs, 2),
kludge_dev('in', attrs, 3), kludge_dev("in", attrs, 3),
kludge_chans('in', attrs, 0), kludge_chans("in", attrs, 0),
kludge_chans('in', attrs, 1), kludge_chans("in", attrs, 1),
kludge_chans('in', attrs, 2), kludge_chans("in", attrs, 2),
kludge_chans('in', attrs, 3), kludge_chans("in", attrs, 3),
kludge_dev('out', attrs, 0), kludge_dev("out", attrs, 0),
kludge_dev('out', attrs, 1), kludge_dev("out", attrs, 1),
kludge_dev('out', attrs, 2), kludge_dev("out", attrs, 2),
kludge_dev('out', attrs, 3), kludge_dev("out", attrs, 3),
kludge_chans('out', attrs, 0), kludge_chans("out", attrs, 0),
kludge_chans('out', attrs, 1), kludge_chans("out", attrs, 1),
kludge_chans('out', attrs, 2), kludge_chans("out", attrs, 2),
kludge_chans('out', attrs, 3), kludge_chans("out", attrs, 3),
get_attr('rate', attrs), get_attr("rate", attrs),
get_attr('advance', attrs), get_attr("advance", attrs),
get_attr('cancallback', attrs), get_attr("cancallback", attrs),
get_attr('blocksize', attrs) get_attr("blocksize", attrs)
); );
attrs = pd_midi_attrs; attrs = pd_midi_attrs;
// Midi dialog // Midi dialog
pdgui.pdsend( pdgui.pdsend(
'pd midi-dialog', "pd midi-dialog",
get_attr('pd-indevs', attrs)[0], get_attr("pd-indevs", attrs)[0],
get_attr('pd-indevs', attrs)[1], get_attr("pd-indevs", attrs)[1],
get_attr('pd-indevs', attrs)[2], get_attr("pd-indevs", attrs)[2],
get_attr('pd-indevs', attrs)[3], get_attr("pd-indevs", attrs)[3],
get_attr('pd-outdevs', attrs)[0], get_attr("pd-outdevs", attrs)[0],
get_attr('pd-outdevs', attrs)[1], get_attr("pd-outdevs", attrs)[1],
get_attr('pd-outdevs', attrs)[2], get_attr("pd-outdevs", attrs)[2],
get_attr('pd-outdevs', attrs)[3], get_attr("pd-outdevs", attrs)[3],
0, // midi_alsain 0, // midi_alsain
0 // midi_alsaout 0 // midi_alsaout
); );
...@@ -400,9 +400,9 @@ function cancel() { ...@@ -400,9 +400,9 @@ function cancel() {
} }
function change_api(elem) { function change_api(elem) {
var id = elem.getAttribute('id'), var id = elem.getAttribute("id"),
value = elem.getAttribute('value'); value = elem.getAttribute("value");
if (id === 'audio_api') { if (id === "audio_api") {
pdgui.pdsend("pd audio-setapi", value); pdgui.pdsend("pd audio-setapi", value);
} else { } else {
pdgui.pdsend("pd midi-setapi", value); pdgui.pdsend("pd midi-setapi", value);
...@@ -416,37 +416,37 @@ function get_attr(name, attrs) { ...@@ -416,37 +416,37 @@ function get_attr(name, attrs) {
function populate_apis(elem, apis, current_api) { function populate_apis(elem, apis, current_api) {
pdgui.gui_post("curent api is " + current_api); pdgui.gui_post("curent api is " + current_api);
var i, opt, api_select = elem; var i, opt, api_select = elem;
pdgui.gui_post('apis are ' + apis); pdgui.gui_post("apis are " + apis);
for (i = 0; i < apis.length; i += 2) { for (i = 0; i < apis.length; i += 2) {
opt = document.createElement('option'); opt = document.createElement("option");
opt.textContent = apis[i]; opt.textContent = apis[i];
opt.setAttribute('value', apis[i+1]); opt.setAttribute("value", apis[i+1]);
api_select.appendChild(opt); api_select.appendChild(opt);
} }
api_select.value = current_api; api_select.value = current_api;
} }
function populate_devs(type, attrs) { function populate_devs(type, attrs) {
var devs = get_attr(type === 'in' ? 'sys-indevs' : 'sys-outdevs', attrs); var devs = get_attr(type === "in" ? "sys-indevs" : "sys-outdevs", attrs);
var i, j, opt, elem, chan_elem, chans; var i, j, opt, elem, chan_elem, chans;
pdgui.gui_post("devs are " + devs); pdgui.gui_post("devs are " + devs);
pdgui.gui_post("type is " + type + 1); pdgui.gui_post("type is " + type + 1);
chans = get_attr('pd-' + type + 'chans', attrs); chans = get_attr("pd-" + type + "chans", attrs);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
elem = document.getElementById(type + (i+1)); elem = document.getElementById(type + (i+1));
chan_elem = document.getElementById(type + 'chans' + (i+1)); chan_elem = document.getElementById(type + "chans" + (i+1));
chan_elem.value = chans[i]; chan_elem.value = chans[i];
// if the user changed the API, we need to remove the old devs // if the user changed the API, we need to remove the old devs
while (elem.firstChild) { while (elem.firstChild) {
elem.removeChild(elem.firstChild); elem.removeChild(elem.firstChild);
} }
// make a dummy device named 'None' with value -1 // make a dummy device named 'None' with value -1
opt = document.createElement('option'); opt = document.createElement("option");
opt.value = -1; opt.value = -1;
opt.textContent = 'None'; opt.textContent = "None";
elem.appendChild(opt); elem.appendChild(opt);
for (j = 0; j < devs.length; j++) { for (j = 0; j < devs.length; j++) {
opt = document.createElement('option'); opt = document.createElement("option");
opt.value = j; opt.value = j;
opt.textContent = devs[j]; opt.textContent = devs[j];
elem.appendChild(opt); elem.appendChild(opt);
...@@ -455,26 +455,26 @@ function populate_devs(type, attrs) { ...@@ -455,26 +455,26 @@ function populate_devs(type, attrs) {
} }
function populate_midi_devs(type, attrs) { function populate_midi_devs(type, attrs) {
var devs = get_attr(type === 'in' ? 'sys-indevs' : 'sys-outdevs', attrs); var devs = get_attr(type === "in" ? "sys-indevs" : "sys-outdevs", attrs);
var i, j, opt, elem, chan_elem, chans; var i, j, opt, elem, chan_elem, chans;
pdgui.gui_post("devs are " + devs); pdgui.gui_post("devs are " + devs);
pdgui.gui_post("type is " + type + 1); pdgui.gui_post("type is " + type + 1);
chans = get_attr('pd-' + type + 'chans', attrs); chans = get_attr("pd-" + type + "chans", attrs);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
elem = document.getElementById(type + (i+1)); elem = document.getElementById(type + (i+1));
chan_elem = document.getElementById(type + 'chans' + (i+1)); chan_elem = document.getElementById(type + "chans" + (i+1));
chan_elem.value = chans[i]; chan_elem.value = chans[i];
// if the user changed the API, we need to remove the old devs // if the user changed the API, we need to remove the old devs
while (elem.firstChild) { while (elem.firstChild) {
elem.removeChild(elem.firstChild); elem.removeChild(elem.firstChild);
} }
// make a dummy device named 'None' with value -1 // make a dummy device named 'None' with value -1
opt = document.createElement('option'); opt = document.createElement("option");
opt.value = -1; opt.value = -1;
opt.textContent = 'None'; opt.textContent = "None";
elem.appendChild(opt); elem.appendChild(opt);
for (j = 0; j < devs.length; j++) { for (j = 0; j < devs.length; j++) {
opt = document.createElement('option'); opt = document.createElement("option");
opt.value = j; opt.value = j;
opt.textContent = devs[j]; opt.textContent = devs[j];
elem.appendChild(opt); elem.appendChild(opt);
...@@ -484,7 +484,7 @@ function populate_midi_devs(type, attrs) { ...@@ -484,7 +484,7 @@ function populate_midi_devs(type, attrs) {
function audio_prefs_callback(attrs) { function audio_prefs_callback(attrs) {
pd_audio_attrs = attrs; pd_audio_attrs = attrs;
var api_select = document.getElementById('audio_api'); var api_select = document.getElementById("audio_api");
var callback, i, j, elem, devs, opt; var callback, i, j, elem, devs, opt;
pdgui.gui_post("audio attrs are " + attrs); pdgui.gui_post("audio attrs are " + attrs);
pdgui.gui_post("attrs length " + attrs.length); pdgui.gui_post("attrs length " + attrs.length);
...@@ -492,35 +492,35 @@ function audio_prefs_callback(attrs) { ...@@ -492,35 +492,35 @@ function audio_prefs_callback(attrs) {
// is open. This is because an API change requires a query // is open. This is because an API change requires a query
// for new properties. So we only populate the api options // for new properties. So we only populate the api options
// if they don't already exist // if they don't already exist
if (api_select.getElementsByTagName('option').length < 1) { if (api_select.getElementsByTagName("option").length < 1) {
populate_apis( populate_apis(
api_select, api_select,
attrs[attrs.indexOf('audio-apis') + 1], attrs[attrs.indexOf("audio-apis") + 1],
attrs[attrs.indexOf('current-api') + 1]); attrs[attrs.indexOf("current-api") + 1]);
} }
document.getElementById('rate').value = get_attr('rate', attrs); document.getElementById("rate").value = get_attr("rate", attrs);
document.getElementById('blocksize').value = get_attr('blocksize', attrs); document.getElementById("blocksize").value = get_attr("blocksize", attrs);
document.getElementById('advance').value = get_attr('advance', attrs); document.getElementById("advance").value = get_attr("advance", attrs);
var callback = get_attr('cancallback', attrs); var callback = get_attr("cancallback", attrs);
//show the checkbox if the API allows //show the checkbox if the API allows
if (callback !== -1) { if (callback !== -1) {
document.getElementById('callback_container') document.getElementById("callback_container")
.classList.remove('hidden'); .classList.remove("hidden");
document.getElementById('callback').checked = !!callback; document.getElementById("callback").checked = !!callback;
} }
populate_devs('in', attrs); populate_devs("in", attrs);
populate_devs('out', attrs); populate_devs("out", attrs);
set_devs('in', get_attr('pd-indevs', attrs)); set_devs("in", get_attr("pd-indevs", attrs));
set_devs('out', get_attr('pd-outdevs', attrs)); set_devs("out", get_attr("pd-outdevs", attrs));
// Set chans after the devs (because they may // Set chans after the devs (because they may
// have the side-effect of setting the dev to 'None') // have the side-effect of setting the dev to 'None')
set_chans('in', get_attr('pd-inchans', attrs)); set_chans("in", get_attr("pd-inchans", attrs));
set_chans('out', get_attr('pd-outchans', attrs)); set_chans("out", get_attr("pd-outchans", attrs));
pdgui.resize_window(pd_object_callback); pdgui.resize_window(pd_object_callback);
} }
...@@ -535,7 +535,7 @@ function set_devs(type, devs) { ...@@ -535,7 +535,7 @@ function set_devs(type, devs) {
function set_chans(type, chans_array) { function set_chans(type, chans_array) {
var i; var i;
for (i = 0; i < chans_array.length; i++) { for (i = 0; i < chans_array.length; i++) {
document.getElementById(type + 'chans' + (i+1)).value = chans_array[i]; document.getElementById(type + "chans" + (i+1)).value = chans_array[i];
// If no chans, set device to -1 (None) // If no chans, set device to -1 (None)
if (chans_array[i] < 1) { if (chans_array[i] < 1) {
document.getElementById(type + (i+1)).value = -1; document.getElementById(type + (i+1)).value = -1;
...@@ -545,15 +545,15 @@ function set_chans(type, chans_array) { ...@@ -545,15 +545,15 @@ function set_chans(type, chans_array) {
function midi_prefs_callback(attrs) { function midi_prefs_callback(attrs) {
pd_midi_attrs = attrs; pd_midi_attrs = attrs;
var api_select = document.getElementById('midi_api'); var api_select = document.getElementById("midi_api");
pdgui.gui_post("midi attrs are " + attrs); pdgui.gui_post("midi attrs are " + attrs);
pdgui.gui_post("attrs length " + attrs.length); pdgui.gui_post("attrs length " + attrs.length);
if (api_select.getElementsByTagName('option').length < 1) { if (api_select.getElementsByTagName("option").length < 1) {
populate_apis( populate_apis(
api_select, api_select,
get_attr('midi-apis', attrs), get_attr("midi-apis", attrs),
get_attr('current-api', attrs) get_attr("current-api", attrs)
); );
} }
...@@ -570,7 +570,7 @@ function register_canvas_id(gfxstub, attr_arrays) { ...@@ -570,7 +570,7 @@ function register_canvas_id(gfxstub, attr_arrays) {
translate_form(); translate_form();
// default to audio preference panel // default to audio preference panel
display_pref('audio'); display_pref("audio");
// We don't turn on rendering of the "container" div until // We don't turn on rendering of the "container" div until
// We've finished displaying all the spans and populating the // We've finished displaying all the spans and populating the
// labels and form elements. That makes it more efficient and // labels and form elements. That makes it more efficient and
...@@ -580,21 +580,21 @@ function register_canvas_id(gfxstub, attr_arrays) { ...@@ -580,21 +580,21 @@ function register_canvas_id(gfxstub, attr_arrays) {
pdgui.pdsend("pd audio-properties"); // request audio pref attrs pdgui.pdsend("pd audio-properties"); // request audio pref attrs
pdgui.pdsend("pd midi-properties"); // request midi pref attrs pdgui.pdsend("pd midi-properties"); // request midi pref attrs
document.getElementsByClassName('container')[0].style.setProperty('display', 'inline'); document.getElementsByClassName("container")[0].style.setProperty("display", "inline");
} }
function tr_text(id) { function tr_text(id) {
var elem = document.getElementById('iem.prop.' + id); var elem = document.getElementById("iem.prop." + id);
elem.textContent = l('iem.prop.' + id); elem.textContent = l("iem.prop." + id);
} }
// Stop-gap translator // Stop-gap translator
function translate_form() { function translate_form() {
var i var i
var elements = document.querySelectorAll('[data-i18n]'); var elements = document.querySelectorAll("[data-i18n]");
for (i = 0; i < elements.length; i++) { for (i = 0; i < elements.length; i++) {
var data = elements[i].dataset.i18n; var data = elements[i].dataset.i18n;
if (data.slice(0,7) === '[title]') { if (data.slice(0,7) === "[title]") {
elements[i].title = l(data.slice(7)); elements[i].title = l(data.slice(7));
} else { } else {
elements[i].textContent = l(data); elements[i].textContent = l(data);
...@@ -610,14 +610,14 @@ function populate_form(attr_array) { ...@@ -610,14 +610,14 @@ function populate_form(attr_array) {
var prop_group = document.getElementsByClassName(attr_array[i])[0]; var prop_group = document.getElementsByClassName(attr_array[i])[0];
if (prop_group !== undefined) { if (prop_group !== undefined) {
console.log("the thing here is " + attr_array[i]); console.log("the thing here is " + attr_array[i]);
prop_group.classList.remove('hidden'); prop_group.classList.remove("hidden");
} else { } else {
pdgui.gui_post("Error: couldn't find iemgui prop group for " + attr_array[i]); pdgui.gui_post("Error: couldn't find iemgui prop group for " + attr_array[i]);
} }
var elem = document.getElementsByName(attr_array[i]); var elem = document.getElementsByName(attr_array[i]);
if (elem.length > 0) { if (elem.length > 0) {
if (elem[0].type === 'checkbox') { if (elem[0].type === "checkbox") {
// The attr here is a string, so we need to // The attr here is a string, so we need to
// force it to number, hence the "+" below // force it to number, hence the "+" below
gui_post("found a CHECKED ITEM!!!"); gui_post("found a CHECKED ITEM!!!");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment