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

@ -155,10 +155,10 @@
jsOMS.Animation.Canvas.ParticleAnimation.prototype.updateDistance = function (p1, p2) jsOMS.Animation.Canvas.ParticleAnimation.prototype.updateDistance = function (p1, p2)
{ {
const pos1 = p1.getPosition(), const pos1 = p1.getPosition(),
pos2 = p2.getPosition(), pos2 = p2.getPosition(),
dx = pos1.x - pos2.x, dx = pos1.x - pos2.x,
dy = pos1.y - pos2.y, dy = pos1.y - pos2.y,
dist = Math.sqrt(dx * dx + dy * dy); dist = Math.sqrt(dx * dx + dy * dy);
let vel1 = p1.getVelocity(), let vel1 = p1.getVelocity(),
vel2 = p2.getVelocity(); vel2 = p2.getVelocity();

View File

@ -35,7 +35,7 @@
jsOMS.Asset.AssetManager.prototype.registerLoadedAssets = function () jsOMS.Asset.AssetManager.prototype.registerLoadedAssets = function ()
{ {
const scripts = document.getElementsByTagName('script'), const scripts = document.getElementsByTagName('script'),
length = !scripts ? 0 : scripts.length; length = !scripts ? 0 : scripts.length;
this.assets = {}; this.assets = {};
@ -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

@ -20,7 +20,7 @@
jsOMS.Auth.Auth = function (uri) jsOMS.Auth.Auth = function (uri)
{ {
this.account = null; this.account = null;
this.uri = uri; this.uri = uri;
}; };
/** /**

View File

@ -33,8 +33,8 @@
let paths = namespace.split('.'); let paths = namespace.split('.');
paths.splice(0, 1); paths.splice(0, 1);
const length = paths.length; const length = paths.length;
let current = jsOMS; let current = jsOMS;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (typeof current[paths[i]] === 'undefined') { if (typeof current[paths[i]] === 'undefined') {
@ -56,7 +56,7 @@
jsOMS.Autoloader.initPreloaded = function () jsOMS.Autoloader.initPreloaded = function ()
{ {
const scripts = document.getElementsByTagName('script'), const scripts = document.getElementsByTagName('script'),
length = !scripts ? 0 : scripts.length; length = !scripts ? 0 : scripts.length;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
/** global: URL */ /** global: URL */
@ -103,7 +103,7 @@
} }
} }
if(typeof callback !== 'undefined' && callback !== null) { if (typeof callback !== 'undefined' && callback !== null) {
callback(); callback();
} }
}; };

View File

@ -4,7 +4,7 @@
jsOMS.Chart.AreaChart = function (id) jsOMS.Chart.AreaChart = function (id)
{ {
this.chart = new jsOMS.Chart.LineChart(id); this.chart = new jsOMS.Chart.LineChart(id);
this.chart.getChart().subtype = 'area'; this.chart.getChart().subtype = 'area';
}; };

View File

@ -9,8 +9,8 @@
// 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 = {
x: { x: {
visible: true, visible: true,
label: { label: {
@ -92,12 +92,12 @@
this.chart.calculateDimension(); this.chart.calculateDimension();
x = this.chart.createXScale('linear'); x = this.chart.createXScale('linear');
y = this.chart.createYScale('ordinal'); y = this.chart.createYScale('ordinal');
xAxis1 = this.chart.createXAxis(x); xAxis1 = this.chart.createXAxis(x);
yAxis1 = this.chart.createYAxis(y); yAxis1 = this.chart.createYAxis(y);
xGrid = this.chart.createXGrid(x); xGrid = this.chart.createXGrid(x);
yGrid = this.chart.createYGrid(y); yGrid = this.chart.createYGrid(y);
x.domain([0, this.chart.axis.y.max + 1]); x.domain([0, this.chart.axis.y.max + 1]);
y.domain(d3.range(this.chart.dataset[0].points.length)).rangeRoundBands([0, this.chart.dimension.height - this.chart.margin.top - this.chart.margin.bottom], .1); y.domain(d3.range(this.chart.dataset[0].points.length)).rangeRoundBands([0, this.chart.dimension.height - this.chart.margin.top - this.chart.margin.bottom], .1);
@ -111,9 +111,9 @@
this.chart.drawGrid(svg, xGrid, yGrid); this.chart.drawGrid(svg, xGrid, yGrid);
let dataPoint = null, let dataPoint = null,
dataPointEnter = null, dataPointEnter = null,
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];
@ -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

@ -9,7 +9,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.quantize() this.chart.color = d3.scale.quantize()
.domain([-.05, .05]) .domain([-.05, .05])
.range(d3.range(11).map(function(d) { return "q" + d + "-11"; })); .range(d3.range(11).map(function(d) { return "q" + d + "-11"; }));
@ -28,14 +28,15 @@
jsOMS.Chart.CalendarChart.prototype.draw = function () jsOMS.Chart.CalendarChart.prototype.draw = function ()
{ {
let percent = d3.format(".1%"), let percent = d3.format(".1%"),
format = d3.time.format("%Y-%m-%d"), format = d3.time.format("%Y-%m-%d"),
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)
@ -43,8 +44,8 @@
.attr("class", "RdYlGn") .attr("class", "RdYlGn")
.append("g") .append("g")
.attr("transform", "translate(" .attr("transform", "translate("
+ ((this.chart.dimension.width - this.chart.cellSize * 53) / 2) + ((this.chart.dimension.width - this.chart.cellSize * 53) / 2)
+ "," + (this.chart.dimension.height - this.chart.cellSize * 7 - 1) + ")"); + "," + (this.chart.dimension.height - this.chart.cellSize * 7 - 1) + ")");
svg.append("text") svg.append("text")
.attr("transform", "translate(-6," + this.chart.cellSize * 3.5 + ")rotate(-90)") .attr("transform", "translate(-6," + this.chart.cellSize * 3.5 + ")rotate(-90)")
@ -82,18 +83,18 @@
// todo: fix the following data filter etc. this is way to much work and slow // todo: fix the following data filter etc. this is way to much work and slow
rect.filter(function(d) { rect.filter(function(d) {
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;
} }
} }
@ -105,17 +106,17 @@
}) })
.attr("class", function(d) { .attr("class", function(d) {
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);
} }
} }
@ -126,17 +127,17 @@
.select("title") .select("title")
.text(function(d) { .text(function(d) {
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

@ -9,8 +9,8 @@
// 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 = {
x: { x: {
visible: true, visible: true,
label: { label: {
@ -49,7 +49,7 @@
} }
}; };
this.chart.grid = { this.chart.grid = {
x: { x: {
visible: true visible: true
}, },
@ -72,18 +72,18 @@
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();
x = this.chart.createXScale('linear'); x = this.chart.createXScale('linear');
y = this.chart.createYScale('linear'); y = this.chart.createYScale('linear');
xAxis1 = this.chart.createXAxis(x); xAxis1 = this.chart.createXAxis(x);
yAxis1 = this.chart.createYAxis(y); yAxis1 = this.chart.createYAxis(y);
xGrid = this.chart.createXGrid(x); xGrid = this.chart.createXGrid(x);
yGrid = this.chart.createYGrid(y); yGrid = this.chart.createYGrid(y);
x.domain([this.chart.axis.x.min - 1, this.chart.axis.x.max + 1]); x.domain([this.chart.axis.x.min - 1, this.chart.axis.x.max + 1]);
y.domain([this.chart.axis.y0.min - 1, this.chart.axis.y.max + 1]); y.domain([this.chart.axis.y0.min - 1, this.chart.axis.y.max + 1]);
@ -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

@ -8,7 +8,7 @@
jsOMS.Chart.ChartAbstract = function (id) jsOMS.Chart.ChartAbstract = function (id)
{ {
/** global: d3 */ /** global: d3 */
this.chartId = id; this.chartId = id;
this.chartSelect = d3.select('#' + this.chartId); this.chartSelect = d3.select('#' + this.chartId);
this.title = { this.title = {
@ -17,23 +17,27 @@
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.dataset = []; this.color = d3.scale.category10();
this.dataset = [];
this.dataSettings = { this.dataSettings = {
style: { style: {
strokewidth: 3, strokewidth: 3,
@ -57,10 +61,10 @@
}; };
this.dimension = {width: 0, height: 0}; this.dimension = {width: 0, height: 0};
this.margin = {top: 0, right: 0, bottom: 0, left: 0}; this.margin = {top: 0, right: 0, bottom: 0, left: 0};
this.axis = {}; this.axis = {};
this.grid = {}; this.grid = {};
this.subtype = ''; this.subtype = '';
this.clean(); this.clean();
@ -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;
} }
@ -363,9 +367,9 @@
if (!this.defined.text.subtitle) { if (!this.defined.text.subtitle) {
this.position.subtitle.top = temp.node().getBoundingClientRect().height / 2; this.position.subtitle.top = temp.node().getBoundingClientRect().height / 2;
this.margin.top += temp.node().getBoundingClientRect().height / 2 + topmargin; this.margin.top += temp.node().getBoundingClientRect().height / 2 + topmargin;
this.defined.text.subtitle = true; this.defined.text.subtitle = true;
this.shouldRedraw = true; this.shouldRedraw = true;
} }
} }
@ -381,9 +385,9 @@
if (!this.defined.text.title) { if (!this.defined.text.title) {
this.position.title.top = 0; this.position.title.top = 0;
this.margin.top += (temp.node().getBoundingClientRect().height) / 2 + this.position.subtitle.top / 2; this.margin.top += (temp.node().getBoundingClientRect().height) / 2 + this.position.subtitle.top / 2;
this.defined.text.title = true; this.defined.text.title = true;
this.shouldRedraw = true; this.shouldRedraw = true;
} }
} }
@ -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;
} }
@ -455,7 +459,7 @@
if (!this.defined.axis.x) { if (!this.defined.axis.x) {
this.margin.bottom += 50; this.margin.bottom += 50;
this.defined.axis.x = true; this.defined.axis.x = true;
this.shouldRedraw = true; this.shouldRedraw = true;
} }
} }
@ -477,9 +481,9 @@
} }
if (!this.defined.axis.y) { if (!this.defined.axis.y) {
this.margin.left += svg.select('.y.axis .tick').node().getBoundingClientRect().width + 25; this.margin.left += svg.select('.y.axis .tick').node().getBoundingClientRect().width + 25;
this.defined.axis.y = true; this.defined.axis.y = true;
this.shouldRedraw = true; this.shouldRedraw = true;
} }
} }
@ -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
@ -602,9 +606,9 @@
jsOMS.Chart.ChartAbstract.prototype.clean = function () jsOMS.Chart.ChartAbstract.prototype.clean = function ()
{ {
this.margin = {top: 0, right: 0, bottom: 0, left: 0}; this.margin = {top: 0, right: 0, bottom: 0, left: 0};
this.dimension = {width: 0, height: 0}; this.dimension = {width: 0, height: 0};
this.position = { this.position = {
title: { title: {
top: 0, top: 0,
left: 0 left: 0
@ -624,7 +628,7 @@
}; };
this.shouldRedraw = false; this.shouldRedraw = false;
this.defined = { this.defined = {
axis: { axis: {
x: false, x: false,
y: false y: false

View File

@ -2,11 +2,11 @@
"use strict"; "use strict";
jsOMS.Chart.Legend = function () { jsOMS.Chart.Legend = function () {
this.position = {x: 0, y: 0}; this.position = {x: 0, y: 0};
this.relative = true; this.relative = true;
this.horizontal = false; this.horizontal = false;
this.visible = true; this.visible = true;
this.labels = []; // {title, color, marker} this.labels = []; // {title, color, marker}
}; };
jsOMS.Chart.Legend.prototype.addLabel = function(label) { jsOMS.Chart.Legend.prototype.addLabel = function(label) {

View File

@ -9,8 +9,8 @@
// 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 = {
x: { x: {
visible: true, visible: true,
label: { label: {
@ -92,12 +92,12 @@
this.chart.calculateDimension(); this.chart.calculateDimension();
x = this.chart.createXScale('ordinal'); x = this.chart.createXScale('ordinal');
y = this.chart.createYScale('linear'); y = this.chart.createYScale('linear');
xAxis1 = this.chart.createXAxis(x); xAxis1 = this.chart.createXAxis(x);
yAxis1 = this.chart.createYAxis(y); yAxis1 = this.chart.createYAxis(y);
xGrid = this.chart.createXGrid(x); xGrid = this.chart.createXGrid(x);
yGrid = this.chart.createYGrid(y); yGrid = this.chart.createYGrid(y);
x.domain(d3.range(this.chart.dataset[0].points.length)).rangeRoundBands([0, this.chart.dimension.width - this.chart.margin.right - this.chart.margin.left], .1); x.domain(d3.range(this.chart.dataset[0].points.length)).rangeRoundBands([0, this.chart.dimension.width - this.chart.margin.right - this.chart.margin.left], .1);
y.domain([0, this.chart.axis.y.max + 1]); y.domain([0, this.chart.axis.y.max + 1]);
@ -111,11 +111,12 @@
this.chart.drawGrid(svg, xGrid, yGrid); this.chart.drawGrid(svg, xGrid, yGrid);
let dataPoint = null, let dataPoint = null,
dataPointEnter = null, dataPointEnter = null,
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

@ -4,9 +4,9 @@
jsOMS.Chart.DiffAreaChart = function (id) jsOMS.Chart.DiffAreaChart = function (id)
{ {
this.chart = new jsOMS.Chart.LineChart(id); this.chart = new jsOMS.Chart.LineChart(id);
this.chart.getChart().dataSettings.marker.visible = false; this.chart.getChart().dataSettings.marker.visible = false;
this.chart.getChart().subtype = 'diffarea'; this.chart.getChart().subtype = 'diffarea';
}; };
jsOMS.Chart.DiffAreaChart.prototype.getChart = function () jsOMS.Chart.DiffAreaChart.prototype.getChart = function ()

View File

@ -8,7 +8,7 @@
// Setting default chart values // Setting default chart values
this.chart.getChart().dataSettings.style.strokewidth = 0.3; this.chart.getChart().dataSettings.style.strokewidth = 0.3;
this.chart.getChart().subtype = 'donut'; this.chart.getChart().subtype = 'donut';
}; };
jsOMS.Chart.DonutChart.prototype.getChart = function () jsOMS.Chart.DonutChart.prototype.getChart = function ()

View File

@ -4,7 +4,7 @@
jsOMS.Chart.GroupedBarChart = function (id) jsOMS.Chart.GroupedBarChart = function (id)
{ {
this.chart = new jsOMS.Chart.BarChart(id); this.chart = new jsOMS.Chart.BarChart(id);
this.chart.getChart().subtype = 'grouped'; this.chart.getChart().subtype = 'grouped';
}; };

View File

@ -4,7 +4,7 @@
jsOMS.Chart.GroupedColumnChart = function (id) jsOMS.Chart.GroupedColumnChart = function (id)
{ {
this.chart = new jsOMS.Chart.ColumnChart(id); this.chart = new jsOMS.Chart.ColumnChart(id);
this.chart.getChart().subtype = 'grouped'; this.chart.getChart().subtype = 'grouped';
}; };

View File

@ -9,8 +9,8 @@
// 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 = {
x: { x: {
visible: true, visible: true,
label: { label: {
@ -78,12 +78,12 @@
this.chart.calculateDimension(); this.chart.calculateDimension();
x = this.chart.createXScale('linear'); x = this.chart.createXScale('linear');
y = this.chart.createYScale('linear'); y = this.chart.createYScale('linear');
xAxis1 = this.chart.createXAxis(x); xAxis1 = this.chart.createXAxis(x);
yAxis1 = this.chart.createYAxis(y); yAxis1 = this.chart.createYAxis(y);
xGrid = this.chart.createXGrid(x); xGrid = this.chart.createXGrid(x);
yGrid = this.chart.createYGrid(y); yGrid = this.chart.createYGrid(y);
x.domain([this.chart.axis.x.min, this.chart.axis.x.max + 1]); x.domain([this.chart.axis.x.min, this.chart.axis.x.max + 1]);
y.domain([this.chart.axis.y.min - 1, this.chart.axis.y.max + 1]); y.domain([this.chart.axis.y.min - 1, this.chart.axis.y.max + 1]);
@ -192,9 +192,9 @@
//svg.selectAll('.x.axis').transition().duration(500).call(xAxis1); //svg.selectAll('.x.axis').transition().duration(500).call(xAxis1);
//svg.selectAll('.y.axis').transition().duration(500).call(yAxis1); //svg.selectAll('.y.axis').transition().duration(500).call(yAxis1);
let dataPoint = null, let dataPoint = null,
dataPointEnter = null, dataPointEnter = null,
temp = this.drawData(svg, line, dataPointEnter, dataPoint); temp = this.drawData(svg, line, dataPointEnter, dataPoint);
dataPointEnter = temp[0]; dataPointEnter = temp[0];
dataPoint = temp[1]; dataPoint = temp[1];
@ -221,8 +221,7 @@
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

@ -4,7 +4,7 @@
jsOMS.Chart.OhlcChart = function (id) jsOMS.Chart.OhlcChart = function (id)
{ {
this.chart = new jsOMS.Chart.CandlestickChart(id); this.chart = new jsOMS.Chart.CandlestickChart(id);
this.chart.getChart().subtype = 'ohlc'; this.chart.getChart().subtype = 'ohlc';
}; };

View File

@ -8,11 +8,12 @@
// 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;
this.chart.dataSettings.style.padding = 3; this.chart.dataSettings.style.padding = 3;
this.chart.subtype = 'pie'; this.chart.subtype = 'pie';
}; };
jsOMS.Chart.PieChart.prototype.getChart = function () jsOMS.Chart.PieChart.prototype.getChart = function ()
@ -33,11 +34,11 @@
+ (this.chart.margin.left) + "," + (this.chart.margin.left) + ","
+ (this.chart.margin.top) + ")"); + (this.chart.margin.top) + ")");
let dataPoint = null, let dataPoint = null,
dataPointEnter = null, dataPointEnter = null,
temp = this.drawData(svg, dataPointEnter, dataPoint); temp = this.drawData(svg, dataPointEnter, dataPoint);
dataPointEnter = temp[0]; dataPointEnter = temp[0];
dataPoint = temp[1]; dataPoint = temp[1];
// todo: create own legend drawing // todo: create own legend drawing
this.chart.drawLegend(svg, dataPointEnter, dataPoint); this.chart.drawLegend(svg, dataPointEnter, dataPoint);
@ -62,20 +63,20 @@
jsOMS.Chart.PieChart.prototype.drawData = function (svg, dataPointEnter, dataPoint) jsOMS.Chart.PieChart.prototype.drawData = function (svg, dataPointEnter, dataPoint)
{ {
const self = this; const self = this;
let pie = d3.layout.pie() let pie = d3.layout.pie()
.sort(null) .sort(null)
.value(function (d) .value(function (d)
{ {
return d.value; return d.value;
}), }),
radius = ( radius = (
Math.min(this.chart.dimension.width, this.chart.dimension.height) / 2 Math.min(this.chart.dimension.width, this.chart.dimension.height) / 2
- Math.max(this.chart.margin.right + this.chart.margin.left, - Math.max(this.chart.margin.right + this.chart.margin.left,
this.chart.margin.top + this.chart.margin.bottom) 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() arc = d3.svg.arc()
.outerRadius(function() { return radius; }) .outerRadius(function() { return radius; })
.innerRadius(function() { return innerRadius; }); .innerRadius(function() { return innerRadius; });

View File

@ -9,8 +9,8 @@
// 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 = {
x: { x: {
visible: true, visible: true,
label: { label: {
@ -64,13 +64,13 @@
jsOMS.Chart.PyramidChart.prototype.setData = function (data) jsOMS.Chart.PyramidChart.prototype.setData = function (data)
{ {
let dataset = [{id: 1, name: 'Dataset', points: []}], let dataset = [{id: 1, name: 'Dataset', points: []}],
length = data.length, length = data.length,
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;
} }
dataset[0].points[length - 1] = { name: data[length - 1].name, y0: 0, y: add }; dataset[0].points[length - 1] = { name: data[length - 1].name, y0: 0, y: add };
@ -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,
@ -145,11 +147,11 @@
this.chart.drawGrid(svg, xGrid, yGrid); this.chart.drawGrid(svg, xGrid, yGrid);
let dataPoint = null, let dataPoint = null,
dataPointEnter = null, dataPointEnter = null,
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.drawText(svg); this.chart.drawText(svg);
this.chart.drawAxis(svg, xAxis1, yAxis1); this.chart.drawAxis(svg, xAxis1, yAxis1);

View File

@ -8,9 +8,10 @@
// 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 = {
x: { x: {
visible: true, visible: true,
label: { label: {
@ -72,12 +73,12 @@
this.chart.calculateDimension('linear'); this.chart.calculateDimension('linear');
x = this.chart.createXScale('linear'); x = this.chart.createXScale('linear');
y = this.chart.createYScale('linear'); y = this.chart.createYScale('linear');
xAxis1 = this.chart.createXAxis(x); xAxis1 = this.chart.createXAxis(x);
yAxis1 = this.chart.createYAxis(y); yAxis1 = this.chart.createYAxis(y);
xGrid = this.chart.createXGrid(x); xGrid = this.chart.createXGrid(x);
yGrid = this.chart.createYGrid(y); yGrid = this.chart.createYGrid(y);
x.domain([this.chart.axis.x.min, this.chart.axis.x.max + 1]); x.domain([this.chart.axis.x.min, this.chart.axis.x.max + 1]);
y.domain([this.chart.axis.y.min - 1, this.chart.axis.y.max + 1]); y.domain([this.chart.axis.y.min - 1, this.chart.axis.y.max + 1]);
@ -91,11 +92,11 @@
this.chart.drawGrid(svg, xGrid, yGrid); this.chart.drawGrid(svg, xGrid, yGrid);
let dataPoint = null, let dataPoint = null,
dataPointEnter = null, dataPointEnter = null,
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.drawLegend(svg, dataPointEnter, dataPoint); this.chart.drawLegend(svg, dataPointEnter, dataPoint);
this.chart.drawText(svg); this.chart.drawText(svg);
@ -116,8 +117,7 @@
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

@ -4,9 +4,9 @@
jsOMS.Chart.StackedAreaChart = function (id) jsOMS.Chart.StackedAreaChart = function (id)
{ {
this.chart = new jsOMS.Chart.LineChart(id); this.chart = new jsOMS.Chart.LineChart(id);
this.chart.getChart().dataSettings.marker.visible = false; this.chart.getChart().dataSettings.marker.visible = false;
this.chart.getChart().subtype = 'stacked'; this.chart.getChart().subtype = 'stacked';
}; };
jsOMS.Chart.StackedAreaChart.prototype.getChart = function () jsOMS.Chart.StackedAreaChart.prototype.getChart = function ()

View File

@ -4,7 +4,7 @@
jsOMS.Chart.StackedBarChart = function (id) jsOMS.Chart.StackedBarChart = function (id)
{ {
this.chart = new jsOMS.Chart.BarChart(id); this.chart = new jsOMS.Chart.BarChart(id);
this.chart.getChart().subtype = 'stacked'; this.chart.getChart().subtype = 'stacked';
}; };

View File

@ -4,7 +4,7 @@
jsOMS.Chart.StackedColumnChart = function (id) jsOMS.Chart.StackedColumnChart = function (id)
{ {
this.chart = new jsOMS.Chart.ColumnChart(id); this.chart = new jsOMS.Chart.ColumnChart(id);
this.chart.getChart().subtype = 'stacked'; this.chart.getChart().subtype = 'stacked';
}; };

View File

@ -8,9 +8,10 @@
// 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 = {
x: { x: {
visible: true, visible: true,
label: { label: {
@ -53,6 +54,7 @@
visible: true visible: true
} }
}; };
this.chart.subtype = 'vwaterfall'; this.chart.subtype = 'vwaterfall';
}; };
@ -64,13 +66,13 @@
jsOMS.Chart.VWaterfallChart.prototype.setData = function (data) jsOMS.Chart.VWaterfallChart.prototype.setData = function (data)
{ {
let dataset = [{id: 1, name: 'Dataset', points: []}], let dataset = [{id: 1, name: 'Dataset', points: []}],
length = data.length, length = data.length,
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;
} }
dataset[0].points[length - 1] = { name: data[length - 1].name, y0: 0, y: add }; dataset[0].points[length - 1] = { name: data[length - 1].name, y0: 0, y: add };
@ -84,14 +86,14 @@
this.chart.calculateDimension(); this.chart.calculateDimension();
x = this.chart.createXScale('linear'); x = this.chart.createXScale('linear');
y = this.chart.createYScale('ordinal'); y = this.chart.createYScale('ordinal');
xAxis1 = this.chart.createXAxis(x); xAxis1 = this.chart.createXAxis(x);
yAxis1 = this.chart.createYAxis(y); yAxis1 = this.chart.createYAxis(y);
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")
@ -103,11 +105,11 @@
this.chart.drawGrid(svg, xGrid, yGrid); this.chart.drawGrid(svg, xGrid, yGrid);
let dataPoint = null, let dataPoint = null,
dataPointEnter = null, dataPointEnter = null,
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.drawText(svg); this.chart.drawText(svg);
this.chart.drawAxis(svg, xAxis1, yAxis1); this.chart.drawAxis(svg, xAxis1, yAxis1);
@ -127,8 +129,7 @@
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,9 +8,10 @@
// 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 = {
x: { x: {
visible: true, visible: true,
label: { label: {
@ -53,6 +54,7 @@
visible: true visible: true
} }
}; };
this.chart.subtype = 'waterfall'; this.chart.subtype = 'waterfall';
}; };
@ -64,13 +66,13 @@
jsOMS.Chart.WaterfallChart.prototype.setData = function (data) jsOMS.Chart.WaterfallChart.prototype.setData = function (data)
{ {
let dataset = [{id: 1, name: 'Dataset', points: []}], let dataset = [{id: 1, name: 'Dataset', points: []}],
length = data.length, length = data.length,
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;
} }
dataset[0].points[length - 1] = { name: data[length - 1].name, y0: 0, y: add }; dataset[0].points[length - 1] = { name: data[length - 1].name, y0: 0, y: add };
@ -84,15 +86,15 @@
this.chart.calculateDimension(); this.chart.calculateDimension();
x = this.chart.createXScale('ordinal'); x = this.chart.createXScale('ordinal');
y = this.chart.createYScale('linear'); y = this.chart.createYScale('linear');
xAxis1 = this.chart.createXAxis(x); xAxis1 = this.chart.createXAxis(x);
yAxis1 = this.chart.createYAxis(y); yAxis1 = this.chart.createYAxis(y);
xGrid = this.chart.createXGrid(x); xGrid = this.chart.createXGrid(x);
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)
@ -103,11 +105,11 @@
this.chart.drawGrid(svg, xGrid, yGrid); this.chart.drawGrid(svg, xGrid, yGrid);
let dataPoint = null, let dataPoint = null,
dataPointEnter = null, dataPointEnter = null,
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.drawText(svg); this.chart.drawText(svg);
this.chart.drawAxis(svg, xAxis1, yAxis1); this.chart.drawAxis(svg, xAxis1, yAxis1);
@ -127,8 +129,7 @@
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;
}; };
@ -67,7 +73,7 @@
if (cStart === -1) { if (cStart === -1) {
cValue = null; cValue = null;
} else { } else {
cStart = cValue.indexOf("=", cStart) + 1; cStart = cValue.indexOf("=", cStart) + 1;
let cEnd = cValue.indexOf(";", cStart); let cEnd = cValue.indexOf(";", cStart);
if (cEnd === -1) { if (cEnd === -1) {

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,12 +166,12 @@
*/ */
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;
} }
remove = typeof remove === 'undefined' ? false : remove; remove = typeof remove === 'undefined' ? false : remove;
reset = typeof reset === 'undefined' ? false : reset; reset = typeof reset === 'undefined' ? false : reset;
this.callbacks[group] = {remove: remove, reset: reset, func: callback}; this.callbacks[group] = {remove: remove, reset: reset, func: callback};

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);
@ -38,7 +38,7 @@
jsOMS.shuntingYard = function(equation) jsOMS.shuntingYard = function(equation)
{ {
const stack = []; const stack = [];
const operators = { const operators = {
'^': {precedence: 4, order: 1}, '^': {precedence: 4, order: 1},
'/': {precedence: 3, order: -1}, '/': {precedence: 3, order: -1},
@ -46,36 +46,34 @@
'+': {precedence: 2, order: -1}, '+': {precedence: 2, order: -1},
'-': {precedence: 2, order: -1}, '-': {precedence: 2, order: -1},
}; };
let output = []; let output = [];
equation = equation.replace(/\s+/g, ''); equation = equation.replace(/\s+/g, '');
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

@ -15,13 +15,13 @@
jsOMS.Message.Notification.NotificationManager = function() jsOMS.Message.Notification.NotificationManager = function()
{ {
this.appNotifier = new jsOMS.Message.Notification.App.AppNotification(); this.appNotifier = new jsOMS.Message.Notification.App.AppNotification();
this.browserNotifier = new jsOMS.Message.Notification.Browser.BrowserNotification(); this.browserNotifier = new jsOMS.Message.Notification.Browser.BrowserNotification();
}; };
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

@ -2,9 +2,9 @@
"use strict"; "use strict";
jsOMS.Account = function () { jsOMS.Account = function () {
this.login = ''; this.login = '';
this.password = ''; this.password = '';
this.id = 0; this.id = 0;
this.auth = null; this.auth = null;
}; };
}(window.jsOMS = window.jsOMS || {})); }(window.jsOMS = window.jsOMS || {}));

View File

@ -21,7 +21,7 @@
jsOMS.Module.ModuleManager = function (app) jsOMS.Module.ModuleManager = function (app)
{ {
this.modules = {}; this.modules = {};
this.app = app; this.app = app;
}; };
/** /**

View File

@ -14,8 +14,8 @@
jsOMS.Spreadsheet.Cell = function(id, raw) jsOMS.Spreadsheet.Cell = function(id, raw)
{ {
this.id = id; this.id = id;
this.raw = raw; this.raw = raw;
this.formatting = raw.formatting; this.formatting = raw.formatting;
}; };
}(window.jsOMS = window.jsOMS || {})); }(window.jsOMS = window.jsOMS || {}));

View File

@ -14,34 +14,34 @@
jsOMS.Spreadsheet.Spreadsheet = function(id, dataset, options) jsOMS.Spreadsheet.Spreadsheet = function(id, dataset, options)
{ {
this.spreadsheet = document.getElementById(id); this.spreadsheet = document.getElementById(id);
this.title = ''; this.title = '';
this.sheets = []; this.sheets = [];
this.columns = true; this.columns = true;
this.rows = true; this.rows = true;
this.dataset = []; this.dataset = [];
this.compiledData = []; this.compiledData = [];
this.scroll = {h: false, v: false}; this.scroll = {h: false, v: false};
}; };
jsOMS.SpreadSheet.prototype.draw = function() jsOMS.SpreadSheet.prototype.draw = function()
{ {
let col = 0, let col = 0,
row = 0, row = 0,
cRows = this.dataset.length(), cRows = this.dataset.length(),
cCols = 0; cCols = 0;
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]);
} }
} }
}; };
jsOMS.SpreadSheet.prototype.drawCell = function() jsOMS.SpreadSheet.prototype.drawCell = function()

View File

@ -42,7 +42,7 @@
jsOMS.UI.ActionManager.prototype.bind = function (id) jsOMS.UI.ActionManager.prototype.bind = function (id)
{ {
const uiElements = typeof id === 'undefined' ? document.querySelectorAll('[data-action]') : (typeof id.length !== 'undefined' ? id : [id]), const uiElements = typeof id === 'undefined' ? document.querySelectorAll('[data-action]') : (typeof id.length !== 'undefined' ? id : [id]),
length = uiElements.length; length = uiElements.length;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (uiElements[i] !== null && uiElements[i].hasAttribute('data-action')) { if (uiElements[i] !== null && uiElements[i].hasAttribute('data-action')) {
@ -64,22 +64,22 @@
*/ */
jsOMS.UI.ActionManager.prototype.bindElement = function (e) jsOMS.UI.ActionManager.prototype.bindElement = function (e)
{ {
const listeners = JSON.parse(e.getAttribute('data-action')), const listeners = JSON.parse(e.getAttribute('data-action')),
listenerLength = listeners.length, listenerLength = listeners.length,
self = this; self = this;
// For everey action an event is registered // For everey action an event is registered
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,23 +88,22 @@
// 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]);
} }
observeConfig.childList = true; observeConfig.childList = true;
observeConfig.subtree = true; observeConfig.subtree = true;
}); });
} }
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);
} }
}; };
@ -123,7 +122,7 @@
*/ */
jsOMS.UI.ActionManager.prototype.bindListener = function(e, listener) jsOMS.UI.ActionManager.prototype.bindListener = function(e, listener)
{ {
const self = this, const self = this,
actionLength = listener.action.length; actionLength = listener.action.length;
for (let j = 1; j < actionLength; j++) { for (let j = 1; j < actionLength; j++) {
@ -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

@ -73,8 +73,8 @@
if (typeof id !== 'undefined' && typeof this.ignore[id] === 'undefined') { if (typeof id !== 'undefined' && typeof this.ignore[id] === 'undefined') {
this.bindForm(id); this.bindForm(id);
} else { } else {
const forms = document.getElementsByTagName('form'), const forms = document.getElementsByTagName('form'),
length = !forms ? 0 : forms.length; length = !forms ? 0 : forms.length;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (typeof forms[i].getAttribute('id') !== 'undefined' && forms[i].getAttribute('id') !== null && typeof this.ignore[forms[i].getAttribute('id')] === 'undefined') { if (typeof forms[i].getAttribute('id') !== 'undefined' && forms[i].getAttribute('id') !== null && typeof this.ignore[forms[i].getAttribute('id')] === 'undefined') {
@ -98,15 +98,15 @@
return; return;
} }
const self = this; const self = this;
this.forms[id] = new jsOMS.Views.FormView(id); this.forms[id] = new jsOMS.Views.FormView(id);
this.unbind(id); this.unbind(id);
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);
@ -149,7 +149,7 @@
jsOMS.UI.Component.Form.prototype.submit = function (form) jsOMS.UI.Component.Form.prototype.submit = function (form)
{ {
/* Handle injects */ /* Handle injects */
const self = this, const self = this,
injects = form.getSubmitInjects(); injects = form.getSubmitInjects();
let counter = 0; let counter = 0;
@ -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());
} }
}; };
@ -198,7 +198,7 @@
/* Handle default submit */ /* Handle default submit */
const request = new jsOMS.Message.Request.Request(), const request = new jsOMS.Message.Request.Request(),
self = this; self = this;
request.setData(form.getData()); request.setData(form.getData());
request.setType(jsOMS.Message.Response.ResponseType.JSON); request.setType(jsOMS.Message.Response.ResponseType.JSON);
@ -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();
} }
}); });
@ -111,7 +111,7 @@
request.setSuccess(function (xhr) request.setSuccess(function (xhr)
{ {
try { try {
const o = JSON.parse(xhr.response), const o = JSON.parse(xhr.response),
response = new jsOMS.Message.Response(o), response = new jsOMS.Message.Response(o),
responseLength = response.count(); responseLength = response.count();
let tempResponse = null, let tempResponse = null,

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 {
@ -66,7 +66,7 @@
{ {
/* Change Tab */ /* Change Tab */
const attr = this.getAttribute('href').substring(1), const attr = this.getAttribute('href').substring(1),
cont = this.parentNode.parentNode.parentNode.children[1]; cont = this.parentNode.parentNode.parentNode.children[1];
jsOMS.removeClass(jsOMS.getByClass(this.parentNode.parentNode, 'active'), 'active'); jsOMS.removeClass(jsOMS.getByClass(this.parentNode.parentNode, 'active'), 'active');
jsOMS.addClass(this.parentNode, 'active'); jsOMS.addClass(this.parentNode, 'active');

View File

@ -36,12 +36,12 @@
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 {
const tables = document.getElementsByTagName('table'), const tables = document.getElementsByTagName('table'),
length = !tables ? 0 : tables.length; length = !tables ? 0 : tables.length;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
this.bindElement(tables[i]); this.bindElement(tables[i]);

View File

@ -20,9 +20,9 @@
*/ */
jsOMS.UI.DragNDrop = function (app) jsOMS.UI.DragNDrop = function (app)
{ {
this.app = app; this.app = app;
this.draggable = {}; this.draggable = {};
this.dragging = null; this.dragging = null;
}; };
/** /**
@ -49,7 +49,7 @@
this.bindElement(id); this.bindElement(id);
} else { } else {
const elements = document.querySelectorAll('[draggable]'), const elements = document.querySelectorAll('[draggable]'),
length = !elements ? 0 : elements.length; length = !elements ? 0 : elements.length;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (typeof elements[i].getAttribute('id') !== 'undefined' && elements[i].getAttribute('id') !== null) { if (typeof elements[i].getAttribute('id') !== 'undefined' && elements[i].getAttribute('id') !== null) {
@ -69,15 +69,15 @@
jsOMS.UI.DragNDrop.prototype.bindElement = function (id) jsOMS.UI.DragNDrop.prototype.bindElement = function (id)
{ {
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,12 +110,12 @@
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
if(self.dragging === this) { if (self.dragging === this) {
return; return;
} }
self.dragging.innerHTML = this.innerHTML; self.dragging.innerHTML = this.innerHTML;
this.innerHTML = e.dataTransfer.getData('text/html'); this.innerHTML = e.dataTransfer.getData('text/html');
// todo: add to now destination // todo: add to now destination
// todo: remove from old destination // todo: remove from old destination

View File

@ -55,10 +55,10 @@
*/ */
jsOMS.UI.GeneralUI.prototype.bindHref = function (e) jsOMS.UI.GeneralUI.prototype.bindHref = function (e)
{ {
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'));
@ -77,11 +77,11 @@
*/ */
jsOMS.UI.GeneralUI.prototype.bindLazyLoad = function (e) jsOMS.UI.GeneralUI.prototype.bindLazyLoad = function (e)
{ {
e = e !== null ? e.querySelectorAll('[data-lazyload]') : document.querySelectorAll('[data-lazyload]'); e = e !== null ? e.querySelectorAll('[data-lazyload]') : document.querySelectorAll('[data-lazyload]');
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

@ -84,10 +84,9 @@
throw 'Unexpected elmenet!'; throw 'Unexpected elmenet!';
} }
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

@ -56,7 +56,7 @@
jsOMS.UI.Input.Mouse.MouseManager.prototype.bind = function (element, type) jsOMS.UI.Input.Mouse.MouseManager.prototype.bind = function (element, type)
{ {
const self = this, const self = this,
e = document.getElementById(element); e = document.getElementById(element);
if (!e) { if (!e) {
return; return;
@ -106,10 +106,12 @@
} }
const actions = this.elements[element], const actions = this.elements[element],
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

@ -48,10 +48,10 @@
*/ */
jsOMS.UI.Input.Touch.TouchManager.prototype.add = function (surface) jsOMS.UI.Input.Touch.TouchManager.prototype.add = function (surface)
{ {
const e = document.getElementById(surface), const e = document.getElementById(surface),
self = this; self = this;
if(!e) { if (!e) {
return; return;
} }
@ -73,7 +73,7 @@
e.addEventListener('touchend', function (event) e.addEventListener('touchend', function (event)
{ {
const touch = this.changedTouches[0], const touch = this.changedTouches[0],
distX = touch.pageX - self.activeSwipe.startX, distX = touch.pageX - self.activeSwipe.startX,
distY = touch.pageY - self.activeSwipe.startY, distY = touch.pageY - self.activeSwipe.startY,
elapsedTime = new Date().getTime() - self.activeSwipe.time; elapsedTime = new Date().getTime() - self.activeSwipe.time;

View File

@ -33,15 +33,15 @@
*/ */
jsOMS.UI.Input.Voice.ReadManager = function (lang) jsOMS.UI.Input.Voice.ReadManager = function (lang)
{ {
this.pitch = 1; this.pitch = 1;
this.rate = 1; this.rate = 1;
this.lang = typeof lang === 'undefined' ? 'en-US' : lang; this.lang = typeof lang === 'undefined' ? 'en-US' : lang;
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];
} }
}; };
@ -57,11 +57,12 @@
jsOMS.UI.Input.Voice.ReadManager.prototype.read = function(text) jsOMS.UI.Input.Voice.ReadManager.prototype.read = function(text)
{ {
/** global: SpeechSynthesisUtterance */ /** global: SpeechSynthesisUtterance */
let utter = new SpeechSynthesisUtterance(text); let utter = new SpeechSynthesisUtterance(text);
utter.lang = this.lang; utter.lang = this.lang;
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

@ -33,14 +33,14 @@
*/ */
jsOMS.UI.Input.Voice.VoiceManager = function (app, commands, lang) jsOMS.UI.Input.Voice.VoiceManager = function (app, commands, lang)
{ {
this.app = app; this.app = app;
this.commands = typeof commands === 'undefined' ? {} : commands; this.commands = typeof commands === 'undefined' ? {} : commands;
this.lang = typeof lang === 'undefined' ? 'en-US' : lang; this.lang = typeof lang === 'undefined' ? 'en-US' : lang;
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

@ -55,10 +55,10 @@
{ {
mode = typeof mode === 'undefined' ? 'php' : mode; mode = typeof mode === 'undefined' ? 'php' : mode;
const key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port', const key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port',
'relative', 'path', 'directory', 'file', 'query', 'fragment' 'relative', 'path', 'directory', 'file', 'query', 'fragment'
], ],
parser = { parser = {
php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-scheme to catch file:/// (should restrict this) loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-scheme to catch file:/// (should restrict this)
@ -68,7 +68,7 @@
throw new Error('Unexpected parsing mode.', 'UriFactory', 52); throw new Error('Unexpected parsing mode.', 'UriFactory', 52);
} }
const m = parser[mode].exec(str), const m = parser[mode].exec(str),
uri = {}; uri = {};
let i = 14; let i = 14;
@ -99,7 +99,7 @@
{ {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
const regex = new RegExp("[\\?&]*" + name + "=([^&#]*)"), const regex = new RegExp("[\\?&]*" + name + "=([^&#]*)"),
results = regex.exec(query); results = regex.exec(query);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
@ -118,7 +118,7 @@
*/ */
jsOMS.Uri.Http.getAllUriQueryParameters = function (query) jsOMS.Uri.Http.getAllUriQueryParameters = function (query)
{ {
const params = {}; const params = {};
let keyValPairs = [], let keyValPairs = [],
pairNum = null; pairNum = null;
@ -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;
@ -118,11 +118,11 @@
*/ */
jsOMS.Uri.UriFactory.clearLike = function(pattern) jsOMS.Uri.UriFactory.clearLike = function(pattern)
{ {
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;
} }
@ -149,10 +149,10 @@
const parts = url.split('?'); const parts = url.split('?');
if (parts.length >= 2) { if (parts.length >= 2) {
let full = parts[1], let full = parts[1],
pars = full.split('&'), pars = full.split('&'),
comps = {}, comps = {},
spl = null, spl = null,
length = pars.length; length = pars.length;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
@ -194,7 +194,7 @@
jsOMS.Uri.UriFactory.build = function (uri, toMatch) jsOMS.Uri.UriFactory.build = function (uri, toMatch)
{ {
const current = jsOMS.Uri.Http.parseUrl(window.location.href); const current = jsOMS.Uri.Http.parseUrl(window.location.href);
let parsed = uri.replace(new RegExp('\{[\/#\?%@\.\$][a-zA-Z0-9\-]*\}', 'g'), function (match) let parsed = uri.replace(new RegExp('\{[\/#\?%@\.\$][a-zA-Z0-9\-]*\}', 'g'), function (match)
{ {
match = match.substr(1, match.length - 2); match = match.substr(1, match.length - 2);
@ -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

@ -28,10 +28,10 @@
jsOMS.getArray = function(path, data, delim) jsOMS.getArray = function(path, data, delim)
{ {
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

@ -82,15 +82,15 @@
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.substr_count = function(str, substr) { jsOMS.substr_count = function(str, substr) {
str += ''; str += '';
substr += ''; substr += '';
if (substr.length <= 0) { if (substr.length <= 0) {
return (str.length + 1); return (str.length + 1);
} }
let n = 0, let n = 0,
pos = 0, pos = 0,
step = substr.length; step = substr.length;
while (true) { while (true) {
@ -120,7 +120,7 @@
*/ */
jsOMS.hash = function (str) jsOMS.hash = function (str)
{ {
let res = 0 let res = 0
const len = str.length; const len = str.length;
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {

View File

@ -65,7 +65,7 @@
jsOMS.removeClass = function (ele, cls) jsOMS.removeClass = function (ele, cls)
{ {
if (jsOMS.hasClass(ele, cls)) { if (jsOMS.hasClass(ele, cls)) {
const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)'); const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
ele.className = ele.className.replace(reg, ''); ele.className = ele.className.replace(reg, '');
} }
}; };
@ -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

@ -28,14 +28,14 @@
jsOMS.getArray = function(path, data, delim) jsOMS.getArray = function(path, data, delim)
{ {
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;
} }
@ -115,15 +115,15 @@
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.substr_count = function(str, substr) { jsOMS.substr_count = function(str, substr) {
str += ''; str += '';
substr += ''; substr += '';
if (substr.length <= 0) { if (substr.length <= 0) {
return (str.length + 1); return (str.length + 1);
} }
let n = 0, let n = 0,
pos = 0, pos = 0,
step = substr.length; step = substr.length;
while (true) { while (true) {
@ -193,7 +193,7 @@
jsOMS.removeClass = function (ele, cls) jsOMS.removeClass = function (ele, cls)
{ {
if (jsOMS.hasClass(ele, cls)) { if (jsOMS.hasClass(ele, cls)) {
const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)'); const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
ele.className = ele.className.replace(reg, ''); ele.className = ele.className.replace(reg, '');
} }
}; };
@ -294,7 +294,7 @@
*/ */
jsOMS.hash = function (str) jsOMS.hash = function (str)
{ {
let res = 0; let res = 0;
const len = str.length; const len = str.length;
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
@ -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,11 +129,11 @@
{ {
const form = document.getElementById(this.id); const form = document.getElementById(this.id);
if(!form) { if (!form) {
return []; return [];
} }
const selects = form.getElementsByTagName('select'), const selects = form.getElementsByTagName('select'),
textareas = form.getElementsByTagName('textarea'), textareas = form.getElementsByTagName('textarea'),
inputs = form.getElementsByTagName('input'), inputs = form.getElementsByTagName('input'),
canvas = form.getElementsByTagName('canvas'), canvas = form.getElementsByTagName('canvas'),
@ -151,14 +151,14 @@
*/ */
jsOMS.Views.FormView.prototype.getData = function () jsOMS.Views.FormView.prototype.getData = function ()
{ {
const data = {}, const data = {},
elements = this.getFormElements(), elements = this.getFormElements(),
length = elements.length; length = elements.length;
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;
@ -192,11 +192,15 @@
jsOMS.Views.FormView.prototype.isValid = function () jsOMS.Views.FormView.prototype.isValid = function ()
{ {
const elements = this.getFormElements(), const elements = this.getFormElements(),
length = elements.length; length = elements.length;
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;
} }
@ -276,7 +280,7 @@
this.action = e.action; this.action = e.action;
const elements = this.getFormElements(), const elements = this.getFormElements(),
length = elements.length; length = elements.length;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
switch (elements[i].tagName) { switch (elements[i].tagName) {
@ -305,7 +309,7 @@
jsOMS.Views.FormView.prototype.unbind = function () jsOMS.Views.FormView.prototype.unbind = function ()
{ {
const elements = this.getFormElements(), const elements = this.getFormElements(),
length = elements.length; length = elements.length;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
switch (elements[i].tagName) { switch (elements[i].tagName) {

View File

@ -4,7 +4,7 @@
jsOMS.ViewAbstract = function () jsOMS.ViewAbstract = function ()
{ {
this.element = null; this.element = null;
this.data = []; this.data = [];
}; };
jsOMS.ViewAbstract.prototype.bind = function (node) jsOMS.ViewAbstract.prototype.bind = function (node)
@ -14,9 +14,9 @@
jsOMS.ViewAbstract.prototype.addData = function(id, data, overwrite) jsOMS.ViewAbstract.prototype.addData = function(id, data, overwrite)
{ {
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;

View File

@ -64,7 +64,7 @@ describe('UriFactoryTest', function ()
{ {
it('Testing global queries', function () it('Testing global queries', function ()
{ {
let uri = 'www.test-uri.com?id={@ID}&test={.mTest}&two={/path}&hash={#hash}&none=#none&found={/not}&v={/valid2}', let uri = 'www.test-uri.com?id={@ID}&test={.mTest}&two={/path}&hash={#hash}&none=#none&found={/not}&v={/valid2}',
vars = { vars = {
'@ID' : 1, '@ID' : 1,
'.mTest': 'someString', '.mTest': 'someString',