diff --git a/src/main/webapp/assets/common/js/gitbucket.js b/src/main/webapp/assets/common/js/gitbucket.js index 93e832e..dc3f74d 100644 --- a/src/main/webapp/assets/common/js/gitbucket.js +++ b/src/main/webapp/assets/common/js/gitbucket.js @@ -4,7 +4,7 @@ // repository url text field $('#repository-url').click(function(){ - this.select(0, this.value.length); + this.select(0, this.value.length); }); // activate tooltip @@ -17,7 +17,7 @@ }); $('.markdown-head').mouseleave(function(e){ var anchorLink = $(e.target).children('a.markdown-anchor-link'); - if(anchorLink.data('active') != true){ + if(anchorLink.data('active') !== true){ anchorLink.hide(); } }); @@ -39,7 +39,7 @@ var i = 0; $.each(data, function(key, value){ $('#error-' + key.split(".").join("_")).text(value); - if(i == 0){ + if(i === 0){ $('#' + key).focus(); } i++; @@ -71,17 +71,15 @@ function diffUsingJS(oldTextId, newTextId, outputId) { // get the baseText and newText values from the two textboxes, and split them into lines var oldText = document.getElementById(oldTextId).value; - if(oldText == ''){ - var oldLines = []; - } else { - var oldLines = difflib.stringAsLines(oldText); + var oldLines = []; + if(oldText !== ''){ + oldLines = difflib.stringAsLines(oldText); } - var newText = document.getElementById(newTextId).value - if(newText == ''){ - var newLines = []; - } else { - var newLines = difflib.stringAsLines(newText); + var newText = document.getElementById(newTextId).value; + var newLines = []; + if(newText !== ''){ + newLines = difflib.stringAsLines(newText); } // create a SequenceMatcher instance that diffs the two sets of lines @@ -106,4 +104,4 @@ function jqSelectorEscape(val) { return val.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '\\$&'); -} \ No newline at end of file +} diff --git a/src/main/webapp/assets/common/js/validation.js b/src/main/webapp/assets/common/js/validation.js index 86a10a5..44111f7 100644 --- a/src/main/webapp/assets/common/js/validation.js +++ b/src/main/webapp/assets/common/js/validation.js @@ -4,25 +4,25 @@ }); $.each($('input[formaction]'), function(i, input){ $(input).click(function(){ - var form = $(input).parents('form') - $(form).attr('action', $(input).attr('formaction')) + var form = $(input).parents('form'); + $(form).attr('action', $(input).attr('formaction')); }); }); }); function validate(e){ var form = $(e.target); - $(form).find('[type=submit]').attr('disabled', 'disabled') - - if(form.data('validated') == true){ + $(form).find('[type=submit]').attr('disabled', 'disabled'); + + if(form.data('validated') !== true){ return true; } $.post(form.attr('action') + '/validate', $(e.target).serialize(), function(data){ - $(form).find('[type=submit]').removeAttr('disabled') + $(form).find('[type=submit]').removeAttr('disabled'); // clear all error messages $('.error').text(''); - + if($.isEmptyObject(data)){ form.data('validated', true); form.submit(); @@ -39,4 +39,4 @@ $.each(data, function(key, value){ $('#error-' + key.split(".").join("_")).text(value); }); -} \ No newline at end of file +}