From 9c4f0d51df4424f410534686f00bf629d98d53e0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 10 Jan 2013 10:59:20 +0100 Subject: [ticket/11314] Cleanup core.js coding function errorHandler() was used in returnHandler() before it was defined. The unused variable alert has been removed from errorHandler(). Overuse of the var keyword for the variable sign has been removed and the if statement has been simplified. The definition of the variable i has been moved outside of the for loop definition. The var keyword shouldn't be used inside the definition of the for loop. PHPBB3-11314 --- phpBB/assets/javascript/core.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'phpBB/assets/javascript/core.js') diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 16ed04746d..9323f4a447 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -252,6 +252,11 @@ phpbb.ajaxify = function(options) { return; } + function errorHandler() { + phpbb.clearLoadingTimeout(); + phpbb.alert(dark.attr('data-ajax-error-title'), dark.attr('data-ajax-error-text')); + } + /** * This is a private function used to handle the callbacks, refreshes * and alert. It calls the callback, refreshes the page if necessary, and @@ -320,13 +325,6 @@ phpbb.ajaxify = function(options) { } } - function errorHandler() { - var alert; - - phpbb.clearLoadingTimeout(); - alert = phpbb.alert(dark.attr('data-ajax-error-title'), dark.attr('data-ajax-error-text')); - } - // If the element is a form, POST must be used and some extra data must // be taken from the form. var runFilter = (typeof options.filter === 'function'); @@ -440,12 +438,11 @@ phpbb.timezonePreselectSelect = function(forceSelector) { // The offset returned here is in minutes and negated. // http://www.w3schools.com/jsref/jsref_getTimezoneOffset.asp var offset = (new Date()).getTimezoneOffset(); + var sign = '-'; if (offset < 0) { - var sign = '+'; + sign = '+'; offset = -offset; - } else { - var sign = '-'; } var minutes = offset % 60; @@ -466,8 +463,9 @@ phpbb.timezonePreselectSelect = function(forceSelector) { var prefix = 'GMT' + sign + hours + ':' + minutes; var prefixLength = prefix.length; var selectorOptions = $('#tz_date > option'); + var i; - for (var i = 0; i < selectorOptions.length; ++i) { + for (i = 0; i < selectorOptions.length; ++i) { var option = selectorOptions[i]; if (option.value.substring(0, prefixLength) == prefix) { -- cgit v1.2.1 From 49edfa49ab9b475e02997f8a89050acc73bf30c8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 12 Jan 2013 19:08:34 +0100 Subject: [ticket/11314] Fix whitespace issues PHPBB3-11314 --- phpBB/assets/javascript/core.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/assets/javascript/core.js') diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 9323f4a447..f38b35d613 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -57,7 +57,7 @@ phpbb.clearLoadingTimeout = function() { * @param string title Title of the message, eg "Information" (HTML). * @param string msg Message to display (HTML). * @param bool fadedark Remove the dark background when done? Defaults - * to yes. + * to yes. * * @returns object Returns the div created. */ @@ -121,9 +121,9 @@ phpbb.alert = function(title, msg, fadedark) { * * @param string msg Message to display (HTML). * @param function callback Callback. Bool param, whether the user pressed - * yes or no (or whatever their language is). + * yes or no (or whatever their language is). * @param bool fadedark Remove the dark background when done? Defaults - * to yes. + * to yes. * * @returns object Returns the div created. */ @@ -232,10 +232,10 @@ phpbb.parseQuerystring = function(string) { * * @param object options Options. * @param bool/function refresh If we are sent back a refresh, should it be - * acted upon? This can either be true / false / a function. + * acted upon? This can either be true / false / a function. * @param function callback Callback to call on completion of event. Has - * three parameters: the element that the event was evoked from, the JSON - * that was returned and (if it is a form) the form action. + * three parameters: the element that the event was evoked from, the JSON + * that was returned and (if it is a form) the form action. */ phpbb.ajaxify = function(options) { var elements = $(options.selector), -- cgit v1.2.1 From 36168b311e5f12937977ffd1040ca4a39f70a0e8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 27 Feb 2013 23:12:34 +0100 Subject: [ticket/11314] Fix issues mentioned in jshint report Additionally, the editor.js files are now the same file in both subsilver2, prosilver, and the acp. PHPBB3-11314 --- phpBB/assets/javascript/core.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'phpBB/assets/javascript/core.js') diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index f38b35d613..b718dabe6c 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -353,7 +353,7 @@ phpbb.ajaxify = function(options) { return; } - if (overlay && (typeof $this.attr('data-overlay') === 'undefined' || $this.attr('data-overlay') == 'true')) + if (overlay && (typeof $this.attr('data-overlay') === 'undefined' || $this.attr('data-overlay') === 'true')) { phpbb.loadingAlert(); } @@ -387,7 +387,7 @@ phpbb.ajaxify = function(options) { * @param bool keepSelection Shall we keep the value selected, or shall the user be forced to repick one. */ phpbb.timezoneSwitchDate = function(keepSelection) { - if ($('#timezone_copy').length == 0) { + if ($('#timezone_copy').length === 0) { // We make a backup of the original dropdown, so we can remove optgroups // instead of setting display to none, because IE and chrome will not // hide options inside of optgroups and selects via css @@ -397,17 +397,17 @@ phpbb.timezoneSwitchDate = function(keepSelection) { $('#timezone').replaceWith($('#timezone_copy').clone().attr('id', 'timezone').css('display', 'block').attr('name', 'tz')); } - if ($('#tz_date').val() != '') { + if ($('#tz_date').val() !== '') { $('#timezone > optgroup').remove(":not([label='" + $('#tz_date').val() + "'])"); } - if ($('#tz_date').val() == $('#tz_select_date_suggest').attr('data-suggested-tz')) { + if ($('#tz_date').val() === $('#tz_select_date_suggest').attr('data-suggested-tz')) { $('#tz_select_date_suggest').css('display', 'none'); } else { $('#tz_select_date_suggest').css('display', 'inline'); } - if ($("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option").size() == 1) { + if ($("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option").size() === 1) { // If there is only one timezone for the selected date, we just select that automatically. $("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option:first").attr('selected', true); keepSelection = true; @@ -468,8 +468,8 @@ phpbb.timezonePreselectSelect = function(forceSelector) { for (i = 0; i < selectorOptions.length; ++i) { var option = selectorOptions[i]; - if (option.value.substring(0, prefixLength) == prefix) { - if ($('#tz_date').val() != option.value && !forceSelector) { + if (option.value.substring(0, prefixLength) === prefix) { + if ($('#tz_date').val() !== option.value && !forceSelector) { // We do not select the option for the user, but notify him, // that we would suggest a different setting. phpbb.timezoneSwitchDate(true); -- cgit v1.2.1 From f0b0978538a1b1e25b688cce1794c764f2d363f0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 26 Mar 2013 13:13:33 +0100 Subject: [ticket/11314] Modify files to comply with coding standards PHPBB3-11314 --- phpBB/assets/javascript/core.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'phpBB/assets/javascript/core.js') diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index b718dabe6c..424989a9f3 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -57,7 +57,7 @@ phpbb.clearLoadingTimeout = function() { * @param string title Title of the message, eg "Information" (HTML). * @param string msg Message to display (HTML). * @param bool fadedark Remove the dark background when done? Defaults - * to yes. + * to yes. * * @returns object Returns the div created. */ @@ -353,8 +353,7 @@ phpbb.ajaxify = function(options) { return; } - if (overlay && (typeof $this.attr('data-overlay') === 'undefined' || $this.attr('data-overlay') === 'true')) - { + if (overlay && (typeof $this.attr('data-overlay') === 'undefined' || $this.attr('data-overlay') === 'true')) { phpbb.loadingAlert(); } -- cgit v1.2.1