# HG changeset patch # User Mads Kiilerich # Date 1578609642 -3600 # Node ID f4e158ed49b105313c1eb3152367934797cc7d70 # Parent c7e67b87fd1b30616d9e6451adcbe80ea3a576cd js: cleanup to use nested named functions instead of vars with anonymous functions diff -r c7e67b87fd1b -r f4e158ed49b1 kallithea/public/js/base.js --- 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'); $('', { @@ -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')){ diff -r c7e67b87fd1b -r f4e158ed49b1 kallithea/public/js/mergely.js --- 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'); diff -r c7e67b87fd1b -r f4e158ed49b1 kallithea/templates/admin/admin.html --- 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); }); diff -r c7e67b87fd1b -r f4e158ed49b1 kallithea/templates/admin/auth/auth_settings.html --- 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 @@