Fix codestyle with phpcs

This commit is contained in:
Dennis Eichhorn 2018-02-10 20:45:42 +01:00
parent ea94fafcdd
commit 6f9367aa64
54 changed files with 400 additions and 381 deletions

View File

@ -72,7 +72,7 @@
if (typeof fileref !== 'undefined') { if (typeof fileref !== 'undefined') {
const head = document.getElementsByTagName('head'); const head = document.getElementsByTagName('head');
if(head) { if (head) {
head[0].appendChild(fileref); head[0].appendChild(fileref);
} }
} }
@ -87,7 +87,7 @@
if (typeof fileref !== 'undefined') { if (typeof fileref !== 'undefined') {
const head = document.getElementsByTagName('head'); const head = document.getElementsByTagName('head');
if(head) { if (head) {
head[0].appendChild(fileref); head[0].appendChild(fileref);
} }
} }

View File

@ -103,7 +103,7 @@
} }
} }
if(typeof callback !== 'undefined' && callback !== null) { if (typeof callback !== 'undefined' && callback !== null) {
callback(); callback();
} }
}; };

View File

@ -165,7 +165,7 @@
.attr("width", 0) .attr("width", 0)
.attr("height", y.rangeBand()); .attr("height", y.rangeBand());
if(this.chart.subtype === 'stacked') { if (this.chart.subtype === 'stacked') {
rect.transition() rect.transition()
.delay(function (d, i) .delay(function (d, i)
{ {
@ -190,7 +190,7 @@
{ {
return y(d.x) + y.rangeBand() / self.chart.dataset.length * j; return y(d.x) + y.rangeBand() / self.chart.dataset.length * j;
}) })
.attr("height", y.rangeBand() /self.chart.dataset.length) .attr("height", y.rangeBand() / self.chart.dataset.length)
.transition() .transition()
.attr("x", 0) .attr("x", 0)
.attr("width", function (d) .attr("width", function (d)

View File

@ -33,9 +33,10 @@
svg, self = this; svg, self = this;
this.chart.calculateDimension(); this.chart.calculateDimension();
this.chart.cellSize = Math.min(this.chart.dimension.width / (12*5), this.chart.dimension.height / (8)); this.chart.cellSize = Math.min(this.chart.dimension.width / (12 * 5), this.chart.dimension.height / (8));
document.getElementById(this.chart.chartId).style.height = (this.chart.dimension.height * this.chart.dataset.length) + 'px'; document.getElementById(this.chart.chartId)
.style.height = (this.chart.dimension.height * this.chart.dataset.length) + 'px';
svg = this.chart.chartSelect.selectAll('svg').data(this.chart.dataset).enter().append("svg") svg = this.chart.chartSelect.selectAll('svg').data(this.chart.dataset).enter().append("svg")
.attr("width", this.chart.dimension.width) .attr("width", this.chart.dimension.width)
@ -85,15 +86,15 @@
let year = d.split('-')[0], let year = d.split('-')[0],
length = self.chart.dataset.length; length = self.chart.dataset.length;
for(let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if(self.chart.dataset[i].name != year) { if (self.chart.dataset[i].name != year) {
continue; continue;
} }
let dataLength = self.chart.dataset[i].points.length; let dataLength = self.chart.dataset[i].points.length;
for(let j = 0; j < dataLength; j++) { for (let j = 0; j < dataLength; j++) {
if(self.chart.dataset[i].points[j].x === d) { if (self.chart.dataset[i].points[j].x === d) {
return true; return true;
} }
} }
@ -107,15 +108,15 @@
let year = d.split('-')[0], let year = d.split('-')[0],
length = self.chart.dataset.length; length = self.chart.dataset.length;
for(let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if(self.chart.dataset[i].name != year) { if (self.chart.dataset[i].name != year) {
continue; continue;
} }
let dataLength = self.chart.dataset[i].points.length; let dataLength = self.chart.dataset[i].points.length;
for(let j = 0; j < dataLength; j++) { for (let j = 0; j < dataLength; j++) {
if(self.chart.dataset[i].points[j].x === d) { if (self.chart.dataset[i].points[j].x === d) {
return "day " + self.chart.color(self.chart.dataset[i].points[j].y); return "day " + self.chart.color(self.chart.dataset[i].points[j].y);
} }
} }
@ -128,15 +129,15 @@
let year = d.split('-')[0], let year = d.split('-')[0],
length = self.chart.dataset.length; length = self.chart.dataset.length;
for(let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if(self.chart.dataset[i].name != year) { if (self.chart.dataset[i].name != year) {
continue; continue;
} }
let dataLength = self.chart.dataset[i].points.length; let dataLength = self.chart.dataset[i].points.length;
for(let j = 0; j < dataLength; j++) { for (let j = 0; j < dataLength; j++) {
if(self.chart.dataset[i].points[j].x === d) { if (self.chart.dataset[i].points[j].x === d) {
return d + ": " + self.chart.dataset[i].points[j].y; return d + ": " + self.chart.dataset[i].points[j].y;
} }
} }

View File

@ -72,9 +72,9 @@
jsOMS.Chart.CandlestickChart.prototype.draw = function () jsOMS.Chart.CandlestickChart.prototype.draw = function ()
{ {
let bar, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom, self = this; let bar, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom,
self = this,
let mm = 50; mm = 50;
this.chart.calculateDimension(); this.chart.calculateDimension();
@ -97,13 +97,13 @@
this.chart.drawGrid(svg, xGrid, yGrid); this.chart.drawGrid(svg, xGrid, yGrid);
if(this.chart.subtype === 'candlestick') { if (this.chart.subtype === 'candlestick') {
svg.selectAll("rect") svg.selectAll("rect")
.data(this.chart.dataset[0].points) .data(this.chart.dataset[0].points)
.enter().append("svg:rect") .enter().append("svg:rect")
.attr("x", function(d) { return x(d.x)-0.5*mm/2; }) .attr("x", function(d) { return x(d.x) - 0.5 * mm / 2; })
.attr("y", function(d) {return y(Math.max(d.open, d.close));}) .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("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("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 { } else {
@ -112,17 +112,17 @@
.enter(); .enter();
datapoint.append("svg:rect") datapoint.append("svg:rect")
.attr("x", function(d) { return x(d.x)-0.25*mm/2; }) .attr("x", function(d) { return x(d.x) - 0.25 * mm / 2; })
.attr("y", function(d) {return y(d.open);}) .attr("y", function(d) {return y(d.open);})
.attr("height", function(d) { return 1;}) .attr("height", function(d) { return 1;})
.attr("width", function(d) { return 0.25 * mm/2; }) .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") datapoint.append("svg:rect")
.attr("x", function(d) { return x(d.x); }) .attr("x", function(d) { return x(d.x); })
.attr("y", function(d) {return y(d.close);}) .attr("y", function(d) {return y(d.close);})
.attr("height", function(d) { return 1;}) .attr("height", function(d) { return 1;})
.attr("width", function(d) { return 0.25 * mm/2; }) .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" ;});
} }

View File

@ -17,21 +17,25 @@
anchor: "middle", anchor: "middle",
position: "center" position: "center"
}; };
this.subtitle = { this.subtitle = {
visible: true, visible: true,
text: "", text: "",
anchor: "middle", anchor: "middle",
position: "center" position: "center"
}; };
this.footer = { this.footer = {
visible: true, visible: true,
text: "", text: "",
anchor: "end", anchor: "end",
position: "right" position: "right"
}; };
this.legend = { this.legend = {
visible: true visible: true
}; };
this.color = d3.scale.category10(); this.color = d3.scale.category10();
this.dataset = []; this.dataset = [];
this.dataSettings = { this.dataSettings = {
@ -221,7 +225,7 @@
jsOMS.Chart.ChartAbstract.prototype.findAxisDomain = function () jsOMS.Chart.ChartAbstract.prototype.findAxisDomain = function ()
{ {
for (let id in this.axis) { for (let id in this.axis) {
if(!this.axis.hasOwnProperty(id)) { if (!this.axis.hasOwnProperty(id)) {
continue; continue;
} }
@ -393,7 +397,7 @@
// if no x axis available an element less will be drawn and the footer // if no x axis available an element less will be drawn and the footer
// will be out of bounds. // will be out of bounds.
// todo: fix this hacky solution!!! // todo: fix this hacky solution!!!
if(typeof this.axis.x === 'undefined') { if (typeof this.axis.x === 'undefined') {
spacer = -this.margin.top; spacer = -this.margin.top;
} }
@ -510,7 +514,7 @@
jsOMS.Chart.ChartAbstract.prototype.createXScale = function (type) jsOMS.Chart.ChartAbstract.prototype.createXScale = function (type)
{ {
if(type === 'ordinal') { if (type === 'ordinal') {
return d3.scale.ordinal().rangeRoundBands([ return d3.scale.ordinal().rangeRoundBands([
0, 0,
this.dimension.width this.dimension.width
@ -529,7 +533,7 @@
jsOMS.Chart.ChartAbstract.prototype.createYScale = function (type) jsOMS.Chart.ChartAbstract.prototype.createYScale = function (type)
{ {
if(type === 'ordinal') { if (type === 'ordinal') {
return d3.scale.ordinal().rangeRoundBands([ return d3.scale.ordinal().rangeRoundBands([
0, 0,
this.dimension.height this.dimension.height

View File

@ -116,6 +116,7 @@
temp = this.drawData(svg, x, y, dataPointEnter, dataPoint); temp = this.drawData(svg, x, y, dataPointEnter, dataPoint);
dataPointEnter = temp[0]; dataPointEnter = temp[0];
dataPoint = temp[1]; dataPoint = temp[1];
this.chart.drawMarker(svg, x, y, dataPointEnter, dataPoint); this.chart.drawMarker(svg, x, y, dataPointEnter, dataPoint);
this.chart.drawLegend(svg, dataPointEnter, dataPoint); this.chart.drawLegend(svg, dataPointEnter, dataPoint);
this.chart.drawText(svg); this.chart.drawText(svg);
@ -163,7 +164,7 @@
.attr("width", x.rangeBand()) .attr("width", x.rangeBand())
.attr("height", 0); .attr("height", 0);
if(this.chart.subtype === 'stacked') { if (this.chart.subtype === 'stacked') {
rect.transition() rect.transition()
.delay(function (d, i) .delay(function (d, i)
{ {

View File

@ -221,7 +221,6 @@
jsOMS.Chart.LineChart.prototype.drawData = function (svg, line, dataPointEnter, dataPoint) jsOMS.Chart.LineChart.prototype.drawData = function (svg, line, dataPointEnter, dataPoint)
{ {
const self = this; const self = this;
dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset, function (c) dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset, function (c)
{ {
return c.id; return c.id;

View File

@ -8,6 +8,7 @@
// Setting default chart values // Setting default chart values
this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0}; this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
/** global: d3 */ /** global: d3 */
this.chart.color = d3.scale.category10(); this.chart.color = d3.scale.category10();
this.chart.dataSettings.style.strokewidth = 1; this.chart.dataSettings.style.strokewidth = 1;

View File

@ -68,7 +68,7 @@
add = 0; add = 0;
// todo: remove value since positive and negative can be checked by looking at the diff of y-y0 // todo: remove value since positive and negative can be checked by looking at the diff of y-y0
for(let i = 0; i < length - 1; i++) { for (let i = 0; i < length - 1; i++) {
dataset[0].points[i] = { name: data[i].name, y0: add, y: data[i].value + add }; dataset[0].points[i] = { name: data[i].name, y0: add, y: data[i].value + add };
add += data[i].value; add += data[i].value;
} }
@ -80,7 +80,9 @@
jsOMS.Chart.PyramidChart.prototype.draw = function () jsOMS.Chart.PyramidChart.prototype.draw = function ()
{ {
let bar, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom, self = this, box = this.chart.chartSelect.node().getBoundingClientRect(); let bar, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom,
self = this,
box = this.chart.chartSelect.node().getBoundingClientRect();
this.chart.dimension = { this.chart.dimension = {
width: box.width, width: box.width,

View File

@ -8,6 +8,7 @@
// Setting default chart values // Setting default chart values
this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0}; this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
/** global: d3 */ /** global: d3 */
this.chart.color = d3.scale.category10(); this.chart.color = d3.scale.category10();
this.chart.axis = { this.chart.axis = {
@ -116,7 +117,6 @@
jsOMS.Chart.ScatterplotChart.prototype.drawData = function (svg, x, y, dataPointEnter, dataPoint) jsOMS.Chart.ScatterplotChart.prototype.drawData = function (svg, x, y, dataPointEnter, dataPoint)
{ {
const self = this; const self = this;
dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset, function (c) dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset, function (c)
{ {
return c.id; return c.id;

View File

@ -8,6 +8,7 @@
// Setting default chart values // Setting default chart values
this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0}; this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
/** global: d3 */ /** global: d3 */
this.chart.color = d3.scale.category10(); this.chart.color = d3.scale.category10();
this.chart.axis = { this.chart.axis = {
@ -53,6 +54,7 @@
visible: true visible: true
} }
}; };
this.chart.subtype = 'vwaterfall'; this.chart.subtype = 'vwaterfall';
}; };
@ -68,7 +70,7 @@
add = 0; add = 0;
// todo: remove value since positive and negative can be checked by looking at the diff of y-y0 // todo: remove value since positive and negative can be checked by looking at the diff of y-y0
for(let i = 0; i < length - 1; i++) { for (let i = 0; i < length - 1; i++) {
dataset[0].points[i] = { name: data[i].name, y0: add, y: data[i].value + add }; dataset[0].points[i] = { name: data[i].name, y0: add, y: data[i].value + add };
add += data[i].value; add += data[i].value;
} }
@ -91,7 +93,7 @@
xGrid = this.chart.createXGrid(x); xGrid = this.chart.createXGrid(x);
yGrid = this.chart.createYGrid(y); yGrid = this.chart.createYGrid(y);
x.domain([0, d3.max(this.chart.dataset[0].points, function(d) { return d.y*1.05; })]); x.domain([0, d3.max(this.chart.dataset[0].points, function(d) { return d.y * 1.05; })]);
y.domain(this.chart.dataset[0].points.map(function(d) { return d.name; })); y.domain(this.chart.dataset[0].points.map(function(d) { return d.name; }));
svg = this.chart.chartSelect.append("svg") svg = this.chart.chartSelect.append("svg")
@ -127,7 +129,6 @@
jsOMS.Chart.VWaterfallChart.prototype.drawData = function (svg, x, y, dataPointEnter, dataPoint) jsOMS.Chart.VWaterfallChart.prototype.drawData = function (svg, x, y, dataPointEnter, dataPoint)
{ {
const self = this; const self = this;
dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset[0].points, function (c) dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset[0].points, function (c)
{ {
return c.name; return c.name;

View File

@ -8,6 +8,7 @@
// Setting default chart values // Setting default chart values
this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0}; this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
/** global: d3 */ /** global: d3 */
this.chart.color = d3.scale.category10(); this.chart.color = d3.scale.category10();
this.chart.axis = { this.chart.axis = {
@ -53,6 +54,7 @@
visible: true visible: true
} }
}; };
this.chart.subtype = 'waterfall'; this.chart.subtype = 'waterfall';
}; };
@ -68,7 +70,7 @@
add = 0; add = 0;
// todo: remove value since positive and negative can be checked by looking at the diff of y-y0 // todo: remove value since positive and negative can be checked by looking at the diff of y-y0
for(let i = 0; i < length - 1; i++) { for (let i = 0; i < length - 1; i++) {
dataset[0].points[i] = { name: data[i].name, y0: add, y: data[i].value + add }; dataset[0].points[i] = { name: data[i].name, y0: add, y: data[i].value + add };
add += data[i].value; add += data[i].value;
} }
@ -92,7 +94,7 @@
yGrid = this.chart.createYGrid(y); yGrid = this.chart.createYGrid(y);
x.domain(this.chart.dataset[0].points.map(function(d) { return d.name; })); 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") svg = this.chart.chartSelect.append("svg")
.attr("width", this.chart.dimension.width) .attr("width", this.chart.dimension.width)
@ -127,7 +129,6 @@
jsOMS.Chart.WaterfallChart.prototype.drawData = function (svg, x, y, dataPointEnter, dataPoint) jsOMS.Chart.WaterfallChart.prototype.drawData = function (svg, x, y, dataPointEnter, dataPoint)
{ {
const self = this; const self = this;
dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset[0].points, function (c) dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset[0].points, function (c)
{ {
return c.name; return c.name;

View File

@ -40,7 +40,13 @@
{ {
const exdate = new Date(); const exdate = new Date();
exdate.setDate(exdate.getDate() + exdays); exdate.setDate(exdate.getDate() + exdays);
const cValue = encodeURI(value) + ((exdays === null) ? "" : "; expires=" + exdate.toUTCString()) + ";domain=" + domain + ";path=" + path;
const cValue = encodeURI(value)
+ ((exdays === null) ? "" : "; expires="
+ exdate.toUTCString()) + ";domain="
+ domain + ";path="
+ path;
document.cookie = cName + "=" + cValue; document.cookie = cName + "=" + cValue;
}; };

View File

@ -112,7 +112,7 @@
{ {
id = typeof id !== 'undefined' ? id : 0; id = typeof id !== 'undefined' ? id : 0;
if(!this.callbacks.hasOwnProperty(group)) { if (!this.callbacks.hasOwnProperty(group)) {
return false; return false;
} }
@ -125,7 +125,7 @@
if (this.callbacks[group].remove) { if (this.callbacks[group].remove) {
this.detach(group); this.detach(group);
} else if(this.callbacks[group].reset) { } else if (this.callbacks[group].reset) {
this.reset(group); this.reset(group);
} }
} }
@ -166,7 +166,7 @@
*/ */
jsOMS.Event.EventManager.prototype.attach = function (group, callback, remove, reset) jsOMS.Event.EventManager.prototype.attach = function (group, callback, remove, reset)
{ {
if(this.callbacks.hasOwnProperty(group)) { if (this.callbacks.hasOwnProperty(group)) {
return false; return false;
} }

View File

@ -3,18 +3,18 @@
jsOMS.mathEvaluate = function(equation) jsOMS.mathEvaluate = function(equation)
{ {
const stack = []; const stack = [],
const postfix = jsOMS.shuntingYard(equation); postfix = jsOMS.shuntingYard(equation);
const length = postfix.length; length = postfix.length;
for(let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (!isNaN(parseFloat(postfix[i])) && isFinite(postfix[i])) { if (!isNaN(parseFloat(postfix[i])) && isFinite(postfix[i])) {
stack.push(postfix[i]); stack.push(postfix[i]);
} else { } else {
let a = jsOMS.parseValue(stack.pop()); let a = jsOMS.parseValue(stack.pop());
let b = jsOMS.parseValue(stack.pop()); let b = jsOMS.parseValue(stack.pop());
if(postfix[i] === '+') { if (postfix[i] === '+') {
stack.push(a + b); stack.push(a + b);
} else if (postfix[i] === '-') { } else if (postfix[i] === '-') {
stack.push(b - a); stack.push(b - a);
@ -52,30 +52,28 @@
equation = equation.split(/([\+\-\*\/\^\(\)])/).filter(function (n) { return n !== '' }); equation = equation.split(/([\+\-\*\/\^\(\)])/).filter(function (n) { return n !== '' });
let length = equation.length; let length = equation.length;
for(let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
let token = equation[i]; let token = equation[i];
if (!isNaN(parseFloat(token)) && isFinite(token)) { if (!isNaN(parseFloat(token)) && isFinite(token)) {
output.push(token); output.push(token);
} else if('^*/+-'.indexOf(token) !== -1) { } else if ('^*/+-'.indexOf(token) !== -1) {
let o1 = token; let o1 = token;
let o2 = stack[stack.length - 1]; let o2 = stack[stack.length - 1];
while ('^*/+-'.indexOf(o2) !== -1 && while ('^*/+-'.indexOf(o2) !== -1
( && ((operators[o1].order === -1 && operators[o1].precedence <= operators[o2].precedence)
(operators[o1].order === -1 && operators[o1].precedence <= operators[o2].precedence) || (operators[o1].order === 1 && operators[o1].precedence < operators[o2].precedence))
|| (operators[o1].order === 1 && operators[o1].precedence < operators[o2].precedence)
)
) { ) {
output.push(stack.pop()); output.push(stack.pop());
o2 = stack[stack.length - 1]; o2 = stack[stack.length - 1];
} }
stack.push(o1); stack.push(o1);
} else if(token === '(') { } else if (token === '(') {
stack.push(token); stack.push(token);
} else if (token === ')') { } else if (token === ')') {
while(stack[stack.length - 1] !== '(') { while (stack[stack.length - 1] !== '(') {
output.push(stack.pop()); output.push(stack.pop());
} }
@ -83,7 +81,7 @@
} }
} }
while(stack.length > 0) { while (stack.length > 0) {
output.push(stack.pop()); output.push(stack.pop());
} }

View File

@ -21,7 +21,7 @@
jsOMS.Message.Notification.NotificationManager.prototype.send = function(message, type) jsOMS.Message.Notification.NotificationManager.prototype.send = function(message, type)
{ {
if(jsOMS.Message.Notification.NotificationType.APP_NOTIFICATION === type) { if (jsOMS.Message.Notification.NotificationType.APP_NOTIFICATION === type) {
this.appNotifier.send(message); this.appNotifier.send(message);
} else { } else {
this.browserNotifier.send(message); this.browserNotifier.send(message);

View File

@ -33,10 +33,10 @@
j = 0, j = 0,
this.compiledData = this.dataset; this.compiledData = this.dataset;
for(let i = 0; i < cRows; i++) { for (let i = 0; i < cRows; i++) {
cCols = this.compiledData[i].length(); cCols = this.compiledData[i].length();
for(j = 0; j < cCols; j++) { for (j = 0; j < cCols; j++) {
this.compiledData[i][j] = Functions.evaluate(this.compiledData[i][j], compiledData); this.compiledData[i][j] = Functions.evaluate(this.compiledData[i][j], compiledData);
this.drawCell(this.compiledData[i][j]); this.drawCell(this.compiledData[i][j]);

View File

@ -72,14 +72,14 @@
for (let i = 0; i < listenerLength; i++) { for (let i = 0; i < listenerLength; i++) {
let c = [e], hasSelector = false; let c = [e], hasSelector = false;
if(listeners[i].hasOwnProperty('selector')) { if (listeners[i].hasOwnProperty('selector')) {
c = document.querySelectorAll(listeners[i].selector); c = document.querySelectorAll(listeners[i].selector);
hasSelector = true; hasSelector = true;
} }
let childLength = c.length; let childLength = c.length;
for(let j = 0; j < childLength; j++) { for (let j = 0; j < childLength; j++) {
this.bindListener(c[j], listeners[i]); this.bindListener(c[j], listeners[i]);
} }
@ -88,13 +88,13 @@
// todo: careful this could cause bugs if there is another component relying on a listener for this dom element. Maybe create actionManager domlistener? // todo: careful this could cause bugs if there is another component relying on a listener for this dom element. Maybe create actionManager domlistener?
// Maybe just use this listener for ALL action listeners and check if delete, then remove otherwise do current stuff. // Maybe just use this listener for ALL action listeners and check if delete, then remove otherwise do current stuff.
// Problem is, the listener doesn't work for the node itself only for children and listening to ALL document nodes might be a bad idea?!?!?! // Problem is, the listener doesn't work for the node itself only for children and listening to ALL document nodes might be a bad idea?!?!?!
const observeConfig = {childList: false, attributes: true, subtree: false}; const observeConfig = { childList: false, attributes: true, subtree: false };
if(hasSelector) { if (hasSelector) {
this.app.eventManager.attach(e.id + 'childList', function(data) { this.app.eventManager.attach(e.id + 'childList', function(data) {
const length = data.addedNodes.length; const length = data.addedNodes.length;
for(let j = 0; j < length; j++) { for (let j = 0; j < length; j++) {
self.bindListener(data.addedNodes[j], listeners[i]); self.bindListener(data.addedNodes[j], listeners[i]);
} }
@ -104,7 +104,6 @@
} }
this.app.eventManager.attach(e.id + 'attributes', function(data) {}); this.app.eventManager.attach(e.id + 'attributes', function(data) {});
this.app.uiManager.getDOMObserver().observe(e, observeConfig); this.app.uiManager.getDOMObserver().observe(e, observeConfig);
} }
}; };
@ -138,7 +137,7 @@
// Register event for first action // Register event for first action
e.addEventListener(listener.listener, function (event) e.addEventListener(listener.listener, function (event)
{ {
if(listener.preventDefault) { if (listener.preventDefault) {
event.preventDefault(); event.preventDefault();
} }

View File

@ -106,7 +106,7 @@
const submits = this.forms[id].getSubmit(), const submits = this.forms[id].getSubmit(),
length = submits.length; length = submits.length;
for(let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
submits[i].addEventListener('click', function (event) submits[i].addEventListener('click', function (event)
{ {
jsOMS.preventAll(event); jsOMS.preventAll(event);
@ -167,7 +167,7 @@
this.app.eventManager.addGroup(form.getId(), counter); this.app.eventManager.addGroup(form.getId(), counter);
const result = injects[property](form, counter, form.getId()); const result = injects[property](form, counter, form.getId());
if(result === false) { if (result === false) {
return; return;
} }
} else { } else {
@ -175,7 +175,7 @@
} }
} }
if(counter === 0) { if (counter === 0) {
this.app.eventManager.trigger(form.getId()); this.app.eventManager.trigger(form.getId());
} }
}; };
@ -225,10 +225,10 @@
} }
} }
} catch (e) { } catch (e) {
jsOMS.Log.Logger.instance.error('Invalid form response. \n' + jsOMS.Log.Logger.instance.error('Invalid form response. \n'
'URL: ' + form.getAction() + '\n' + + 'URL: ' + form.getAction() + '\n'
'Request: ' + JSON.stringify(form.getData()) + '\n' + + 'Request: ' + JSON.stringify(form.getData()) + '\n'
'Response: ' + xhr.response + 'Response: ' + xhr.response
); );
} }
}); });

View File

@ -36,7 +36,7 @@
*/ */
jsOMS.UI.Input.bindElement = function (input) jsOMS.UI.Input.bindElement = function (input)
{ {
if(typeof input === 'undefined') { if (typeof input === 'undefined') {
throw 'Input element required' throw 'Input element required'
} }
@ -61,7 +61,7 @@
if (typeof (ref = this.getAttribute('data-ref')) !== 'undefined') { if (typeof (ref = this.getAttribute('data-ref')) !== 'undefined') {
let e = document.getElementById(ref); let e = document.getElementById(ref);
if(!e) { if (!e) {
return; return;
} }
@ -81,7 +81,7 @@
{ {
const db = document.getElementById(dataButton); const db = document.getElementById(dataButton);
if(db) { if (db) {
db.click(); db.click();
} }
}); });

View File

@ -36,7 +36,7 @@
if (typeof id !== 'undefined') { if (typeof id !== 'undefined') {
const e = document.getElementById(id); const e = document.getElementById(id);
if(e) { if (e) {
this.bindElement(); this.bindElement();
} }
} else { } else {

View File

@ -36,7 +36,7 @@
if (typeof id !== 'undefined') { if (typeof id !== 'undefined') {
const e = document.getElementById(id); const e = document.getElementById(id);
if(e) { if (e) {
this.bindElement(e); this.bindElement(e);
} }
} else { } else {

View File

@ -71,12 +71,12 @@
const element = document.getElementById(id), const element = document.getElementById(id),
self = this; self = this;
if(!element) { if (!element) {
return; return;
} }
element.addEventListener('dragstart', function(e) { element.addEventListener('dragstart', function(e) {
if(self.dragging === null) { if (self.dragging === null) {
self.dragging = this; self.dragging = this;
e.dataTransfer.effectAllowed = 'move'; e.dataTransfer.effectAllowed = 'move';
e.dataTransfer.setData('text/html', this.innerHTML); e.dataTransfer.setData('text/html', this.innerHTML);
@ -110,7 +110,7 @@
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
if(self.dragging === this) { if (self.dragging === this) {
return; return;
} }

View File

@ -58,7 +58,7 @@
e = e !== null ? e.querySelectorAll('[data-href]') : document.querySelectorAll('[data-href]'); e = e !== null ? e.querySelectorAll('[data-href]') : document.querySelectorAll('[data-href]');
const length = e.length; const length = e.length;
for(let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
e[i].addEventListener('click', function(event) { e[i].addEventListener('click', function(event) {
jsOMS.preventAll(event); jsOMS.preventAll(event);
window.location = jsOMS.Uri.UriFactory.build(this.getAttribute('data-href')); window.location = jsOMS.Uri.UriFactory.build(this.getAttribute('data-href'));
@ -81,7 +81,7 @@
const length = e.length; const length = e.length;
/** global: IntersectionObserver */ /** global: IntersectionObserver */
if(!this.visObs && window.IntersectionObserver) { if (!this.visObs && window.IntersectionObserver) {
this.visObs = new IntersectionObserver(function(eles, obs) { this.visObs = new IntersectionObserver(function(eles, obs) {
eles.forEach(ele => { eles.forEach(ele => {
if (ele.intersectionRatio > 0) { if (ele.intersectionRatio > 0) {
@ -93,8 +93,8 @@
}); });
} }
for(let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if(!this.visObs) { if (!this.visObs) {
e[i].src = e[i].dataset.lazyload; e[i].src = e[i].dataset.lazyload;
delete e[i].dataset.lazyload; delete e[i].dataset.lazyload;
} else { } else {

View File

@ -87,7 +87,6 @@
const actions = this.elements[element], const actions = this.elements[element],
length = actions.length, length = actions.length,
keyLength = this.down.length; keyLength = this.down.length;
let match = false; let match = false;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {

View File

@ -109,7 +109,9 @@
length = actions.length; length = actions.length;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if ((!actions[i].exact || event.target.getAttribute('id') === element) && actions[i].button === event.button) { if ((!actions[i].exact || event.target.getAttribute('id') === element)
&& actions[i].button === event.button
) {
jsOMS.preventAll(event); jsOMS.preventAll(event);
actions[i].callback(); actions[i].callback();
} }

View File

@ -51,7 +51,7 @@
const e = document.getElementById(surface), const e = document.getElementById(surface),
self = this; self = this;
if(!e) { if (!e) {
return; return;
} }

View File

@ -39,7 +39,7 @@
this.voices = []; this.voices = [];
this.voice = null; this.voice = null;
if(SpeechRecognition !== null) { if (SpeechRecognition !== null) {
this.voices = window.speechSynthesis.getVoices(); this.voices = window.speechSynthesis.getVoices();
this.voice = this.voices[0]; this.voice = this.voices[0];
} }
@ -62,6 +62,7 @@
utter.voice = this.voice; utter.voice = this.voice;
utter.pitch = this.pitch; utter.pitch = this.pitch;
utter.rate = this.rate; utter.rate = this.rate;
window.speechSynthesis.speak(utter); window.speechSynthesis.speak(utter);
}; };

View File

@ -39,7 +39,7 @@
this.recognition = null; this.recognition = null;
this.speechRecognitionList = null; this.speechRecognitionList = null;
if(SpeechRecognition !== null) { if (SpeechRecognition !== null) {
this.recognition = new SpeechRecognition(); this.recognition = new SpeechRecognition();
this.speechRecognitionList = new SpeechGrammarList(); this.speechRecognitionList = new SpeechGrammarList();
} }
@ -54,41 +54,43 @@
*/ */
jsOMS.UI.Input.Voice.VoiceManager.prototype.setup = function() jsOMS.UI.Input.Voice.VoiceManager.prototype.setup = function()
{ {
if(SpeechRecognition === null) { if (SpeechRecognition === null) {
return; return;
} }
const self = this; const self = this;
this.recognition.lang = this.lang; this.recognition.lang = this.lang;
this.recognition.interimResults = false; this.recognition.interimResults = false;
this.recognition.maxAlternatives = 1; this.recognition.maxAlternatives = 1;
this.recognition.continuous = true; this.recognition.continuous = true;
this.recognition.lang = this.lang; this.recognition.lang = this.lang;
if(typeof this.commands !== 'undefined') { if (typeof this.commands !== 'undefined') {
this.speechRecognitionList.addFromString(this.getCommandsString(), 1); this.speechRecognitionList.addFromString(this.getCommandsString(), 1);
this.recognition.grammars = this.speechRecognitionList; this.recognition.grammars = this.speechRecognitionList;
} }
this.recognition.onstart = function() {}; this.recognition.onstart = function() {};
this.recognition.onresult = function(event)
this.recognition.onresult = function(event) { {
let result = jsOMS.trim(event.results[event.resultIndex][0].transcript); let result = jsOMS.trim(event.results[event.resultIndex][0].transcript);
if(self.commands.hasOwnProperty(result)) { if (self.commands.hasOwnProperty(result)) {
self.commands[result](); self.commands[result]();
} }
}; };
this.recognition.onspeechend = function() { this.recognition.onspeechend = function()
{
}; };
this.recognition.onnomatch = function(event) { this.recognition.onnomatch = function(event)
{
jsOMS.Log.Logger.instance.warning('Couldn\'t recognize speech'); jsOMS.Log.Logger.instance.warning('Couldn\'t recognize speech');
}; };
this.recognition.onerror = function(event) { this.recognition.onerror = function(event)
{
jsOMS.Log.Logger.instance.warning('Error during speech recognition: ' + event.error); jsOMS.Log.Logger.instance.warning('Error during speech recognition: ' + event.error);
}; };
}; };
@ -144,7 +146,7 @@
*/ */
jsOMS.UI.Input.Voice.VoiceManager.prototype.start = function() jsOMS.UI.Input.Voice.VoiceManager.prototype.start = function()
{ {
if(SpeechRecognition === null) { if (SpeechRecognition === null) {
return; return;
} }
@ -160,7 +162,7 @@
*/ */
jsOMS.UI.Input.Voice.VoiceManager.prototype.stop = function() jsOMS.UI.Input.Voice.VoiceManager.prototype.stop = function()
{ {
if(SpeechRecognition === null) { if (SpeechRecognition === null) {
return; return;
} }

View File

@ -126,7 +126,7 @@
keyValPairs = query.split('&'); keyValPairs = query.split('&');
for (pairNum in keyValPairs) { for (pairNum in keyValPairs) {
if(!keyValPairs.hasOwnProperty(pairNum)) { if (!keyValPairs.hasOwnProperty(pairNum)) {
continue; continue;
} }

View File

@ -96,7 +96,7 @@
*/ */
jsOMS.Uri.UriFactory.clear = function(key) jsOMS.Uri.UriFactory.clear = function(key)
{ {
if(jsOMS.Uri.UriFactory.uri.hasOwnProperty(key)) { if (jsOMS.Uri.UriFactory.uri.hasOwnProperty(key)) {
delete jsOMS.Uri.UriFactory.uri[key]; delete jsOMS.Uri.UriFactory.uri[key];
return true; return true;
@ -121,8 +121,8 @@
let success = false; let success = false;
const regexp = new RegExp(pattern); const regexp = new RegExp(pattern);
for(let key in jsOMS.Uri.UriFactory.uri) { for (let key in jsOMS.Uri.UriFactory.uri) {
if(jsOMS.Uri.UriFactory.uri.hasOwnProperty(key) && regexp.test(key)) { if (jsOMS.Uri.UriFactory.uri.hasOwnProperty(key) && regexp.test(key)) {
delete jsOMS.Uri.UriFactory.uri[key]; delete jsOMS.Uri.UriFactory.uri[key];
success = true; success = true;
} }
@ -205,7 +205,7 @@
} else if (match.indexOf('#') === 0) { } else if (match.indexOf('#') === 0) {
const e = document.getElementById(match.substr(1)); const e = document.getElementById(match.substr(1));
if(e) { if (e) {
return e.value; return e.value;
} }

View File

@ -30,8 +30,8 @@
const pathParts = path.split(delim); const pathParts = path.split(delim);
let current = data; let current = data;
for(let key in pathParts) { for (let key in pathParts) {
if(!pathParts.hasOwnProperty(key)) { if (!pathParts.hasOwnProperty(key)) {
continue; continue;
} }

View File

@ -151,8 +151,7 @@
{ {
/** global: Node */ /** global: Node */
return ( return (
typeof Node === "object" ? ele instanceof Node : typeof Node === "object" ? ele instanceof Node : ele && typeof ele === "object" && typeof ele.nodeType === "number" && typeof ele.nodeName === "string"
ele && typeof ele === "object" && typeof ele.nodeType === "number" && typeof ele.nodeName === "string"
); );
}; };

View File

@ -30,12 +30,12 @@
const pathParts = path.split(delim); const pathParts = path.split(delim);
let current = data; let current = data;
for(let key in pathParts) { for (let key in pathParts) {
if(!pathParts.hasOwnProperty(key)) { if (!pathParts.hasOwnProperty(key)) {
continue; continue;
} }
if(typeof current === 'undefined' || !current.hasOwnProperty(pathParts[key])) { if (typeof current === 'undefined' || !current.hasOwnProperty(pathParts[key])) {
return null; return null;
} }
@ -321,8 +321,7 @@
{ {
/** global: Node */ /** global: Node */
return ( return (
typeof Node === "object" ? ele instanceof Node : typeof Node === "object" ? ele instanceof Node : ele && typeof ele === "object" && typeof ele.nodeType === "number" && typeof ele.nodeName === "string"
ele && typeof ele === "object" && typeof ele.nodeType === "number" && typeof ele.nodeName === "string"
); );
}; };

View File

@ -129,7 +129,7 @@
{ {
const form = document.getElementById(this.id); const form = document.getElementById(this.id);
if(!form) { if (!form) {
return []; return [];
} }
@ -158,7 +158,7 @@
let value = null; let value = null;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if(elements[i].tagName.toLowerCase() === 'canvas') { if (elements[i].tagName.toLowerCase() === 'canvas') {
value = elements[i].toDataURL('image/png'); value = elements[i].toDataURL('image/png');
} else { } else {
value = elements[i].value; value = elements[i].value;
@ -196,7 +196,11 @@
try { try {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if ((elements[i].required && elements[i].value === '') || (typeof elements[i].pattern !== 'undefined' && elements[i].pattern !== '' && !(new RegExp(elements[i].pattern)).test(elements[i].value))) { if ((elements[i].required && elements[i].value === '')
|| (typeof elements[i].pattern !== 'undefined'
&& elements[i].pattern !== ''
&& !(new RegExp(elements[i].pattern)).test(elements[i].value))
) {
return false; return false;
} }
} }
@ -268,7 +272,7 @@
const e = document.getElementById(this.id); const e = document.getElementById(this.id);
if(!e) { if (!e) {
return; return;
} }

View File

@ -16,7 +16,7 @@
{ {
overwrite = typeof overwrite !== 'undefined' ? overwrite : false; overwrite = typeof overwrite !== 'undefined' ? overwrite : false;
if(typeof this.data[id] === 'undefined' || overwrite) { if (typeof this.data[id] === 'undefined' || overwrite) {
this.data[id] = data; this.data[id] = data;
return true; return true;