← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/js-awfulness into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/js-awfulness into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/js-awfulness/+merge/97393

Fix a few general JS issues that affect IE8. Adding some missing semicolons, and replacing some ECMAScript 5 Array method calls with the corresponding calls in Y.Array. I also had to fix a few callsites that tried to use Y.Array as a constructor, when it really just returns a native array.
-- 
https://code.launchpad.net/~wgrant/launchpad/js-awfulness/+merge/97393
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/js-awfulness into lp:launchpad.
=== modified file 'lib/lp/app/javascript/autocomplete/autocomplete.js'
--- lib/lp/app/javascript/autocomplete/autocomplete.js	2011-06-29 14:56:15 +0000
+++ lib/lp/app/javascript/autocomplete/autocomplete.js	2012-03-14 13:10:28 +0000
@@ -611,7 +611,7 @@
 
         // More ugliness, looking at protected object members that should
         // be made public.
-        var firstItem = menu._rootMenu.all('.yui3-menuitem').item(0)
+        var firstItem = menu._rootMenu.all('.yui3-menuitem').item(0);
         var item = menu ? firstItem : null;
         if (!menu || !item) {
             return null;

=== modified file 'lib/lp/app/javascript/choiceedit/choiceedit.js'
--- lib/lp/app/javascript/choiceedit/choiceedit.js	2012-02-26 22:45:40 +0000
+++ lib/lp/app/javascript/choiceedit/choiceedit.js	2012-03-14 13:10:28 +0000
@@ -663,7 +663,7 @@
         value: [],
         getter: function(v) {
             if (!Y.Lang.isValue(this.get("value"))) {
-                v = Y.Array(v).filter(function(item) {
+                v = Y.Array.filter(v, function(item) {
                     return (Y.Lang.isValue(item.value));
                 });
             }

=== modified file 'lib/lp/app/javascript/expander.js'
--- lib/lp/app/javascript/expander.js	2011-08-03 03:04:42 +0000
+++ lib/lp/app/javascript/expander.js	2012-03-14 13:10:28 +0000
@@ -88,7 +88,7 @@
     },
 
     _stateChangeProcessor: function(group_id, new_state, active_expander) {
-        this.expanders[group_id].forEach(function(expander) {
+        Y.Array.forEach(this.expanders[group_id], function(expander) {
             if (new_state === EXPANDED && expander !== active_expander) {
                 if (expander.isExpanded()) {
                     expander.render(false);
@@ -106,7 +106,7 @@
 
     _deregisterExpander: function(group_id, expander) {
         if (this.expanders.hasOwnProperty(group_id)) {
-            var idx = this.expanders[group_id].indexOf(expander);
+            var idx = Y.Array.indexOf(this.expanders[group_id], expander);
             if (idx !== -1) {
                 this.expanders[group_id].splice(idx, 1);
             }

=== modified file 'lib/lp/app/javascript/extras/extras.js'
--- lib/lp/app/javascript/extras/extras.js	2012-01-12 10:38:47 +0000
+++ lib/lp/app/javascript/extras/extras.js	2012-03-14 13:10:28 +0000
@@ -26,7 +26,8 @@
  *     instance.
  */
 NodeList.map = function(instance, fn, context) {
-    return NodeList.getDOMNodes(instance).map(Y.one).map(
+    return Y.Array.map(
+        Y.Array.map(NodeList.getDOMNodes(instance), Y.one),
         function(node) {
             return fn.call(context || node, node);
         }
@@ -65,7 +66,7 @@
  */
 var attrselect = function(name) {
     return function(things) {
-        return Y.Array(things).map(attrgetter(name));
+        return Y.Array.map(things, attrgetter(name));
     };
 };
 

=== modified file 'lib/lp/app/javascript/hide_comment.js'
--- lib/lp/app/javascript/hide_comment.js	2011-08-09 14:18:02 +0000
+++ lib/lp/app/javascript/hide_comment.js	2012-03-14 13:10:28 +0000
@@ -33,7 +33,7 @@
             failure: callbacks.failure
             },
         parameters: parameters
-        }
+        };
     lp_client.named_post(
         comment_context.self_link, 'setCommentVisibility', config);
 }

=== modified file 'lib/lp/app/javascript/lp.ui.js'
--- lib/lp/app/javascript/lp.ui.js	2011-08-09 14:18:02 +0000
+++ lib/lp/app/javascript/lp.ui.js	2012-03-14 13:10:28 +0000
@@ -17,7 +17,7 @@
       var element = Y.one(selector);
       element.setContent(content);
       Y.lp.anim.green_flash({node:element}).run();
-    }
+    };
 
   }, "0.1", {"requires": ["node", "escape", "lp.anim"]}
 );

=== modified file 'lib/lp/app/javascript/picker/picker.js'
--- lib/lp/app/javascript/picker/picker.js	2012-03-02 16:17:46 +0000
+++ lib/lp/app/javascript/picker/picker.js	2012-03-14 13:10:28 +0000
@@ -463,7 +463,7 @@
             Y.each(data.badges, function(badge_info) {
                 var badge_url = badge_info.url;
                 var badge_alt = badge_info.label + ' ' + badge_info.role;
-                if (already_processed.indexOf(badge_info.label)<0) {
+                if (Y.Array.indexOf(already_processed, badge_info.label)<0) {
                     already_processed.push(badge_info.label);
                     var badge = Y.Node.create('<img></img>')
                         .addClass('badge')
@@ -518,7 +518,7 @@
         if (Y.Lang.isArray(data.badges)) {
             var already_processed = [];
             Y.each(data.badges, function(badge_info) {
-                if (already_processed.indexOf(badge_info.label)<0) {
+                if (Y.Array.indexOf(already_processed, badge_info.label)<0) {
                     already_processed.push(badge_info.label);
                     var affiliation = Y.Node.create('<div></div>')
                         .addClass('affiliation');

=== modified file 'lib/lp/bugs/javascript/bug_tags_entry.js'
--- lib/lp/bugs/javascript/bug_tags_entry.js	2012-01-19 02:00:52 +0000
+++ lib/lp/bugs/javascript/bug_tags_entry.js	2012-03-14 13:10:28 +0000
@@ -62,9 +62,9 @@
 var base_url = window.location.href.split('/+bug')[0] + '/+bugs?field.tag=';
 
 namespace.parse_tags = function(tag_string) {
-    var tags  = Y.Array(
-        Y.Lang.trim(tag_string).split(new RegExp('\\s+'))).filter(
-            function(elem) { return elem !== ''; });
+    var tags  = Y.Array.filter(
+        Y.Lang.trim(tag_string).split(new RegExp('\\s+')),
+        function(elem) { return elem !== ''; });
     return tags;
 };
 
@@ -88,7 +88,7 @@
             var official_tags = [];
             var unofficial_tags = [];
             Y.each(updated_entry.get('tags'), function(tag) {
-                if (available_tags.indexOf(tag) > -1) {
+                if (Y.Array.indexOf(available_tags, tag) > -1) {
                     official_tags.push(tag);
                 } else {
                     unofficial_tags.push(tag);
@@ -96,11 +96,11 @@
             });
             official_tags.sort();
             unofficial_tags.sort();
-            var tags_html = Y.Array(official_tags).map(function(tag) {
+            var tags_html = Y.Array.map(official_tags, function(tag) {
                 return Y.Lang.sub(
                     '<a href="{tag_url}" class="official-tag">{tag}</a>',
                     {tag_url: base_url + tag, tag: tag});
-            }).join(' ') + ' ' + Y.Array(unofficial_tags).map(function(tag) {
+            }).join(' ') + ' ' + Y.Array.map(unofficial_tags, function(tag) {
                 return Y.Lang.sub(
                     '<a href="{tag_url}" class="unofficial-tag">{tag}</a>',
                     {tag_url: base_url + tag, tag: tag});
@@ -173,7 +173,7 @@
 namespace.setup_tag_entry = function(available_official_tags) {
     if (LP.links.me === undefined) { return; }
 
-    available_tags = Y.Array(available_official_tags);
+    available_tags = available_official_tags;
     bug_tags_div = Y.one('#bug-tags');
     edit_tags_trigger = bug_tags_div.one('#edit-tags-trigger');
     add_tags_trigger = Y.one('#add-tags-trigger');

=== modified file 'lib/lp/bugs/javascript/official_bug_tags.js'
--- lib/lp/bugs/javascript/official_bug_tags.js	2012-01-11 13:10:45 +0000
+++ lib/lp/bugs/javascript/official_bug_tags.js	2012-03-14 13:10:28 +0000
@@ -98,7 +98,7 @@
 var get_other_bug_tags = function(used_bug_tags) {
     var tags = [];
     Y.each(used_bug_tags, function(value, key, obj) {
-        if (official_bug_tags.indexOf(key) < 0) {
+        if (Y.Array.indexOf(official_bug_tags, key) < 0) {
             tags.push({tag: key, count: value});
         }
     });
@@ -140,7 +140,7 @@
 
 var mangle_id = function(value) {
     var chars = value.split('');
-    chars = Y.Array(chars).map(function(ch) {
+    chars = Y.Array.map(chars, function(ch) {
         if (ch.match(re_alphanum)) {
             return ch;
         } else {
@@ -277,7 +277,7 @@
         new_to_tags.push(item);
     });
     new_from_tags = filter_array(from_tags, function(item) {
-        return (selected_tags.indexOf(item) < 0);
+        return (Y.Array.indexOf(selected_tags, item) < 0);
     });
     sort_tags(new_from_tags);
     sort_tags(new_to_tags);

=== modified file 'lib/lp/code/javascript/branchmergeproposal.nominate.js'
--- lib/lp/code/javascript/branchmergeproposal.nominate.js	2012-02-14 03:54:01 +0000
+++ lib/lp/code/javascript/branchmergeproposal.nominate.js	2012-03-14 13:10:28 +0000
@@ -18,8 +18,8 @@
  */
 var _make_confirm_propmpt = function(branches_to_check, branch_info) {
     var visible_branches = branch_info.visible_branches;
-    var invisible_branches = branches_to_check.filter(function(i) {
-        return visible_branches.indexOf(i) < 0;
+    var invisible_branches = Y.Array.filter(branches_to_check, function(i) {
+        return Y.Array.indexOf(visible_branches, i) < 0;
     });
     return Y.lp.mustache.to_html([
     "<p class='large-warning' style='padding:12px 2px 0 36px;'>",

=== modified file 'lib/lp/code/javascript/requestbuild_overlay.js'
--- lib/lp/code/javascript/requestbuild_overlay.js	2012-03-02 16:17:46 +0000
+++ lib/lp/code/javascript/requestbuild_overlay.js	2012-03-14 13:10:28 +0000
@@ -204,7 +204,7 @@
     Y.Array.each(row_classes, function(row_class) {
         Y.all('.'+row_class).each(function(row) {
             var row_id = row.getAttribute('id');
-            if (builds.indexOf(row_id)<0) {
+            if (Y.Array.indexOf(builds, row_id)<0) {
                 builds.push(row_id);
             }
         });
@@ -221,7 +221,7 @@
     var new_builds = harvest_current_build_records();
     var nr_new_builds = 0;
     Y.Array.each(new_builds, function(row_id) {
-        if( current_builds.indexOf(row_id)>=0 ) {
+        if( Y.Array.indexOf(current_builds, row_id)>=0 ) {
             return;
         }
         nr_new_builds += 1;

=== modified file 'lib/lp/registry/javascript/structural-subscription.js'
--- lib/lp/registry/javascript/structural-subscription.js	2012-01-09 11:51:09 +0000
+++ lib/lp/registry/javascript/structural-subscription.js	2012-03-14 13:10:28 +0000
@@ -72,7 +72,7 @@
  */
 function list_contains(list, target) {
     // The list may be undefined in some cases.
-    return Y.Lang.isArray(list) && list.indexOf(target) !== -1;
+    return Y.Lang.isArray(list) && Y.Array.indexOf(list, target) !== -1;
 }
 
 // Expose to tests.

=== modified file 'lib/lp/registry/javascript/team_mailinglists.js'
--- lib/lp/registry/javascript/team_mailinglists.js	2012-02-06 14:57:12 +0000
+++ lib/lp/registry/javascript/team_mailinglists.js	2012-03-14 13:10:28 +0000
@@ -131,7 +131,7 @@
                     // Create a new array of the nested messages from the ids
                     // provided by the current message's `nested_messages`
                     // parameter.
-                    nested_messages = messages.filter(filter_func);
+                    nested_messages = Y.Array.filter(messages, filter_func);
                     this._create_mustache_model(
                         nested_messages,
                         mustache_model,

=== modified file 'lib/lp/translations/javascript/importqueueentry.js'
--- lib/lp/translations/javascript/importqueueentry.js	2011-08-09 14:18:02 +0000
+++ lib/lp/translations/javascript/importqueueentry.js	2012-03-14 13:10:28 +0000
@@ -205,7 +205,7 @@
     if (option_index > 0) {
         // Template selected.  Use its name and translation domain.
         name = dropdown.get('options').item(option_index).get('text');
-        domain = template_domains[name]
+        domain = template_domains[name];
     } else {
         // No template selected.  Pick whatever we had for this case.
         name = custom_template_name;
@@ -224,7 +224,7 @@
     custom_translation_domain = getFormFieldValue('translation_domain');
     updateTemplatesDropdown();
 
-    getFormField('potemplate').on('change', handleTemplateChoice)
+    getFormField('potemplate').on('change', handleTemplateChoice);
 
     getFormField('name').on('change', updateTemplatesDropdown);
     getFormField('translation_domain').on('change', updateTemplatesDropdown);