Commit 353de7d1 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

use double-quotes consistently

parent 4d29dbff
...@@ -277,9 +277,9 @@ ...@@ -277,9 +277,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;
...@@ -300,28 +300,28 @@ function ok() { ...@@ -300,28 +300,28 @@ function ok() {
} }
function toggle_fill_color(value) { function toggle_fill_color(value) {
var fill_color_div = document.getElementsByClassName('array-fill')[0]; var fill_color_div = document.getElementsByClassName("array-fill")[0];
if (value === 3) { if (value === 3) {
fill_color_div.classList.remove('hidden'); fill_color_div.classList.remove("hidden");
} else { } else {
fill_color_div.classList.add('hidden'); fill_color_div.classList.add("hidden");
} }
} }
function flag_change(elem) { function flag_change(elem) {
var array_attr, arrays_select, name, value, flag; var array_attr, arrays_select, name, value, flag;
arrays_select = document.getElementById('arrays_select'); arrays_select = document.getElementById("arrays_select");
array_attr = pd_garray_attrs[arrays_select.value]; array_attr = pd_garray_attrs[arrays_select.value];
name = elem.name; name = elem.name;
// get value from radio group, checked from checkboxes // get value from radio group, checked from checkboxes
if (name === 'array_style') { if (name === "array_style") {
value = document.querySelector('input[name="array_style"]:checked').value; value = document.querySelector('input[name="array_style"]:checked').value;
pdgui.gui_post("array style found: " + value); pdgui.gui_post("array style found: " + value);
// Toggle visibility of the fill color button-- only show for bar // Toggle visibility of the fill color button-- only show for bar
// graph style (= 3) // graph style (= 3)
toggle_fill_color(+value); toggle_fill_color(+value);
} else { } else {
// '+' for casting boolean to number // "+" for casting boolean to number
value = +elem.checked; value = +elem.checked;
} }
//pdgui.gui_post("value is " + value); //pdgui.gui_post("value is " + value);
...@@ -348,29 +348,29 @@ function flag_change(elem) { ...@@ -348,29 +348,29 @@ function flag_change(elem) {
function flag2_change(elem) { function flag2_change(elem) {
var array_attr, arrays_select, name, value, flag; var array_attr, arrays_select, name, value, flag;
arrays_select = document.getElementById('arrays_select'); arrays_select = document.getElementById("arrays_select");
array_attr = pd_garray_attrs[arrays_select.value]; array_attr = pd_garray_attrs[arrays_select.value];
name = elem.name; name = elem.name;
// get value from radio group, checked from checkboxes // get value from radio group, checked from checkboxes
// '+' for casting boolean to number // "+" for casting boolean to number
value = +elem.checked; value = +elem.checked;
array_attr[name] = value; array_attr[name] = value;
pdgui.gui_post("array is " + array_attr); pdgui.gui_post("array is " + array_attr);
} }
function array_delete_change(elem) { function array_delete_change(elem) {
var arrays_select = document.getElementById('arrays_select'), var arrays_select = document.getElementById("arrays_select"),
array_attr = pd_garray_attrs[arrays_select.value]; array_attr = pd_garray_attrs[arrays_select.value];
array_attr.array_delete = elem.checked; array_attr.array_delete = elem.checked;
} }
function attr_change(elem) { function attr_change(elem) {
var array_index, array_attr, arrays_select, name; var array_index, array_attr, arrays_select, name;
arrays_select = document.getElementById('arrays_select'); arrays_select = document.getElementById("arrays_select");
array_attr = pd_garray_attrs[arrays_select.value]; array_attr = pd_garray_attrs[arrays_select.value];
name = elem.name; name = elem.name;
array_attr[name] = elem.value; array_attr[name] = elem.value;
if (elem.name === 'array-fill') { if (elem.name === "array-fill") {
array-fill array-fill
} }
pdgui.gui_post("name is " + elem.name); pdgui.gui_post("name is " + elem.name);
...@@ -393,13 +393,13 @@ console.log("namer is " + name); ...@@ -393,13 +393,13 @@ console.log("namer is " + name);
case "array_gfxstub": break; case "array_gfxstub": break;
case "array_flags": case "array_flags":
// save contents // save contents
elem = document.getElementsByName('array_save')[0]; elem = document.getElementsByName("array_save")[0];
elem.checked = (value & 1) != 0; elem.checked = (value & 1) != 0;
// jump on click // jump on click
elem = document.getElementsByName('array_jump')[0]; elem = document.getElementsByName("array_jump")[0];
elem.checked = (value & 16) != 0; elem.checked = (value & 16) != 0;
// draw style // draw style
style_opts = document.getElementsByName('array_style'); style_opts = document.getElementsByName("array_style");
style_index = (value & 6) >> 1; style_index = (value & 6) >> 1;
elem = style_opts[style_index]; elem = style_opts[style_index];
elem.checked = true; elem.checked = true;
...@@ -417,19 +417,19 @@ console.log("namer is " + name); ...@@ -417,19 +417,19 @@ console.log("namer is " + name);
} }
} }
var arrays_select = document.getElementById('arrays_select'); var arrays_select = document.getElementById("arrays_select");
arrays_select.addEventListener('change', function() { arrays_select.addEventListener("change", function() {
pdgui.gui_post('changed the thing is ' + this.value); pdgui.gui_post("changed the thing is " + this.value);
array_choose(this.value); array_choose(this.value);
}); });
var gop_label = document.getElementById('gop_label'); var gop_label = document.getElementById("gop_label");
gop_label.addEventListener('click', function() { gop_label.addEventListener("click", function() {
document.getElementsByName('gop')[0].click(); document.getElementsByName("gop")[0].click();
}); });
var gop_button = document.getElementsByName('gop')[0]; var gop_button = document.getElementsByName("gop")[0];
gop_button.addEventListener('click', function(evt) { gop_button.addEventListener("click", function(evt) {
set_gop(this.checked); set_gop(this.checked);
}); });
...@@ -437,14 +437,14 @@ function update_gop_form(opts, state) { ...@@ -437,14 +437,14 @@ function update_gop_form(opts, state) {
var elem, i; var elem, i;
for(i = 0; i < opts.length; i++) { for(i = 0; i < opts.length; i++) {
elem = opts[i]; elem = opts[i];
if (elem.type === 'checkbox' || if (elem.type === "checkbox" ||
elem.type === 'text') { elem.type === "text") {
elem.disabled = state ? false : true; elem.disabled = state ? false : true;
} }
if (state) { if (state) {
elem.classList.remove('disabled'); elem.classList.remove("disabled");
} else { } else {
elem.classList.add('disabled'); elem.classList.add("disabled");
} }
} }
} }
...@@ -453,11 +453,11 @@ var gop_click_count = 0; ...@@ -453,11 +453,11 @@ var gop_click_count = 0;
function show_sane_defaults() { function show_sane_defaults() {
var w, h, xoff, yoff; var w, h, xoff, yoff;
w = document.getElementsByName('x-pix')[0]; w = document.getElementsByName("x-pix")[0];
h = document.getElementsByName('y-pix')[0]; h = document.getElementsByName("y-pix")[0];
xoff = document.getElementsByName('x-margin')[0]; xoff = document.getElementsByName("x-margin")[0];
yoff = document.getElementsByName('y-margin')[0]; yoff = document.getElementsByName("y-margin")[0];
if (w.value === '0' && h.value === '0') { if (w.value === "0" && h.value === "0") {
w.value = 85; w.value = 85;
h.value = 60; h.value = 60;
xoff.value = 100; xoff.value = 100;
...@@ -471,22 +471,22 @@ function set_gop(state) { ...@@ -471,22 +471,22 @@ function set_gop(state) {
if (state === true && gop_click_count === 0) { if (state === true && gop_click_count === 0) {
show_sane_defaults(); show_sane_defaults();
} }
gop_opts = document.getElementsByClassName('gop_opt'); gop_opts = document.getElementsByClassName("gop_opt");
no_gop_opts = document.getElementsByClassName('no_gop_opt'); no_gop_opts = document.getElementsByClassName("no_gop_opt");
update_gop_form(gop_opts, state); update_gop_form(gop_opts, state);
update_gop_form(no_gop_opts, state === false); update_gop_form(no_gop_opts, state === false);
} }
function substitute_space(arg) { function substitute_space(arg) {
var fake_space = String.fromCharCode(11); var fake_space = String.fromCharCode(11);
return arg.split(' ').join(fake_space); return arg.split(" ").join(fake_space);
} }
function strip_problem_chars(arg) { function strip_problem_chars(arg) {
var problem_chars = [';', ',', '{', '}', '\\']; var problem_chars = [";", ",", "{", "}", "\\"];
var ret = arg; var ret = arg;
for(var i = 0; i < problem_chars.length; i++) { for(var i = 0; i < problem_chars.length; i++) {
ret = ret.split(';').join(''); ret = ret.split(";").join("");
} }
return ret; return ret;
} }
...@@ -512,7 +512,7 @@ function get_array_value(name, attrs) { ...@@ -512,7 +512,7 @@ function get_array_value(name, attrs) {
// feature probably not worth improving. // feature probably not worth improving.
function get_array_slot_4(attrs) { function get_array_slot_4(attrs) {
if (new_array_dialog) { if (new_array_dialog) {
return document.getElementById('array_in_existing_graph').checked ? return document.getElementById("array_in_existing_graph").checked ?
"1" : "0"; "1" : "0";
} else if (pd_garray_attrs.length > 1) { } else if (pd_garray_attrs.length > 1) {
return attrs.array_delete ? "1" : "0"; return attrs.array_delete ? "1" : "0";
...@@ -527,21 +527,21 @@ function apply() { ...@@ -527,21 +527,21 @@ function apply() {
// skip the canvas dialog callback // skip the canvas dialog callback
if (!new_array_dialog) { if (!new_array_dialog) {
// Note: the "+" casts Boolean to Number // Note: the "+" casts Boolean to Number
gop = +document.getElementsByName('gop')[0].checked; gop = +document.getElementsByName("gop")[0].checked;
hide_name = +document.getElementsByName('hide-name')[0].checked; hide_name = +document.getElementsByName("hide-name")[0].checked;
pdgui.pdsend(pd_object_callback, 'donecanvasdialog', pdgui.pdsend(pd_object_callback, "donecanvasdialog",
+get_input('x-scale'), +get_input("x-scale"),
+get_input('y-scale'), +get_input("y-scale"),
(gop + 2 * hide_name), (gop + 2 * hide_name),
+get_input('x1'), +get_input("x1"),
+get_input('y1'), +get_input("y1"),
+get_input('x2'), +get_input("x2"),
+get_input('y2'), +get_input("y2"),
+get_input('x-pix'), +get_input("x-pix"),
+get_input('y-pix'), +get_input("y-pix"),
+get_input('x-margin'), +get_input("x-margin"),
+get_input('y-margin') +get_input("y-margin")
); );
} }
...@@ -549,21 +549,21 @@ function apply() { ...@@ -549,21 +549,21 @@ function apply() {
// message for each array // message for each array
for (i = 0; i < pd_garray_attrs.length; i++) { for (i = 0; i < pd_garray_attrs.length; i++) {
attrs = pd_garray_attrs[i]; attrs = pd_garray_attrs[i];
name = get_array_value('array_name', attrs); name = get_array_value("array_name", attrs);
if (name.slice(0, 1) === '$') { if (name.slice(0, 1) === "$") {
name = '#' + name.slice(1); name = "#" + name.slice(1);
} }
pdgui.pdsend( pdgui.pdsend(
get_array_value('array_gfxstub', attrs), get_array_value("array_gfxstub", attrs),
'arraydialog', "arraydialog",
name, name,
get_array_value('array_size', attrs), get_array_value("array_size", attrs),
get_array_value('array_flags', attrs), get_array_value("array_flags", attrs),
get_array_slot_4(attrs), get_array_slot_4(attrs),
0, // xdraw-- not sure if this is still used 0, // xdraw-- not sure if this is still used
0, // ydraw-- not sure if this is still used 0, // ydraw-- not sure if this is still used
get_array_value('array_fill', attrs), get_array_value("array_fill", attrs),
get_array_value('array_outline', attrs) get_array_value("array_outline", attrs)
); );
} }
...@@ -582,18 +582,18 @@ function cancel() { ...@@ -582,18 +582,18 @@ function cancel() {
} }
function populate_array_form(objects) { function populate_array_form(objects) {
var arrays_select = document.getElementById('arrays_select'), var arrays_select = document.getElementById("arrays_select"),
a_field = document.getElementById('arrays'), a_field = document.getElementById("arrays"),
opt, i; opt, i;
a_field.classList.remove('hidden'); a_field.classList.remove("hidden");
if (objects.length > 1) { if (objects.length > 1) {
// show the select element if there's more than one array // show the select element if there's more than one array
arrays_select.classList.remove('hidden'); arrays_select.classList.remove("hidden");
} }
for (i = 0; i < objects.length; i++) { for (i = 0; i < objects.length; i++) {
opt = document.createElement('option'); opt = document.createElement("option");
opt.setAttribute('value', i); opt.setAttribute("value", i);
opt.textContent = 'Array #' + (i+1); opt.textContent = "Array #" + (i+1);
arrays_select.appendChild(opt); arrays_select.appendChild(opt);
} }
// We're permanently hiding the checkbutton for creating a new array // We're permanently hiding the checkbutton for creating a new array
...@@ -601,14 +601,14 @@ function populate_array_form(objects) { ...@@ -601,14 +601,14 @@ function populate_array_form(objects) {
// few benefits. However, patches that already have multiple arrays // few benefits. However, patches that already have multiple arrays
// inside a graph will continue to work. (And if users really want // inside a graph will continue to work. (And if users really want
// this feature back it's easy to turn it back on. // this feature back it's easy to turn it back on.
if (!new_array_dialog || 1) { // to re-enable, remove the '|| 1' if (!new_array_dialog || 1) { // to re-enable, remove the "|| 1"
document.getElementsByClassName('array_in_existing_graph')[0] document.getElementsByClassName("array_in_existing_graph")[0]
.classList.add('hidden'); .classList.add("hidden");
} }
// Hide the "delete this array" button if we don't have // Hide the "delete this array" button if we don't have
// more than one array // more than one array
if (new_array_dialog || objects.length < 2) { if (new_array_dialog || objects.length < 2) {
document.getElementsByClassName('array_delete')[0].classList.add('hidden'); document.getElementsByClassName("array_delete")[0].classList.add("hidden");
} }
array_choose(0); array_choose(0);
} }
...@@ -642,11 +642,11 @@ function register_canvas_id(gfxstub, attr_objects) { ...@@ -642,11 +642,11 @@ function register_canvas_id(gfxstub, attr_objects) {
translate_form(); translate_form();
// If this is a new array dialog we might not have any canvas // If this is a new array dialog we might not have any canvas
// properties to set. If so, just show the array form elements // properties to set. If so, just show the array form elements
if (attr_objects[0].hasOwnProperty('array_gfxstub')) { if (attr_objects[0].hasOwnProperty("array_gfxstub")) {
new_array_dialog = true; // this is a new array dialog new_array_dialog = true; // this is a new array dialog
canvas_fieldsets = document.getElementsByClassName('canvas'); canvas_fieldsets = document.getElementsByClassName("canvas");
for (i = 0; i < canvas_fieldsets.length; i++) { for (i = 0; i < canvas_fieldsets.length; i++) {
canvas_fieldsets[i].classList.add('hidden'); canvas_fieldsets[i].classList.add("hidden");
} }
init_arrays(attr_objects); init_arrays(attr_objects);
} else { } else {
...@@ -659,22 +659,22 @@ function register_canvas_id(gfxstub, attr_objects) { ...@@ -659,22 +659,22 @@ function register_canvas_id(gfxstub, attr_objects) {
// 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
// snappier, at least on older machines. // snappier, at least on older machines.
document.getElementsByClassName('container')[0].style.setProperty('display', 'inline'); document.getElementsByClassName("container")[0].style.setProperty("display", "inline");
pdgui.resize_window(pd_object_callback); pdgui.resize_window(pd_object_callback);
} }
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);
...@@ -690,29 +690,29 @@ function populate_form(attr_object) { ...@@ -690,29 +690,29 @@ function populate_form(attr_object) {
var prop_group = document.getElementsByClassName(prop)[0]; var prop_group = document.getElementsByClassName(prop)[0];
if (prop_group !== undefined) { if (prop_group !== undefined) {
console.log("the thing here is " + prop); console.log("the thing here is " + prop);
prop_group.classList.remove('hidden'); prop_group.classList.remove("hidden");
} else { } else {
pdgui.gui_post("Error: couldn't find iemgui prop group for " + pdgui.gui_post("Error: couldn't find iemgui prop group for " +
prop); prop);
} }
if (prop === 'display-flags') { if (prop === "display-flags") {
// protip: '!!' forces Boolean, '+' forces Number type // protip: "!!" forces Boolean, "+" forces Number type
var flag = +attr_object[prop]; var flag = +attr_object[prop];
document.getElementsByName('gop')[0].checked = !!flag; document.getElementsByName("gop")[0].checked = !!flag;
document.getElementsByName('hide-name')[0].checked = !!(flag & 2); document.getElementsByName("hide-name")[0].checked = !!(flag & 2);
// Set the gop-related parts of the form to be // Set the gop-related parts of the form to be
// enabled/disabled based on state // enabled/disabled based on state
set_gop(!!flag); set_gop(!!flag);
} }
var elem = document.getElementsByName(prop); var elem = document.getElementsByName(prop);
if (elem.length > 0) { if (elem.length > 0) {
if(prop.slice(-5) === 'color') { if(prop.slice(-5) === "color") {
var hex_string = Number(attr_object[prop]).toString(16); var hex_string = Number(attr_object[prop]).toString(16);
var color_string = "#" + var color_string = "#" +
(hex_string === '0' ? '000000' : hex_string); (hex_string === "0" ? "000000" : hex_string);
pdgui.gui_post("color is " + color_string); pdgui.gui_post("color is " + color_string);
elem[0].value = color_string; elem[0].value = color_string;
} else if (elem[0].type === 'checkbox') { } else 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!!!");
...@@ -727,17 +727,17 @@ function populate_form(attr_object) { ...@@ -727,17 +727,17 @@ function populate_form(attr_object) {
if (pd_garray_attrs.length > 0) { if (pd_garray_attrs.length > 0) {
console.log("fungyfungyfungyfungy"); console.log("fungyfungyfungyfungy");
// Graph-on-parent toggle // Graph-on-parent toggle
document.getElementsByClassName('display-flags')[0] document.getElementsByClassName("display-flags")[0]
.classList.add('hidden'); .classList.add("hidden");
// Graph-on-parent flag for hiding object name/args // Graph-on-parent flag for hiding object name/args
document.getElementsByClassName('display-flags')[1] document.getElementsByClassName("display-flags")[1]
.classList.add('hidden'); .classList.add("hidden");
// GOP-rect margins don't make sense for garrays, so hide them // GOP-rect margins don't make sense for garrays, so hide them
document.getElementsByClassName('x-margin')[0] document.getElementsByClassName("x-margin")[0]
.classList.add('hidden'); .classList.add("hidden");
// X/Y scaling-- garray is always in a gop so not needed // X/Y scaling-- garray is always in a gop so not needed
document.getElementsByClassName('x-scale')[0] document.getElementsByClassName("x-scale")[0]
.classList.add('hidden'); .classList.add("hidden");
} }
} }
......
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