[ticket/11314] Fix JSHint issues in adm editor.js

This time without changing the behavior.

PHPBB3-11314
This commit is contained in:
Marc Alexander 2013-03-26 11:19:03 +01:00
parent 36168b311e
commit 4870387f3a

View file

@ -12,9 +12,8 @@ var theSelection = false;
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion, 10); // Get browser version
var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1));
var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));
var is_ie = ((clientPC.indexOf('msie') !== -1) && (clientPC.indexOf('opera') === -1));
var is_win = ((clientPC.indexOf('win') !== -1) || (clientPC.indexOf('16bit') !== -1));
var baseHeight;
/**
@ -32,6 +31,7 @@ function helpline(help)
function initInsertions()
{
var doc;
if (document.forms[form_name])
{
doc = document;
@ -42,7 +42,8 @@ function initInsertions()
}
var textarea = doc.forms[form_name].elements[text_name];
if (is_ie && typeof(baseHeight) != 'number')
if (is_ie && typeof(baseHeight) !== 'number')
{
textarea.focus();
baseHeight = doc.selection.createRange().duplicate().boundingHeight;
@ -59,7 +60,7 @@ function initInsertions()
*/
function bbstyle(bbnumber)
{
if (bbnumber != -1)
if (bbnumber !== -1)
{
bbfontstyle(bbtags[bbnumber], bbtags[bbnumber+1]);
}
@ -160,17 +161,16 @@ function insert_text(text, spaces, popup)
textarea.selectionStart = sel_start + text.length;
textarea.selectionEnd = sel_end + text.length;
}
else if (textarea.createTextRange && textarea.caretPos)
{
if (baseHeight != textarea.caretPos.boundingHeight)
if (baseHeight !== textarea.caretPos.boundingHeight)
{
textarea.focus();
storeCaret(textarea);
}
var caret_pos = textarea.caretPos;
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
var caret_pos = textarea.caretPos;
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) === ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
}
else
{
@ -181,7 +181,6 @@ function insert_text(text, spaces, popup)
{
textarea.focus();
}
}
/**
@ -225,7 +224,7 @@ function addquote(post_id, username)
theSelection = document.selection.createRange().text;
}
if (theSelection == '' || typeof theSelection == 'undefined' || theSelection == null)
if (theSelection === '' || typeof theSelection === 'undefined' || theSelection === null)
{
if (divarea.innerHTML)
{
@ -263,12 +262,12 @@ function addquote(post_id, username)
*/
function mozWrap(txtarea, open, close)
{
var selLength = (typeof(txtarea.textLength) == 'undefined') ? txtarea.value.length : txtarea.textLength;
var selLength = (typeof(txtarea.textLength) === 'undefined') ? txtarea.value.length : txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
var scrollTop = txtarea.scrollTop;
if (selEnd == 1 || selEnd == 2)
if (selEnd === 1 || selEnd === 2)
{
selEnd = selLength;
}
@ -317,14 +316,14 @@ function colorPalette(dir, width, height)
for (r = 0; r < 5; r++)
{
if (dir == 'h')
if (dir === 'h')
{
document.writeln('<tr>');
}
for (g = 0; g < 5; g++)
{
if (dir == 'v')
if (dir === 'v')
{
document.writeln('<tr>');
}
@ -337,13 +336,13 @@ function colorPalette(dir, width, height)
document.writeln('</td>');
}
if (dir == 'v')
if (dir === 'v')
{
document.writeln('</tr>');
}
}
if (dir == 'h')
if (dir === 'h')
{
document.writeln('</tr>');
}
@ -351,7 +350,6 @@ function colorPalette(dir, width, height)
document.writeln('</table>');
}
/**
* Caret Position object
*/
@ -361,7 +359,6 @@ function caretPosition()
var end = null;
}
/**
* Get the caret position in an textarea
*/
@ -370,7 +367,7 @@ function getCaretPosition(txtarea)
var caretPos = new caretPosition();
// simple Gecko/Opera way
if (txtarea.selectionStart || txtarea.selectionStart == 0)
if (txtarea.selectionStart || txtarea.selectionStart === 0)
{
caretPos.start = txtarea.selectionStart;
caretPos.end = txtarea.selectionEnd;