Modernize utility scripts

Change-Id: I7f673519d91fbebf1ba00f4821c896fda839c93b
diff --git a/dev/js/src/state.js b/dev/js/src/state.js
index 69e2d54..7d0d25e 100644
--- a/dev/js/src/state.js
+++ b/dev/js/src/state.js
@@ -12,10 +12,9 @@
  *   can easily be serialized and kept between page turns (via cookie
  *   and/or query param)
  */
+"use strict";
+
 define(function () {
-
-  "use strict";
-
   return {
 
     /**
@@ -25,22 +24,25 @@
       return Object.create(this)._init(value);
     },
 
+
     // Initialize
     _init : function (values) {
-      this._assoc = [];
+      const t = this;
+      t._assoc = [];
       if (values == undefined) {
-        this.values = [false,true];
+        t.values = [false,true];
       }
       else if (Array.isArray(values)) {
-        this.values = values;
+        t.values = values;
       }
       else {
-        this.values = [values];
+        t.values = [values];
       }
-      this.value = this.values[0];
-      return this;
+      t.value = t.values[0];
+      return t;
     },
 
+
     /**
      * Associate the state with some objects.
      */
@@ -55,6 +57,7 @@
       }
     },
 
+
     /**
      * Set the state to a certain value.
      * This will set the state to all associated objects as well.
@@ -66,6 +69,7 @@
       };
     },
 
+
     /**
      * Get the state value
      */
@@ -81,6 +85,7 @@
       return this._assoc.length;
     },
 
+
     /**
      * Clear all associated objects
      */
@@ -88,6 +93,7 @@
       return this._assoc = [];
     },
 
+
     /**
      * Roll to the next value.
      * This may be used for toggling.