1 (edited by apmuthu 11/21/2014 10:46:50 am)

Topic: Erroneous Commit to be reverted or updated

On 2014-11-13, a commit was made with the following title:
Javascript now works with multiple classes on elements.
This is erroneous as

indexOf on arrays uses "==" on each element where as indexOf on string will treat the string as an array of char which effectively will do substring

It has since been corrected by the author in his github repo along with other missing replacements.

Please revert the commit or update it with the authors corrected files.

Re: Erroneous Commit to be reverted or updated

Attached is the fix for the Javascript commit done.

--- old/js/utils.js    Sat Nov 22 03:08:34 2014
+++ new/js/utils.js    Sat Nov 22 03:10:08 2014
@@ -356,5 +356,6 @@
 }
 
 function string_contains(haystack, needle) {
-  return haystack.indexOf(needle) > -1;
+  var words = haystack.split(' ');
+  return words.indexOf(needle) > -1;
 }
--- old/js/inserts.js    Sat Nov 22 03:07:55 2014
+++ new/js/inserts.js    Sat Nov 22 03:20:42 2014
@@ -162,7 +162,7 @@
                 event.returnValue = false;
                     return false;
               }
-            if (box && (key == 32) && (this.className == 'combo2')) {
+            if (box && (key == 32) && (string_contains(this.className, 'combo2'))) {
                 this.style.display = 'none';
                 box.style.display = 'inline';
                 box.value='';
@@ -276,11 +276,11 @@
         if(e.onfocus==undefined) {
             e.onfocus = function() {
                 save_focus(this);
-                if (this.className == 'combo' || this.className == 'combo3')
+                if (string_contains(this.className, 'combo') || string_contains(this.className, 'combo3'))
                     this.select();
             };
         }
-        if (e.className == 'combo' || e.className == 'combo2' || e.className == 'combo3') {
+        if (string_contains(e.className, 'combo') || string_contains(e.className, 'combo2') || string_contains(e.className, 'combo3')) {
                 _set_combo_input(e);
         }
         else
@@ -289,7 +289,7 @@
                       ev = ev||window.event;
                       key = ev.keyCode||ev.which;
                        if(key == 13) {
-                        if(e.className == 'searchbox') e.onblur();
+                        if(string_contains(e.className, 'searchbox')) e.onblur();
                         return false;
                     }
                     return true;
@@ -443,10 +443,10 @@
             }
         }
         // prevent unneeded transaction entry abortion
-        if (e.className == 'shortcut'
-         || e.className == 'menu_option'
-         || e.className == 'menu_tab'
-          || e.className == 'selected')
+        if (string_contains(e.className, 'shortcut')
+         || string_contains(e.className, 'menu_option')
+         || string_contains(e.className, 'menu_tab')
+          || string_contains(e.className, 'selected'))
             e.onclick = function(ev) {
                 if (_validate._processing
                  && _validate._modified
Post's attachments

Fixed_js_patch.zip 11.1 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

3 (edited by apmuthu 11/22/2014 11:30:48 am)

Re: Erroneous Commit to be reverted or updated

This has now been partially committed today.

The balance of the diff needs to be committed as below:

--- old/js/inserts.js    Sat Nov 22 16:50:29 2014
+++ new/js/inserts.js    Sat Nov 22 16:54:09 2014
@@ -289,7 +289,7 @@
                       ev = ev||window.event;
                       key = ev.keyCode||ev.which;
                        if(key == 13) {
-                        if(e.className == 'searchbox') e.onblur();
+                        if(string_contains(e.className, 'searchbox')) e.onblur();
                         return false;
                     }
                     return true;
@@ -443,10 +443,10 @@
             }
         }
         // prevent unneeded transaction entry abortion
-        if (e.className == 'shortcut'
-         || e.className == 'menu_option'
-         || e.className == 'menu_tab'
-          || e.className == 'selected')
+        if (string_contains(e.className, 'shortcut')
+         || string_contains(e.className, 'menu_option')
+         || string_contains(e.className, 'menu_tab')
+          || string_contains(e.className, 'selected'))
             e.onclick = function(ev) {
                 if (_validate._processing
                  && _validate._modified