From 9c4f0d51df4424f410534686f00bf629d98d53e0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 10 Jan 2013 10:59:20 +0100 Subject: [PATCH] [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(-) 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) {