Commit 1a588ebf authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

first code

parent 979ccc47
{"millisecond":{"datetime":[1488981600000,1488982500000,1488983400000,1488984300000,1488985200000,1488986100000,1488987000000,1488987900000,1488988800000,1488989700000,1488990600000,1488991500000,1488992400000,1488993300000,1488994200000,1488995100000,1488996000000,1488996900000,1488997800000,1488998700000,1488999600000,1489000500000,1489001400000,1489002300000,1489003200000,1489004100000,1489005000000,1489005900000,1489006800000,1489007700000,1489008600000,1489009500000,1489010400000,1489011300000,1489012200000,1489013100000,1489014000000,1489014900000,1489015800000,1489016700000,1489017600000,1489018500000,1489019400000,1489020300000,1489021200000,1489022100000,1489023000000,1489023900000,1489024800000]},"cubicmeter":{"volume":[111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111],"surface":[111,110.8,110.8,111,110.8,111,110.8,110.8,111,111,110.8,110.4,110.2,110.6,110.8,110.8,111,110.8,110.8,110.6,110.8,110.6,110.8,110.8,110.8,111,111,111,110.8,111,111,110.8,111,111,111,111,111,111,111,111,111,111,111,111,110.8,110.8,110.6,111,111],"dispersed":[0,0.2,0.2,0,0.2,0,0.2,0.2,0,0,0.2,0.6,0.8,0.4,0.2,0.2,0,0.2,0.2,0.4,0.2,0.4,0.2,0.2,0.2,0,0,0,0.2,0,0,0.2,0,0,0,0,0,0,0,0,0,0,0,0,0.2,0.2,0.4,0,0],"seabed":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"shore":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"percentage":{"evaporated":[40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40],"surface":[60,59.9,59.9,60,59.9,60,59.9,59.9,60,60,59.9,59.7,59.6,59.8,59.9,59.9,60,59.9,59.9,59.8,59.9,59.8,59.9,59.9,59.9,60,60,60,59.9,60,60,59.9,60,60,60,60,60,60,60,60,60,60,60,60,59.9,59.9,59.8,60,60],"dispersed":[0,0.1,0.1,0,0.1,0,0.1,0.1,0,0,0.1,0.3,0.4,0.2,0.1,0.1,0,0.1,0.1,0.2,0.1,0.2,0.1,0.1,0.1,0,0,0,0.1,0,0,0.1,0,0,0,0,0,0,0,0,0,0,0,0,0.1,0.1,0.2,0,0],"seabed":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"shore":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"watercontent":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"knot":{"current":[0.15,0.15,0.15,0.15,0.16,0.16,0.24,0.24,0.23,0.23,0.23,0.23,0.22,0.22,0.22,0.22,0.21,0.2,0.2,0.2,0.19,0.19,0.19,0.19,0.17,0.17,0.17,0.17,0.16,0.17,0.25,0.25,0.25,0.25,0.25,0.24,0.25,0.25,0.25,0.24,0.27,0.27,0.27,0.26,0.3,0.29,0.29,0.29,0.32]},"degree":{"current":[20,20,20,21,25,25,16,16,20,20,20,20,24,24,25,25,27,27,28,28,28,28,28,29,29,29,29,29,24,29,18,18,13,13,13,13,7,7,7,7,4,4,4,4,5,5,5,5,4],"wind":[229,229,229,229,228,228,228,228,225,225,225,225,222,222,222,222,217,217,217,217,211,211,211,211,209,209,209,209,198,200,200,200,186,186,186,186,181,181,181,181,190,190,190,190,190,190,190,190,181]},"meterpersecond":{"wind":[10.8,10.8,10.8,10.8,10.6,10.6,10.7,10.7,10.6,10.6,10.6,10.6,10.6,10.6,10.6,10.6,10.4,10.4,10.4,10.4,10,10,10,10,9.2,9.2,9.2,9.2,8.7,8.8,8.8,8.8,7.9,7.9,7.9,7.9,7.6,7.6,7.6,7.6,8.7,8.7,8.7,8.7,9.4,9.4,9.4,9.4,10]},"cst":{"viscosity":[4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2,4366.2]},"kilopercubicmeter":{"density":[950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950,950]}}
\ No newline at end of file
......@@ -32,18 +32,20 @@
var graphDiv = document.createElement("DIV");
var graphbutton = document.createElement("BUTTON");
var t = document.createTextNode("Graph");
var id = '39e8929d-8d9d-4b0f-b95b-61361bd7446e';
var graphid = "graph" + id;
graphbutton.setAttribute('data-uk-modal', "{target:'#" + graphid + "'}");
graphbutton.appendChild(t);
graphbutton.onclick = function() {
var language = "en";
var langData = {
"tTitle" : "Graph"
};
var graph = new Graph(graphDiv, {
"lang" : language,
"langdata" : langData
});
var language = "en";
var langData = {
"tTitle" : "Graph"
};
var graph = new Graph(graphid, {
"lang" : language,
"langdata" : langData
});
document.body.appendChild(graphbutton);
</script>
......
.graph-modal {
font: 400 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif;
font-family: "Proxima Nova", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
\ No newline at end of file
......@@ -3,7 +3,7 @@
/// <reference path="def/reqwest.d.ts" />
/// <reference path="def/jquery.dataTables.d.ts" />
var Graph = (function () {
function Graph(graphDivId, options) {
function Graph(id, options) {
var self = this;
this.lang = "en";
if (options.lang) {
......@@ -13,7 +13,7 @@ var Graph = (function () {
this.langData = options.langdata;
}
if (self.langData) {
self.setup(self.langData.tTitle, graphDivId);
self.setup(self.langData.tTitle, id);
}
else {
reqwest({
......@@ -22,14 +22,38 @@ var Graph = (function () {
type: 'json',
success: function (lang) {
self.langData = lang;
self.setup(self.langData.tTitle, graphDivId);
self.setup(self.langData.tTitle, id);
}
});
}
}
Graph.prototype.setup = function (title, graphDivId) {
Graph.prototype.createDom = function (type, classString, parent) {
var element = document.createElement(type);
var classes = classString.split(' ');
for (var i = 0; i < classes.length; i++) {
if (classes[i] && classes[i] !== '')
element.classList.add(classes[i]);
}
if (parent)
parent.appendChild(element);
return element;
};
Graph.prototype.setup = function (title, id) {
var self = this;
self.graphDiv = document.getElementById(graphDivId);
var graphDiv = document.createElement("DIV");
var graphModal = self.createDom('div', 'uk-modal graph-modal uk-form');
graphModal.id = id;
// places it outside to avoid conflicts with positioning
$(graphModal).appendTo('body');
var dialog = self.createDom('div', 'uk-modal-dialog', graphModal);
var close = self.createDom('button', 'uk-modal-close uk-close', dialog);
var mainDiv = self.createDom('div', '', dialog);
var headerTxt = self.createDom('span', '', mainDiv);
headerTxt.innerHTML = "<b>Graph</b><br><p>";
var bodyDiv = self.createDom('div', '', mainDiv);
var footer = self.createDom('div', 'uk-modal-footer uk-text-right', dialog);
var okDialogButton = self.createDom('button', 'uk-button uk-modal-close', footer);
okDialogButton.textContent = "Ok";
};
return Graph;
}());
......
{"version":3,"file":"stw-padmws-graph.js","sourceRoot":"","sources":["stw-padmws-graph.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,wCAAw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AAC,SAAS,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QAEjE,IAAI,MAAM,GAAmB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,+BAA+B,EAAE,MAAM,CAAC,CAAC;QAC5F,IAAI,cAAc,GAAsB,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,0BAA0B,EAAE,MAAM,CAAC,CAAC;QACrG,cAAc,CAAC,WAAW,GAAG,IAAI,CAAC;IAGtC,CAAC;IACL,YAAC;AAAD,CAAC,AAlED,IAkEC"}
\ No newline at end of file
......@@ -7,11 +7,10 @@
class Graph {
private container: HTMLElement;
private graphDiv: HTMLDivElement;
private lang: string;
private langData: any;
constructor(graphDivId, options) {
constructor(id, options) {
var self = this;
this.lang = "en";
if (options.lang) {
......@@ -23,7 +22,7 @@ class Graph {
if (self.langData) {
self.setup(self.langData.tTitle, graphDivId);
self.setup(self.langData.tTitle, id);
} else {
reqwest({
url: "lang/graph." + self.lang + ".json",
......@@ -31,15 +30,44 @@ class Graph {
type: 'json',
success: function (lang) {
self.langData = lang;
self.setup(self.langData.tTitle, graphDivId);
self.setup(self.langData.tTitle, id);
}
});
}
}
private setup(title: string, graphDivId: string) {
private createDom(type : string, classString: string, parent?: any) {
var element = document.createElement(type);
var classes = classString.split(' ');
for (var i = 0; i < classes.length; i++) {
if (classes[i] && classes[i] !== '')
element.classList.add(classes[i]);
}
if (parent) parent.appendChild(element);
return element;
}
private setup(title: string, id: string) {
var self = this;
self.graphDiv = <HTMLDivElement>document.getElementById(graphDivId);
var graphDiv = document.createElement("DIV");
var graphModal = <HTMLDivElement>self.createDom('div', 'uk-modal graph-modal uk-form');
graphModal.id = id;
// places it outside to avoid conflicts with positioning
$(graphModal).appendTo('body');
var dialog = <HTMLDivElement>self.createDom('div', 'uk-modal-dialog', graphModal);
var close = <HTMLButtonElement>self.createDom('button', 'uk-modal-close uk-close', dialog);
var mainDiv = <HTMLDivElement>self.createDom('div', '', dialog);
var headerTxt = <HTMLSpanElement>self.createDom('span', '', mainDiv);
headerTxt.innerHTML = "<b>Graph</b><br><p>";
var bodyDiv = <HTMLDivElement>self.createDom('div', '', mainDiv);
var footer = <HTMLDivElement>self.createDom('div', 'uk-modal-footer uk-text-right', dialog);
var okDialogButton = <HTMLButtonElement>self.createDom('button', 'uk-button uk-modal-close', footer);
okDialogButton.textContent = "Ok";
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment