mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[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
This commit is contained in:
@@ -23,9 +23,9 @@ function jumpto()
|
||||
{
|
||||
var page = prompt(jump_page, on_page);
|
||||
|
||||
if (page !== null && !isNaN(page) && page == Math.floor(page) && page > 0)
|
||||
if (page !== null && !isNaN(page) && page === Math.floor(page) && page > 0)
|
||||
{
|
||||
if (base_url.indexOf('?') == -1)
|
||||
if (base_url.indexOf('?') === -1)
|
||||
{
|
||||
document.location.href = base_url + '?start=' + ((page - 1) * per_page);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ function marklist(id, name, state)
|
||||
|
||||
for (var r = 0; r < rb.length; r++)
|
||||
{
|
||||
if (rb[r].name.substr(0, name.length) == name)
|
||||
if (rb[r].name.substr(0, name.length) === name)
|
||||
{
|
||||
rb[r].checked = state;
|
||||
}
|
||||
@@ -66,7 +66,10 @@ function marklist(id, name, state)
|
||||
*/
|
||||
function viewableArea(e, itself)
|
||||
{
|
||||
if (!e) return;
|
||||
if (!e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itself)
|
||||
{
|
||||
e = e.parentNode;
|
||||
@@ -106,9 +109,9 @@ function dE(n, s, type)
|
||||
var e = document.getElementById(n);
|
||||
if (!s)
|
||||
{
|
||||
s = (e.style.display == '' || e.style.display == type) ? -1 : 1;
|
||||
s = (e.style.display === '' || e.style.display === type) ? -1 : 1;
|
||||
}
|
||||
e.style.display = (s == 1) ? type : 'none';
|
||||
e.style.display = (s === 1) ? type : 'none';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +121,7 @@ function subPanels(p)
|
||||
{
|
||||
var i, e, t;
|
||||
|
||||
if (typeof(p) == 'string')
|
||||
if (typeof(p) === 'string')
|
||||
{
|
||||
show_panel = p;
|
||||
}
|
||||
@@ -130,7 +133,7 @@ function subPanels(p)
|
||||
|
||||
if (e)
|
||||
{
|
||||
if (panels[i] == show_panel)
|
||||
if (panels[i] === show_panel)
|
||||
{
|
||||
e.style.display = 'block';
|
||||
if (t)
|
||||
@@ -173,7 +176,7 @@ function printPage()
|
||||
*/
|
||||
function displayBlocks(c, e, t)
|
||||
{
|
||||
var s = (e.checked == true) ? 1 : -1;
|
||||
var s = (e.checked === true) ? 1 : -1;
|
||||
|
||||
if (t)
|
||||
{
|
||||
@@ -184,9 +187,9 @@ function displayBlocks(c, e, t)
|
||||
|
||||
for (var d = 0; d < divs.length; d++)
|
||||
{
|
||||
if (divs[d].className.indexOf(c) == 0)
|
||||
if (divs[d].className.indexOf(c) === 0)
|
||||
{
|
||||
divs[d].style.display = (s == 1) ? 'none' : 'block';
|
||||
divs[d].style.display = (s === 1) ? 'none' : 'block';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,11 +198,12 @@ function selectCode(a)
|
||||
{
|
||||
// Get ID of code block
|
||||
var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
|
||||
var s, r;
|
||||
|
||||
// Not IE and IE9+
|
||||
if (window.getSelection)
|
||||
{
|
||||
var s = window.getSelection();
|
||||
s = window.getSelection();
|
||||
// Safari
|
||||
if (s.setBaseAndExtent)
|
||||
{
|
||||
@@ -209,12 +213,12 @@ function selectCode(a)
|
||||
else
|
||||
{
|
||||
// workaround for bug # 42885
|
||||
if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')
|
||||
if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) === '<BR>')
|
||||
{
|
||||
e.innerHTML = e.innerHTML + ' ';
|
||||
}
|
||||
|
||||
var r = document.createRange();
|
||||
r = document.createRange();
|
||||
r.selectNodeContents(e);
|
||||
s.removeAllRanges();
|
||||
s.addRange(r);
|
||||
@@ -223,8 +227,8 @@ function selectCode(a)
|
||||
// Some older browsers
|
||||
else if (document.getSelection)
|
||||
{
|
||||
var s = document.getSelection();
|
||||
var r = document.createRange();
|
||||
s = document.getSelection();
|
||||
r = document.createRange();
|
||||
r.selectNodeContents(e);
|
||||
s.removeAllRanges();
|
||||
s.addRange(r);
|
||||
@@ -232,7 +236,7 @@ function selectCode(a)
|
||||
// IE
|
||||
else if (document.selection)
|
||||
{
|
||||
var r = document.body.createTextRange();
|
||||
r = document.body.createTextRange();
|
||||
r.moveToElementText(e);
|
||||
r.select();
|
||||
}
|
||||
@@ -245,22 +249,23 @@ function selectCode(a)
|
||||
function play_qt_file(obj)
|
||||
{
|
||||
var rectangle = obj.GetRectangle();
|
||||
var width, height;
|
||||
|
||||
if (rectangle)
|
||||
{
|
||||
rectangle = rectangle.split(',');
|
||||
var x1 = parseInt(rectangle[0]);
|
||||
var x2 = parseInt(rectangle[2]);
|
||||
var y1 = parseInt(rectangle[1]);
|
||||
var y2 = parseInt(rectangle[3]);
|
||||
var x1 = parseInt(rectangle[0], 10);
|
||||
var x2 = parseInt(rectangle[2], 10);
|
||||
var y1 = parseInt(rectangle[1], 10);
|
||||
var y2 = parseInt(rectangle[3], 10);
|
||||
|
||||
var width = (x1 < 0) ? (x1 * -1) + x2 : x2 - x1;
|
||||
var height = (y1 < 0) ? (y1 * -1) + y2 : y2 - y1;
|
||||
width = (x1 < 0) ? (x1 * -1) + x2 : x2 - x1;
|
||||
height = (y1 < 0) ? (y1 * -1) + y2 : y2 - y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
var width = 200;
|
||||
var height = 0;
|
||||
width = 200;
|
||||
height = 0;
|
||||
}
|
||||
|
||||
obj.width = width;
|
||||
@@ -276,7 +281,7 @@ function play_qt_file(obj)
|
||||
*/
|
||||
function is_node_name(elem, name)
|
||||
{
|
||||
return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
|
||||
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,10 +290,12 @@ function is_node_name(elem, name)
|
||||
*/
|
||||
function is_in_array(elem, array)
|
||||
{
|
||||
for (var i = 0, length = array.length; i < length; i++)
|
||||
for (var i = 0, length = array.length; i < length; i++) {
|
||||
// === is correct (IE)
|
||||
if (array[i] === elem)
|
||||
if (array[i] === elem) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -304,17 +311,22 @@ function find_in_tree(node, tag, type, class_name)
|
||||
|
||||
for (element = node.childNodes[0]; i < length; element = node.childNodes[++i])
|
||||
{
|
||||
if (!element || element.nodeType != 1) continue;
|
||||
if (!element || element.nodeType !== 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((!tag || is_node_name(element, tag)) && (!type || element.type == type) && (!class_name || is_in_array(class_name, (element.className || element).toString().split(/\s+/)) > -1))
|
||||
if ((!tag || is_node_name(element, tag)) && (!type || element.type === type) && (!class_name || is_in_array(class_name, (element.className || element).toString().split(/\s+/)) > -1))
|
||||
{
|
||||
return element;
|
||||
}
|
||||
|
||||
if (element.childNodes.length)
|
||||
if (element.childNodes.length) {
|
||||
result = find_in_tree(element, tag, type, class_name);
|
||||
}
|
||||
|
||||
if (result) return result;
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,14 +339,15 @@ var last_key_entered = '';
|
||||
function phpbb_check_key(event)
|
||||
{
|
||||
// Keycode is array down or up?
|
||||
if (event.keyCode && (event.keyCode == 40 || event.keyCode == 38))
|
||||
if (event.keyCode && (event.keyCode === 40 || event.keyCode === 38)) {
|
||||
in_autocomplete = true;
|
||||
}
|
||||
|
||||
// Make sure we are not within an "autocompletion" field
|
||||
if (in_autocomplete)
|
||||
{
|
||||
// If return pressed and key changed we reset the autocompletion
|
||||
if (!last_key_entered || last_key_entered == event.which)
|
||||
if (!last_key_entered || last_key_entered === event.which)
|
||||
{
|
||||
in_autocompletion = false;
|
||||
return true;
|
||||
@@ -342,7 +355,7 @@ function phpbb_check_key(event)
|
||||
}
|
||||
|
||||
// Keycode is not return, then return. ;)
|
||||
if (event.which != 13)
|
||||
if (event.which !== 13)
|
||||
{
|
||||
last_key_entered = event.which;
|
||||
return true;
|
||||
@@ -357,17 +370,20 @@ function phpbb_check_key(event)
|
||||
function submit_default_button(event, selector, class_name)
|
||||
{
|
||||
// Add which for key events
|
||||
if (!event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode))
|
||||
if (!event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode)) {
|
||||
event.which = event.charCode || event.keyCode;
|
||||
}
|
||||
|
||||
if (phpbb_check_key(event))
|
||||
if (phpbb_check_key(event)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var current = selector['parentNode'];
|
||||
var current = selector.parentNode;
|
||||
|
||||
// Search parent form element
|
||||
while (current && (!current.nodeName || current.nodeType != 1 || !is_node_name(current, 'form')) && current != document)
|
||||
current = current['parentNode'];
|
||||
while (current && (!current.nodeName || current.nodeType !== 1 || !is_node_name(current, 'form')) && current !== document) {
|
||||
current = current.parentNode;
|
||||
}
|
||||
|
||||
// Find the input submit button with the class name
|
||||
//current = find_in_tree(current, 'input', 'submit', class_name);
|
||||
@@ -376,12 +392,14 @@ function submit_default_button(event, selector, class_name)
|
||||
|
||||
for (var i = 0, element = input_tags[0]; i < input_tags.length; element = input_tags[++i])
|
||||
{
|
||||
if (element.type == 'submit' && is_in_array(class_name, (element.className || element).toString().split(/\s+/)) > -1)
|
||||
if (element.type === 'submit' && is_in_array(class_name, (element.className || element).toString().split(/\s+/)) > -1) {
|
||||
current = element;
|
||||
}
|
||||
}
|
||||
|
||||
if (!current)
|
||||
if (!current) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Submit form
|
||||
current.focus();
|
||||
@@ -403,13 +421,15 @@ function apply_onkeypress_event()
|
||||
{
|
||||
var default_button = jQuery(this).parents('form').find('input[type=submit].default-submit-action');
|
||||
|
||||
if (!default_button || default_button.length <= 0)
|
||||
if (!default_button || default_button.length <= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (phpbb_check_key(e))
|
||||
if (phpbb_check_key(e)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
|
||||
if ((e.which && e.which === 13) || (e.keyCode && e.keyCode === 13))
|
||||
{
|
||||
default_button.click();
|
||||
return false;
|
||||
@@ -425,7 +445,7 @@ function apply_onkeypress_event()
|
||||
|
||||
for (var i = 0, element = input_tags[0]; i < input_tags.length ; element = input_tags[++i])
|
||||
{
|
||||
if (element.type == 'text' || element.type == 'password')
|
||||
if (element.type === 'text' || element.type === 'password')
|
||||
{
|
||||
// onkeydown is possible too
|
||||
element.onkeypress = function (evt) { submit_default_button((evt || window.event), this, 'default-submit-action'); };
|
||||
@@ -436,4 +456,4 @@ function apply_onkeypress_event()
|
||||
/**
|
||||
* Detect JQuery existance. We currently do not deliver it, but some styles do, so why not benefit from it. ;)
|
||||
*/
|
||||
var jquery_present = typeof jQuery == 'function';
|
||||
var jquery_present = typeof jQuery === 'function';
|
||||
|
Reference in New Issue
Block a user