1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-30 17:50:00 +02:00

Basic JS code cleanup

This commit is contained in:
Peter Knut
2024-09-18 09:39:17 +02:00
parent 9ea8f44919
commit 4863f48d33
2 changed files with 69 additions and 69 deletions

View File

@@ -54,7 +54,7 @@ function bodyLoad(version, maria) {
function formField(form, name) { function formField(form, name) {
// required in IE < 8, form.elements[name] doesn't work // required in IE < 8, form.elements[name] doesn't work
for (var i=0; i < form.length; i++) { for (var i=0; i < form.length; i++) {
if (form[i].name == name) { if (form[i].name === name) {
return form[i]; return form[i];
} }
} }
@@ -104,7 +104,7 @@ var dbPrevious = {};
*/ */
function dbMouseDown(event) { function dbMouseDown(event) {
dbCtrl = isCtrl(event); dbCtrl = isCtrl(event);
if (dbPrevious[this.name] == undefined) { if (dbPrevious[this.name] === undefined) {
dbPrevious[this.name] = this.value; dbPrevious[this.name] = this.value;
} }
} }
@@ -118,7 +118,7 @@ function dbChange() {
} }
this.form.submit(); this.form.submit();
this.form.target = ''; this.form.target = '';
if (dbCtrl && dbPrevious[this.name] != undefined) { if (dbCtrl && dbPrevious[this.name] !== undefined) {
this.value = dbPrevious[this.name]; this.value = dbPrevious[this.name];
dbPrevious[this.name] = undefined; dbPrevious[this.name] = undefined;
} }
@@ -145,23 +145,23 @@ function selectFieldChange() {
for (var i=0; i < selects.length; i++) { for (var i=0; i < selects.length; i++) {
var select = selects[i]; var select = selects[i];
var col = selectValue(select); var col = selectValue(select);
var match = /^(where.+)col\]/.exec(select.name); var match = /^(where.+)col]/.exec(select.name);
if (match) { if (match) {
var op = selectValue(form[match[1] + 'op]']); var op = selectValue(form[match[1] + 'op]']);
var val = form[match[1] + 'val]'].value; var val = form[match[1] + 'val]'].value;
if (col in indexColumns && (!/LIKE|REGEXP/.test(op) || (op == 'LIKE' && val.charAt(0) != '%'))) { if (col in indexColumns && (!/LIKE|REGEXP/.test(op) || (op === 'LIKE' && val.charAt(0) !== '%'))) {
return true; return true;
} else if (col || val) { } else if (col || val) {
ok = false; ok = false;
} }
} }
if ((match = /^(columns.+)fun\]/.exec(select.name))) { if ((match = /^(columns.+)fun]/.exec(select.name))) {
if (/^(avg|count|count distinct|group_concat|max|min|sum)$/.test(col)) { if (/^(avg|count|count distinct|group_concat|max|min|sum)$/.test(col)) {
group = true; group = true;
} }
var val = selectValue(form[match[1] + 'col]']); var val = selectValue(form[match[1] + 'col]']);
if (val) { if (val) {
columns[col && col != 'count' ? '' : val] = 1; columns[col && col !== 'count' ? '' : val] = 1;
} }
} }
if (col && /^order/.test(select.name)) { if (col && /^order/.test(select.name)) {
@@ -194,7 +194,7 @@ var added = '.', rowCount;
* @return boolean * @return boolean
*/ */
function delimiterEqual(val, a, b) { function delimiterEqual(val, a, b) {
return (val == a + '_' + b || val == a + b || val == a + b.charAt(0).toUpperCase() + b.substr(1)); return (val === a + '_' + b || val === a + b || val === a + b.charAt(0).toUpperCase() + b.substr(1));
} }
/** Escape string to use as identifier /** Escape string to use as identifier
@@ -255,7 +255,7 @@ function editingClick(event) {
} else if (/^drop_col\[/.test(name)) { } else if (/^drop_col\[/.test(name)) {
editingRemoveRow.call(el, 'fields\$1[field]'); editingRemoveRow.call(el, 'fields\$1[field]');
} else { } else {
if (name == 'auto_increment_col') { if (name === 'auto_increment_col') {
var field = el.form['fields[' + el.value + '][field]']; var field = el.form['fields[' + el.value + '][field]'];
if (!field.value) { if (!field.value) {
field.value = 'id'; field.value = 'id';
@@ -273,7 +273,7 @@ function editingClick(event) {
*/ */
function editingInput(event) { function editingInput(event) {
var el = getTarget(event); var el = getTarget(event);
if (/\[default\]$/.test(el.name)) { if (/\[default]$/.test(el.name)) {
el.previousSibling.checked = true; el.previousSibling.checked = true;
} }
} }
@@ -290,7 +290,7 @@ function editingNameChange() {
for (var i = opts.length; i--; ) { for (var i = opts.length; i--; ) {
var match = /(.+)`(.+)/.exec(opts[i].value); var match = /(.+)`(.+)/.exec(opts[i].value);
if (!match) { // common type if (!match) { // common type
if (candidate && i == opts.length - 2 && val == opts[candidate].value.replace(/.+`/, '') && name == 'fields[1]') { // single target table, link to column, first field - probably `id` if (candidate && i === opts.length - 2 && val === opts[candidate].value.replace(/.+`/, '') && name === 'fields[1]') { // single target table, link to column, first field - probably `id`
return; return;
} }
break; break;
@@ -300,7 +300,7 @@ function editingNameChange() {
var tables = [ table, table.replace(/s$/, ''), table.replace(/es$/, '') ]; var tables = [ table, table.replace(/s$/, ''), table.replace(/es$/, '') ];
for (var j=0; j < tables.length; j++) { for (var j=0; j < tables.length; j++) {
table = tables[j]; table = tables[j];
if (val == column || val == table || delimiterEqual(val, table, column) || delimiterEqual(val, column, table)) { if (val === column || val === table || delimiterEqual(val, table, column) || delimiterEqual(val, column, table)) {
if (candidate) { if (candidate) {
return; return;
} }
@@ -335,7 +335,7 @@ function editingAddRow(focus) {
tags2 = qsa('input', row2); tags2 = qsa('input', row2);
var input = tags2[0]; // IE loose tags2 after insertBefore() var input = tags2[0]; // IE loose tags2 after insertBefore()
for (var i=0; i < tags.length; i++) { for (var i=0; i < tags.length; i++) {
if (tags[i].name == 'auto_increment_col') { if (tags[i].name === 'auto_increment_col') {
tags2[i].value = x; tags2[i].value = x;
tags2[i].checked = false; tags2[i].checked = false;
} }
@@ -397,7 +397,7 @@ function editingTypeChange() {
var text = selectValue(type); var text = selectValue(type);
for (var i=0; i < type.form.elements.length; i++) { for (var i=0; i < type.form.elements.length; i++) {
var el = type.form.elements[i]; var el = type.form.elements[i];
if (el.name == name + '[length]') { if (el.name === name + '[length]') {
if (!( if (!(
(/(char|binary)$/.test(lastType) && /(char|binary)$/.test(text)) (/(char|binary)$/.test(lastType) && /(char|binary)$/.test(text))
|| (/(enum|set)$/.test(lastType) && /(enum|set)$/.test(text)) || (/(enum|set)$/.test(lastType) && /(enum|set)$/.test(text))
@@ -406,19 +406,19 @@ function editingTypeChange() {
} }
el.oninput.apply(el); el.oninput.apply(el);
} }
if (lastType == 'timestamp' && el.name == name + '[has_default]' && /timestamp/i.test(formField(type.form, name + '[default]').value)) { if (lastType === 'timestamp' && el.name == name + '[has_default]' && /timestamp/i.test(formField(type.form, name + '[default]').value)) {
el.checked = false; el.checked = false;
} }
if (el.name == name + '[collation]') { if (el.name === name + '[collation]') {
alterClass(el, 'hidden', !/(char|text|enum|set)$/.test(text)); alterClass(el, 'hidden', !/(char|text|enum|set)$/.test(text));
} }
if (el.name == name + '[unsigned]') { if (el.name === name + '[unsigned]') {
alterClass(el, 'hidden', !/(^|[^o])int(?!er)|numeric|real|float|double|decimal|money/.test(text)); alterClass(el, 'hidden', !/(^|[^o])int(?!er)|numeric|real|float|double|decimal|money/.test(text));
} }
if (el.name == name + '[on_update]') { if (el.name === name + '[on_update]') {
alterClass(el, 'hidden', !/timestamp|datetime/.test(text)); // MySQL supports datetime since 5.6.5 alterClass(el, 'hidden', !/timestamp|datetime/.test(text)); // MySQL supports datetime since 5.6.5
} }
if (el.name == name + '[on_delete]') { if (el.name === name + '[on_delete]') {
alterClass(el, 'hidden', !/`/.test(text)); alterClass(el, 'hidden', !/`/.test(text));
} }
} }
@@ -457,13 +457,13 @@ function enumValues(s) {
var offset = 0; var offset = 0;
var match; var match;
while (match = re.exec(s)) { while (match = re.exec(s)) {
if (offset != match.index) { if (offset !== match.index) {
break; break;
} }
result.push(match[2].replace(/'(')|\\(.)/g, '$1$2')); result.push(match[2].replace(/'(')|\\(.)/g, '$1$2'));
offset += match[0].length; offset += match[0].length;
} }
return (offset == s.length ? result.join('\n') : s); return (offset === s.length ? result.join('\n') : s);
} }
/** Finish editing of enum or set /** Finish editing of enum or set
@@ -531,7 +531,7 @@ function dumpClick(event) {
var el = parentTag(getTarget(event), 'label'); var el = parentTag(getTarget(event), 'label');
if (el) { if (el) {
el = qs('input', el); el = qs('input', el);
var match = /(.+)\[\]$/.exec(el.name); var match = /(.+)\[]$/.exec(el.name);
if (match) { if (match) {
checkboxClick.call(el, event); checkboxClick.call(el, event);
formUncheck('check-' + match[1]); formUncheck('check-' + match[1]);
@@ -549,7 +549,7 @@ function foreignAddRow() {
this.onchange = function () { }; this.onchange = function () { };
var selects = qsa('select', row); var selects = qsa('select', row);
for (var i=0; i < selects.length; i++) { for (var i=0; i < selects.length; i++) {
selects[i].name = selects[i].name.replace(/\]/, '1$&'); selects[i].name = selects[i].name.replace(']', '1]');
selects[i].selectedIndex = 0; selects[i].selectedIndex = 0;
} }
parentTag(this, 'table').appendChild(row); parentTag(this, 'table').appendChild(row);
@@ -585,7 +585,7 @@ function indexesChangeColumn(prefix) {
for (var tag in { 'select': 1, 'input': 1 }) { for (var tag in { 'select': 1, 'input': 1 }) {
var columns = qsa(tag, parentTag(this, 'td')); var columns = qsa(tag, parentTag(this, 'td'));
for (var i=0; i < columns.length; i++) { for (var i=0; i < columns.length; i++) {
if (/\[columns\]/.test(columns[i].name)) { if (/\[columns]/.test(columns[i].name)) {
var value = selectValue(columns[i]); var value = selectValue(columns[i]);
if (value) { if (value) {
names.push(value); names.push(value);
@@ -593,7 +593,7 @@ function indexesChangeColumn(prefix) {
} }
} }
} }
this.form[this.name.replace(/\].*/, '][name]')].value = prefix + names.join('_'); this.form[this.name.replace(/].*/, '][name]')].value = prefix + names.join('_');
} }
/** Add column for index /** Add column for index
@@ -602,9 +602,9 @@ function indexesChangeColumn(prefix) {
*/ */
function indexesAddColumn(prefix) { function indexesAddColumn(prefix) {
var field = this; var field = this;
var select = field.form[field.name.replace(/\].*/, '][type]')]; var select = field.form[field.name.replace(/].*/, '][type]')];
if (!select.selectedIndex) { if (!select.selectedIndex) {
while (selectValue(select) != "INDEX" && select.selectedIndex < select.options.length) { while (selectValue(select) !== "INDEX" && select.selectedIndex < select.options.length) {
select.selectedIndex++; select.selectedIndex++;
} }
select.onchange(); select.onchange();
@@ -613,15 +613,15 @@ function indexesAddColumn(prefix) {
var selects = qsa('select', column); var selects = qsa('select', column);
for (var i = 0; i < selects.length; i++) { for (var i = 0; i < selects.length; i++) {
select = selects[i]; select = selects[i];
select.name = select.name.replace(/\]\[\d+/, '$&1'); select.name = select.name.replace(/]\[\d+/, '$&1');
select.selectedIndex = 0; select.selectedIndex = 0;
} }
field.onchange = partial(indexesChangeColumn, prefix); field.onchange = partial(indexesChangeColumn, prefix);
var inputs = qsa('input', column); var inputs = qsa('input', column);
for (var i = 0; i < inputs.length; i++) { for (var i = 0; i < inputs.length; i++) {
var input = inputs[i]; var input = inputs[i];
input.name = input.name.replace(/\]\[\d+/, '$&1'); input.name = input.name.replace(/]\[\d+/, '$&1');
if (input.type != 'checkbox') { if (input.type !== 'checkbox') {
input.value = ''; input.value = '';
} }
} }
@@ -670,7 +670,7 @@ var that, x, y; // em and tablePos defined in schema.inc.php
* @this HTMLElement * @this HTMLElement
*/ */
function schemaMousedown(event) { function schemaMousedown(event) {
if ((event.which ? event.which : event.button) == 1) { if ((event.which ? event.which : event.button) === 1) {
that = this; that = this;
x = event.clientX - this.offsetLeft; x = event.clientX - this.offsetLeft;
y = event.clientY - this.offsetTop; y = event.clientY - this.offsetTop;
@@ -687,12 +687,12 @@ function schemaMousemove(event) {
var divs = qsa('div', that); var divs = qsa('div', that);
var lineSet = { }; var lineSet = { };
for (var i=0; i < divs.length; i++) { for (var i=0; i < divs.length; i++) {
if (divs[i].className == 'references') { if (divs[i].className === 'references') {
var div2 = qs('[id="' + (/^refs/.test(divs[i].id) ? 'refd' : 'refs') + divs[i].id.substr(4) + '"]'); var div2 = qs('[id="' + (/^refs/.test(divs[i].id) ? 'refd' : 'refs') + divs[i].id.substr(4) + '"]');
var ref = (tablePos[divs[i].title] ? tablePos[divs[i].title] : [ div2.parentNode.offsetTop / em, 0 ]); var ref = (tablePos[divs[i].title] ? tablePos[divs[i].title] : [ div2.parentNode.offsetTop / em, 0 ]);
var left1 = -1; var left1 = -1;
var id = divs[i].id.replace(/^ref.(.+)-.+/, '$1'); var id = divs[i].id.replace(/^ref.(.+)-.+/, '$1');
if (divs[i].parentNode != div2.parentNode) { if (divs[i].parentNode !== div2.parentNode) {
left1 = Math.min(0, ref[1] - left) - 1; left1 = Math.min(0, ref[1] - left) - 1;
divs[i].style.left = left1 + 'em'; divs[i].style.left = left1 + 'em';
divs[i].querySelector('div').style.width = -left1 + 'em'; divs[i].querySelector('div').style.width = -left1 + 'em';
@@ -704,7 +704,7 @@ function schemaMousemove(event) {
var line = qs('[id="' + divs[i].id.replace(/^....(.+)-.+$/, 'refl$1') + '"]'); var line = qs('[id="' + divs[i].id.replace(/^....(.+)-.+$/, 'refl$1') + '"]');
var top1 = top + divs[i].offsetTop / em; var top1 = top + divs[i].offsetTop / em;
var top2 = top + div2.offsetTop / em; var top2 = top + div2.offsetTop / em;
if (divs[i].parentNode != div2.parentNode) { if (divs[i].parentNode !== div2.parentNode) {
top2 += ref[0] - top; top2 += ref[0] - top;
line.querySelector('div').style.height = Math.abs(top1 - top2) + 'em'; line.querySelector('div').style.height = Math.abs(top1 - top2) + 'em';
} }
@@ -752,7 +752,7 @@ function helpMouseover(event, text, side) {
var target = getTarget(event); var target = getTarget(event);
if (!text) { if (!text) {
helpClose(); helpClose();
} else if (window.jush && (!helpIgnore || this != target)) { } else if (window.jush && (!helpIgnore || this !== target)) {
helpOpen = 1; helpOpen = 1;
var help = qs('#help'); var help = qs('#help');
help.innerHTML = text; help.innerHTML = text;
@@ -771,7 +771,7 @@ function helpMouseover(event, text, side) {
*/ */
function helpMouseout(event) { function helpMouseout(event) {
helpOpen = 0; helpOpen = 0;
helpIgnore = (this != getTarget(event)); helpIgnore = (this !== getTarget(event));
setTimeout(function () { setTimeout(function () {
if (!helpOpen) { if (!helpOpen) {
helpClose(); helpClose();

View File

@@ -4,7 +4,7 @@
* @param [HTMLElement] defaults to document * @param [HTMLElement] defaults to document
* @return HTMLElement * @return HTMLElement
*/ */
function qs(selector, context) { function qs(selector, context = null) {
return (context || document).querySelector(selector); return (context || document).querySelector(selector);
} }
@@ -13,7 +13,7 @@ function qs(selector, context) {
* @param [HTMLElement] defaults to document * @param [HTMLElement] defaults to document
* @return HTMLElement * @return HTMLElement
*/ */
function qsl(selector, context) { function qsl(selector, context = null) {
var els = qsa(selector, context); var els = qsa(selector, context);
return els[els.length - 1]; return els[els.length - 1];
} }
@@ -23,7 +23,7 @@ function qsl(selector, context) {
* @param [HTMLElement] defaults to document * @param [HTMLElement] defaults to document
* @return NodeList * @return NodeList
*/ */
function qsa(selector, context) { function qsa(selector, context = null) {
return (context || document).querySelectorAll(selector); return (context || document).querySelectorAll(selector);
} }
@@ -79,7 +79,7 @@ function alterClass(el, className, enable) {
*/ */
function toggle(id) { function toggle(id) {
var el = qs('#' + id); var el = qs('#' + id);
el.className = (el.className == 'hidden' ? '' : 'hidden'); el.className = (el.className === 'hidden' ? '' : 'hidden');
return false; return false;
} }
@@ -111,7 +111,7 @@ function verifyVersion(current, url, token) {
if (window.postMessage && window.addEventListener) { if (window.postMessage && window.addEventListener) {
iframe.style.display = 'none'; iframe.style.display = 'none';
addEventListener('message', function (event) { addEventListener('message', function (event) {
if (event.origin == 'https://www.adminer.org') { if (event.origin === 'https://www.adminer.org') {
var match = /version=(.+)/.exec(event.data); var match = /version=(.+)/.exec(event.data);
if (match) { if (match) {
cookie('adminer_version=' + match[1], 1); cookie('adminer_version=' + match[1], 1);
@@ -139,7 +139,7 @@ function selectValue(select) {
/** Verify if element has a specified tag name /** Verify if element has a specified tag name
* @param HTMLElement * @param HTMLElement
* @param string regular expression * @param string regular expression
* @return bool * @return boolean
*/ */
function isTag(el, tag) { function isTag(el, tag) {
var re = new RegExp('^(' + tag + ')$', 'i'); var re = new RegExp('^(' + tag + ')$', 'i');
@@ -181,8 +181,8 @@ function selectCount(id, count) {
var inputs = qsa('input', el.parentNode.parentNode); var inputs = qsa('input', el.parentNode.parentNode);
for (var i = 0; i < inputs.length; i++) { for (var i = 0; i < inputs.length; i++) {
var input = inputs[i]; var input = inputs[i];
if (input.type == 'submit') { if (input.type === 'submit') {
input.disabled = (count == '0'); input.disabled = (count === '0');
} }
} }
} }
@@ -252,7 +252,7 @@ function tableClick(event, click) {
var el = getTarget(event); var el = getTarget(event);
while (!isTag(el, 'tr')) { while (!isTag(el, 'tr')) {
if (isTag(el, 'table|a|input|textarea')) { if (isTag(el, 'table|a|input|textarea')) {
if (el.type != 'checkbox') { if (el.type !== 'checkbox') {
return; return;
} }
checkboxClick.call(el, event); checkboxClick.call(el, event);
@@ -268,7 +268,7 @@ function tableClick(event, click) {
el.checked = !el.checked; el.checked = !el.checked;
el.onclick && el.onclick(); el.onclick && el.onclick();
} }
if (el.name == 'check[]') { if (el.name === 'check[]') {
el.form['all'].checked = false; el.form['all'].checked = false;
formUncheck('all-page'); formUncheck('all-page');
} }
@@ -288,7 +288,7 @@ function checkboxClick(event) {
if (!this.name) { if (!this.name) {
return; return;
} }
if (event.shiftKey && (!lastChecked || lastChecked.name == this.name)) { if (event.shiftKey && (!lastChecked || lastChecked.name === this.name)) {
var checked = (lastChecked ? lastChecked.checked : true); var checked = (lastChecked ? lastChecked.checked : true);
var inputs = qsa('input', parentTag(this, 'table')); var inputs = qsa('input', parentTag(this, 'table'));
var checking = !lastChecked; var checking = !lastChecked;
@@ -333,7 +333,7 @@ function setHtml(id, html) {
*/ */
function nodePosition(el) { function nodePosition(el) {
var pos = 0; var pos = 0;
while (el = el.previousSibling) { while ((el = el.previousSibling)) {
pos++; pos++;
} }
return pos; return pos;
@@ -345,7 +345,7 @@ function nodePosition(el) {
*/ */
function pageClick(href, page) { function pageClick(href, page) {
if (!isNaN(page) && page) { if (!isNaN(page) && page) {
location.href = href + (page != 1 ? '&page=' + (page - 1) : ''); location.href = href + (page !== 1 ? '&page=' + (page - 1) : '');
} }
} }
@@ -388,7 +388,7 @@ function selectAddRow() {
for (var i=0; i < inputs.length; i++) { for (var i=0; i < inputs.length; i++) {
inputs[i].name = inputs[i].name.replace(/[a-z]\[\d+/, '$&1'); inputs[i].name = inputs[i].name.replace(/[a-z]\[\d+/, '$&1');
inputs[i].className = ''; inputs[i].className = '';
if (inputs[i].type == 'checkbox') { if (inputs[i].type === 'checkbox') {
inputs[i].checked = false; inputs[i].checked = false;
} else { } else {
inputs[i].value = ''; inputs[i].value = '';
@@ -402,7 +402,7 @@ function selectAddRow() {
* @this HTMLInputElement * @this HTMLInputElement
*/ */
function selectSearchKeydown(event) { function selectSearchKeydown(event) {
if (event.keyCode == 13 || event.keyCode == 10) { if (event.keyCode === 13 || event.keyCode === 10) {
this.onsearch = function () { this.onsearch = function () {
}; };
} }
@@ -445,11 +445,11 @@ function selectSearch(name) {
for (var i=0; i < divs.length; i++) { for (var i=0; i < divs.length; i++) {
var div = divs[i]; var div = divs[i];
var el = qs('[name$="[col]"]', div); var el = qs('[name$="[col]"]', div);
if (el && selectValue(el) == name) { if (el && selectValue(el) === name) {
break; break;
} }
} }
if (i == divs.length) { if (i === divs.length) {
div.firstChild.value = name; div.firstChild.value = name;
div.firstChild.onchange(); div.firstChild.onchange();
} }
@@ -487,7 +487,7 @@ function bodyKeydown(event, button) {
if (target.jushTextarea) { if (target.jushTextarea) {
target = target.jushTextarea; target = target.jushTextarea;
} }
if (isCtrl(event) && (event.keyCode == 13 || event.keyCode == 10) && isTag(target, 'select|textarea|input')) { // 13|10 - Enter if (isCtrl(event) && (event.keyCode === 13 || event.keyCode === 10) && isTag(target, 'select|textarea|input')) { // 13|10 - Enter
target.blur(); target.blur();
if (button) { if (button) {
target.form[button].click(); target.form[button].click();
@@ -508,7 +508,7 @@ function bodyKeydown(event, button) {
*/ */
function bodyClick(event) { function bodyClick(event) {
var target = getTarget(event); var target = getTarget(event);
if ((isCtrl(event) || event.shiftKey) && target.type == 'submit' && isTag(target, 'input')) { if ((isCtrl(event) || event.shiftKey) && target.type === 'submit' && isTag(target, 'input')) {
target.form.target = '_blank'; target.form.target = '_blank';
setTimeout(function () { setTimeout(function () {
// if (isCtrl(event)) { focus(); } doesn't work // if (isCtrl(event)) { focus(); } doesn't work
@@ -524,9 +524,9 @@ function bodyClick(event) {
* @return boolean * @return boolean
*/ */
function editingKeydown(event) { function editingKeydown(event) {
if ((event.keyCode == 40 || event.keyCode == 38) && isCtrl(event)) { // 40 - Down, 38 - Up if ((event.keyCode === 40 || event.keyCode === 38) && isCtrl(event)) { // 40 - Down, 38 - Up
var target = getTarget(event); var target = getTarget(event);
var sibling = (event.keyCode == 40 ? 'nextSibling' : 'previousSibling'); var sibling = (event.keyCode === 40 ? 'nextSibling' : 'previousSibling');
var el = target.parentNode.parentNode[sibling]; var el = target.parentNode.parentNode[sibling];
if (el && (isTag(el, 'tr') || (el = el[sibling])) && isTag(el, 'tr') && (el = el.childNodes[nodePosition(target.parentNode)]) && (el = el.childNodes[nodePosition(target)])) { if (el && (isTag(el, 'tr') || (el = el[sibling])) && isTag(el, 'tr') && (el = el.childNodes[nodePosition(target.parentNode)]) && (el = el.childNodes[nodePosition(target)])) {
el.focus(); el.focus();
@@ -614,7 +614,7 @@ function ajax(url, callback, data, message) {
} }
request.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
request.onreadystatechange = function () { request.onreadystatechange = function () {
if (request.readyState == 4) { if (request.readyState === 4) {
if (/^2/.test(request.status)) { if (/^2/.test(request.status)) {
callback(request); callback(request);
} else { } else {
@@ -656,7 +656,7 @@ function ajaxForm(form, message, button) {
if (/^file$/i.test(el.type) && el.value) { if (/^file$/i.test(el.type) && el.value) {
return false; return false;
} }
if (!/^(checkbox|radio|submit|file)$/i.test(el.type) || el.checked || el == button) { if (!/^(checkbox|radio|submit|file)$/i.test(el.type) || el.checked || el === button) {
data.push(encodeURIComponent(el.name) + '=' + encodeURIComponent(isTag(el, 'select') ? selectValue(el) : el.value)); data.push(encodeURIComponent(el.name) + '=' + encodeURIComponent(isTag(el, 'select') ? selectValue(el) : el.value));
} }
} }
@@ -703,7 +703,7 @@ function selectClick(event, text, warning) {
if (!event) { if (!event) {
event = window.event; event = window.event;
} }
if (event.keyCode == 27 && !event.shiftKey && !event.altKey && !isCtrl(event)) { // 27 - Esc if (event.keyCode === 27 && !event.shiftKey && !event.altKey && !isCtrl(event)) { // 27 - Esc
inputBlur.apply(input); inputBlur.apply(input);
td.innerHTML = original; td.innerHTML = original;
} }
@@ -733,7 +733,7 @@ function selectClick(event, text, warning) {
td.appendChild(input); td.appendChild(input);
setupSubmitHighlight(td); setupSubmitHighlight(td);
input.focus(); input.focus();
if (text == 2) { // long text if (text === 2) { // long text
return ajax(location.href + '&' + encodeURIComponent(td.id) + '=', function (request) { return ajax(location.href + '&' + encodeURIComponent(td.id) + '=', function (request) {
if (request.responseText) { if (request.responseText) {
input.value = request.responseText; input.value = request.responseText;
@@ -855,7 +855,7 @@ function findDefaultSubmit(el) {
var inputs = qsa('input', el.form); var inputs = qsa('input', el.form);
for (var i = 0; i < inputs.length; i++) { for (var i = 0; i < inputs.length; i++) {
var input = inputs[i]; var input = inputs[i];
if (input.type == 'submit' && !input.style.zIndex) { if (input.type === 'submit' && !input.style.zIndex) {
return input; return input;
} }
} }