From 0e6d581adb09f7aa4456375b68bf29cfb0e125d5 Mon Sep 17 00:00:00 2001
From: user <user@user-ThinkPad-X60.(none)>
Date: Fri, 5 Jun 2015 23:38:20 -0400
Subject: [PATCH] code cleanup, plus bugfix for updating iemgui border size
 after dialog changes

---
 pd/nw/dialog_canvas.html |  72 ++------
 pd/nw/dialog_font.html   |  94 ++++------
 pd/nw/dialog_gatom.html  | 104 +++++------
 pd/nw/dialog_iemgui.html | 383 ++++++++++++++++++---------------------
 pd/nw/pdgui.js           |   2 +-
 pd/src/g_all_guis.c      |   5 +
 6 files changed, 277 insertions(+), 383 deletions(-)

diff --git a/pd/nw/dialog_canvas.html b/pd/nw/dialog_canvas.html
index af086e5d8..aef6b0717 100644
--- a/pd/nw/dialog_canvas.html
+++ b/pd/nw/dialog_canvas.html
@@ -286,16 +286,11 @@
         cancel();
     }
 
-//    function toggler(evt) {
-//        evt.value = evt.checked ? 1 : 0; 
-//    }
-
     function flag_change(elem) {
         var attr, arrays_select, name, value, flag;
         arrays_select = document.getElementById('arrays_select');
         attr = pd_garray_attrs[arrays_select.value];
         name = elem.name;
-//        pdgui.gui_post("name is " + name);
         // get value from radio group, checked from checkboxes
         if (name === 'array_style') {
             value = document.querySelector('input[name="array_style"]:checked').value;
@@ -304,7 +299,7 @@
             // '+' for casting boolean to number
             value = +elem.checked;
         }
-//        pdgui.gui_post("value is " + value);
+        //pdgui.gui_post("value is " + value);
         flag = attr[attr.indexOf('array_flags') + 1];
         pdgui.gui_post("flag before is " + flag);
         switch (name) {
@@ -331,11 +326,9 @@
         arrays_select = document.getElementById('arrays_select');
         attr = pd_garray_attrs[arrays_select.value];
         name = elem.name;
-//        pdgui.gui_post("name is " + name);
         // get value from radio group, checked from checkboxes
         // '+' for casting boolean to number
         value = +elem.checked;
-//        pdgui.gui_post("value is " + value);
         attr[attr.indexOf(name) + 1] = value;
         pdgui.gui_post("array is " + attr);
     }
@@ -441,7 +434,6 @@
         update_gop_form(no_gop_opts, state === false);
     }
 
-
     function substitute_space(arg) {
         var fake_space = String.fromCharCode(11);
         return arg.split(' ').join(fake_space);
@@ -466,14 +458,14 @@
         return attrs[attrs.indexOf(name) + 1];
     }
 
-
     function apply() {
         var i, attrs, gop, hide_name;
         pdgui.gui_post("we're applying shits!");
 
         // If this is a dialog to create a new array, we
         // skip the canvas dialog callback
-        if (pd_garray_attrs.length < 1 || pd_garray_attrs[0][0] !== 'array_gfxstub')
+        if (pd_garray_attrs.length < 1 ||
+            pd_garray_attrs[0][0] !== 'array_gfxstub')
         {
             // Note: the "+" casts Boolean to Number
             gop = +document.getElementsByName('gop')[0].checked;
@@ -517,33 +509,16 @@
             ].join(' '));
 
         }
-/*
-    pd [concat $id donecanvasdialog \
-            $::dialog($vid:xscale) \
-            $::dialog($vid:yscale) \
-            [expr $::dialog($vid:graphme)+2*$::dialog($vid:hidetext)] \
-            $::dialog($vid:x1) \
-            $::dialog($vid:y1) \
-            $::dialog($vid:x2) \
-            $::dialog($vid:y2) \
-            $::dialog($vid:xpix) \
-            $::dialog($vid:ypix) \
-            $::dialog($vid:xmargin) \
-            $::dialog($vid:ymargin) \
-            \;]
-}
-*/
     }
 
     function cancel() {
         var i, attrs, gfxstub;
         pdgui.gui_post("closing the window at this point");
-//        window.close(true);
+        //window.close(true);
         pdgui.pdsend(pd_object_callback + " cancel");
         for (i = 0; i < pd_garray_attrs.length; i++) {
             attrs = pd_garray_attrs[i];
             gfxstub = attrs[attrs.indexOf("array_gfxstub") + 1];
-pdgui.gui_post("guistub is " + gfxstub);
             pdgui.pdsend(gfxstub + " cancel");
         }
     }
@@ -588,8 +563,8 @@ pdgui.gui_post("guistub is " + gfxstub);
             pdgui.gui_post(attr_arrays[i] + ": " + attr_arrays[i+1]);
         }
         add_events(gfxstub);
-        // not sure that we need this for properties windows
-//        pdgui.canvas_map(gfxstub);
+        // not sure that we need this for properties windows...
+        // pdgui.canvas_map(gfxstub);
         translate_form();
         if (attr_arrays[0] === 'array_gfxstub') {
             canvas_fieldsets = document.getElementsByClassName('canvas');
@@ -607,7 +582,6 @@ pdgui.gui_post("guistub is " + gfxstub);
         // labels and form elements.  That makes it more efficient and
         // snappier, at least on older machines.
         document.getElementsByClassName('container')[0].style.setProperty('display', 'inline');
-//        document.getElementsByClass("fumbles")[0].setAttribute('style', 'display: inline;');
     }
 
 function tr_text(id) {
@@ -630,23 +604,7 @@ function translate_form() {
 }
 
 function populate_form(attr_array) {
-
     // First, let's put the translated text for the form labels:
-
-//    tr_text('heading.size');
-//    tr_text('heading.messages');
-//    tr_text('heading.label');
-//    tr_text('heading.colors');
-//    tr_prop('width');
-//    tr_tooltip('width');
-
-//    var headings = ["size", "messages", "label", "colors"];
-//    for (var i = 0; i < headings.length; i++) {
-//        var str = "iem.prop.heading." + headings[i];
-//        var heading = document.getElementById(str);
-//        heading.textContent = l(str);
-//    }
-
     for(var i = 0; i < attr_array.length; i+=2) {
         // Unhide the span with the class with the same name as the id
         var prop_group = document.getElementsByClassName(attr_array[i])[0];
@@ -654,23 +612,24 @@ function populate_form(attr_array) {
             console.log("the thing here is " + attr_array[i]);
             prop_group.classList.remove('hidden');
         } 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]);
         }
-
         if (attr_array[i] === 'display-flags') {
             // protip: '!!' forces Boolean, '+' forces Number type
             var flag = +attr_array[i+1];
             document.getElementsByName('gop')[0].checked = !!flag;
             document.getElementsByName('hide-name')[0].checked = !!(flag & 2);
-            // Set the gop-related parts of the form to be enabled/disabled based on state
+            // Set the gop-related parts of the form to be
+            // enabled/disabled based on state
             set_gop(!!flag);
         }            
-
         var elem = document.getElementsByName(attr_array[i]);
         if (elem.length > 0) {
             if(attr_array[i].slice(-5) === 'color') {
                 var hex_string = Number(attr_array[i+1]).toString(16);
-                var color_string = "#" + (hex_string === '0' ? '000000' : hex_string);
+                var color_string = "#" +
+                    (hex_string === '0' ? '000000' : hex_string);
                 pdgui.gui_post("color is " + color_string);
                 elem[0].value = color_string;
             } else if (elem[0].type === 'checkbox') {
@@ -686,17 +645,14 @@ function populate_form(attr_array) {
 }
 
 function add_events(name) {
-    // let's handle some events for this window...
-
     // closing the Window
     nw.Window.get().on("close", function() {
         // this needs to do whatever the "cancel" button does
-//        pdgui.pdsend(name + " menuclose 0");
-//        cancel();
+        //pdgui.pdsend(name + " menuclose 0");
+        //cancel();
         pdgui.remove_dialogwin(pd_object_callback);
         this.close(true);
     });
-
 }
 
   </script>
diff --git a/pd/nw/dialog_font.html b/pd/nw/dialog_font.html
index b935cc81b..b45e642f9 100644
--- a/pd/nw/dialog_font.html
+++ b/pd/nw/dialog_font.html
@@ -93,25 +93,25 @@
   </div>      
 
   <script>
-    'use strict';
-    var nw = require('nw.gui'); 
-    var pdgui = require('./pdgui.js');
+'use strict';
+var nw = require('nw.gui'); 
+var pdgui = require('./pdgui.js');
 
-    // For translations
-    var l = pdgui.get_local_string;
+// For translations
+var l = pdgui.get_local_string;
 
-    console.log("my working dire is " + pdgui.get_pwd());
+console.log("my working dire is " + pdgui.get_pwd());
 
-    pdgui.skin.apply(this);
+pdgui.skin.apply(this);
 
-    var pd_object_callback;
-    var current_size;
-    var canvas;
+var pd_object_callback;
+var current_size;
+var canvas;
 
-    function ok() {
-        apply();
-        cancel();
-    }
+function ok() {
+    apply();
+    cancel();
+}
 
 function change_size() {
     pdgui.gui_post("changing the size");
@@ -119,16 +119,7 @@ function change_size() {
 }
 
 function apply() {
-        pdgui.gui_post("we're applying shits!");
-
-/*
-    set cmd [concat $id param \
-        $::dialog($vid:width) $::dialog($vid:lo) $::dialog($vid:hi) \
-        [gatom_escape $::dialog($vid:label)] $::dialog($vid:wherelabel) \
-        [gatom_escape $::dialog($vid:symfrom)] \
-        [gatom_escape $::dialog($vid:symto)] \;]
-*/
- 
+    pdgui.gui_post("we're applying font size changes!");
     pdgui.pdsend([canvas, 'font', 
         +document.querySelector('input[name="font_size"]:checked').value,
         current_size,
@@ -137,31 +128,30 @@ function apply() {
     ].join(' '));
 }
 
-    function cancel() {
-        pdgui.gui_post("closing the window at this point");
-//        window.close(true);
-        pdgui.pdsend(pd_object_callback + " cancel");
-    }
+function cancel() {
+    pdgui.gui_post("closing the window at this point");
+    //window.close(true);
+    pdgui.pdsend(pd_object_callback + " cancel");
+}
 
-    // This gets called from the nw_create_window function in index.html
-    // It provides us with our window id from the C side.  Once we have it
-    // we can create the menu and register event callbacks
-    function register_canvas_id(gfxstub, attrs) {
-        pd_object_callback = gfxstub;
-
-        console.log('attrs are ' + attrs.toString());
-        add_events(gfxstub);
-        // not sure that we need this for properties windows
-//        pdgui.canvas_map(gfxstub);
-        translate_form();
-        populate_form(attrs);
-        // We don't turn on rendering of the "container" div until
-        // We've finished displaying all the spans and populating the
-        // labels and form elements.  That makes it more efficient and
-        // snappier, at least on older machines.
-        document.getElementsByClassName('container')[0].style.setProperty('display', 'inline');
-//        document.getElementsByClass("fumbles")[0].setAttribute('style', 'display: inline;');
-    }
+// This gets called from the nw_create_window function in index.html
+// It provides us with our window id from the C side.  Once we have it
+// we can create the menu and register event callbacks
+function register_canvas_id(gfxstub, attrs) {
+    pd_object_callback = gfxstub;
+    console.log('attrs are ' + attrs.toString());
+    add_events(gfxstub);
+    // not sure that we need this for properties windows
+    //pdgui.canvas_map(gfxstub);
+    translate_form();
+    populate_form(attrs);
+    // We don't turn on rendering of the "container" div until
+    // We've finished displaying all the spans and populating the
+    // labels and form elements.  That makes it more efficient and
+    // snappier, at least on older machines.
+    document.getElementsByClassName('container')[0]
+        .style.setProperty('display', 'inline');
+}
 
 // Stop-gap translator
 function translate_form() {
@@ -192,19 +182,15 @@ function populate_form(attrs) {
 }
 
 function add_events(name) {
-    // let's handle some events for this window...
-
     // closing the Window
     nw.Window.get().on("close", function() {
         // this needs to do whatever the "cancel" button does
-//        pdgui.pdsend(name + " menuclose 0");
-//        cancel();
+        //pdgui.pdsend(name + " menuclose 0");
+        //cancel();
         pdgui.remove_dialogwin(pd_object_callback);
         this.close(true);
     });
-
 }
-
   </script>
   </body>
 </html>
diff --git a/pd/nw/dialog_gatom.html b/pd/nw/dialog_gatom.html
index 523794922..a52cf11b8 100644
--- a/pd/nw/dialog_gatom.html
+++ b/pd/nw/dialog_gatom.html
@@ -136,32 +136,28 @@
   </div>      
 
   <script>
-    'use strict';
-    var nw = require('nw.gui'); 
-    var pdgui = require('./pdgui.js');
+'use strict';
+var nw = require('nw.gui'); 
+var pdgui = require('./pdgui.js');
 
-    // For translations
-    var l = pdgui.get_local_string;
+// For translations
+var l = pdgui.get_local_string;
 
-    console.log("my working dire is " + pdgui.get_pwd());
+console.log("my working dire is " + pdgui.get_pwd());
 
-    pdgui.skin.apply(this);
+pdgui.skin.apply(this);
 
-    var pd_object_callback;
+var pd_object_callback;
 
-    function ok() {
-        apply();
-        cancel();
-    }
-
-//    function toggler(evt) {
-//        evt.value = evt.checked ? 1 : 0; 
-//    }
+function ok() {
+    apply();
+    cancel();
+}
 
-    function substitute_space(arg) {
-        var fake_space = String.fromCharCode(11);
-        return arg.split(' ').join(fake_space);
-    }
+function substitute_space(arg) {
+    var fake_space = String.fromCharCode(11);
+    return arg.split(' ').join(fake_space);
+}
 
 function strip_problem_chars(arg) {
     var problem_chars = [';', ',', '{', '}', '\\'];
@@ -191,16 +187,7 @@ function gatom_escape(str) {
 }
 
 function apply() {
-        pdgui.gui_post("we're applying shits!");
-
-/*
-    set cmd [concat $id param \
-        $::dialog($vid:width) $::dialog($vid:lo) $::dialog($vid:hi) \
-        [gatom_escape $::dialog($vid:label)] $::dialog($vid:wherelabel) \
-        [gatom_escape $::dialog($vid:symfrom)] \
-        [gatom_escape $::dialog($vid:symto)] \;]
-*/
- 
+    pdgui.gui_post("we're applying gatom changes!");
     pdgui.pdsend([pd_object_callback, 'param', 
         +document.getElementById('width').value,
         +document.getElementById('minimum-range').value,
@@ -212,34 +199,34 @@ function apply() {
     ].join(' '));
 }
 
-    function cancel() {
-        pdgui.gui_post("closing the window at this point");
-//        window.close(true);
-        pdgui.pdsend(pd_object_callback + " cancel");
-    }
+function cancel() {
+    pdgui.gui_post("closing the window at this point");
+    //window.close(true);
+    pdgui.pdsend(pd_object_callback + " cancel");
+}
 
-    // This gets called from the nw_create_window function in index.html
-    // It provides us with our window id from the C side.  Once we have it
-    // we can create the menu and register event callbacks
-    function register_canvas_id(gfxstub, attr_array) {
-        pd_object_callback = gfxstub;
+// This gets called from the nw_create_window function in index.html
+// It provides us with our window id from the C side.  Once we have it
+// we can create the menu and register event callbacks
+function register_canvas_id(gfxstub, attr_array) {
+    pd_object_callback = gfxstub;
 
-        console.log('attr array is ' + attr_array.toString());
-        for (var i = 0; i < attr_array.length; i+=2) {
-            console.log(attr_array[i] + ": " + attr_array[i+1]);
-        }
-        add_events(gfxstub);
-        // not sure that we need this for properties windows
-//        pdgui.canvas_map(gfxstub);
-        translate_form();
-        populate_form(attr_array);
-        // We don't turn on rendering of the "container" div until
-        // We've finished displaying all the spans and populating the
-        // labels and form elements.  That makes it more efficient and
-        // snappier, at least on older machines.
-        document.getElementsByClassName('container')[0].style.setProperty('display', 'inline');
-//        document.getElementsByClass("fumbles")[0].setAttribute('style', 'display: inline;');
+    console.log('attr array is ' + attr_array.toString());
+    for (var i = 0; i < attr_array.length; i+=2) {
+        console.log(attr_array[i] + ": " + attr_array[i+1]);
     }
+    add_events(gfxstub);
+    // not sure that we need this for properties windows
+    //pdgui.canvas_map(gfxstub);
+    translate_form();
+    populate_form(attr_array);
+    // We don't turn on rendering of the "container" div until
+    // We've finished displaying all the spans and populating the
+    // labels and form elements.  That makes it more efficient and
+    // snappier, at least on older machines.
+    document.getElementsByClassName('container')[0]
+        .style.setProperty('display', 'inline');
+}
 
 function tr_text(id) {
     var elem = document.getElementById('iem.prop.' + id);
@@ -290,17 +277,14 @@ function populate_form(attr_array) {
 }
 
 function add_events(name) {
-    // let's handle some events for this window...
-
     // closing the Window
     nw.Window.get().on("close", function() {
         // this needs to do whatever the "cancel" button does
-//        pdgui.pdsend(name + " menuclose 0");
-//        cancel();
+        //pdgui.pdsend(name + " menuclose 0");
+        //cancel();
         pdgui.remove_dialogwin(pd_object_callback);
         this.close(true);
     });
-
 }
 
   </script>
diff --git a/pd/nw/dialog_iemgui.html b/pd/nw/dialog_iemgui.html
index 52239720d..08d64d11e 100644
--- a/pd/nw/dialog_iemgui.html
+++ b/pd/nw/dialog_iemgui.html
@@ -298,223 +298,204 @@
   </div>      
 
   <script>
-    'use strict';
-    var nw = require('nw.gui'); 
-    var pdgui = require('./pdgui.js');
+'use strict';
+var nw = require('nw.gui'); 
+var pdgui = require('./pdgui.js');
 
-    // For translations
-    var l = pdgui.get_local_string;
+// For translations
+var l = pdgui.get_local_string;
 
-    console.log("my working dire is " + pdgui.get_pwd());
+console.log("my working dire is " + pdgui.get_pwd());
 
-    var pd_object_callback;
+var pd_object_callback;
 
-    function ok() {
-        apply();
-        cancel();
-    }
+function ok() {
+    apply();
+    cancel();
+}
 
-//    function toggler(evt) {
-//        evt.value = evt.checked ? 1 : 0; 
-//    }
+function substitute_space(arg) {
+    var fake_space = String.fromCharCode(11);
+    return arg.split(' ').join(fake_space);
+}
 
-    function substitute_space(arg) {
-        var fake_space = String.fromCharCode(11);
-        return arg.split(' ').join(fake_space);
+function strip_problem_chars(arg) {
+    var problem_chars = [';', ',', '{', '}', '\\'];
+    var ret = arg;
+    for(var i = 0; i < problem_chars.length; i++) {
+        ret = ret.split(';').join('');
     }
+    return ret;
+}
 
-    function strip_problem_chars(arg) {
-        var problem_chars = [';', ',', '{', '}', '\\'];
-        var ret = arg;
-        for(var i = 0; i < problem_chars.length; i++) {
-            ret = ret.split(';').join('');
-        }
-        return ret;
+function apply() {
+    pdgui.gui_post("we're applying iemgui changes!");
+    /* Not sure what these are...
+        iemgui_clip_dim $id
+        iemgui_clip_num $id
+        iemgui_sched_rng $id
+        iemgui_verify_rng $id
+        iemgui_sched_rng $id
+        iemgui_clip_fontsize $id
+    */
+    var send_symbol = document.getElementsByName('send-symbol')[0].value;
+    var receive_symbol = document.getElementsByName('receive-symbol')[0].value;
+    var label =  document.getElementsByName('label')[0].value;
+    if (send_symbol === null || send_symbol === '') {
+        send_symbol = 'empty';
+    }
+    if (receive_symbol === null || receive_symbol === '') {
+        receive_symbol = 'empty';
+    }
+    if (label === null || label === '') {
+        label = 'empty';
+    }
+    console.log("send_symbol is " + send_symbol);
+    if (send_symbol.charAt(0) === '$') {
+        send_symbol = '#' + send_symbol.slice(1);
+    }
+    if (receive_symbol.charAt(0) === '$') {
+        receive_symbol = '#' + receive_symbol.slice(1);
+    }
+    if (label.charAt(0) === '$') {
+        label = '#' + label.slice(1);
     }
 
-    function apply() {
-        pdgui.gui_post("we're applying shits!");
-
-        /* Not sure what these are...
-            iemgui_clip_dim $id
-            iemgui_clip_num $id
-            iemgui_sched_rng $id
-            iemgui_verify_rng $id
-            iemgui_sched_rng $id
-            iemgui_clip_fontsize $id
-        */
-
-
-
-        var send_symbol = document.getElementsByName('send-symbol')[0].value;
-        var receive_symbol = document.getElementsByName('receive-symbol')[0].value;
-        var label =  document.getElementsByName('label')[0].value;
-        if (send_symbol === null || send_symbol === '') { send_symbol = 'empty'; }
-        if (receive_symbol === null || receive_symbol === '') { receive_symbol = 'empty'; }
-        if (label === null || label === '') { label = 'empty'; }
-
-        console.log("send_symbol is " + send_symbol);
-
-        if (send_symbol.charAt(0) === '$') {
-            send_symbol = '#' + send_symbol.slice(1);
-        }
-        if (receive_symbol.charAt(0) === '$') {
-            receive_symbol = '#' + receive_symbol.slice(1);
-        }
-        if (label.charAt(0) === '$') {
-            label = '#' + label.slice(1);
-        }
+    send_symbol = substitute_space(send_symbol);
+    receive_symbol = substitute_space(receive_symbol);
+    label = substitute_space(label);
 
-        send_symbol = substitute_space(send_symbol);
-        receive_symbol = substitute_space(receive_symbol);
-        label = substitute_space(label);
+    send_symbol = strip_problem_chars(send_symbol);
+    receive_symbol = strip_problem_chars(receive_symbol);
+    label = strip_problem_chars(label);
 
-        send_symbol = strip_problem_chars(send_symbol);
-        receive_symbol = strip_problem_chars(receive_symbol);
-        label = strip_problem_chars(label);
+    var label_x_offset =  document.getElementsByName('x-offset')[0].value;
+    var label_y_offset =  document.getElementsByName('y-offset')[0].value;
 
-        var label_x_offset =  document.getElementsByName('x-offset')[0].value;
-        var label_y_offset =  document.getElementsByName('y-offset')[0].value;
+    // make sure the offset boxes have a value
+    if (label_x_offset === null) { label_x_offset = 0; }
+    if (label_y_offset === null) { label_y_offset = 0; }
 
-	// make sure the offset boxes have a value
-        if (label_x_offset === null) { label_x_offset = 0; }
-        if (label_y_offset === null) { label_y_offset = 0; }
+    var height, width;
+    var size = document.getElementsByName('size')[0].value;
+    if (size === '') {
+        var size = document.getElementsByName('selection-size')[0].value;
+    }
 
-        var height, width;
-        var size = document.getElementsByName('size')[0].value;
-        if (size === '') {
-            var size = document.getElementsByName('selection-size')[0].value;
-        }
+    if (size !== '') {
+        width = size;
+        height = size;
+    } else {
+        width = document.getElementsByName('width')[0].value;
+        height = document.getElementsByName('height')[0].value;
+    }
 
-        if (size !== '') {
-            width = size;
-            height = size;
-        } else {
-            width = document.getElementsByName('width')[0].value;
-            height = document.getElementsByName('height')[0].value;
-        }
+    var slot3 = document.getElementsByName('minimum-range')[0].value;
+    var slot4 = document.getElementsByName('maximum-range')[0].value;
 
-        var slot3 = document.getElementsByName('minimum-range')[0].value;
-        var slot4 = document.getElementsByName('maximum-range')[0].value;
+    if (slot3 === '') {
+        slot3 = document.getElementsByName('flash-interrupt')[0].value;
+        slot4 = document.getElementsByName('flash-hold')[0].value;
+    }
 
-        if (slot3 === '') {
-            slot3 = document.getElementsByName('flash-interrupt')[0].value;
-            slot4 = document.getElementsByName('flash-hold')[0].value;
-        }
+    if (slot3 === '') {
+        slot3 = document.getElementsByName('visible-width')[0].value;
+        slot4 = document.getElementsByName('visible-height')[0].value;
+    }
 
+    if (slot3 === '') { // toggle
+        slot3 = document.getElementsByName('nonzero-value')[0].value;
         if (slot3 === '') {
-            slot3 = document.getElementsByName('visible-width')[0].value;
-            slot4 = document.getElementsByName('visible-height')[0].value;
-        }
-
-        if (slot3 === '') { // toggle
-            slot3 = document.getElementsByName('nonzero-value')[0].value;
-            if (slot3 === '') {
-                slot3 = 0;
-            }
-            slot4 = 0;
+            slot3 = 0;
         }
+        slot4 = 0;
+    }
 
-        var slot5 = +document.getElementsByName('log-scaling')[0].checked;
-        // Hack to accomodate the vu-scale property, which exists in the same
-        // slot as this one
-        var log_scaling_spanner = document.getElementsByClassName('log-scaling')[0];
-        var log_display = log_scaling_spanner.style.getPropertyValue('display');
+    var slot5 = +document.getElementsByName('log-scaling')[0].checked;
+    // Hack to accomodate the vu-scale property, which exists in the same
+    // slot as this one
+    var log_scaling_spanner = document.getElementsByClassName('log-scaling')[0];
+    var log_display = log_scaling_spanner.style.getPropertyValue('display');
 
-        if (log_display === null) {
-            slot5 = +document.getElementsByName('vu-scale')[0].checked;
-            pdgui.gui_post('slot five is ' + slot5);
-        }
+    if (log_display === null) {
+        slot5 = +document.getElementsByName('vu-scale')[0].checked;
         pdgui.gui_post('slot five is ' + slot5);
+    }
+    pdgui.gui_post('slot five is ' + slot5);
 
-        var init = +document.getElementsByName('init')[0].checked;
-        if (init === '') { init = 0; }
-
-        var slot7 = document.getElementsByName('log-height')[0].value;
-        if (slot7 === '') {
-            slot7 = document.getElementsByName('number')[0].value;
-        }
-        if (slot7 === '') {
-            slot7 = 0;
-        }
-
-        var font_style = document.getElementsByName('font-style')[0].value;
-        if (font_style !== null) { font_style = 0; }
-
-        var font_size = document.getElementsByName('font-size')[0].value;
-        if (font_size === '') { font_size = 0; }
-
-        var foreground_color = parseInt(document.getElementsByName('foreground-color')[0].value.slice(1), 16);
-        var background_color = parseInt(document.getElementsByName('background-color')[0].value.slice(1), 16);
-        var label_color = parseInt(document.getElementsByName('label-color')[0].value.slice(1), 16);
-
-        var slot18 = +document.getElementsByName('steady-on-click')[0].checked;
-
-        pdgui.pdsend([pd_object_callback, 'dialog',
-            width, height,
-            slot3, // bng: flash-interrupt
-                   // slider: min-range
-                   // toggle: nonzero-value
-                   // my_canvas: visible_width
-            slot4, // bng: flash-hold
-                   // slider: max-range
-                   // my_canvas: visible_height
-            slot5, // slider: lin/log thingy
-                   // nbx: lin/log
-                   // vu: vu-scale
-            init,
-            slot7, // log-height or vradio/hradio number
-            send_symbol, receive_symbol, label,
-            label_x_offset, label_y_offset,
-            font_style, font_size,
-            background_color, foreground_color,
-            label_color,
-            slot18, // steady on click
-            0].join(' '));
-/*
-	pd [concat $id dialog \
-		$::dialog($vid:wdt) $::dialog($vid:hgt) \
-		$::dialog($vid:min_rng) $::dialog($vid:max_rng) \
-		$::dialog($vid:lin0_log1) $::dialog($vid:loadbang) \
-		$::dialog($vid:num) \
-		$hhhsnd $hhhrcv $hhhgui_nam \
-		$::dialog($vid:gn_dx) $::dialog($vid:gn_dy) \
-		$::dialog($vid:gn_f) $::dialog($vid:gn_fs) \
-		$::dialog($vid:bcol) $::dialog($vid:fcol) \
-		$::dialog($vid:lcol) \
-		$::dialog($vid:steady) $::dialog($vid:hide) \;]
-*/
+    var init = +document.getElementsByName('init')[0].checked;
+    if (init === '') { init = 0; }
 
+    var slot7 = document.getElementsByName('log-height')[0].value;
+    if (slot7 === '') {
+        slot7 = document.getElementsByName('number')[0].value;
     }
-
-    function cancel() {
-        pdgui.gui_post("closing the window at this point");
-//        window.close(true);
-        pdgui.pdsend(pd_object_callback + " cancel");
+    if (slot7 === '') {
+        slot7 = 0;
     }
 
-    // This gets called from the nw_create_window function in index.html
-    // It provides us with our window id from the C side.  Once we have it
-    // we can create the menu and register event callbacks
-    function register_canvas_id(gfxstub, attr_array) {
-        pd_object_callback = gfxstub;
+    var font_style = document.getElementsByName('font-style')[0].value;
+    if (font_style !== null) { font_style = 0; }
+
+    var font_size = document.getElementsByName('font-size')[0].value;
+    if (font_size === '') { font_size = 0; }
+
+    var foreground_color = parseInt(document.getElementsByName('foreground-color')[0].value.slice(1), 16);
+    var background_color = parseInt(document.getElementsByName('background-color')[0].value.slice(1), 16);
+    var label_color = parseInt(document.getElementsByName('label-color')[0].value.slice(1), 16);
+
+    var slot18 = +document.getElementsByName('steady-on-click')[0].checked;
+
+    pdgui.pdsend([pd_object_callback, 'dialog',
+        width, height,
+        slot3, // bng: flash-interrupt
+               // slider: min-range
+               // toggle: nonzero-value
+               // my_canvas: visible_width
+        slot4, // bng: flash-hold
+               // slider: max-range
+               // my_canvas: visible_height
+        slot5, // slider: lin/log thingy
+               // nbx: lin/log
+               // vu: vu-scale
+        init,
+        slot7, // log-height or vradio/hradio number
+        send_symbol, receive_symbol, label,
+        label_x_offset, label_y_offset,
+        font_style, font_size,
+        background_color, foreground_color,
+        label_color,
+        slot18, // steady on click
+        0].join(' '));
+}
 
-        console.log('attr array is ' + attr_array.toString());
-        for (var i = 0; i < attr_array.length; i+=2) {
-            console.log(attr_array[i] + ": " + attr_array[i+1]);
-        }
-        add_events(gfxstub);
-        // not sure that we need this for properties windows
-//        pdgui.canvas_map(gfxstub);
-        translate_form();
-        populate_form(attr_array);
-        // We don't turn on rendering of the "container" div until
-        // We've finished displaying all the spans and populating the
-        // labels and form elements.  That makes it more efficient and
-        // snappier, at least on older machines.
-        document.getElementsByClassName('container')[0].style.setProperty('display', 'inline');
-//        document.getElementsByClass("fumbles")[0].setAttribute('style', 'display: inline;');
+function cancel() {
+    pdgui.gui_post("closing the window at this point");
+    //window.close(true);
+    pdgui.pdsend(pd_object_callback + " cancel");
+}
+
+// This gets called from the nw_create_window function in index.html
+// It provides us with our window id from the C side.  Once we have it
+// we can create the menu and register event callbacks
+function register_canvas_id(gfxstub, attr_array) {
+    pd_object_callback = gfxstub;
+
+    console.log('attr array is ' + attr_array.toString());
+    for (var i = 0; i < attr_array.length; i+=2) {
+        console.log(attr_array[i] + ": " + attr_array[i+1]);
     }
+    add_events(gfxstub);
+    // not sure that we need this for properties windows
+    //pdgui.canvas_map(gfxstub);
+    translate_form();
+    populate_form(attr_array);
+    // We don't turn on rendering of the "container" div until
+    // We've finished displaying all the spans and populating the
+    // labels and form elements.  That makes it more efficient and
+    // snappier, at least on older machines.
+    document.getElementsByClassName('container')[0].style.setProperty('display', 'inline');
+}
 
 function tr_text(id) {
     var elem = document.getElementById('iem.prop.' + id);
@@ -536,23 +517,6 @@ function translate_form() {
 }
 
 function populate_form(attr_array) {
-
-    // First, let's put the translated text for the form labels:
-
-//    tr_text('heading.size');
-//    tr_text('heading.messages');
-//    tr_text('heading.label');
-//    tr_text('heading.colors');
-//    tr_prop('width');
-//    tr_tooltip('width');
-
-//    var headings = ["size", "messages", "label", "colors"];
-//    for (var i = 0; i < headings.length; i++) {
-//        var str = "iem.prop.heading." + headings[i];
-//        var heading = document.getElementById(str);
-//        heading.textContent = l(str);
-//    }
-
     for(var i = 0; i < attr_array.length; i+=2) {
         // Unhide the span with the class with the same name as the id
         var prop_group = document.getElementsByClassName(attr_array[i])[0];
@@ -560,7 +524,8 @@ function populate_form(attr_array) {
             console.log("the thing here is " + attr_array[i]);
             prop_group.classList.remove('hidden');
         } 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]);
         }
         // iemguis use the string 'empty' for null because of
         // the limitations of Pd's state-saving API.  So we have
@@ -570,7 +535,8 @@ function populate_form(attr_array) {
             if (elem.length > 0) {
                 if(attr_array[i].slice(-5) === 'color') {
                     var hex_string = Number(attr_array[i+1]).toString(16);
-                    var color_string = "#" + (hex_string === '0' ? '000000' : hex_string);
+                    var color_string = "#" +
+                        (hex_string === '0' ? '000000' : hex_string);
                     pdgui.gui_post("color is " + color_string);
                     elem[0].value = color_string;
                 } else if (elem[0].type === 'checkbox') {
@@ -586,17 +552,14 @@ function populate_form(attr_array) {
 }
 
 function add_events(name) {
-    // let's handle some events for this window...
-
     // closing the Window
     nw.Window.get().on("close", function() {
         // this needs to do whatever the "cancel" button does
-//        pdgui.pdsend(name + " menuclose 0");
-//        cancel();
+        //pdgui.pdsend(name + " menuclose 0");
+        //cancel();
         pdgui.remove_dialogwin(pd_object_callback);
         this.close(true);
     });
-
 }
 
   </script>
diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 3d7ce8dae..e088ba763 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -2680,7 +2680,7 @@ function gui_iemgui_drawborder(cid, tag, bgcolor, x1, y1, x2, y2) {
 }
 
 function gui_iemgui_redraw_border(cid, tag, x1, y1, x2, y2) {
-    var item = get_item(cid, tag + 'border');
+    var item = get_gobj(cid, tag).querySelector('.border');
     configure_item(item, {
         width: x2 - x1,
         height: y2 - y1
diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c
index ca7e1f75c..8289f9231 100644
--- a/pd/src/g_all_guis.c
+++ b/pd/src/g_all_guis.c
@@ -1232,10 +1232,14 @@ void iemgui_base_draw_move(t_iemgui *x) {
         canvas, x, x1, y1, x2, y2);
 }
 
+/* I don't think this is needed anymore */
 void iemgui_base_draw_config(t_iemgui *x) {
+    /*
     t_canvas *canvas=glist_getcanvas(x->x_glist);
     char fcol[8]; sprintf(fcol,"#%6.6x", x->x_fcol);
+    */
     //sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas, x, x->x_bcol);
+    /*
     char tagbuf[MAXPDSTRING];
     char bcol[8]; sprintf(bcol, "#%6.6x", x->x_bcol);
     sprintf(tagbuf, "x%lxborder", (long unsigned int)x);
@@ -1246,6 +1250,7 @@ void iemgui_base_draw_config(t_iemgui *x) {
     gui_s(bcol);
     gui_end_array();
     gui_end_vmess();
+    */
 }
 
 void iemgui_draw_update(t_iemgui *x, t_glist *glist) {
-- 
GitLab