From da4032f5d6a0ac5ca9c78ee1762c2f318d7d94dd Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 20 Nov 2019 22:27:51 +0100 Subject: [PATCH] cleanup and tests added for ci/cd --- Autoloader.js | 4 +- Chart/CandlestickChart.js | 9 ++-- Chart/ChartAbstract.js | 4 +- Chart/ColumnChart.js | 2 +- Chart/PieChart.js | 2 +- Chart/PyramidChart.js | 3 +- Chart/ScatterplotChart.js | 1 + Event/EventManager.js | 6 +-- Model/Action/Dom/GetValue.js | 2 +- Socket/Client/Client.js | 11 ++-- Spreadsheet/Cell.js | 4 +- UI/Component/AdvancedInput.js | 2 +- UI/Component/AdvancedSelect.js | 32 ++++++------ UI/Component/Form.js | 92 +++++++++++++++++----------------- UI/Component/Tab.js | 8 +-- UI/Component/Table.js | 2 +- UI/GeneralUI.js | 2 +- Uri/UriFactory.js | 2 +- Utils/Debug.js | 42 ++++++++-------- Utils/StringUtils.js | 4 +- Utils/UiUtils.js | 2 +- Utils/oLib.js | 2 +- Views/TableView.js | 8 +-- 23 files changed, 125 insertions(+), 121 deletions(-) diff --git a/Autoloader.js b/Autoloader.js index 439a8f9..c4f82c5 100644 --- a/Autoloader.js +++ b/Autoloader.js @@ -15,8 +15,8 @@ import { AssetManager } from './Asset/AssetManager.js'; */ export const Autoloader = {}; -Autoloader.loaded = []; -Autoloader.namespaced = []; +Autoloader.loaded = []; +Autoloader.namespaced = []; Autoloader.assetLoader = new AssetManager(); /** diff --git a/Chart/CandlestickChart.js b/Chart/CandlestickChart.js index 18f6856..a46dbf6 100644 --- a/Chart/CandlestickChart.js +++ b/Chart/CandlestickChart.js @@ -49,7 +49,7 @@ } }; - this.chart.grid = { + this.chart.grid = { x: { visible: true }, @@ -57,6 +57,7 @@ visible: true } }; + this.chart.subtype = 'candlestick'; }; @@ -105,7 +106,7 @@ .attr("y", function(d) { return y(Math.max(d.open, d.close)); }) .attr("height", function(d) { return Math.max(1, y(Math.min(d.open, d.close)) - y(Math.max(d.open, d.close)));}) .attr("width", function(d) { return 0.5 * mm; }) - .attr("fill",function(d) { return d.open > d.close ? "red" : "green" ;}); + .attr("fill",function(d) { return d.open > d.close ? "red" : "green"; }); } else { let datapoint = svg.selectAll("rect") .data(this.chart.dataset[0].points) @@ -116,14 +117,14 @@ .attr("y", function(d) {return y(d.open);}) .attr("height", function(d) { return 1;}) .attr("width", function(d) { return 0.25 * mm / 2; }) - .attr("fill",function(d) { return d.open > d.close ? "red" : "green" ;}); + .attr("fill",function(d) { return d.open > d.close ? "red" : "green"; }); datapoint.append("svg:rect") .attr("x", function(d) { return x(d.x); }) .attr("y", function(d) {return y(d.close);}) .attr("height", function(d) { return 1;}) .attr("width", function(d) { return 0.25 * mm / 2; }) - .attr("fill",function(d) { return d.open > d.close ? "red" : "green" ;}); + .attr("fill",function(d) { return d.open > d.close ? "red" : "green"; }); } svg.selectAll("line.stem") diff --git a/Chart/ChartAbstract.js b/Chart/ChartAbstract.js index 573b998..c92ebb8 100644 --- a/Chart/ChartAbstract.js +++ b/Chart/ChartAbstract.js @@ -413,9 +413,9 @@ if (!this.defined.text.footer) { this.position.footer.top = temp.node().getBoundingClientRect().height; - this.margin.bottom += temp.node().getBoundingClientRect().height + 10; + this.margin.bottom += temp.node().getBoundingClientRect().height + 10; this.defined.text.footer = true; - this.shouldRedraw = true; + this.shouldRedraw = true; } } }; diff --git a/Chart/ColumnChart.js b/Chart/ColumnChart.js index 675d5f6..97c7905 100644 --- a/Chart/ColumnChart.js +++ b/Chart/ColumnChart.js @@ -189,7 +189,7 @@ { return x(d.x) + x.rangeBand() / self.chart.dataset.length * j; }) - .attr("width", x.rangeBand() /self.chart.dataset.length) + .attr("width", x.rangeBand() / self.chart.dataset.length) .transition() .attr("y", function (d) { diff --git a/Chart/PieChart.js b/Chart/PieChart.js index 586a9ce..a439d9d 100644 --- a/Chart/PieChart.js +++ b/Chart/PieChart.js @@ -75,7 +75,7 @@ - Math.max(this.chart.margin.right + this.chart.margin.left, this.chart.margin.top + this.chart.margin.bottom) ), - innerRadius = radius - radius*self.chart.dataSettings.style.strokewidth, + innerRadius = radius - radius * self.chart.dataSettings.style.strokewidth, arc = d3.svg.arc() .outerRadius(function() { return radius; }) .innerRadius(function() { return innerRadius; }); diff --git a/Chart/PyramidChart.js b/Chart/PyramidChart.js index ffedcc2..e701e27 100644 --- a/Chart/PyramidChart.js +++ b/Chart/PyramidChart.js @@ -53,6 +53,7 @@ visible: true } }; + this.chart.subtype = 'waterfall'; }; @@ -136,7 +137,7 @@ .tickFormat(""); x.domain(this.chart.dataset[0].points.map(function(d) { return d.name; })); - y.domain([0, d3.max(this.chart.dataset[0].points, function(d) { return d.y*1.05; })]); + y.domain([0, d3.max(this.chart.dataset[0].points, function(d) { return d.y * 1.05; })]); svg = this.chart.chartSelect.append("svg") .attr("width", this.chart.dimension.width) diff --git a/Chart/ScatterplotChart.js b/Chart/ScatterplotChart.js index 60990ce..24fe8b7 100644 --- a/Chart/ScatterplotChart.js +++ b/Chart/ScatterplotChart.js @@ -54,6 +54,7 @@ visible: true } }; + this.chart.subtype = 'scatterplot'; }; diff --git a/Event/EventManager.js b/Event/EventManager.js index 55b8ed4..04eab18 100644 --- a/Event/EventManager.js +++ b/Event/EventManager.js @@ -103,11 +103,11 @@ export class EventManager { { if (this.callbacks.hasOwnProperty(group)) { return this.triggerSingleEvent(group, id, data); - } + }p const allGroups = Object.keys(this.callbacks), - regex = new RegExp(group), - length = allGroups.length; + regex = new RegExp(group), + length = allGroups.length; let result = false; diff --git a/Model/Action/Dom/GetValue.js b/Model/Action/Dom/GetValue.js index 68b4b0f..d66aa7c 100644 --- a/Model/Action/Dom/GetValue.js +++ b/Model/Action/Dom/GetValue.js @@ -11,7 +11,7 @@ export function domGetValue (action, callback, id) { "use strict"; - const e = action.base === 'self' ? (action.selector === '' || typeof action.selector === 'undefined' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector); + const e = action.base === 'self' ? (action.selector === '' || typeof action.selector === 'undefined' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector); let value = {}; for (let i in e) { diff --git a/Socket/Client/Client.js b/Socket/Client/Client.js index eb41762..2492fb6 100644 --- a/Socket/Client/Client.js +++ b/Socket/Client/Client.js @@ -2,12 +2,13 @@ "use strict"; jsOMS.Client = function (ip, port, protocol) { - this.port = port; - this.ip = ip; - this.protocol = protocol; + this.port = port; + this.ip = ip; + this.protocol = protocol; this.connection = null; - this.messages = []; + this.messages = []; }; + jsOMS.Client.prototype.setMessage = function(id, callback) { this.messages[id] = callback; }; @@ -25,7 +26,7 @@ }; jsOMS.Client.prototype.connect = function() { - var self = this; + var self = this; this.connection = new WebSocket(this.ip, this.protocol); this.connection.onmessage = function(event) { diff --git a/Spreadsheet/Cell.js b/Spreadsheet/Cell.js index a143f70..a6da2a7 100644 --- a/Spreadsheet/Cell.js +++ b/Spreadsheet/Cell.js @@ -14,8 +14,8 @@ jsOMS.Spreadsheet.Cell = function(id, raw) { - this.id = id; - this.raw = raw; + this.id = id; + this.raw = raw; this.formatting = raw.formatting; }; }(window.jsOMS = window.jsOMS || {})); \ No newline at end of file diff --git a/UI/Component/AdvancedInput.js b/UI/Component/AdvancedInput.js index 78f0b31..0e0f06f 100644 --- a/UI/Component/AdvancedInput.js +++ b/UI/Component/AdvancedInput.js @@ -122,7 +122,7 @@ export class AdvancedInput { remoteCallback(self, data) { console.log(data); - data = JSON.parse(data.response)[0]; + data = JSON.parse(data.response)[0]; const dataLength = data.length; console.table(data); diff --git a/UI/Component/AdvancedSelect.js b/UI/Component/AdvancedSelect.js index bb4493c..7ac782e 100644 --- a/UI/Component/AdvancedSelect.js +++ b/UI/Component/AdvancedSelect.js @@ -27,16 +27,16 @@ export class AdvancedSelect { * @since 1.0.0 */ constructor(e) { - this.id = e.id; + this.id = e.id; this.selectComponent = e; - this.selectField = this.selectComponent.getElementsByClassName('input')[0]; + this.selectField = this.selectComponent.getElementsByClassName('input')[0]; this.dropdownElement = document.getElementById(this.id + '-dropdown'); - this.tagElement = document.getElementById(this.id + '-tags'); - this.dataList = this.dropdownElement.getElementsByTagName('table')[0]; - this.dataListBody = this.dataList.getElementsByTagName('tbody')[0]; - this.dataTpl = document.getElementById(this.id + '-rowElement'); - this.tagTpl = this.tagElement.getElementsByTagName('template')[0]; - this.src = this.selectField.getAttribute('data-src'); + this.tagElement = document.getElementById(this.id + '-tags'); + this.dataList = this.dropdownElement.getElementsByTagName('table')[0]; + this.dataListBody = this.dataList.getElementsByTagName('tbody')[0]; + this.dataTpl = document.getElementById(this.id + '-rowElement'); + this.tagTpl = this.tagElement.getElementsByTagName('template')[0]; + this.src = this.selectField.getAttribute('data-src'); const self = this; this.selectField.addEventListener('focusout', function (e) { @@ -128,7 +128,7 @@ export class AdvancedSelect { */ remoteCallback(self, data) { console.log(data); - data = JSON.parse(data.response)[0]; + data = JSON.parse(data.response)[0]; const dataLength = data.length; console.table(data); @@ -141,8 +141,8 @@ export class AdvancedSelect { for (let i = 0; i < dataLength; ++i) { // set readable value - const newRow = self.dataTpl.content.cloneNode(true); - let fields = newRow.querySelectorAll('[data-tpl-text]'); + const newRow = self.dataTpl.content.cloneNode(true); + let fields = newRow.querySelectorAll('[data-tpl-text]'); let fieldLength = fields.length; for (let j = 0; j < fieldLength; ++j) { @@ -154,7 +154,7 @@ export class AdvancedSelect { } // set internal value - fields = newRow.querySelectorAll('[data-tpl-value]'); + fields = newRow.querySelectorAll('[data-tpl-value]'); fieldLength = fields.length; for (let j = 0; j < fieldLength; ++j) { @@ -249,10 +249,10 @@ export class AdvancedSelect { const newTag = self.tagTpl.content.cloneNode(true); // set internal value - let fields = newTag.querySelectorAll('[data-tpl-value]'); + let fields = newTag.querySelectorAll('[data-tpl-value]'); let fieldLength = fields.length; - let uuid = ''; - let value = ''; + let uuid = ''; + let value = ''; for (let j = 0; j < fieldLength; ++j) { value = document.activeElement.querySelectorAll('[data-tpl-value="' + fields[j].getAttribute('data-tpl-value') + '"]')[0].getAttribute('data-value'); @@ -270,7 +270,7 @@ export class AdvancedSelect { newTag.firstElementChild.setAttribute('data-tpl-uuid', uuid); // set readable text - fields = newTag.querySelectorAll('[data-tpl-text]'); + fields = newTag.querySelectorAll('[data-tpl-text]'); fieldLength = fields.length; for (let j = 0; j < fieldLength; ++j) { diff --git a/UI/Component/Form.js b/UI/Component/Form.js index ea55f1b..cd3412e 100644 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -141,19 +141,19 @@ export class Form { } const removable = this.forms[id].getRemove(); - length = removable === null ? 0 : removable.length; + length = removable === null ? 0 : removable.length; for (let i = 0; i < length; ++i) { this.bindRemovable(removable[i], id); } const addable = this.forms[id].getAdd(); - length = addable === null ? 0 : addable.length; + length = addable === null ? 0 : addable.length; for (let i = 0; i < length; ++i) { this.bindAddInline(addable[i], id); } const save = this.forms[id].getSave(); - length = save === null ? 0 : save.length; + length = save === null ? 0 : save.length; for (let i = 0; i < length; ++i) { this.bindSaveInline(save[i], id); } @@ -163,19 +163,19 @@ export class Form { } const cancel = this.forms[id].getCancel(); - length = cancel === null ? 0 : cancel.length; + length = cancel === null ? 0 : cancel.length; for (let i = 0; i < length; ++i) { this.bindCancelInline(cancel[i], id); } const update = this.forms[id].getUpdate(); - length = update === null ? 0 : update.length; + length = update === null ? 0 : update.length; for (let i = 0; i < length; ++i) { this.bindUpdatable(update[i], id); } const imgPreviews = this.forms[id].getImagePreviews(); - length = imgPreviews === null ? 0 : imgPreviews.length; + length = imgPreviews === null ? 0 : imgPreviews.length; for (let i = 0; i < length; ++i) { this.bindImagePreview(imgPreviews[i], id); } @@ -196,9 +196,9 @@ export class Form { imageUpload.addEventListener('change', function () { const formElement = document.getElementById(id); - const preview = formElement.querySelector('img#preview-' + imageUpload.getAttribute('name')); + const preview = formElement.querySelector('img#preview-' + imageUpload.getAttribute('name')); - preview.src = window.URL.createObjectURL(imageUpload.files[0]); + preview.src = window.URL.createObjectURL(imageUpload.files[0]); preview.onload = function () { window.URL.revokeObjectURL(this.src); } @@ -322,9 +322,9 @@ export class Form { console.log(xhr.response); try { - const o = JSON.parse(xhr.response)[0], - response = new Response(o); - let successInject = null; + const o = JSON.parse(xhr.response)[0], + response = new Response(o); + let successInject = null; if ((successInject = form.getSuccess()) !== null) { successInject(response); @@ -396,18 +396,18 @@ export class Form { this.app.uiManager.getFormManager().get(createForm).injectSubmit(function () { const formElement = document.getElementById(id); - const subMain = formElement.getAttribute('data-ui-content').charAt(0) === '#' + const subMain = formElement.getAttribute('data-ui-content').charAt(0) === '#' ? document.querySelector(formElement.getAttribute('data-ui-content')) : formElement.querySelector(formElement.getAttribute('data-ui-content')); // todo: [0/1] is no longer working because of arbitrary templates for inline editing - const newEle = subMain.getElementsByTagName('template')[0].content.cloneNode(true); + const newEle = subMain.getElementsByTagName('template')[0].content.cloneNode(true); // set internal value - let fields = newEle.querySelectorAll('[data-tpl-value]'); + let fields = newEle.querySelectorAll('[data-tpl-value]'); let fieldLength = fields.length; - let uuid = ''; - let value = ''; + let uuid = ''; + let value = ''; for (let j = 0; j < fieldLength; ++j) { value = document.querySelectorAll( @@ -429,7 +429,7 @@ export class Form { newEle.firstElementChild.setAttribute('data-tpl-uuid', uuid); // set readable text - fields = newEle.querySelectorAll('[data-tpl-text]'); + fields = newEle.querySelectorAll('[data-tpl-text]'); fieldLength = fields.length; for (let j = 0; j < fieldLength; ++j) { @@ -472,16 +472,16 @@ export class Form { createForm.addEventListener('click', function () { const formElement = document.getElementById(id); - const subMain = formElement.getAttribute('data-ui-content').charAt(0) === '#' + const subMain = formElement.getAttribute('data-ui-content').charAt(0) === '#' ? document.querySelector(formElement.getAttribute('data-ui-content')) : formElement.querySelector(formElement.getAttribute('data-ui-content')); // todo: [0/1] is no longer working because of arbitrary templates for inline editing - const newEle = subMain.getElementsByTagName('template')[1].content.cloneNode(true); - const eleId = 'f' + Math.random().toString(36).substring(7); + const newEle = subMain.getElementsByTagName('template')[1].content.cloneNode(true); + const eleId = 'f' + Math.random().toString(36).substring(7); // todo: check if random id doesn't already exist - newEle.firstElementChild.id = eleId; + newEle.firstElementChild.id = eleId; newEle.firstElementChild.getElementsByTagName('form')[0].id = eleId + '-form'; const fields = newEle.firstElementChild.querySelectorAll('[data-form="' + id + '"]'); @@ -575,7 +575,7 @@ export class Form { values = values.concat( parents[i].hasAttribute('data-tpl-value') ? parents[i] : Array.prototype.slice.call(parents[i].querySelectorAll('[data-tpl-value]')) ); - text = text.concat( + text = text.concat( parents[i].hasAttribute('data-tpl-text') ? parents[i] : Array.prototype.slice.call(parents[i].querySelectorAll('[data-tpl-text]')) ); @@ -668,13 +668,13 @@ export class Form { jsOMS.addClass(this, 'hidden'); const saveButtons = self.forms[id].getSave(); - length = saveButtons.length; + length = saveButtons.length; for (let i = 0; i < length; ++i) { jsOMS.removeClass(saveButtons[i], 'hidden'); } const cancelButtons = self.forms[id].getCancel(); - length = cancelButtons.length; + length = cancelButtons.length; for (let i = 0; i < length; ++i) { jsOMS.removeClass(cancelButtons[i], 'hidden'); } @@ -717,21 +717,21 @@ export class Form { const self = this; save.addEventListener('click', function () { - const formElement = document.getElementById(id); - const parentsTpl = []; + const formElement = document.getElementById(id); + const parentsTpl = []; const parentsContent = []; - const selectors = formElement.getAttribute('data-ui-element').split(','), - selectorLength = selectors.length; + const selectors = formElement.getAttribute('data-ui-element').split(','), + selectorLength = selectors.length; let values = []; - let text = []; + let text = []; for (let i = 0; i < selectorLength; ++i) { // todo: similar logic is in updatable Inline and probably in External... pull out? // this handles selectors such as 'ancestor > child/or/sibling' and many more // todo: maybe move this to the library as an advanced ancestor function? let selector = selectors[i].trim(' ').split(' '); - let closest = selector[0].trim(); + let closest = selector[0].trim(); // template elements let subSelector = ''; @@ -747,8 +747,8 @@ export class Form { ); // content elements - selector = selectors[i].trim(' ').split(' '); - closest = selector[0].trim(); + selector = selectors[i].trim(' ').split(' '); + closest = selector[0].trim(); subSelector = ''; if (selector.length !== 0) { selector.shift(); @@ -764,7 +764,7 @@ export class Form { values = values.concat( parentsTpl[i].hasAttribute('data-tpl-value') ? parentsTpl[i] : Array.prototype.slice.call(parentsTpl[i].querySelectorAll('[data-tpl-value]')) ); - text = text.concat( + text = text.concat( parentsTpl[i].hasAttribute('data-tpl-text') ? parentsTpl[i] : Array.prototype.slice.call(parentsTpl[i].querySelectorAll('[data-tpl-text]')) ); } @@ -818,13 +818,13 @@ export class Form { */ removeEditTemplate(ele, id) { - const formElement = document.getElementById(id); - const selectors = formElement.getAttribute('data-ui-element').split(','), + const formElement = document.getElementById(id); + const selectors = formElement.getAttribute('data-ui-element').split(','), selectorLength = selectors.length; for (let i = 0; i < selectorLength; ++i) { let selector = selectors[i].trim(' ').split(' '); - let closest = selector[0].trim(); + let closest = selector[0].trim(); let subSelector = ''; if (selector.length !== 0) { @@ -832,8 +832,8 @@ export class Form { subSelector = selector.join(' ').trim(); } - let content = selector.length === 0 ? ele.closest(closest) : ele.closest(closest).querySelector(subSelector); - const tpls = content.parentNode.querySelectorAll('[data-marker=tpl]'), + let content = selector.length === 0 ? ele.closest(closest) : ele.closest(closest).querySelector(subSelector); + const tpls = content.parentNode.querySelectorAll('[data-marker=tpl]'), tplsLength = tpls.length; for (let j = 0; j < tplsLength; ++j) { @@ -845,19 +845,19 @@ export class Form { } const saveButtons = this.forms[id].getSave(); - let length = saveButtons.length; + let length = saveButtons.length; for (let i = 0; i < length; ++i) { jsOMS.addClass(saveButtons[i], 'hidden'); } const cancelButtons = this.forms[id].getCancel(); - length = cancelButtons.length; + length = cancelButtons.length; for (let i = 0; i < length; ++i) { jsOMS.addClass(cancelButtons[i], 'hidden'); } const update = this.forms[id].getUpdate(); - length = update === null ? 0 : update.length; + length = update === null ? 0 : update.length; for (let i = 0; i < length; ++i) { jsOMS.removeClass(update[i], 'hidden'); } @@ -879,13 +879,13 @@ export class Form { update.addEventListener('click', function () { const formElement = document.getElementById(id); - const parent = this.closest(formElement.getAttribute('data-ui-element')); - const formId = formElement.getAttribute('data-ui-form'); - const values = parent.querySelectorAll('[data-tpl-value]'); - const text = parent.querySelectorAll('[data-tpl-text]'); + const parent = this.closest(formElement.getAttribute('data-ui-element')); + const formId = formElement.getAttribute('data-ui-form'); + const values = parent.querySelectorAll('[data-tpl-value]'); + const text = parent.querySelectorAll('[data-tpl-text]'); const fields = document.getElementById(formId).querySelectorAll('[data-form="' + id + '"]'); - let length = fields.length; + let length = fields.length; for (let i = 0; i < length; ++i) { fields[i].setAttribute('data-form', eleId); diff --git a/UI/Component/Tab.js b/UI/Component/Tab.js index 4bc4356..86aee75 100644 --- a/UI/Component/Tab.js +++ b/UI/Component/Tab.js @@ -38,8 +38,8 @@ export class Tab { this.bindElement(e); } } else { - const tabs = document.getElementsByClassName('tabview'), - length = !tabs ? 0 : tabs.length; + const tabs = document.getElementsByClassName('tabview'); + const length = !tabs ? 0 : tabs.length; for (let i = 0; i < length; ++i) { this.bindElement(tabs[i]); @@ -59,7 +59,7 @@ export class Tab { bindElement (e) { const nodes = e.querySelectorAll('.tab-links li'), - length = nodes.length; + length = nodes.length; for (let i = 0; i < length; ++i) { nodes[i].addEventListener('click', function (evt) @@ -122,7 +122,7 @@ export class Tab { { const fragmentString = window.location.href.includes('#') ? Http.parseUrl(window.location.href).fragment : ''; const fragments = fragmentString.split(','), - fragLength = fragments.length; + fragLength = fragments.length; if (fragLength > 0 && fragmentString !== '') { for (let i = 0; i < fragLength; ++i) { diff --git a/UI/Component/Table.js b/UI/Component/Table.js index 1e1c66a..a492621 100644 --- a/UI/Component/Table.js +++ b/UI/Component/Table.js @@ -19,7 +19,7 @@ export class Table { */ constructor(app) { - this.app = app; + this.app = app; /** @var {Object } */ this.tables = {}; diff --git a/UI/GeneralUI.js b/UI/GeneralUI.js index 212de1c..d22e12c 100644 --- a/UI/GeneralUI.js +++ b/UI/GeneralUI.js @@ -113,7 +113,7 @@ export class GeneralUI { */ bindInput (e) { - e = e !== null ? [e] : document.getElementsByClassName('advancedInput'); + e = e !== null ? [e] : document.getElementsByClassName('advancedInput'); const length = e.length; for (let i = 0; i < length; ++i) { diff --git a/Uri/UriFactory.js b/Uri/UriFactory.js index 0b304f8..f8fbb2e 100644 --- a/Uri/UriFactory.js +++ b/Uri/UriFactory.js @@ -146,7 +146,7 @@ export class UriFactory { // unique fragments const fragments = url.match(/\#[a-zA-Z0-9\-,]+/g), - fragLength = fragments !== null ? fragments.length : 0; + fragLength = fragments !== null ? fragments.length : 0; for (let i = 0; i < fragLength - 1; ++i) { // remove all from old url diff --git a/Utils/Debug.js b/Utils/Debug.js index 3c53e59..6b9dafc 100644 --- a/Utils/Debug.js +++ b/Utils/Debug.js @@ -1,18 +1,18 @@ -var visited = []; -var findings = {}; -var cssSelectors = {}, +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; +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(); +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), + const cssText = this.responseText; + const result = cssText.match(/[a-zA-Z0-9\ :>~\.\"'#,\[\]=\-\(\)\*]+{/g), resultLength = result.length; for (let i = 1; i < resultLength; ++i) { @@ -41,7 +41,7 @@ validatePage = function(url) findings[url] = {}; // web request - var webRequest = new XMLHttpRequest(); + var webRequest = new XMLHttpRequest(); webRequest.onreadystatechange = function() { if (webRequest.readyState == 4 && webRequest.status == 200) { @@ -51,45 +51,45 @@ validatePage = function(url) document.close(); // analyze img alt attribute - let imgAlt = document.querySelectorAll('img:not([alt]), img[alt=""], img[alt=" "]'); + 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=" "]'); + 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="#"]'); + 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]'); + 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="#"]'); + 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)'); + 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]'); + 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, '')); + 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; + let links = document.querySelectorAll('a'), + linkLength = links.length; for (let i = 0; i < linkLength; ++i) { if (visited.includes(links[i].href) || diff --git a/Utils/StringUtils.js b/Utils/StringUtils.js index dcde26c..ace5018 100644 --- a/Utils/StringUtils.js +++ b/Utils/StringUtils.js @@ -96,8 +96,8 @@ return (str.length + 1); } - let n = 0, - pos = 0; + let n = 0, + pos = 0; while (true) { pos = str.indexOf(substr, pos); diff --git a/Utils/UiUtils.js b/Utils/UiUtils.js index a8c78cb..3ee6b6e 100644 --- a/Utils/UiUtils.js +++ b/Utils/UiUtils.js @@ -52,7 +52,7 @@ event.eventName = eventName; element.dispatchEvent(event); } else { - event = document.createEventObject(); + event = document.createEventObject(); event.eventName = eventName; event.eventType = eventName; element.fireEvent(event.eventType, event); diff --git a/Utils/oLib.js b/Utils/oLib.js index de965c6..b57938a 100644 --- a/Utils/oLib.js +++ b/Utils/oLib.js @@ -32,7 +32,7 @@ event.eventName = eventName; element.dispatchEvent(event); } else { - event = document.createEventObject(); + event = document.createEventObject(); event.eventName = eventName; event.eventType = eventName; element.fireEvent(event.eventType, event); diff --git a/Views/TableView.js b/Views/TableView.js index 036787a..e412d8a 100644 --- a/Views/TableView.js +++ b/Views/TableView.js @@ -40,7 +40,7 @@ export class TableView { serialize() { const table = document.getElementById(this.id); - let data = { + let data = { caption: null, header: [], rows: [] @@ -48,20 +48,20 @@ export class TableView { data.caption = table.getElementsByTagName('caption')[0].innerText; - const header = table.querySelectorAll('thead tr td, thead tr th'), + const header = table.querySelectorAll('thead tr td, thead tr th'), headerLength = header.length; for (let i = 0; i < headerLength; ++i) { data.header.push(header[i].innerText); } - const rows = table.querySelectorAll('tbody tr'), + const rows = table.querySelectorAll('tbody tr'), rowsLength = rows.length; for (let i = 0; i < rowsLength; ++i) { data.rows[i] = []; - const columns = rows[i].querySelectorAll('td, th'), + const columns = rows[i].querySelectorAll('td, th'), columnLength = columns.length; for (let j = 0; j < columnLength; ++j) {