changeset 8253:f4e158ed49b1

js: cleanup to use nested named functions instead of vars with anonymous functions
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 09 Jan 2020 23:40:42 +0100
parents c7e67b87fd1b
children 4d36432bf705
files kallithea/public/js/base.js kallithea/public/js/mergely.js kallithea/templates/admin/admin.html kallithea/templates/admin/auth/auth_settings.html kallithea/templates/admin/repo_groups/repo_group_add.html kallithea/templates/admin/repos/repo_add_base.html kallithea/templates/admin/settings/settings_hooks.html kallithea/templates/base/base.html kallithea/templates/base/perms_summary.html kallithea/templates/changelog/changelog.html kallithea/templates/changeset/diff_block.html kallithea/templates/compare/compare_diff.html kallithea/templates/journal/journal.html kallithea/templates/pullrequests/pullrequest.html
diffstat 14 files changed, 38 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/public/js/base.js	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/public/js/base.js	Thu Jan 09 23:40:42 2020 +0100
@@ -171,12 +171,12 @@
             return output.join('');
         }
 
-        var str_format = function() {
+        function str_format() {
             if (!str_format.cache.hasOwnProperty(arguments[0])) {
                 str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
             }
             return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
-        };
+        }
 
         str_format.format = function(parse_tree, argv) {
             var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
@@ -727,7 +727,7 @@
             'save_close': pr_close,
             'save_delete': pr_delete
         };
-        var success = function(json_data) {
+        function success(json_data) {
             if (pr_delete) {
                 location = json_data['location'];
             } else {
@@ -740,8 +740,8 @@
                     location.reload(true);
                 }
             }
-        };
-        var failure = function(x, s, e) {
+        }
+        function failure(x, s, e) {
             $preview.removeClass('submitting').addClass('failed');
             var $status = $preview.find('.comment-submission-status');
             $('<span>', {
@@ -766,7 +766,7 @@
                     comment_div_state($comment_div, f_path, line_no);
                 })
             ).appendTo($status);
-        };
+        }
         ajaxPOST(AJAX_COMMENT_URL, postData, success, failure);
     });
 
@@ -788,7 +788,7 @@
 function deleteComment(comment_id) {
     var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__', comment_id);
     var postData = {};
-    var success = function(o) {
+    function success(o) {
         $('#comment-'+comment_id).remove();
         // Ignore that this might leave a stray Add button (or have a pending form with another comment) ...
     }
@@ -831,7 +831,7 @@
     var filterTimeout = null;
     var nodes = null;
 
-    var initFilter = function(){
+    function initFilter(){
         $('#node_filter_box_loading').show();
         $('#search_activate_id').hide();
         $('#add_node_id').hide();
@@ -852,7 +852,7 @@
         ;
     }
 
-    var updateFilter = function(e) {
+    function updateFilter(e) {
         return function(){
             // Reset timeout
             filterTimeout = null;
@@ -899,7 +899,7 @@
                 $('#tbody_filtered').hide();
             }
         }
-    };
+    }
 
     $('#filter_activate').click(function(){
             initFilter();
@@ -1322,12 +1322,12 @@
 }
 
 function ajaxActionRevokePermission(url, obj_id, obj_type, field_id, extra_data) {
-    var success = function (o) {
+    function success(o) {
             $('#' + field_id).remove();
-        };
-    var failure = function (o) {
+        }
+    function failure(o) {
             alert(_TM['Failed to revoke permission'] + ": " + o.status);
-        };
+        }
     var query_params = {};
     // put extra data into POST
     if (extra_data !== undefined && (typeof extra_data === 'object')){
--- a/kallithea/public/js/mergely.js	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/public/js/mergely.js	Thu Jan 09 23:40:42 2020 +0100
@@ -699,7 +699,7 @@
 		// resize
 		if (this.settings.autoresize) {
 			var sz_timeout1 = null;
-			var sz = function(init) {
+			function sz(init) {
 				//self.em_height = null; //recalculate
 				if (self.settings.resize) self.settings.resize(init);
 				self.editor[self.id + '-lhs'].refresh();
@@ -854,7 +854,7 @@
 	_clear: function() {
 		var self = this, name, editor, fns, timer, i, change, l;
 
-		var clear_changes = function() {
+		function clear_changes() {
 			timer = new Mgly.Timer();
 			for (i = 0, l = editor.lineCount(); i < l; ++i) {
 				editor.removeLineClass(i, 'background');
--- a/kallithea/templates/admin/admin.html	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/templates/admin/admin.html	Thu Jan 09 23:40:42 2020 +0100
@@ -35,9 +35,9 @@
         $jfilter.val('');
     }
   });
-  var fix_j_filter_width = function(len){
+  function fix_j_filter_width(len){
       $('#j_filter').css('width', Math.max(80, len*6.50)+'px');
-  };
+  }
   $('#j_filter').keyup(function () {
     fix_j_filter_width($('#j_filter').val().length);
   });
--- a/kallithea/templates/admin/auth/auth_settings.html	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/templates/admin/auth/auth_settings.html	Thu Jan 09 23:40:42 2020 +0100
@@ -108,7 +108,7 @@
 <script>'use strict';
     $('.toggle-plugin').click(function(e){
         var $auth_plugins_input = $('#auth_plugins');
-        var notEmpty = function(element, index, array) {
+        function notEmpty(element, index, array) {
             return (element != "");
         }
         var elems = $auth_plugins_input.val().split(',').filter(notEmpty);
--- a/kallithea/templates/admin/repo_groups/repo_group_add.html	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/templates/admin/repo_groups/repo_group_add.html	Thu Jan 09 23:40:42 2020 +0100
@@ -63,7 +63,7 @@
 </div>
 <script>'use strict';
     $(document).ready(function(){
-        var setCopyPermsOption = function(group_val){
+        function setCopyPermsOption(group_val){
             if(group_val != "-1"){
                 $('#copy_perms').show();
             }
--- a/kallithea/templates/admin/repos/repo_add_base.html	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/templates/admin/repos/repo_add_base.html	Thu Jan 09 23:40:42 2020 +0100
@@ -67,7 +67,7 @@
 </div>
 <script>'use strict';
     $(document).ready(function(){
-        var setCopyPermsOption = function(group_val){
+        function setCopyPermsOption(group_val){
             if(group_val != "-1"){
                 $('#copy_perms').show();
             }
--- a/kallithea/templates/admin/settings/settings_hooks.html	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/templates/admin/settings/settings_hooks.html	Thu Jan 09 23:40:42 2020 +0100
@@ -53,12 +53,12 @@
 <script>'use strict';
 function delete_hook(hook_id, field_id) {
     var sUrl = ${h.js(h.url('admin_settings_hooks_delete'))};
-    var success = function (o) {
+    function success(o) {
             $('#' + field_id).remove();
-        };
-    var failure = function (o) {
+        }
+    function failure(o) {
             alert(${h.js(_('Failed to remove hook'))});
-        };
+        }
     var postData = {'hook_id': hook_id};
     ajaxPOST(sUrl, postData, success, failure);
 };
--- a/kallithea/templates/base/base.html	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/templates/base/base.html	Thu Jan 09 23:40:42 2020 +0100
@@ -404,7 +404,7 @@
             var visual_show_public_icon = ${h.js(c.visual.show_public_icon)};
             var cache = {}
             /*format the look of items in the list*/
-            var format = function(state){
+            function format(state){
                 if (!state.id){
                   return state.text.html_escape(); // optgroup
                 }
--- a/kallithea/templates/base/perms_summary.html	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/templates/base/perms_summary.html	Thu Jan 09 23:40:42 2020 +0100
@@ -99,7 +99,7 @@
 </div>
 <script>'use strict';
     $(document).ready(function(){
-        var show_empty = function(section){
+        function show_empty(section){
             var visible = $('.section_{0} tr.perm_row:visible'.format(section)).length;
             if(visible == 0){
                 $('#empty_{0}'.format(section)).show();
@@ -108,7 +108,7 @@
                 $('#empty_{0}'.format(section)).hide();
             }
         }
-        var update_show = function($checkbox){
+        function update_show($checkbox){
             var section = $checkbox.data('section');
 
             var elems = $('.filter_' + section).each(function(el){
--- a/kallithea/templates/changelog/changelog.html	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/templates/changelog/changelog.html	Thu Jan 09 23:40:42 2020 +0100
@@ -90,7 +90,7 @@
 
                 pyroutes.register('changeset_home', ${h.js(h.url('changeset_home', repo_name='%(repo_name)s', revision='%(revision)s'))}, ['repo_name', 'revision']);
 
-                var checkbox_checker = function(e) {
+                function checkbox_checker(e) {
                     var $checked_checkboxes = $checkboxes.filter(':checked');
                     var $singlerange = $('#singlerange');
 
@@ -163,7 +163,7 @@
                         $('#compare_fork').show();
                         $checkboxes.closest('tr').removeClass('out-of-range');
                     }
-                };
+                }
                 checkbox_checker();
                 $checkboxes.click(function() {
                     checkbox_checker();
--- a/kallithea/templates/changeset/diff_block.html	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/templates/changeset/diff_block.html	Thu Jan 09 23:40:42 2020 +0100
@@ -112,10 +112,10 @@
         $('#'+e.currentTarget.id+'-img-a.img-diff-swapable')
           .before($('#'+e.currentTarget.id+'-img-b.img-diff-swapable'));
     });
-    var reset = function(e){
+    function reset(e){
         $('#'+e.currentTarget.id+'-img-a.img-diff-swapable')
           .after($('#'+e.currentTarget.id+'-img-b.img-diff-swapable'));
-    };
+    }
     $('.btn-image-diff-swap').mouseup(reset);
     $('.btn-image-diff-swap').mouseleave(reset);
 
--- a/kallithea/templates/compare/compare_diff.html	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/templates/compare/compare_diff.html	Thu Jan 09 23:40:42 2020 +0100
@@ -154,7 +154,7 @@
     make_revision_dropdown("#compare_org",   ${h.js(c.a_repo.repo_name)},  ${h.js(c.a_ref_name)},  'cache');
     make_revision_dropdown("#compare_other", ${h.js(c.cs_repo.repo_name)}, ${h.js(c.cs_ref_name)}, 'cache2');
 
-    var values_changed = function() {
+    function values_changed() {
         var values = $('#compare_org').select2('data') && $('#compare_other').select2('data');
         if (values) {
              $('#compare_revs').removeClass("disabled");
--- a/kallithea/templates/journal/journal.html	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/templates/journal/journal.html	Thu Jan 09 23:40:42 2020 +0100
@@ -49,9 +49,9 @@
             $jfilter.val('');
         }
     });
-    var fix_j_filter_width = function(len){
+    function fix_j_filter_width(len){
         $('#j_filter').css('width', Math.max(80, len*6.50)+'px');
-    };
+    }
     $('#j_filter').keyup(function(){
         fix_j_filter_width($('#j_filter').val().length);
     });
--- a/kallithea/templates/pullrequests/pullrequest.html	Sun Feb 16 02:47:09 2020 +0100
+++ b/kallithea/templates/pullrequests/pullrequest.html	Thu Jan 09 23:40:42 2020 +0100
@@ -96,7 +96,7 @@
   pyroutes.register('pullrequest_repo_info', ${h.js(url('pullrequest_repo_info',repo_name='%(repo_name)s'))}, ['repo_name']);
 
   var pendingajax = undefined;
-  var otherrepoChanged = function(){
+  function otherrepoChanged(){
       var $other_ref = $('#other_ref');
       $other_ref.prop('disabled', true);
       var repo_name = $('#other_repo').val();
@@ -132,9 +132,9 @@
               $other_ref.prop('disabled', false);
               loadPreview();
           });
-  };
+  }
 
-  var loadPreview = function(){
+  function loadPreview(){
       //url template
       var url = ${h.js(h.url('compare_url',
                          repo_name='__other_repo__',