fix for/if spacing

This commit is contained in:
Dennis Eichhorn 2019-10-05 19:58:54 +02:00
parent 0ea60b07e5
commit 4bd3a89045
10 changed files with 131 additions and 18 deletions

View File

@ -314,11 +314,11 @@
{
let state = this.createParserState();
if(text.indexOf('\r\n') !== -1) {
if (text.indexOf('\r\n') !== -1) {
text = text.replace(/\r\n/g, '/n');
}
if(text.indexOf('\\\n') !== -1) {
if (text.indexOf('\\\n') !== -1) {
text = text.replace(/\\\n/g, '');
}
@ -330,7 +330,7 @@
result = [],
trimLeft = (typeof ''.trimLeft === 'function');
for(let i = 0, l = lines.length; i < l; i++) {
for (let i = 0, l = lines.length; i < l; i++) {
line = lines[i];
line = trimLeft ? line.trimLeft() : line.trim();
lineLength = line.length;

View File

@ -39,7 +39,7 @@ export class Logger {
*/
static getInstance (verbose = true, ui = true, remote = false)
{
if(!Logger.instance) {
if (!Logger.instance) {
Logger.instance = new Logger(verbose, ui, remote);
}

View File

@ -43,9 +43,9 @@ export class BrowserNotification {
const self = this;
/** global: Notification */
if(Notification.permission !== 'granted' && Notification.permission !== 'denied') {
if (Notification.permission !== 'granted' && Notification.permission !== 'denied') {
Notification.requestPermission(function(permission) {
if(permission === 'granted') {
if (permission === 'granted') {
let msg = new jsOMS.Message.Notification.NotificationMessage();
self.send(msg);

View File

@ -13,21 +13,21 @@ export function popupButtonAction (action, callback, id)
const popup = action.base === 'self' ? (action.selector === '' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector);
for(let i in popup) {
for (let i in popup) {
/** global: HTMLElement */
if(!popup.hasOwnProperty(i) || !popup[i] || !(popup[i] instanceof HTMLElement)) {
if (!popup.hasOwnProperty(i) || !popup[i] || !(popup[i] instanceof HTMLElement)) {
continue;
}
const clone = document.importNode(popup[i].content, true);
const dim = document.getElementById('dim');
if(dim) {
if (dim) {
document.getElementById('dim').classList.remove('vh');
}
for(let j in clone) {
if(!clone.hasOwnProperty(j) || !(clone[j] instanceof HTMLElement)) {
for (let j in clone) {
if (!clone.hasOwnProperty(j) || !(clone[j] instanceof HTMLElement)) {
continue;
}
@ -38,7 +38,7 @@ export function popupButtonAction (action, callback, id)
let e = document.getElementById(popup[i].id.substr(0, popup[i].id.length - 4));
if(!e) {
if (!e) {
continue;
}

View File

@ -20,7 +20,7 @@ export function dataCollectionAction (action, callback)
elements = document.querySelectorAll(action.collect[selector]);
for (let e in elements) {
if(!elements.hasOwnProperty(e)) {
if (!elements.hasOwnProperty(e)) {
continue;
}

View File

@ -8,7 +8,7 @@
export function formValidationMessage (data) {
const form = document.getElementById(data.form);
if(!form) {
if (!form) {
return;
}

View File

@ -133,7 +133,7 @@ export class AdvancedInput {
self.dataListBody.removeChild(self.dataListBody.firstChild);
}
for(let i = 0; i < dataLength; ++i) {
for (let i = 0; i < dataLength; ++i) {
// set readable value
const newRow = self.dataTpl.content.cloneNode(true);
let fields = newRow.querySelectorAll('[data-tpl-text]');

View File

@ -1,7 +1,7 @@
import { Logger } from '../../../Log/Logger.js';
/**
* Form manager class.
* Voice manager class.
*
* @copyright Dennis Eichhorn
* @license OMS License 1.0

View File

@ -36,7 +36,7 @@ export class UIManager {
this.domObserver = new MutationObserver(function(mutations) {
const length = mutations.length;
for(let i = 0; i < length; ++i) {
for (let i = 0; i < length; ++i) {
self.app.eventManager.trigger(mutations[i].target.id + '-' + mutations[i].type, 0, mutations[i]);
}
});
@ -64,7 +64,7 @@ export class UIManager {
const tag = document.getElementById(id);
this.generalUI.bind(tag);
if(!tag) {
if (!tag) {
return;
}

113
Utils/Debug.js Normal file
View File

@ -0,0 +1,113 @@
var visited = [];
var findings = {};
var cssSelectors = {},
cssSelectorsLength = 0;
const cssFiles = ['http://127.0.0.1/cssOMS/styles.css'];
const cssFilesLength = cssFiles.length;
const domain = window.location.hostname;
const pageLimit = 10;
var cssRequest = new XMLHttpRequest();
cssRequest.onreadystatechange = function()
{
if (cssRequest.readyState == 4 && cssRequest.status == 200) {
const cssText = this.responseText;
const result = cssText.match(/[a-zA-Z0-9\ :>~\.\"'#,\[\]=\-\(\)\*]+{/g),
resultLength = result.length;
for (let i = 1; i < resultLength; ++i) {
let sel = result[i].substring(0, result[i].length - 1).trimLeft().trimRight().trimRight();
if (!cssSelectors.hasOwnProperty(sel)) {
cssSelectors[sel] = 0;
++cssSelectorsLength;
}
}
}
}
for (let i = 0; i < cssFilesLength; ++i) {
cssRequest.open('GET', cssFiles[i], true);
cssRequest.send();
}
validatePage = function(url)
{
if (visited.includes(url) || visited.length > pageLimit - 1) {
return;
}
// mark url as visited
visited.push(url);
findings[url] = {};
// web request
var webRequest = new XMLHttpRequest();
webRequest.onreadystatechange = function()
{
if (webRequest.readyState == 4 && webRequest.status == 200) {
// replace content
document.open();
document.write(this.responseText);
document.close();
// analyze img alt attribute
let imgAlt = document.querySelectorAll('img:not([alt]), img[alt=""], img[alt=" "]');
findings[url]['img_alt'] = imgAlt.length;
// analyze img src
let imgSrc = document.querySelectorAll('img:not([src]), img[src=""], img[src=" "]');
findings[url]['img_src'] = imgSrc.length;
// analyze empty link
let aHref = document.querySelectorAll('a:not([alt]), a[href=""], a[href=" "], a[href="#"]');
findings[url]['href_empty'] = aHref.length;
// analyze inline on* function
let 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;
// analyze missing form element attributes
let formElements = document.querySelectorAll('input:not([id]), input[type=""], select:not([id]), textarea:not([id]), label:not([for]), label[for=""], label[for=" "], input:not([name]), select:not([name]), textarea:not([name]), form:not([id]), form:not([action]), form[action=""], form[action=" "], form[action="#"]');
findings[url]['form_elements'] = formElements.length;
// analyze invalid container-children relationship (e.g. empty containers, invalid children)
let 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;
// has inline styles
let hasInlineStyles = document.querySelectorAll('*[style]');
findings[url]['form_elements'] = hasInlineStyles.length;
// analyze css usage
let cssFound;
for (let i in cssSelectors) {
try {
cssFound = document.querySelectorAll(i.replace(/:hover|:active/gi, ''));
cssSelectors[i] = cssFound === null ? 0 : cssFound.length
} catch (e) {}
}
// check other pages
let links = document.querySelectorAll('a'),
linkLength = links.length;
for (let i = 0; i < linkLength; ++i) {
if (visited.includes(links[i].href) ||
(!links[i].href.startsWith('/') && links[i].href.startsWith('http') && !links[i].href.includes(domain))
) {
continue;
}
validatePage(links[i].href);
}
}
};
webRequest.open('GET', url, true);
webRequest.send();
};
validatePage(location.href);
console.table(findings);
console.table(cssSelectors);