mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-01-11 17:58:41 +00:00
fix eslint errors
This commit is contained in:
parent
e3aef7338a
commit
7bf4ebd3df
|
|
@ -324,7 +324,7 @@ export class Request
|
|||
// GET request doesn't allow body/payload. Therefor we have to put the data into the uri
|
||||
if (this.method === RequestMethod.GET) {
|
||||
let url = this.uri;
|
||||
for (let pair of this.data.entries()) {
|
||||
for (const pair of this.data.entries()) {
|
||||
url += '&' + pair[0] + '=' + pair[1];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ export class ResponseManager
|
|||
) {
|
||||
this.messages[key][request](data);
|
||||
} else if (typeof this.messages[key] !== 'undefined') {
|
||||
this.messages[key][null](data);
|
||||
this.messages[key].null(data);
|
||||
} else {
|
||||
jsOMS.Log.Logger.instance.warning('Undefined type: ' + key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,13 @@ export function formSubmitAction (action, callback, id)
|
|||
{
|
||||
'use strict';
|
||||
|
||||
const submit = action.base === 'self' ? (action.selector === '' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector);
|
||||
const submit = action.base === 'self'
|
||||
? (
|
||||
action.selector === ''
|
||||
? [document.getElementById(id)]
|
||||
: document.getElementById(id).querySelectorAll(action.selector)
|
||||
)
|
||||
: document.querySelectorAll(action.selector);
|
||||
|
||||
if (!submit) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -29,15 +29,15 @@ export class SystemUtils
|
|||
return BrowserType.FIREFOX;
|
||||
} else if (Object.toString.call(window.HTMLElement).indexOf('Constructor') > 0) {
|
||||
return BrowserType.SAFARI;
|
||||
} else if (/* @cc_on!@ */false || !!document.documentMode) {
|
||||
} else if (/* @cc_on!@ */false || !!document.documentMode) { // eslint-disable-line no-extra-boolean-cast
|
||||
return BrowserType.IE;
|
||||
} else if (!!window.StyleMedia) {
|
||||
} else if (!!window.StyleMedia) { // eslint-disable-line no-extra-boolean-cast
|
||||
return BrowserType.EDGE;
|
||||
} else if (!!window.chrome && !!window.chrome.webstore) {
|
||||
} else if (!!window.chrome && !!window.chrome.webstore) { // eslint-disable-line no-extra-boolean-cast
|
||||
return BrowserType.CHROME;
|
||||
} else if (((typeof isChrome !== 'undefined' && isChrome)
|
||||
|| (typeof isOpera !== 'undefined' && isOpera))
|
||||
&& !!window.CSS
|
||||
&& !!window.CSS // eslint-disable-line no-extra-boolean-cast
|
||||
) {
|
||||
return BrowserType.BLINK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -277,7 +277,10 @@ export class Form
|
|||
/** @var {Element} dataOriginElement Element where the value data comes from */
|
||||
const dataOriginElement = tplValue.startsWith('http') || tplValue.startsWith('{')
|
||||
? newElements[i].firstElementChild // data comes from remote source
|
||||
: formElement; // data comes from the form (even if the api returns something after adding). What if remote returns a DB id? how do we add it? is this a @todo ? probably yes, maybe first use local data and then if remote data available replace local data?
|
||||
: formElement; // data comes from the form (even if the api returns something after adding).
|
||||
// What if remote returns a DB id? how do we add it?
|
||||
// is this a @todo ? probably yes.
|
||||
// maybe first use local data and then if remote data available replace local data?
|
||||
|
||||
values = values.concat(
|
||||
dataOriginElement.hasAttribute('data-tpl-value')
|
||||
|
|
@ -400,7 +403,10 @@ export class Form
|
|||
/** @var {Element} dataOriginElement Element where the value data comes from */
|
||||
const dataOriginElement = tplValue.startsWith('http') || tplValue.startsWith('{')
|
||||
? newElements[i].firstElementChild // data comes from remote source
|
||||
: elementContainer; // data comes from the form (even if the api returns something after adding). What if remote returns a DB id? how do we add it? is this a @todo ? probably yes, maybe first use local data and then if remote data available replace local data?
|
||||
: elementContainer; // data comes from the form (even if the api returns something after adding).
|
||||
// What if remote returns a DB id? how do we add it?
|
||||
// is this a @todo ? probably yes.
|
||||
// maybe first use local data and then if remote data available replace local data?
|
||||
|
||||
values = values.concat(
|
||||
dataOriginElement.hasAttribute('data-tpl-value')
|
||||
|
|
@ -468,7 +474,10 @@ export class Form
|
|||
/** @var {Element} dataOriginElement Element where the value data comes from */
|
||||
const dataOriginElement = updateValue.startsWith('http') || updateValue.startsWith('{')
|
||||
? updateElements[i].firstElementChild // data comes from remote source
|
||||
: elementContainer; // data comes from the form (even if the api returns something after adding). What if remote returns a DB id? how do we add it? is this a @todo ? probably yes, maybe first use local data and then if remote data available replace local data?
|
||||
: elementContainer; // data comes from the form (even if the api returns something after adding).
|
||||
// What if remote returns a DB id? how do we add it?
|
||||
// is this a @todo ? probably yes.
|
||||
// maybe first use local data and then if remote data available replace local data?
|
||||
|
||||
values = values.concat(
|
||||
dataOriginElement.hasAttribute('data-tpl-value')
|
||||
|
|
@ -554,7 +563,10 @@ export class Form
|
|||
/** @var {Element} dataOriginElement Element where the value data comes from */
|
||||
const dataOriginElement = updateValue.startsWith('http') || updateValue.startsWith('{')
|
||||
? updateElements[i].firstElementChild // data comes from remote source
|
||||
: externalFormElement; // data comes from the form (even if the api returns something after adding). What if remote returns a DB id? how do we add it? is this a @todo ? probably yes, maybe first use local data and then if remote data available replace local data?
|
||||
: externalFormElement; // data comes from the form (even if the api returns something after adding).
|
||||
// What if remote returns a DB id? how do we add it?
|
||||
// is this a @todo ? probably yes.
|
||||
// maybe first use local data and then if remote data available replace local data?
|
||||
|
||||
values = values.concat(
|
||||
dataOriginElement.hasAttribute('data-tpl-value')
|
||||
|
|
@ -591,21 +603,21 @@ export class Form
|
|||
|
||||
// show add button + hide update button + hide cancel button
|
||||
const addButtons = self.forms[externalFormId].getAdd();
|
||||
length = addButtons.length;
|
||||
let buttonLength = addButtons.length;
|
||||
|
||||
for (let i = 0; i < length; ++i) {
|
||||
for (let i = 0; i < buttonLength; ++i) {
|
||||
jsOMS.removeClass(addButtons[i], 'hidden');
|
||||
}
|
||||
|
||||
const saveButtons = self.forms[externalFormId].getSave();
|
||||
length = saveButtons.length;
|
||||
for (let i = 0; i < length; ++i) {
|
||||
buttonLength = saveButtons.length;
|
||||
for (let i = 0; i < buttonLength; ++i) {
|
||||
jsOMS.addClass(saveButtons[i], 'hidden');
|
||||
}
|
||||
|
||||
const cancelButtons = self.forms[externalFormId].getCancel();
|
||||
length = cancelButtons.length;
|
||||
for (let i = 0; i < length; ++i) {
|
||||
buttonLength = cancelButtons.length;
|
||||
for (let i = 0; i < buttonLength; ++i) {
|
||||
jsOMS.addClass(cancelButtons[i], 'hidden');
|
||||
}
|
||||
}
|
||||
|
|
@ -636,7 +648,7 @@ export class Form
|
|||
|
||||
jsOMS.removeClass(element, 'hidden');
|
||||
|
||||
elementContainer.parentNode.removeChild(elementContainer)
|
||||
elementContainer.parentNode.removeChild(elementContainer);
|
||||
} else {
|
||||
// handle external cancel
|
||||
|
||||
|
|
@ -732,14 +744,14 @@ export class Form
|
|||
}
|
||||
|
||||
const saveButtons = self.forms[id].getSave();
|
||||
length = saveButtons.length;
|
||||
for (let i = 0; i < length; ++i) {
|
||||
let buttonLength = saveButtons.length;
|
||||
for (let i = 0; i < buttonLength; ++i) {
|
||||
jsOMS.removeClass(saveButtons[i], 'hidden');
|
||||
}
|
||||
|
||||
const cancelButtons = self.forms[id].getCancel();
|
||||
length = cancelButtons.length;
|
||||
for (let i = 0; i < length; ++i) {
|
||||
buttonLength = cancelButtons.length;
|
||||
for (let i = 0; i < buttonLength; ++i) {
|
||||
jsOMS.removeClass(cancelButtons[i], 'hidden');
|
||||
}
|
||||
} else {
|
||||
|
|
@ -819,7 +831,7 @@ export class Form
|
|||
) {
|
||||
jsOMS.preventAll(event);
|
||||
self.submit(self.forms[id], self.forms[id].getSubmit()[elementIndex]);
|
||||
} else if ((elementIndex = '')) {
|
||||
} else if (false) { // eslint-disable-line no-constant-condition
|
||||
// @todo: if table head input field in popups changes -> check if input empty -> deactivate -> checkbox : else activate checkbox
|
||||
// careful: the same checkbox is used for showing the filter popup. maybe create a separate checkbox, which only handles the highlighting if filter is defined.
|
||||
// this means popup active highlights filter icon AND different content checkbox also highlights filter
|
||||
|
|
@ -962,7 +974,7 @@ export class Form
|
|||
|
||||
request.setData(data);
|
||||
request.setType(RequestType.FORM_DATA); // @todo: consider to allow different request type
|
||||
request.setUri(action ? action : form.getAction());
|
||||
request.setUri(action !== null ? action : form.getAction());
|
||||
request.setMethod(form.getMethod());
|
||||
request.setSuccess(function (xhr)
|
||||
{
|
||||
|
|
@ -1157,7 +1169,7 @@ export class Form
|
|||
if (data[i].getAttribute('data-tpl-' + type).startsWith('http')
|
||||
|| data[i].getAttribute('data-tpl-' + type).startsWith('{')
|
||||
) {
|
||||
Form.populateRemoteUrls(type, data[i], path, remoteUrls);
|
||||
Form.populateRemoteUrls(matches[c], type, data[i], path, remoteUrls);
|
||||
} else {
|
||||
if (type === 'value') {
|
||||
GeneralUI.setValueOfElement(matches[c], GeneralUI.getValueFromDataSource(data[i]));
|
||||
|
|
@ -1184,7 +1196,7 @@ export class Form
|
|||
if (data[i].getAttribute('data-tpl-' + type).startsWith('http')
|
||||
|| data[i].getAttribute('data-tpl-' + type).startsWith('{')
|
||||
) {
|
||||
Form.populateRemoteUrls(type, data[i], path, remoteUrls);
|
||||
Form.populateRemoteUrls(matches[c], type, data[i], path, remoteUrls);
|
||||
} else {
|
||||
if (type === 'value') {
|
||||
GeneralUI.setValueOfElement(matches[c], GeneralUI.getValueFromDataSource(data[i]));
|
||||
|
|
@ -1196,7 +1208,7 @@ export class Form
|
|||
}
|
||||
};
|
||||
|
||||
static populateRemoteUrls (type, data, path, remoteUrls)
|
||||
static populateRemoteUrls (ele, type, data, path, remoteUrls)
|
||||
{
|
||||
const uri = data.getAttribute('data-tpl-' + type).startsWith('/')
|
||||
? document.getElementsByTagName('base')[0].href
|
||||
|
|
@ -1208,7 +1220,7 @@ export class Form
|
|||
|
||||
remoteUrls[uri + data.getAttribute('data-tpl-' + type)].push({
|
||||
path: path,
|
||||
element: matches[c],
|
||||
element: ele,
|
||||
type: type
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ export class Input
|
|||
const response = new Response(o);
|
||||
const responseLength = response.count();
|
||||
let tempResponse = null;
|
||||
let success = null;
|
||||
|
||||
for (let k = 0; k < responseLength; ++k) {
|
||||
tempResponse = response.getByIndex(k);
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ export class GeneralUI
|
|||
const length = e.length;
|
||||
|
||||
for (let i = 0; i < length; ++i) {
|
||||
new AdvancedInput(e[i], this.app.eventManager, this.app.uiManager.getDOMObserver());
|
||||
new AdvancedInput(e[i], this.app.eventManager, this.app.uiManager.getDOMObserver()); // eslint-disable-line no-new
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ export class UIStateManager
|
|||
element.scrollLeft = state.x;
|
||||
element.scrollTop = state.y;
|
||||
|
||||
element.scrollTo({ top: state.y, left: state.x })
|
||||
element.scrollTo({ top: state.y, left: state.x });
|
||||
|
||||
element.addEventListener('scroll', function () {
|
||||
window.localStorage.setItem('ui-state-' + this.id, JSON.stringify({ x: this.scrollLeft, y: this.scrollTop }));
|
||||
|
|
|
|||
|
|
@ -77,11 +77,13 @@ export class HttpUri
|
|||
'relative', 'path', 'directory', 'file', 'query', 'fragment'
|
||||
];
|
||||
|
||||
/* eslint-disable max-len */
|
||||
const parser = {
|
||||
php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
||||
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
||||
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-scheme to catch file:/// (should restrict this)
|
||||
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
|
||||
};
|
||||
/* eslint-enable max-len */
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(parser, mode)) {
|
||||
throw new Error('Unexpected parsing mode.', 'UriFactory', 52);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ const validatePage = function (url)
|
|||
const aHref = document.querySelectorAll('a:not([alt]), a[href=""], a[href=" "], a[href="#"]');
|
||||
findings[url].href_empty = aHref.length;
|
||||
|
||||
/* eslint-disable max-len */
|
||||
// analyze inline on* function
|
||||
const onFunction = document.querySelectorAll('[onafterprint], [onbeforeprint], [onbeforeunload], [onerror], [onhaschange], [onload], [onmessage], [onoffline], [ononline], [onpagehide], [onpageshow], [onpopstate], [onredo], [onresize], [onstorage], [onundo], [onunload], [onblur], [onchage], [oncontextmenu], [onfocus], [onformchange], [onforminput], [oninput], [oninvalid], [onreset], [onselect], [onsubmit], [onkeydown], [onkeypress], [onkeyup], [onclick], [ondblclick], [ondrag], [ondragend], [ondragenter], [ondragleave], [ondragover], [ondragstart], [ondrop], [onmousedown], [onmousemove], [onmouseout], [onmouseover], [onmouseup], [onmousewheel], [onscroll], [onabort], [oncanplay], [oncanplaythrough], [ondurationchange], [onemptied], [onended], [onerror], [onloadeddata], [onloadedmetadata], [onloadstart], [onpause], [onplay], [onplaying], [onprogress], [onratechange], [onreadystatechange], [onseeked], [onseeking], [onstalled], [onsuspend], [ontimeupdate], [onvolumechange], [onwaiting]');
|
||||
findings[url].js_on = onFunction.length;
|
||||
|
|
@ -71,6 +72,7 @@ const validatePage = function (url)
|
|||
// analyze invalid container-children relationship (e.g. empty containers, invalid children)
|
||||
const invalidContainerChildren = document.querySelectorAll(':not(tr) > td, :not(tr) > th, colgroup *:not(col), :not(colgroup) > col, tr > :not(td):not(th), optgroup > :not(option), :not(select) > option, :not(fieldset) > legend, select > :not(option):not(optgroup), :not(select):not(optgroup) > option, table > *:not(thead):not(tfoot):not(tbody):not(tr):not(colgroup):not(caption)');
|
||||
findings[url].invalid_container_children = invalidContainerChildren.length;
|
||||
/* eslint-enable max-len */
|
||||
|
||||
// has inline styles
|
||||
const hasInlineStyles = document.querySelectorAll('*[style]');
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
jsOMS.watcher = (function ()
|
||||
{
|
||||
var timer = 0;
|
||||
var timer = 0; // eslint-disable-line no-var
|
||||
return function (callback, ms)
|
||||
{
|
||||
clearTimeout(timer);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user