Remove another bad idea.
[pwl6.git] / src / yuu / director.js
index 7f90fd4..a078ef5 100644 (file)
@@ -1,7 +1,7 @@
 /* Copyright 2014 Yukkuri Games
    Licensed under the terms of the GNU GPL v2 or later
-   @license http://www.gnu.org/licenses/gpl-2.0.html
-   @source: http://yukkurigames.com/yuu/
+   @license https://www.gnu.org/licenses/gpl-2.0.html
+   @source: https://yukkurigames.com/yuu/
 */
 
 (function (yuu) {
     if (!yuu.InputState) require("./input");
     if (!yuu.Material) require("./gfx");
 
+    function getCommand (element) {
+        var command = element.getAttribute('data-yuu-command');
+        if (!command || command === 'data-yuu-command')
+            element.setAttribute('data-yuu-command', command = element.id);
+        return command;
+    }
+
     yuu.Director = yT({
         constructor: function (commandStack, input, tickHz) {
             /** Manage and update a set of Scenes
 
         // Aside from the performance considerations, deferring
         // resizing by multiple frames fixes mis-sizing during startup
-        // and fullscreen transition in node-webkit on Windows. (And
+        // and fullscreen transition in NW.js on Windows. (And
         // probably similar bugs in other configurations.)
         _doresize: yf.debounce(function () {
             this._resized = true;
                 return;
             this._tickCount = 0;
             this._timerStart = 0;
-            // GNU/Linux with node-webkit sizes things incorrectly on
+            // GNU/Linux with NW.js sizes things incorrectly on
             // startup, so force a recalculating as soon as the render
             // loop runs.
             this._resized = true;
             var elements = element.querySelectorAll("[data-yuu-command]");
 
             yf.each(function (element) {
-                var command = element.getAttribute("data-yuu-command");
+                var command = getCommand(element);
                 switch (element.tagName.toLowerCase()) {
                 case "input":
                     switch (element.type.toLowerCase()) {
         function handleElement (event) {
             /*jshint validthis:true */
             /* `this` comes from being a DOM element event handler. */
-            var command = this.getAttribute("data-yuu-command");
+            var command = getCommand(this);
             switch (this.tagName.toLowerCase()) {
             case "input":
                 switch (this.type.toLowerCase()) {