mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 15:47:00 +02:00
JS: Change var to let/const
Created by `eslint . --fix` with rules no-var and then prefer-const.
This commit is contained in:
@@ -8,13 +8,13 @@ function syntaxHighlighting(version, vendor) {
|
|||||||
if (window.jush) {
|
if (window.jush) {
|
||||||
jush.create_links = ' target="_blank" rel="noreferrer noopener"';
|
jush.create_links = ' target="_blank" rel="noreferrer noopener"';
|
||||||
if (version) {
|
if (version) {
|
||||||
for (var key in jush.urls) {
|
for (let key in jush.urls) {
|
||||||
var obj = jush.urls;
|
let obj = jush.urls;
|
||||||
if (typeof obj[key] != 'string') {
|
if (typeof obj[key] != 'string') {
|
||||||
obj = obj[key];
|
obj = obj[key];
|
||||||
key = 0;
|
key = 0;
|
||||||
if (vendor == 'maria') {
|
if (vendor == 'maria') {
|
||||||
for (var i = 1; i < obj.length; i++) {
|
for (let i = 1; i < obj.length; i++) {
|
||||||
obj[i] = obj[i]
|
obj[i] = obj[i]
|
||||||
.replace('.html', '/')
|
.replace('.html', '/')
|
||||||
.replace('-type-syntax', '-data-types')
|
.replace('-type-syntax', '-data-types')
|
||||||
@@ -43,7 +43,7 @@ function syntaxHighlighting(version, vendor) {
|
|||||||
jush.highlight_tag('code', 0);
|
jush.highlight_tag('code', 0);
|
||||||
for (const tag of qsa('textarea')) {
|
for (const tag of qsa('textarea')) {
|
||||||
if (/(^|\s)jush-/.test(tag.className)) {
|
if (/(^|\s)jush-/.test(tag.className)) {
|
||||||
var pre = jush.textarea(tag);
|
const pre = jush.textarea(tag);
|
||||||
if (pre) {
|
if (pre) {
|
||||||
setupSubmitHighlightInput(pre);
|
setupSubmitHighlightInput(pre);
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ function syntaxHighlighting(version, vendor) {
|
|||||||
*/
|
*/
|
||||||
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 (let i=0; i < form.length; i++) {
|
||||||
if (form[i].name == name) {
|
if (form[i].name == name) {
|
||||||
return form[i];
|
return form[i];
|
||||||
}
|
}
|
||||||
@@ -92,16 +92,16 @@ function messagesPrint(parent) {
|
|||||||
* @param HTMLSelectElement
|
* @param HTMLSelectElement
|
||||||
*/
|
*/
|
||||||
function loginDriver(driver) {
|
function loginDriver(driver) {
|
||||||
var trs = parentTag(driver, 'table').rows;
|
const trs = parentTag(driver, 'table').rows;
|
||||||
var disabled = /sqlite/.test(selectValue(driver));
|
const disabled = /sqlite/.test(selectValue(driver));
|
||||||
alterClass(trs[1], 'hidden', disabled); // 1 - row with server
|
alterClass(trs[1], 'hidden', disabled); // 1 - row with server
|
||||||
trs[1].getElementsByTagName('input')[0].disabled = disabled;
|
trs[1].getElementsByTagName('input')[0].disabled = disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var dbCtrl;
|
let dbCtrl;
|
||||||
var dbPrevious = {};
|
const dbPrevious = {};
|
||||||
|
|
||||||
/** Check if database should be opened to a new window
|
/** Check if database should be opened to a new window
|
||||||
* @param MouseEvent
|
* @param MouseEvent
|
||||||
@@ -142,22 +142,22 @@ function dbChange() {
|
|||||||
* @this HTMLElement
|
* @this HTMLElement
|
||||||
*/
|
*/
|
||||||
function selectFieldChange() {
|
function selectFieldChange() {
|
||||||
var form = this.form;
|
const form = this.form;
|
||||||
var ok = (function () {
|
const ok = (function () {
|
||||||
for (const input of qsa('input', form)) {
|
for (const input of qsa('input', form)) {
|
||||||
if (input.value && /^fulltext/.test(input.name)) {
|
if (input.value && /^fulltext/.test(input.name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var ok = form.limit.value;
|
let ok = form.limit.value;
|
||||||
var group = false;
|
let group = false;
|
||||||
var columns = {};
|
const columns = {};
|
||||||
for (const select of qsa('select', form)) {
|
for (const select of qsa('select', form)) {
|
||||||
var col = selectValue(select);
|
const col = selectValue(select);
|
||||||
var match = /^(where.+)col]/.exec(select.name);
|
let match = /^(where.+)col]/.exec(select.name);
|
||||||
if (match) {
|
if (match) {
|
||||||
var op = selectValue(form[match[1] + 'op]']);
|
const op = selectValue(form[match[1] + 'op]']);
|
||||||
var val = form[match[1] + 'val]'].value;
|
const 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) {
|
||||||
@@ -168,7 +168,7 @@ function selectFieldChange() {
|
|||||||
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]']);
|
const val = selectValue(form[match[1] + 'col]']);
|
||||||
if (val) {
|
if (val) {
|
||||||
columns[col && col != 'count' ? '' : val] = 1;
|
columns[col && col != 'count' ? '' : val] = 1;
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ function selectFieldChange() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (group) {
|
if (group) {
|
||||||
for (var col in columns) {
|
for (const col in columns) {
|
||||||
if (!(col in indexColumns)) {
|
if (!(col in indexColumns)) {
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,7 @@ function selectFieldChange() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
var added = '.', rowCount;
|
let added = '.', rowCount;
|
||||||
|
|
||||||
/** Check if val is equal to a-delimiter-b where delimiter is '_', '' or big letter
|
/** Check if val is equal to a-delimiter-b where delimiter is '_', '' or big letter
|
||||||
* @param string
|
* @param string
|
||||||
@@ -249,13 +249,13 @@ function editFields() {
|
|||||||
* @return boolean false to cancel action
|
* @return boolean false to cancel action
|
||||||
*/
|
*/
|
||||||
function editingClick(event) {
|
function editingClick(event) {
|
||||||
var el = getTarget(event);
|
let el = getTarget(event);
|
||||||
if (!isTag(el, 'input')) {
|
if (!isTag(el, 'input')) {
|
||||||
el = parentTag(el, 'label');
|
el = parentTag(el, 'label');
|
||||||
el = el && qs('input', el);
|
el = el && qs('input', el);
|
||||||
}
|
}
|
||||||
if (el) {
|
if (el) {
|
||||||
var name = el.name;
|
const name = el.name;
|
||||||
if (/^add\[/.test(name)) {
|
if (/^add\[/.test(name)) {
|
||||||
editingAddRow.call(el, 1);
|
editingAddRow.call(el, 1);
|
||||||
} else if (/^up\[/.test(name)) {
|
} else if (/^up\[/.test(name)) {
|
||||||
@@ -266,7 +266,7 @@ function editingClick(event) {
|
|||||||
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]'];
|
const field = el.form['fields[' + el.value + '][field]'];
|
||||||
if (!field.value) {
|
if (!field.value) {
|
||||||
field.value = 'id';
|
field.value = 'id';
|
||||||
field.oninput();
|
field.oninput();
|
||||||
@@ -282,7 +282,7 @@ function editingClick(event) {
|
|||||||
* @param InputEvent
|
* @param InputEvent
|
||||||
*/
|
*/
|
||||||
function editingInput(event) {
|
function editingInput(event) {
|
||||||
var el = getTarget(event);
|
const el = getTarget(event);
|
||||||
if (/\[default]$/.test(el.name)) {
|
if (/\[default]$/.test(el.name)) {
|
||||||
el.previousElementSibling.checked = true;
|
el.previousElementSibling.checked = true;
|
||||||
el.previousElementSibling.selectedIndex = Math.max(el.previousElementSibling.selectedIndex, 1);
|
el.previousElementSibling.selectedIndex = Math.max(el.previousElementSibling.selectedIndex, 1);
|
||||||
@@ -293,21 +293,21 @@ function editingInput(event) {
|
|||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function editingNameChange() {
|
function editingNameChange() {
|
||||||
var name = this.name.substr(0, this.name.length - 7);
|
const name = this.name.substr(0, this.name.length - 7);
|
||||||
var type = formField(this.form, name + '[type]');
|
const type = formField(this.form, name + '[type]');
|
||||||
var opts = type.options;
|
const opts = type.options;
|
||||||
var candidate; // don't select anything with ambiguous match (like column `id`)
|
let candidate; // don't select anything with ambiguous match (like column `id`)
|
||||||
var val = this.value;
|
const val = this.value;
|
||||||
for (var i = opts.length; i--; ) {
|
for (let i = opts.length; i--; ) {
|
||||||
var match = /(.+)`(.+)/.exec(opts[i].value);
|
const 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;
|
||||||
}
|
}
|
||||||
var base = match[1];
|
const base = match[1];
|
||||||
var column = match[2];
|
const column = match[2];
|
||||||
for (const table of [ base, base.replace(/s$/, ''), base.replace(/es$/, '') ]) {
|
for (const table of [ base, base.replace(/s$/, ''), base.replace(/es$/, '') ]) {
|
||||||
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) {
|
||||||
@@ -330,20 +330,20 @@ function editingNameChange() {
|
|||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function editingAddRow(focus) {
|
function editingAddRow(focus) {
|
||||||
var match = /(\d+)(\.\d+)?/.exec(this.name);
|
const match = /(\d+)(\.\d+)?/.exec(this.name);
|
||||||
var x = match[0] + (match[2] ? added.substr(match[2].length) : added) + '1';
|
const x = match[0] + (match[2] ? added.substr(match[2].length) : added) + '1';
|
||||||
var row = parentTag(this, 'tr');
|
const row = parentTag(this, 'tr');
|
||||||
var row2 = cloneNode(row);
|
const row2 = cloneNode(row);
|
||||||
var tags = qsa('select', row);
|
let tags = qsa('select', row);
|
||||||
var tags2 = qsa('select', row2);
|
let tags2 = qsa('select', row2);
|
||||||
for (var i=0; i < tags.length; i++) {
|
for (let i=0; i < tags.length; i++) {
|
||||||
tags2[i].name = tags[i].name.replace(/[0-9.]+/, x);
|
tags2[i].name = tags[i].name.replace(/[0-9.]+/, x);
|
||||||
tags2[i].selectedIndex = tags[i].selectedIndex;
|
tags2[i].selectedIndex = tags[i].selectedIndex;
|
||||||
}
|
}
|
||||||
tags = qsa('input', row);
|
tags = qsa('input', row);
|
||||||
tags2 = qsa('input', row2);
|
tags2 = qsa('input', row2);
|
||||||
var input = tags2[0]; // IE loose tags2 after insertBefore()
|
const input = tags2[0]; // IE loose tags2 after insertBefore()
|
||||||
for (var i=0; i < tags.length; i++) {
|
for (let 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;
|
||||||
@@ -374,7 +374,7 @@ function editingAddRow(focus) {
|
|||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function editingRemoveRow(name) {
|
function editingRemoveRow(name) {
|
||||||
var field = formField(this.form, this.name.replace(/[^[]+(.+)/, name));
|
const field = formField(this.form, this.name.replace(/[^[]+(.+)/, name));
|
||||||
field.parentNode.removeChild(field);
|
field.parentNode.removeChild(field);
|
||||||
parentTag(this, 'tr').style.display = 'none';
|
parentTag(this, 'tr').style.display = 'none';
|
||||||
return false;
|
return false;
|
||||||
@@ -386,7 +386,7 @@ function editingRemoveRow(name) {
|
|||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function editingMoveRow(up){
|
function editingMoveRow(up){
|
||||||
var row = parentTag(this, 'tr');
|
const row = parentTag(this, 'tr');
|
||||||
if (!('nextElementSibling' in row)) {
|
if (!('nextElementSibling' in row)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -402,9 +402,9 @@ var lastType = '';
|
|||||||
* @this HTMLSelectElement
|
* @this HTMLSelectElement
|
||||||
*/
|
*/
|
||||||
function editingTypeChange() {
|
function editingTypeChange() {
|
||||||
var type = this;
|
const type = this;
|
||||||
var name = type.name.substr(0, type.name.length - 6);
|
const name = type.name.substr(0, type.name.length - 6);
|
||||||
var text = selectValue(type);
|
const text = selectValue(type);
|
||||||
for (const el of type.form.elements.length) {
|
for (const el of type.form.elements.length) {
|
||||||
if (el.name == name + '[length]') {
|
if (el.name == name + '[length]') {
|
||||||
if (!(
|
if (!(
|
||||||
@@ -446,9 +446,9 @@ function editingLengthChange() {
|
|||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function editingLengthFocus() {
|
function editingLengthFocus() {
|
||||||
var td = this.parentNode;
|
const td = this.parentNode;
|
||||||
if (/(enum|set)$/.test(selectValue(td.previousSibling.firstChild))) {
|
if (/(enum|set)$/.test(selectValue(td.previousSibling.firstChild))) {
|
||||||
var edit = qs('#enum-edit');
|
const edit = qs('#enum-edit');
|
||||||
edit.value = enumValues(this.value);
|
edit.value = enumValues(this.value);
|
||||||
td.appendChild(edit);
|
td.appendChild(edit);
|
||||||
this.style.display = 'none';
|
this.style.display = 'none';
|
||||||
@@ -462,10 +462,10 @@ function editingLengthFocus() {
|
|||||||
* @return string values separated by newlines
|
* @return string values separated by newlines
|
||||||
*/
|
*/
|
||||||
function enumValues(s) {
|
function enumValues(s) {
|
||||||
var re = /(^|,)\s*'(([^\\']|\\.|'')*)'\s*/g;
|
const re = /(^|,)\s*'(([^\\']|\\.|'')*)'\s*/g;
|
||||||
var result = [];
|
const result = [];
|
||||||
var offset = 0;
|
let offset = 0;
|
||||||
var match;
|
let match;
|
||||||
while ((match = re.exec(s))) {
|
while ((match = re.exec(s))) {
|
||||||
if (offset != match.index) {
|
if (offset != match.index) {
|
||||||
break;
|
break;
|
||||||
@@ -480,8 +480,8 @@ function enumValues(s) {
|
|||||||
* @this HTMLTextAreaElement
|
* @this HTMLTextAreaElement
|
||||||
*/
|
*/
|
||||||
function editingLengthBlur() {
|
function editingLengthBlur() {
|
||||||
var field = this.parentNode.firstChild;
|
const field = this.parentNode.firstChild;
|
||||||
var val = this.value;
|
const val = this.value;
|
||||||
field.value = (/^'[^\n]+'$/.test(val) ? val : val && "'" + val.replace(/\n+$/, '').replace(/'/g, "''").replace(/\\/g, '\\\\').replace(/\n/g, "','") + "'");
|
field.value = (/^'[^\n]+'$/.test(val) ? val : val && "'" + val.replace(/\n+$/, '').replace(/'/g, "''").replace(/\\/g, '\\\\').replace(/\n/g, "','") + "'");
|
||||||
field.style.display = 'inline';
|
field.style.display = 'inline';
|
||||||
this.style.display = 'none';
|
this.style.display = 'none';
|
||||||
@@ -510,7 +510,7 @@ function indexOptionsShow(checked) {
|
|||||||
* @this HTMLSelectElement
|
* @this HTMLSelectElement
|
||||||
*/
|
*/
|
||||||
function partitionByChange() {
|
function partitionByChange() {
|
||||||
var partitionTable = /RANGE|LIST/.test(selectValue(this));
|
const partitionTable = /RANGE|LIST/.test(selectValue(this));
|
||||||
alterClass(this.form['partitions'], 'hidden', partitionTable || !this.selectedIndex);
|
alterClass(this.form['partitions'], 'hidden', partitionTable || !this.selectedIndex);
|
||||||
alterClass(qs('#partition-table'), 'hidden', !partitionTable);
|
alterClass(qs('#partition-table'), 'hidden', !partitionTable);
|
||||||
helpClose();
|
helpClose();
|
||||||
@@ -520,7 +520,7 @@ function partitionByChange() {
|
|||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function partitionNameChange() {
|
function partitionNameChange() {
|
||||||
var row = cloneNode(parentTag(this, 'tr'));
|
const row = cloneNode(parentTag(this, 'tr'));
|
||||||
row.firstChild.firstChild.value = '';
|
row.firstChild.firstChild.value = '';
|
||||||
parentTag(this, 'table').appendChild(row);
|
parentTag(this, 'table').appendChild(row);
|
||||||
this.oninput = function () {};
|
this.oninput = function () {};
|
||||||
@@ -531,7 +531,7 @@ function partitionNameChange() {
|
|||||||
* @param [boolean] whether to focus Comment if checked
|
* @param [boolean] whether to focus Comment if checked
|
||||||
*/
|
*/
|
||||||
function editingCommentsClick(el, focus) {
|
function editingCommentsClick(el, focus) {
|
||||||
var comment = el.form['Comment'];
|
const comment = el.form['Comment'];
|
||||||
columnShow(el.checked, 6);
|
columnShow(el.checked, 6);
|
||||||
alterClass(comment, 'hidden', !el.checked);
|
alterClass(comment, 'hidden', !el.checked);
|
||||||
if (focus && el.checked) {
|
if (focus && el.checked) {
|
||||||
@@ -546,10 +546,10 @@ function editingCommentsClick(el, focus) {
|
|||||||
* @this HTMLTableElement
|
* @this HTMLTableElement
|
||||||
*/
|
*/
|
||||||
function dumpClick(event) {
|
function dumpClick(event) {
|
||||||
var el = parentTag(getTarget(event), 'label');
|
let el = parentTag(getTarget(event), 'label');
|
||||||
if (el) {
|
if (el) {
|
||||||
el = qs('input', el);
|
el = qs('input', el);
|
||||||
var match = /(.+)\[]$/.exec(el.name);
|
const match = /(.+)\[]$/.exec(el.name);
|
||||||
if (match) {
|
if (match) {
|
||||||
checkboxClick.call(el, event);
|
checkboxClick.call(el, event);
|
||||||
formUncheck('check-' + match[1]);
|
formUncheck('check-' + match[1]);
|
||||||
@@ -563,7 +563,7 @@ function dumpClick(event) {
|
|||||||
* @this HTMLSelectElement
|
* @this HTMLSelectElement
|
||||||
*/
|
*/
|
||||||
function foreignAddRow() {
|
function foreignAddRow() {
|
||||||
var row = cloneNode(parentTag(this, 'tr'));
|
const row = cloneNode(parentTag(this, 'tr'));
|
||||||
this.onchange = function () { };
|
this.onchange = function () { };
|
||||||
for (const select of qsa('select', row)) {
|
for (const select of qsa('select', row)) {
|
||||||
select.name = select.name.replace(/\d+]/, '1$&');
|
select.name = select.name.replace(/\d+]/, '1$&');
|
||||||
@@ -578,7 +578,7 @@ function foreignAddRow() {
|
|||||||
* @this HTMLSelectElement
|
* @this HTMLSelectElement
|
||||||
*/
|
*/
|
||||||
function indexesAddRow() {
|
function indexesAddRow() {
|
||||||
var row = cloneNode(parentTag(this, 'tr'));
|
const row = cloneNode(parentTag(this, 'tr'));
|
||||||
this.onchange = function () { };
|
this.onchange = function () { };
|
||||||
for (const select of qsa('select', row)) {
|
for (const select of qsa('select', row)) {
|
||||||
select.name = select.name.replace(/indexes\[\d+/, '$&1');
|
select.name = select.name.replace(/indexes\[\d+/, '$&1');
|
||||||
@@ -596,11 +596,11 @@ function indexesAddRow() {
|
|||||||
* @this HTMLSelectElement
|
* @this HTMLSelectElement
|
||||||
*/
|
*/
|
||||||
function indexesChangeColumn(prefix) {
|
function indexesChangeColumn(prefix) {
|
||||||
var names = [];
|
const names = [];
|
||||||
for (var tag in { 'select': 1, 'input': 1 }) {
|
for (const tag in { 'select': 1, 'input': 1 }) {
|
||||||
for (const column of qsa(tag, parentTag(this, 'td'))) {
|
for (const column of qsa(tag, parentTag(this, 'td'))) {
|
||||||
if (/\[columns]/.test(column.name)) {
|
if (/\[columns]/.test(column.name)) {
|
||||||
var value = selectValue(column);
|
const value = selectValue(column);
|
||||||
if (value) {
|
if (value) {
|
||||||
names.push(value);
|
names.push(value);
|
||||||
}
|
}
|
||||||
@@ -615,15 +615,15 @@ function indexesChangeColumn(prefix) {
|
|||||||
* @this HTMLSelectElement
|
* @this HTMLSelectElement
|
||||||
*/
|
*/
|
||||||
function indexesAddColumn(prefix) {
|
function indexesAddColumn(prefix) {
|
||||||
var field = this;
|
const field = this;
|
||||||
var select = field.form[field.name.replace(/].*/, '][type]')];
|
const 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();
|
||||||
}
|
}
|
||||||
var column = cloneNode(field.parentNode);
|
const column = cloneNode(field.parentNode);
|
||||||
for (const select of qsa('select', column)) {
|
for (const select of qsa('select', column)) {
|
||||||
select.name = select.name.replace(/]\[\d+/, '$&1');
|
select.name = select.name.replace(/]\[\d+/, '$&1');
|
||||||
select.selectedIndex = 0;
|
select.selectedIndex = 0;
|
||||||
@@ -664,7 +664,7 @@ function sqlSubmit(form, root) {
|
|||||||
* @param HTMLFormElement
|
* @param HTMLFormElement
|
||||||
*/
|
*/
|
||||||
function triggerChange(tableRe, table, form) {
|
function triggerChange(tableRe, table, form) {
|
||||||
var formEvent = selectValue(form['Event']);
|
const formEvent = selectValue(form['Event']);
|
||||||
if (tableRe.test(form['Trigger'].value)) {
|
if (tableRe.test(form['Trigger'].value)) {
|
||||||
form['Trigger'].value = table + '_' + (selectValue(form['Timing']).charAt(0) + formEvent.charAt(0)).toLowerCase();
|
form['Trigger'].value = table + '_' + (selectValue(form['Timing']).charAt(0) + formEvent.charAt(0)).toLowerCase();
|
||||||
}
|
}
|
||||||
@@ -673,7 +673,7 @@ function triggerChange(tableRe, table, form) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
var that, x, y; // em and tablePos defined in schema.inc.php
|
let that, x, y; // em and tablePos defined in schema.inc.php
|
||||||
|
|
||||||
/** Get mouse position
|
/** Get mouse position
|
||||||
* @param MouseEvent
|
* @param MouseEvent
|
||||||
@@ -692,27 +692,27 @@ function schemaMousedown(event) {
|
|||||||
*/
|
*/
|
||||||
function schemaMousemove(event) {
|
function schemaMousemove(event) {
|
||||||
if (that !== undefined) {
|
if (that !== undefined) {
|
||||||
var left = (event.clientX - x) / em;
|
const left = (event.clientX - x) / em;
|
||||||
var top = (event.clientY - y) / em;
|
const top = (event.clientY - y) / em;
|
||||||
var lineSet = { };
|
const lineSet = { };
|
||||||
for (const div of qsa('div', that)) {
|
for (const div of qsa('div', that)) {
|
||||||
if (div.className == 'references') {
|
if (div.className == 'references') {
|
||||||
var div2 = qs('[id="' + (/^refs/.test(div.id) ? 'refd' : 'refs') + div.id.substr(4) + '"]');
|
const div2 = qs('[id="' + (/^refs/.test(div.id) ? 'refd' : 'refs') + div.id.substr(4) + '"]');
|
||||||
var ref = (tablePos[div.title] || [ div2.parentNode.offsetTop / em, 0 ]);
|
const ref = (tablePos[div.title] || [ div2.parentNode.offsetTop / em, 0 ]);
|
||||||
var left1 = -1;
|
let left1 = -1;
|
||||||
var id = div.id.replace(/^ref.(.+)-.+/, '$1');
|
const id = div.id.replace(/^ref.(.+)-.+/, '$1');
|
||||||
if (div.parentNode != div2.parentNode) {
|
if (div.parentNode != div2.parentNode) {
|
||||||
left1 = Math.min(0, ref[1] - left) - 1;
|
left1 = Math.min(0, ref[1] - left) - 1;
|
||||||
div.style.left = left1 + 'em';
|
div.style.left = left1 + 'em';
|
||||||
div.querySelector('div').style.width = -left1 + 'em';
|
div.querySelector('div').style.width = -left1 + 'em';
|
||||||
var left2 = Math.min(0, left - ref[1]) - 1;
|
const left2 = Math.min(0, left - ref[1]) - 1;
|
||||||
div2.style.left = left2 + 'em';
|
div2.style.left = left2 + 'em';
|
||||||
div2.querySelector('div').style.width = -left2 + 'em';
|
div2.querySelector('div').style.width = -left2 + 'em';
|
||||||
}
|
}
|
||||||
if (!lineSet[id]) {
|
if (!lineSet[id]) {
|
||||||
var line = qs('[id="' + div.id.replace(/^....(.+)-.+$/, 'refl$1') + '"]');
|
const line = qs('[id="' + div.id.replace(/^....(.+)-.+$/, 'refl$1') + '"]');
|
||||||
var top1 = top + div.offsetTop / em;
|
const top1 = top + div.offsetTop / em;
|
||||||
var top2 = top + div2.offsetTop / em;
|
let top2 = top + div2.offsetTop / em;
|
||||||
if (div.parentNode != div2.parentNode) {
|
if (div.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';
|
||||||
@@ -736,12 +736,12 @@ function schemaMouseup(event, db) {
|
|||||||
if (that !== undefined) {
|
if (that !== undefined) {
|
||||||
tablePos[that.firstChild.firstChild.firstChild.data] = [ (event.clientY - y) / em, (event.clientX - x) / em ];
|
tablePos[that.firstChild.firstChild.firstChild.data] = [ (event.clientY - y) / em, (event.clientX - x) / em ];
|
||||||
that = undefined;
|
that = undefined;
|
||||||
var s = '';
|
let s = '';
|
||||||
for (var key in tablePos) {
|
for (const key in tablePos) {
|
||||||
s += '_' + key + ':' + Math.round(tablePos[key][0] * 10000) / 10000 + 'x' + Math.round(tablePos[key][1] * 10000) / 10000;
|
s += '_' + key + ':' + Math.round(tablePos[key][0] * 10000) / 10000 + 'x' + Math.round(tablePos[key][1] * 10000) / 10000;
|
||||||
}
|
}
|
||||||
s = encodeURIComponent(s.substr(1));
|
s = encodeURIComponent(s.substr(1));
|
||||||
var link = qs('#schema-link');
|
const link = qs('#schema-link');
|
||||||
link.href = link.href.replace(/[^=]+$/, '') + s;
|
link.href = link.href.replace(/[^=]+$/, '') + s;
|
||||||
cookie('adminer_schema-' + db + '=' + s, 30); //! special chars in db
|
cookie('adminer_schema-' + db + '=' + s, 30); //! special chars in db
|
||||||
}
|
}
|
||||||
@@ -749,7 +749,7 @@ function schemaMouseup(event, db) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
var helpOpen, helpIgnore; // when mouse outs <option> then it mouse overs border of <select> - ignore it
|
let helpOpen, helpIgnore; // when mouse outs <option> then it mouse overs border of <select> - ignore it
|
||||||
|
|
||||||
/** Display help
|
/** Display help
|
||||||
* @param MouseEvent
|
* @param MouseEvent
|
||||||
@@ -758,17 +758,17 @@ var helpOpen, helpIgnore; // when mouse outs <option> then it mouse overs border
|
|||||||
* @this HTMLElement
|
* @this HTMLElement
|
||||||
*/
|
*/
|
||||||
function helpMouseover(event, text, side) {
|
function helpMouseover(event, text, side) {
|
||||||
var target = getTarget(event);
|
const 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');
|
const help = qs('#help');
|
||||||
help.innerHTML = text;
|
help.innerHTML = text;
|
||||||
jush.highlight_tag([ help ]);
|
jush.highlight_tag([ help ]);
|
||||||
alterClass(help, 'hidden');
|
alterClass(help, 'hidden');
|
||||||
var rect = target.getBoundingClientRect();
|
const rect = target.getBoundingClientRect();
|
||||||
var body = document.documentElement;
|
const body = document.documentElement;
|
||||||
help.style.top = (body.scrollTop + rect.top - (side ? (help.offsetHeight - target.offsetHeight) / 2 : help.offsetHeight)) + 'px';
|
help.style.top = (body.scrollTop + rect.top - (side ? (help.offsetHeight - target.offsetHeight) / 2 : help.offsetHeight)) + 'px';
|
||||||
help.style.left = (body.scrollLeft + rect.left - (side ? help.offsetWidth : (help.offsetWidth - target.offsetWidth) / 2)) + 'px';
|
help.style.left = (body.scrollLeft + rect.left - (side ? help.offsetWidth : (help.offsetWidth - target.offsetWidth) / 2)) + 'px';
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@ function qs(selector, context) {
|
|||||||
* @return HTMLElement
|
* @return HTMLElement
|
||||||
*/
|
*/
|
||||||
function qsl(selector, context) {
|
function qsl(selector, context) {
|
||||||
var els = qsa(selector, context);
|
const els = qsa(selector, context);
|
||||||
return els[els.length - 1];
|
return els[els.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ function qsa(selector, context) {
|
|||||||
* @return function with preserved this
|
* @return function with preserved this
|
||||||
*/
|
*/
|
||||||
function partial(fn) {
|
function partial(fn) {
|
||||||
var args = Array.apply(null, arguments).slice(1);
|
const args = Array.apply(null, arguments).slice(1);
|
||||||
return function () {
|
return function () {
|
||||||
return fn.apply(this, args);
|
return fn.apply(this, args);
|
||||||
};
|
};
|
||||||
@@ -45,7 +45,7 @@ function partial(fn) {
|
|||||||
* @return function with preserved this
|
* @return function with preserved this
|
||||||
*/
|
*/
|
||||||
function partialArg(fn) {
|
function partialArg(fn) {
|
||||||
var args = Array.apply(null, arguments);
|
const args = Array.apply(null, arguments);
|
||||||
return function (arg) {
|
return function (arg) {
|
||||||
args[0] = arg;
|
args[0] = arg;
|
||||||
return fn.apply(this, args);
|
return fn.apply(this, args);
|
||||||
@@ -57,7 +57,7 @@ function partialArg(fn) {
|
|||||||
* @param Object
|
* @param Object
|
||||||
*/
|
*/
|
||||||
function mixin(target, source) {
|
function mixin(target, source) {
|
||||||
for (var key in source) {
|
for (const key in source) {
|
||||||
target[key] = source[key];
|
target[key] = source[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ function alterClass(el, className, enable) {
|
|||||||
* @return boolean false
|
* @return boolean false
|
||||||
*/
|
*/
|
||||||
function toggle(id) {
|
function toggle(id) {
|
||||||
var el = qs('#' + id);
|
const el = qs('#' + id);
|
||||||
alterClass(el, 'hidden', !/(^|\s)hidden(\s|$)/.test(el.className));
|
alterClass(el, 'hidden', !/(^|\s)hidden(\s|$)/.test(el.className));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ function toggle(id) {
|
|||||||
* @param number
|
* @param number
|
||||||
*/
|
*/
|
||||||
function cookie(assign, days) {
|
function cookie(assign, days) {
|
||||||
var date = new Date();
|
const date = new Date();
|
||||||
date.setDate(date.getDate() + days);
|
date.setDate(date.getDate() + days);
|
||||||
document.cookie = assign + '; expires=' + date;
|
document.cookie = assign + '; expires=' + date;
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ function cookie(assign, days) {
|
|||||||
*/
|
*/
|
||||||
function verifyVersion(current, url, token) {
|
function verifyVersion(current, url, token) {
|
||||||
cookie('adminer_version=0', 1);
|
cookie('adminer_version=0', 1);
|
||||||
var iframe = document.createElement('iframe');
|
const iframe = document.createElement('iframe');
|
||||||
iframe.src = 'https://www.adminer.org/version/?current=' + current;
|
iframe.src = 'https://www.adminer.org/version/?current=' + current;
|
||||||
iframe.frameBorder = 0;
|
iframe.frameBorder = 0;
|
||||||
iframe.marginHeight = 0;
|
iframe.marginHeight = 0;
|
||||||
@@ -110,7 +110,7 @@ function verifyVersion(current, url, token) {
|
|||||||
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);
|
const match = /version=(.+)/.exec(event.data);
|
||||||
if (match) {
|
if (match) {
|
||||||
cookie('adminer_version=' + match[1], 1);
|
cookie('adminer_version=' + match[1], 1);
|
||||||
ajax(url + 'script=version', function () {
|
ajax(url + 'script=version', function () {
|
||||||
@@ -129,7 +129,7 @@ function selectValue(select) {
|
|||||||
if (!select.selectedIndex) {
|
if (!select.selectedIndex) {
|
||||||
return select.value;
|
return select.value;
|
||||||
}
|
}
|
||||||
var selected = select.options[select.selectedIndex];
|
const selected = select.options[select.selectedIndex];
|
||||||
return ((selected.attributes.value || {}).specified ? selected.value : selected.text);
|
return ((selected.attributes.value || {}).specified ? selected.value : selected.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ function selectValue(select) {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function isTag(el, tag) {
|
function isTag(el, tag) {
|
||||||
var re = new RegExp('^(' + tag + ')$', 'i');
|
const re = new RegExp('^(' + tag + ')$', 'i');
|
||||||
return el && re.test(el.tagName);
|
return el && re.test(el.tagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ function parentTag(el, tag) {
|
|||||||
* @param HTMLInputElement
|
* @param HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function trCheck(el) {
|
function trCheck(el) {
|
||||||
var tr = parentTag(el, 'tr');
|
const tr = parentTag(el, 'tr');
|
||||||
alterClass(tr, 'checked', el.checked);
|
alterClass(tr, 'checked', el.checked);
|
||||||
if (el.form && el.form['all'] && el.form['all'].onclick) { // Opera treats form.all as document.all
|
if (el.form && el.form['all'] && el.form['all'].onclick) { // Opera treats form.all as document.all
|
||||||
el.form['all'].onclick();
|
el.form['all'].onclick();
|
||||||
@@ -173,7 +173,7 @@ function trCheck(el) {
|
|||||||
*/
|
*/
|
||||||
function selectCount(id, count) {
|
function selectCount(id, count) {
|
||||||
setHtml(id, (count === '' ? '' : '(' + (count + '').replace(/\B(?=(\d{3})+$)/g, thousandsSeparator) + ')'));
|
setHtml(id, (count === '' ? '' : '(' + (count + '').replace(/\B(?=(\d{3})+$)/g, thousandsSeparator) + ')'));
|
||||||
var el = qs('#' + id);
|
const el = qs('#' + id);
|
||||||
if (el) {
|
if (el) {
|
||||||
for (const input of qsa('input', el.parentNode.parentNode)) {
|
for (const input of qsa('input', el.parentNode.parentNode)) {
|
||||||
if (input.type == 'submit') {
|
if (input.type == 'submit') {
|
||||||
@@ -208,7 +208,7 @@ function tableCheck() {
|
|||||||
* @param string
|
* @param string
|
||||||
*/
|
*/
|
||||||
function formUncheck(id) {
|
function formUncheck(id) {
|
||||||
var el = qs('#' + id);
|
const el = qs('#' + id);
|
||||||
el.checked = false;
|
el.checked = false;
|
||||||
trCheck(el);
|
trCheck(el);
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ function formUncheck(id) {
|
|||||||
* @return number
|
* @return number
|
||||||
*/
|
*/
|
||||||
function formChecked(input, name) {
|
function formChecked(input, name) {
|
||||||
var checked = 0;
|
let checked = 0;
|
||||||
for (const el of input.form.elements) {
|
for (const el of input.form.elements) {
|
||||||
if (name.test(el.name) && el.checked) {
|
if (name.test(el.name) && el.checked) {
|
||||||
checked++;
|
checked++;
|
||||||
@@ -233,15 +233,15 @@ function formChecked(input, name) {
|
|||||||
* @param [boolean] force click
|
* @param [boolean] force click
|
||||||
*/
|
*/
|
||||||
function tableClick(event, click) {
|
function tableClick(event, click) {
|
||||||
var td = parentTag(getTarget(event), 'td');
|
const td = parentTag(getTarget(event), 'td');
|
||||||
var text;
|
let text;
|
||||||
if (td && (text = td.getAttribute('data-text'))) {
|
if (td && (text = td.getAttribute('data-text'))) {
|
||||||
if (selectClick.call(td, event, +text, td.getAttribute('data-warning'))) {
|
if (selectClick.call(td, event, +text, td.getAttribute('data-warning'))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
click = (click || !window.getSelection || getSelection().isCollapsed);
|
click = (click || !window.getSelection || getSelection().isCollapsed);
|
||||||
var el = getTarget(event);
|
let 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') {
|
||||||
@@ -270,7 +270,7 @@ function tableClick(event, click) {
|
|||||||
trCheck(el);
|
trCheck(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastChecked;
|
let lastChecked;
|
||||||
|
|
||||||
/** Shift-click on checkbox for multiple selection.
|
/** Shift-click on checkbox for multiple selection.
|
||||||
* @param MouseEvent
|
* @param MouseEvent
|
||||||
@@ -281,8 +281,8 @@ function checkboxClick(event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.shiftKey && (!lastChecked || lastChecked.name == this.name)) {
|
if (event.shiftKey && (!lastChecked || lastChecked.name == this.name)) {
|
||||||
var checked = (lastChecked ? lastChecked.checked : true);
|
const checked = (lastChecked ? lastChecked.checked : true);
|
||||||
var checking = !lastChecked;
|
let checking = !lastChecked;
|
||||||
for (const input of qsa('input', parentTag(this, 'table'))) {
|
for (const input of qsa('input', parentTag(this, 'table'))) {
|
||||||
if (input.name === this.name) {
|
if (input.name === this.name) {
|
||||||
if (checking) {
|
if (checking) {
|
||||||
@@ -307,7 +307,7 @@ function checkboxClick(event) {
|
|||||||
* @param string undefined to set parentNode to empty string
|
* @param string undefined to set parentNode to empty string
|
||||||
*/
|
*/
|
||||||
function setHtml(id, html) {
|
function setHtml(id, html) {
|
||||||
var el = qs('[id="' + id.replace(/[\\"]/g, '\\$&') + '"]'); // database name is used as ID
|
const el = qs('[id="' + id.replace(/[\\"]/g, '\\$&') + '"]'); // database name is used as ID
|
||||||
if (el) {
|
if (el) {
|
||||||
if (html == null) {
|
if (html == null) {
|
||||||
el.parentNode.innerHTML = '';
|
el.parentNode.innerHTML = '';
|
||||||
@@ -322,7 +322,7 @@ function setHtml(id, html) {
|
|||||||
* @return number
|
* @return number
|
||||||
*/
|
*/
|
||||||
function nodePosition(el) {
|
function nodePosition(el) {
|
||||||
var pos = 0;
|
let pos = 0;
|
||||||
while ((el = el.previousSibling)) {
|
while ((el = el.previousSibling)) {
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
@@ -346,7 +346,7 @@ function pageClick(href, page) {
|
|||||||
* @this HTMLElement
|
* @this HTMLElement
|
||||||
*/
|
*/
|
||||||
function menuOver(event) {
|
function menuOver(event) {
|
||||||
var a = getTarget(event);
|
const a = getTarget(event);
|
||||||
if (isTag(a, 'a|span') && a.offsetLeft + a.offsetWidth > a.parentNode.offsetWidth - 15) { // 15 - ellipsis
|
if (isTag(a, 'a|span') && a.offsetLeft + a.offsetWidth > a.parentNode.offsetWidth - 15) { // 15 - ellipsis
|
||||||
this.style.overflow = 'visible';
|
this.style.overflow = 'visible';
|
||||||
}
|
}
|
||||||
@@ -365,8 +365,8 @@ function menuOut() {
|
|||||||
* @this HTMLSelectElement
|
* @this HTMLSelectElement
|
||||||
*/
|
*/
|
||||||
function selectAddRow() {
|
function selectAddRow() {
|
||||||
var field = this;
|
const field = this;
|
||||||
var row = cloneNode(field.parentNode);
|
const row = cloneNode(field.parentNode);
|
||||||
field.onchange = selectFieldChange;
|
field.onchange = selectFieldChange;
|
||||||
field.onchange();
|
field.onchange();
|
||||||
for (const select of qsa('select', row)) {
|
for (const select of qsa('select', row)) {
|
||||||
@@ -426,12 +426,12 @@ function columnMouse(className) {
|
|||||||
* @return boolean false
|
* @return boolean false
|
||||||
*/
|
*/
|
||||||
function selectSearch(name) {
|
function selectSearch(name) {
|
||||||
var el = qs('#fieldset-search');
|
let el = qs('#fieldset-search');
|
||||||
el.className = '';
|
el.className = '';
|
||||||
var divs = qsa('div', el);
|
const divs = qsa('div', el);
|
||||||
var i;
|
let i, div;
|
||||||
for (i=0; i < divs.length; i++) {
|
for (i=0; i < divs.length; i++) {
|
||||||
var div = divs[i];
|
div = divs[i];
|
||||||
el = qs('[name$="[col]"]', div);
|
el = qs('[name$="[col]"]', div);
|
||||||
if (el && selectValue(el) == name) {
|
if (el && selectValue(el) == name) {
|
||||||
break;
|
break;
|
||||||
@@ -471,7 +471,7 @@ function getTarget(event) {
|
|||||||
*/
|
*/
|
||||||
function bodyKeydown(event, button) {
|
function bodyKeydown(event, button) {
|
||||||
eventStop(event);
|
eventStop(event);
|
||||||
var target = getTarget(event);
|
let target = getTarget(event);
|
||||||
if (target.jushTextarea) {
|
if (target.jushTextarea) {
|
||||||
target = target.jushTextarea;
|
target = target.jushTextarea;
|
||||||
}
|
}
|
||||||
@@ -495,7 +495,7 @@ function bodyKeydown(event, button) {
|
|||||||
* @param MouseEvent
|
* @param MouseEvent
|
||||||
*/
|
*/
|
||||||
function bodyClick(event) {
|
function bodyClick(event) {
|
||||||
var target = getTarget(event);
|
const 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 () {
|
||||||
@@ -513,9 +513,9 @@ function bodyClick(event) {
|
|||||||
*/
|
*/
|
||||||
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);
|
const target = getTarget(event);
|
||||||
var sibling = (event.keyCode == 40 ? 'nextSibling' : 'previousSibling');
|
const sibling = (event.keyCode == 40 ? 'nextSibling' : 'previousSibling');
|
||||||
var el = target.parentNode.parentNode[sibling];
|
let 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();
|
||||||
}
|
}
|
||||||
@@ -531,7 +531,7 @@ function editingKeydown(event) {
|
|||||||
* @this HTMLSelectElement
|
* @this HTMLSelectElement
|
||||||
*/
|
*/
|
||||||
function functionChange() {
|
function functionChange() {
|
||||||
var input = this.form[this.name.replace(/^function/, 'fields')];
|
const input = this.form[this.name.replace(/^function/, 'fields')];
|
||||||
if (input) { // undefined with the set data type
|
if (input) { // undefined with the set data type
|
||||||
if (selectValue(this)) {
|
if (selectValue(this)) {
|
||||||
if (input.origType === undefined) {
|
if (input.origType === undefined) {
|
||||||
@@ -556,7 +556,7 @@ function functionChange() {
|
|||||||
* @this HTMLTableCellElement
|
* @this HTMLTableCellElement
|
||||||
*/
|
*/
|
||||||
function skipOriginal(first) {
|
function skipOriginal(first) {
|
||||||
var fnSelect = qs('select', this.previousSibling);
|
const fnSelect = qs('select', this.previousSibling);
|
||||||
if (fnSelect.selectedIndex < first) {
|
if (fnSelect.selectedIndex < first) {
|
||||||
fnSelect.selectedIndex = first;
|
fnSelect.selectedIndex = first;
|
||||||
}
|
}
|
||||||
@@ -566,7 +566,7 @@ function skipOriginal(first) {
|
|||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function fieldChange() {
|
function fieldChange() {
|
||||||
var row = cloneNode(parentTag(this, 'tr'));
|
const row = cloneNode(parentTag(this, 'tr'));
|
||||||
for (const input of qsa('input', row)) {
|
for (const input of qsa('input', row)) {
|
||||||
input.value = '';
|
input.value = '';
|
||||||
}
|
}
|
||||||
@@ -586,9 +586,9 @@ function fieldChange() {
|
|||||||
* @uses offlineMessage
|
* @uses offlineMessage
|
||||||
*/
|
*/
|
||||||
function ajax(url, callback, data, message) {
|
function ajax(url, callback, data, message) {
|
||||||
var request = new XMLHttpRequest();
|
const request = new XMLHttpRequest();
|
||||||
if (request) {
|
if (request) {
|
||||||
var ajaxStatus = qs('#ajaxstatus');
|
const ajaxStatus = qs('#ajaxstatus');
|
||||||
if (message) {
|
if (message) {
|
||||||
ajaxStatus.innerHTML = '<div class="message">' + message + '</div>';
|
ajaxStatus.innerHTML = '<div class="message">' + message + '</div>';
|
||||||
ajaxStatus.className = ajaxStatus.className.replace(/ hidden/g, '');
|
ajaxStatus.className = ajaxStatus.className.replace(/ hidden/g, '');
|
||||||
@@ -621,8 +621,8 @@ function ajax(url, callback, data, message) {
|
|||||||
*/
|
*/
|
||||||
function ajaxSetHtml(url) {
|
function ajaxSetHtml(url) {
|
||||||
return !ajax(url, function (request) {
|
return !ajax(url, function (request) {
|
||||||
var data = JSON.parse(request.responseText);
|
const data = JSON.parse(request.responseText);
|
||||||
for (var key in data) {
|
for (const key in data) {
|
||||||
setHtml(key, data[key]);
|
setHtml(key, data[key]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -635,7 +635,7 @@ function ajaxSetHtml(url) {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function ajaxForm(form, message, button) {
|
function ajaxForm(form, message, button) {
|
||||||
var data = [];
|
let data = [];
|
||||||
for (const el of form.elements) {
|
for (const el of form.elements) {
|
||||||
if (el.name && !el.disabled) {
|
if (el.name && !el.disabled) {
|
||||||
if (/^file$/i.test(el.type) && el.value) {
|
if (/^file$/i.test(el.type) && el.value) {
|
||||||
@@ -648,7 +648,7 @@ function ajaxForm(form, message, button) {
|
|||||||
}
|
}
|
||||||
data = data.join('&');
|
data = data.join('&');
|
||||||
|
|
||||||
var url = form.action;
|
let url = form.action;
|
||||||
if (!/post/i.test(form.method)) {
|
if (!/post/i.test(form.method)) {
|
||||||
url = url.replace(/\?.*/, '') + '?' + data;
|
url = url.replace(/\?.*/, '') + '?' + data;
|
||||||
data = '';
|
data = '';
|
||||||
@@ -672,8 +672,8 @@ function ajaxForm(form, message, button) {
|
|||||||
* @this HTMLElement
|
* @this HTMLElement
|
||||||
*/
|
*/
|
||||||
function selectClick(event, text, warning) {
|
function selectClick(event, text, warning) {
|
||||||
var td = this;
|
const td = this;
|
||||||
var target = getTarget(event);
|
const target = getTarget(event);
|
||||||
if (!isCtrl(event) || isTag(td.firstChild, 'input|textarea') || isTag(target, 'a')) {
|
if (!isCtrl(event) || isTag(td.firstChild, 'input|textarea') || isTag(target, 'a')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -681,9 +681,9 @@ function selectClick(event, text, warning) {
|
|||||||
alert(warning);
|
alert(warning);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var original = td.innerHTML;
|
const original = td.innerHTML;
|
||||||
text = text || /\n/.test(original);
|
text = text || /\n/.test(original);
|
||||||
var input = document.createElement(text ? 'textarea' : 'input');
|
const input = document.createElement(text ? 'textarea' : 'input');
|
||||||
input.onkeydown = function (event) {
|
input.onkeydown = function (event) {
|
||||||
if (!event) {
|
if (!event) {
|
||||||
event = window.event;
|
event = window.event;
|
||||||
@@ -701,7 +701,7 @@ function selectClick(event, text, warning) {
|
|||||||
input.style.width = Math.max(td.clientWidth - parseFloat(tdStyle.paddingLeft) - parseFloat(tdStyle.paddingRight), 20) + 'px';
|
input.style.width = Math.max(td.clientWidth - parseFloat(tdStyle.paddingLeft) - parseFloat(tdStyle.paddingRight), 20) + 'px';
|
||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
var rows = 1;
|
let rows = 1;
|
||||||
value.replace(/\n/g, function () {
|
value.replace(/\n/g, function () {
|
||||||
rows++;
|
rows++;
|
||||||
});
|
});
|
||||||
@@ -711,9 +711,9 @@ function selectClick(event, text, warning) {
|
|||||||
value = '';
|
value = '';
|
||||||
}
|
}
|
||||||
if (document.selection) {
|
if (document.selection) {
|
||||||
var range = document.selection.createRange();
|
const range = document.selection.createRange();
|
||||||
range.moveToPoint(event.clientX, event.clientY);
|
range.moveToPoint(event.clientX, event.clientY);
|
||||||
var range2 = range.duplicate();
|
const range2 = range.duplicate();
|
||||||
range2.moveToElementText(td);
|
range2.moveToElementText(td);
|
||||||
range2.setEndPoint('EndToEnd', range);
|
range2.setEndPoint('EndToEnd', range);
|
||||||
pos = range2.text.length;
|
pos = range2.text.length;
|
||||||
@@ -735,7 +735,7 @@ function selectClick(event, text, warning) {
|
|||||||
input.selectionStart = pos;
|
input.selectionStart = pos;
|
||||||
input.selectionEnd = pos;
|
input.selectionEnd = pos;
|
||||||
if (document.selection) {
|
if (document.selection) {
|
||||||
var range = document.selection.createRange();
|
const range = document.selection.createRange();
|
||||||
range.moveEnd('character', -input.value.length + pos);
|
range.moveEnd('character', -input.value.length + pos);
|
||||||
range.select();
|
range.select();
|
||||||
}
|
}
|
||||||
@@ -751,14 +751,14 @@ function selectClick(event, text, warning) {
|
|||||||
* @this HTMLLinkElement
|
* @this HTMLLinkElement
|
||||||
*/
|
*/
|
||||||
function selectLoadMore(limit, loading) {
|
function selectLoadMore(limit, loading) {
|
||||||
var a = this;
|
const a = this;
|
||||||
var title = a.innerHTML;
|
const title = a.innerHTML;
|
||||||
var href = a.href;
|
const href = a.href;
|
||||||
a.innerHTML = loading;
|
a.innerHTML = loading;
|
||||||
if (href) {
|
if (href) {
|
||||||
a.removeAttribute('href');
|
a.removeAttribute('href');
|
||||||
return !ajax(href, function (request) {
|
return !ajax(href, function (request) {
|
||||||
var tbody = document.createElement('tbody');
|
const tbody = document.createElement('tbody');
|
||||||
tbody.innerHTML = request.responseText;
|
tbody.innerHTML = request.responseText;
|
||||||
qs('#table').appendChild(tbody);
|
qs('#table').appendChild(tbody);
|
||||||
if (tbody.children.length < limit) {
|
if (tbody.children.length < limit) {
|
||||||
@@ -792,7 +792,7 @@ function eventStop(event) {
|
|||||||
* @param HTMLElement
|
* @param HTMLElement
|
||||||
*/
|
*/
|
||||||
function setupSubmitHighlight(parent) {
|
function setupSubmitHighlight(parent) {
|
||||||
for (var key in { input: 1, select: 1, textarea: 1 }) {
|
for (const key in { input: 1, select: 1, textarea: 1 }) {
|
||||||
for (const input of qsa(key, parent)) {
|
for (const input of qsa(key, parent)) {
|
||||||
setupSubmitHighlightInput(input);
|
setupSubmitHighlightInput(input);
|
||||||
}
|
}
|
||||||
@@ -813,7 +813,7 @@ function setupSubmitHighlightInput(input) {
|
|||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function inputFocus() {
|
function inputFocus() {
|
||||||
var submit = findDefaultSubmit(this);
|
const submit = findDefaultSubmit(this);
|
||||||
if (submit) {
|
if (submit) {
|
||||||
alterClass(submit, 'default', true);
|
alterClass(submit, 'default', true);
|
||||||
}
|
}
|
||||||
@@ -823,7 +823,7 @@ function inputFocus() {
|
|||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function inputBlur() {
|
function inputBlur() {
|
||||||
var submit = findDefaultSubmit(this);
|
const submit = findDefaultSubmit(this);
|
||||||
if (submit) {
|
if (submit) {
|
||||||
alterClass(submit, 'default');
|
alterClass(submit, 'default');
|
||||||
}
|
}
|
||||||
@@ -867,13 +867,13 @@ function addEvent(el, action, handler) {
|
|||||||
* @return HTMLElement
|
* @return HTMLElement
|
||||||
*/
|
*/
|
||||||
function cloneNode(el) {
|
function cloneNode(el) {
|
||||||
var el2 = el.cloneNode(true);
|
const el2 = el.cloneNode(true);
|
||||||
var selector = 'input, select';
|
const selector = 'input, select';
|
||||||
var origEls = qsa(selector, el);
|
const origEls = qsa(selector, el);
|
||||||
var cloneEls = qsa(selector, el2);
|
const cloneEls = qsa(selector, el2);
|
||||||
for (var i=0; i < origEls.length; i++) {
|
for (let i=0; i < origEls.length; i++) {
|
||||||
var origEl = origEls[i];
|
const origEl = origEls[i];
|
||||||
for (var key in origEl) {
|
for (const key in origEl) {
|
||||||
if (/^on/.test(key) && origEl[key]) {
|
if (/^on/.test(key) && origEl[key]) {
|
||||||
cloneEls[i][key] = origEl[key];
|
cloneEls[i][key] = origEl[key];
|
||||||
}
|
}
|
||||||
@@ -884,7 +884,7 @@ function cloneNode(el) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
oninput = function (event) {
|
oninput = function (event) {
|
||||||
var target = event.target;
|
const target = event.target;
|
||||||
var maxLength = target.getAttribute('data-maxlength');
|
const maxLength = target.getAttribute('data-maxlength');
|
||||||
alterClass(target, 'maxlength', target.value && maxLength != null && target.value.length > maxLength); // maxLength could be 0
|
alterClass(target, 'maxlength', target.value && maxLength != null && target.value.length > maxLength); // maxLength could be 0
|
||||||
};
|
};
|
||||||
|
@@ -6,7 +6,7 @@ function messagesPrint() {
|
|||||||
function selectFieldChange() {
|
function selectFieldChange() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var helpOpen;
|
let helpOpen;
|
||||||
|
|
||||||
function helpMouseover() {
|
function helpMouseover() {
|
||||||
}
|
}
|
||||||
@@ -22,14 +22,14 @@ function helpClose() {
|
|||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function whisper(url) {
|
function whisper(url) {
|
||||||
var field = this;
|
const field = this;
|
||||||
field.orig = field.value;
|
field.orig = field.value;
|
||||||
field.previousSibling.value = field.value; // accept number, reject string
|
field.previousSibling.value = field.value; // accept number, reject string
|
||||||
return ajax(url + encodeURIComponent(field.value), function (xmlhttp) {
|
return ajax(url + encodeURIComponent(field.value), function (xmlhttp) {
|
||||||
if (xmlhttp.status && field.orig == field.value) { // ignore old responses
|
if (xmlhttp.status && field.orig == field.value) { // ignore old responses
|
||||||
field.nextSibling.innerHTML = xmlhttp.responseText;
|
field.nextSibling.innerHTML = xmlhttp.responseText;
|
||||||
field.nextSibling.style.display = '';
|
field.nextSibling.style.display = '';
|
||||||
var a = field.nextSibling.firstChild;
|
const a = field.nextSibling.firstChild;
|
||||||
if (a && a.firstChild.data == field.value) {
|
if (a && a.firstChild.data == field.value) {
|
||||||
field.previousSibling.value = decodeURIComponent(a.href.replace(/.*=/, ''));
|
field.previousSibling.value = decodeURIComponent(a.href.replace(/.*=/, ''));
|
||||||
a.className = 'active';
|
a.className = 'active';
|
||||||
@@ -44,8 +44,8 @@ function whisper(url) {
|
|||||||
* @this HTMLDivElement
|
* @this HTMLDivElement
|
||||||
*/
|
*/
|
||||||
function whisperClick(event) {
|
function whisperClick(event) {
|
||||||
var field = this.previousSibling;
|
const field = this.previousSibling;
|
||||||
var el = getTarget(event);
|
const el = getTarget(event);
|
||||||
if (isTag(el, 'a') && !(event.button || event.shiftKey || event.altKey || isCtrl(event))) {
|
if (isTag(el, 'a') && !(event.button || event.shiftKey || event.altKey || isCtrl(event))) {
|
||||||
field.value = el.firstChild.data;
|
field.value = el.firstChild.data;
|
||||||
field.previousSibling.value = decodeURIComponent(el.href.replace(/.*=/, ''));
|
field.previousSibling.value = decodeURIComponent(el.href.replace(/.*=/, ''));
|
||||||
@@ -58,7 +58,7 @@ function whisperClick(event) {
|
|||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function emailFileChange() {
|
function emailFileChange() {
|
||||||
var el = this.cloneNode(true);
|
const el = this.cloneNode(true);
|
||||||
this.onchange = function () { };
|
this.onchange = function () { };
|
||||||
el.value = '';
|
el.value = '';
|
||||||
this.parentNode.appendChild(el);
|
this.parentNode.appendChild(el);
|
||||||
|
Reference in New Issue
Block a user