From a6f9aeebc952a26cd35ffd2998cf8a50d2c3b03b Mon Sep 17 00:00:00 2001
From: Dennis Eichhorn
Date: Sun, 29 Nov 2015 22:01:42 +0100
Subject: [PATCH] Init
---
Account/AccountManager.js | 80 +
Account/AccountType.enum.js | 16 +
Asset/AssetManager.js | 136 ++
Auth/Auth.js | 104 +
Chart/BarChart.js | 0
Chart/Chart.js | 67 +
Chart/ChartLegend.js | 47 +
Chart/DonutChart.js | 0
Chart/LineChart.js | 31 +
Chart/PieChart.js | 0
Chart/PositionEnum.js | 0
Config/Options.js | 94 +
Controllers/Form.js | 0
DataStorage/CacheManager.js | 6 +
DataStorage/CookieJar.js | 82 +
DataStorage/LocalStorage.js | 41 +
DataStorage/StorageManager.js | 5 +
Dispatcher/Dispatcher.js | 5 +
Event/EventManager.js | 4 +
Localization/README.md | 0
Math/MathProcessor.js | 138 ++
Media/Audio/UISound.js | 0
Media/README.md | 1 +
Message/Request/Request.js | 302 +++
Message/Request/RequestData.enum.js | 16 +
Message/Request/RequestManager.js | 24 +
Message/Request/RequestMethod.enum.js | 19 +
Message/Request/RequestType.enum.js | 16 +
Message/Response/ResponseManager.js | 75 +
Message/Response/ResponseResultType.enum.js | 19 +
Message/Response/ResponseType.enum.js | 20 +
Models/Account.js | 8 +
Module/ModuleFactory.js | 40 +
Module/ModuleManager.js | 47 +
Route/Route.js | 15 +
Security/Hash/Sha1.js | 58 +
Security/Hash/Sha1b.js | 84 +
Socket/Client/Client.js | 44 +
Stdlib/README.md | 0
System/README.md | 0
UI/FormManager.js | 408 ++++
UI/Input/InputManager.js | 5 +
UI/Input/Keyboard/KeyboardManager.js | 11 +
UI/Input/Math/Evaluator.class.js | 22 +
UI/Input/Mouse/ClickType.enum.js | 5 +
UI/Input/Mouse/MouseManager.js | 11 +
UI/LinkManager.js | 0
UI/Loader.js | 1 +
UI/TabManager.js | 77 +
UI/TableManager.js | 60 +
UI/UIManager.js | 100 +
Uri/Uri.js | 106 +
Uri/UriFactory.js | 3 +
Utils/Markdown/Markdown.js | 82 +
Utils/oLib.js | 271 +++
Validattion/ValidateDate.class.js | 0
Validattion/ValidateMath.class.js | 0
Validattion/ValidateNumber.class.js | 0
Validattion/ValidateString.class.js | 0
Validattion/Validation.js | 9 +
Views/FormView.js | 14 +
Views/TableView.js | 36 +
Views/ViewAbstract.js | 30 +
oms.min.js | 1979 +++++++++++++++++++
64 files changed, 4874 insertions(+)
create mode 100644 Account/AccountManager.js
create mode 100644 Account/AccountType.enum.js
create mode 100644 Asset/AssetManager.js
create mode 100644 Auth/Auth.js
create mode 100644 Chart/BarChart.js
create mode 100644 Chart/Chart.js
create mode 100644 Chart/ChartLegend.js
create mode 100644 Chart/DonutChart.js
create mode 100644 Chart/LineChart.js
create mode 100644 Chart/PieChart.js
create mode 100644 Chart/PositionEnum.js
create mode 100644 Config/Options.js
create mode 100644 Controllers/Form.js
create mode 100644 DataStorage/CacheManager.js
create mode 100644 DataStorage/CookieJar.js
create mode 100644 DataStorage/LocalStorage.js
create mode 100644 DataStorage/StorageManager.js
create mode 100644 Dispatcher/Dispatcher.js
create mode 100644 Event/EventManager.js
create mode 100644 Localization/README.md
create mode 100644 Math/MathProcessor.js
create mode 100644 Media/Audio/UISound.js
create mode 100644 Media/README.md
create mode 100644 Message/Request/Request.js
create mode 100644 Message/Request/RequestData.enum.js
create mode 100644 Message/Request/RequestManager.js
create mode 100644 Message/Request/RequestMethod.enum.js
create mode 100644 Message/Request/RequestType.enum.js
create mode 100644 Message/Response/ResponseManager.js
create mode 100644 Message/Response/ResponseResultType.enum.js
create mode 100644 Message/Response/ResponseType.enum.js
create mode 100644 Models/Account.js
create mode 100644 Module/ModuleFactory.js
create mode 100644 Module/ModuleManager.js
create mode 100644 Route/Route.js
create mode 100644 Security/Hash/Sha1.js
create mode 100644 Security/Hash/Sha1b.js
create mode 100644 Socket/Client/Client.js
create mode 100644 Stdlib/README.md
create mode 100644 System/README.md
create mode 100644 UI/FormManager.js
create mode 100644 UI/Input/InputManager.js
create mode 100644 UI/Input/Keyboard/KeyboardManager.js
create mode 100644 UI/Input/Math/Evaluator.class.js
create mode 100644 UI/Input/Mouse/ClickType.enum.js
create mode 100644 UI/Input/Mouse/MouseManager.js
create mode 100644 UI/LinkManager.js
create mode 100644 UI/Loader.js
create mode 100644 UI/TabManager.js
create mode 100644 UI/TableManager.js
create mode 100644 UI/UIManager.js
create mode 100644 Uri/Uri.js
create mode 100644 Uri/UriFactory.js
create mode 100644 Utils/Markdown/Markdown.js
create mode 100644 Utils/oLib.js
create mode 100644 Validattion/ValidateDate.class.js
create mode 100644 Validattion/ValidateMath.class.js
create mode 100644 Validattion/ValidateNumber.class.js
create mode 100644 Validattion/ValidateString.class.js
create mode 100644 Validattion/Validation.js
create mode 100644 Views/FormView.js
create mode 100644 Views/TableView.js
create mode 100644 Views/ViewAbstract.js
create mode 100644 oms.min.js
diff --git a/Account/AccountManager.js b/Account/AccountManager.js
new file mode 100644
index 0000000..3740d53
--- /dev/null
+++ b/Account/AccountManager.js
@@ -0,0 +1,80 @@
+/**
+ * Account Manager.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.AccountManager = function ()
+ {
+ this.accounts = [];
+ };
+
+ /**
+ * Add account.
+ *
+ * @param {Object} account Account
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.AccountManager.prototype.add = function (account)
+ {
+ this.accounts[account.getId()] = account;
+ };
+
+ /**
+ * Remove account.
+ *
+ * @param {int} id Account id
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.AccountManager.prototype.remove = function (id)
+ {
+ if (typeof this.accounts[id] !== 'undefined') {
+ delete this.accounts[id];
+
+ return true;
+ }
+
+ return false;
+ };
+
+ /**
+ * Get account by id.
+ *
+ * @param {int} id Account id
+ *
+ * @return {Object}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.AccountManager.prototype.get = function (id)
+ {
+ if (this.accounts[id]) {
+ return this.accounts[id];
+ }
+
+ return undefined;
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Account/AccountType.enum.js b/Account/AccountType.enum.js
new file mode 100644
index 0000000..b9a08f0
--- /dev/null
+++ b/Account/AccountType.enum.js
@@ -0,0 +1,16 @@
+/**
+ * Account type.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+ jsOMS.EnumAccountType = Object.freeze({
+ USER: 0,
+ GROUP: 1
+ });
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Asset/AssetManager.js b/Asset/AssetManager.js
new file mode 100644
index 0000000..3027740
--- /dev/null
+++ b/Asset/AssetManager.js
@@ -0,0 +1,136 @@
+/**
+ * Asset manager.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.AssetManager = function ()
+ {
+ this.assets = {};
+ };
+
+ /**
+ * Load asset.
+ *
+ * @param {string} path Asset path
+ * @param {string} filename Name of the asset
+ * @param {string} filetype Filetype of the asset
+ * @param {requestCallback} [callback] Callback after load
+ *
+ * @return {string}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.AssetManager.prototype.load = function (path, filename, filetype, callback)
+ {
+ var hash;
+
+ if (!this.assets[(hash = jsOMS.hash(path + '/' + filename))]) {
+ var fileref = null;
+
+ if (filetype === 'js') {
+ fileref = document.createElement('script');
+ fileref.setAttribute('type', 'text/javascript');
+ fileref.setAttribute('src', path + '/' + filename);
+
+ if (typeof fileref !== 'undefined') {
+ document.getElementsByTagName('head')[0].appendChild(fileref);
+ }
+
+ this.assets[hash] = path + '/' + filename;
+ } else if (filetype === 'css') {
+ fileref = document.createElement('link');
+ fileref.setAttribute('rel', 'stylesheet');
+ fileref.setAttribute('type', 'text/css');
+ fileref.setAttribute('href', path + '/' + filename);
+
+ if (typeof fileref !== 'undefined') {
+ document.getElementsByTagName('head')[0].appendChild(fileref);
+ }
+
+ this.assets[hash] = path + '/' + filename;
+ } else if (filetype === 'img') {
+ this.assets[hash] = new Image();
+ this.assets[hash].src = path + '/' + filename;
+ } else if (filetype === 'audio') {
+ // TODO: implement audio asset
+ } else if (filetype === 'video') {
+ // TODO: implement video asset
+ }
+
+ if (callback) {
+ fileref.onreadystatechange = function ()
+ {
+ if (this.readyState == 'complete') {
+ callback();
+ }
+ };
+
+ fileref.onload = callback();
+ }
+
+ return hash;
+ }
+
+ return false;
+ };
+
+ /**
+ * Get asset.
+ *
+ * @param {string} id Id of the asset (hash)
+ *
+ * @return
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.AssetManager.prototype.get = function (id)
+ {
+ if (this.assets[id]) {
+ return this.assets[id];
+ }
+
+ return undefined;
+ };
+
+ /**
+ * Remove asset.
+ *
+ * @param {string} key Key of the asset (hash)
+ *
+ * @return {bool}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.AssetManager.prototype.remove = function (key)
+ {
+ if (typeof this.assets[key] !== 'undefined') {
+ delete this.assets[key];
+
+ return true;
+ }
+
+ return false;
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Auth/Auth.js b/Auth/Auth.js
new file mode 100644
index 0000000..04d15b4
--- /dev/null
+++ b/Auth/Auth.js
@@ -0,0 +1,104 @@
+/**
+ * Auth class.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Auth = function (uri)
+ {
+ this.account = null;
+ this.uri = uri;
+ };
+
+ /**
+ * Set account for authentication.
+ *
+ * @param {Object} account Account
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Auth.prototype.setAccount = function (account)
+ {
+ this.account = account;
+ };
+
+ /**
+ * Get account.
+ *
+ * @return {Object}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Auth.prototype.getAccount = function ()
+ {
+ return this.account;
+ };
+
+ /**
+ * Login account.
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Auth.prototype.login = function ()
+ {
+ var authRequest = new jsOMS.Request();
+ authRequest.setUri(this.uri);
+ authRequest.setMethod(jsOMS.EnumRequestMethod.POST);
+ authRequest.setResponseType(jsOMS.EnumRequestType.JSON);
+ authRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+ authRequest.setSuccess(function (xhr)
+ {
+ this.loginResult(xhr);
+ });
+
+ authRequest.send();
+ };
+
+ /**
+ * Logout account.
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Auth.prototype.logout = function ()
+ {
+ location.reload();
+ };
+
+ /**
+ * Handle login result.
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Auth.prototype.loginResult = function (xhr)
+ {
+ console.log(xhr);
+ location.reload();
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/BarChart.js b/Chart/BarChart.js
new file mode 100644
index 0000000..e69de29
diff --git a/Chart/Chart.js b/Chart/Chart.js
new file mode 100644
index 0000000..4335f02
--- /dev/null
+++ b/Chart/Chart.js
@@ -0,0 +1,67 @@
+(function (jsOMS, undefined) {
+ jsOMS.Chart = function() {
+ this.title = null;
+ this.subtitle = null;
+ this.footer = null;
+ this.legend = null;
+ this.dataset = null;
+ this.dimension = {width: 100, height: 100, position: jsOMS.Chart.PositionEnum.RELATIVE};
+ this.margin = {top: 0, right: 0, bottom: 0, left: 0, position: jsOMS.Chart.PositionEnum.ABSOLUTE};
+ };
+
+ jsOMS.Chart.prototype.setDimension = function(dimension) {
+ this.dimension = dimension;
+ };
+
+ jsOMS.Chart.prototype.getDimension = function() {
+ return this.dimension;
+ };
+
+ jsOMS.Chart.prototype.setDimensionRelative = function(relative) {
+ this.relative = relative;
+ };
+
+ jsOMS.Chart.prototype.setTitle = function(title) {
+ this.title = title;
+ };
+
+ jsOMS.Chart.prototype.getTitle = function() {
+ return this.title;
+ };
+
+ jsOMS.Chart.prototype.setSubtitle = function(subtitle) {
+ this.subtitle = subtitle;
+ };
+
+ jsOMS.Chart.prototype.getSubtitle = function() {
+ return this.subtitle;
+ };
+
+ jsOMS.Chart.prototype.setFooter = function(footer) {
+ this.footer = footer;
+ };
+
+ jsOMS.Chart.prototype.getFooter = function() {
+ return this.footer;
+ };
+
+ jsOMS.Chart.prototype.setLegend = function(legend) {
+ this.legend = legend;
+ };
+
+ jsOMS.Chart.prototype.getLegend = function() {
+ if(!this.legend) {
+ this.legend = new jsOMS.ChartLegend();
+ }
+
+ return this.legend;
+ };
+
+ jsOMS.Chart.prototype.setDataset = function(dataset) {
+ this.dataset = dataset;
+ };
+
+ jsOMS.Chart.prototype.getDataset = function() {
+ return this.dataset;
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/ChartLegend.js b/Chart/ChartLegend.js
new file mode 100644
index 0000000..c3ea723
--- /dev/null
+++ b/Chart/ChartLegend.js
@@ -0,0 +1,47 @@
+(function (jsOMS, undefined) {
+ jsOMS.ChartLegend = function () {
+ this.position = {x: 0, y: 0};
+ this.relative = true;
+ this.horizontal = false;
+ this.visible = true;
+ this.labels = []; // {title, color, marker}
+ };
+
+ jsOMS.ChartLegend.prototype.addLabel = function(label) {
+ this.labels.push(label);
+ };
+
+ jsOMS.ChartLegend.prototype.setVisibility = function(visibility) {
+ this.visible = visibility;
+ };
+
+ jsOMS.ChartLegend.prototype.getVisibility = function() {
+ return this.visible;
+ };
+
+ jsOMS.ChartLegend.prototype.setPosition = function(position) {
+ this.position = position;
+ };
+
+ jsOMS.ChartLegend.prototype.getPosition = function() {
+ return this.position;
+ };
+
+ jsOMS.ChartLegend.prototype.setRelative = function(relative) {
+ this.relative = relative;
+ };
+
+ jsOMS.ChartLegend.prototype.isRelative = function() {
+ return this.relative;
+ };
+
+ jsOMS.ChartLegend.prototype.setHorizontal = function(horizontal) {
+ this.horizontal = horizontal;
+ };
+
+ jsOMS.ChartLegend.prototype.isHorizontal = function() {
+ return this.horizontal;
+ };
+
+
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/DonutChart.js b/Chart/DonutChart.js
new file mode 100644
index 0000000..e69de29
diff --git a/Chart/LineChart.js b/Chart/LineChart.js
new file mode 100644
index 0000000..5a41484
--- /dev/null
+++ b/Chart/LineChart.js
@@ -0,0 +1,31 @@
+(function (jsOMS, undefined) {
+ jsOMS.LineChart = function () {
+ this.chart = new jsOMS.Chart();
+ this.xIsDate = false;
+ this.yIsDate = false;
+ };
+
+ jsOMS.LineChart.prototype.setXDate = function(date) {
+ this.xIsDate = date;
+ };
+
+ jsOMS.LineChart.prototype.setYDate = function(date) {
+ this.yIsDate = date;
+ };
+
+ jsOMS.LineChart.prototype.draw = function() {
+ var x, y;
+
+ if(this.xIsDate) {
+ x = d3.time.scale().range([0, this.chart.getDimension().width]);
+ } else {
+ x = d3.scale.linear().range([0, this.chart.getDimension().width]);
+ }
+
+ if(this.yIsDate) {
+ y = d3.time.scale().range([this.chart.getDimension().height, 0]);
+ } else {
+ y = d3.scale.linear().range([this.chart.getDimension().height, 0]);
+ }
+ }
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/PieChart.js b/Chart/PieChart.js
new file mode 100644
index 0000000..e69de29
diff --git a/Chart/PositionEnum.js b/Chart/PositionEnum.js
new file mode 100644
index 0000000..e69de29
diff --git a/Config/Options.js b/Config/Options.js
new file mode 100644
index 0000000..3e404b8
--- /dev/null
+++ b/Config/Options.js
@@ -0,0 +1,94 @@
+/**
+ * Options class.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Options = function ()
+ {
+ this.options = {};
+ };
+
+ /**
+ * Set option.
+ *
+ * @param {int|string} key Option key
+ * @param {boo|int|float|string|Array} value Option value
+ * @param {bool} [overwrite=true] Overwrite value
+ *
+ * @param {bool}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Options.prototype.set = function (key, value, overwrite)
+ {
+ overwrite = typeof overwrite === bool ? overwrite : true;
+
+ if (overwrite || typeof this.options[key] === 'undefined') {
+ this.options[key] = value;
+
+ return true;
+ }
+
+ return false;
+ };
+
+ /**
+ * Get option.
+ *
+ * @param {int|string} key Option key
+ *
+ * @return {boo|int|float|string|Array}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Options.prototype.get = function (key)
+ {
+ if (typeof this.options[key] !== 'undefined') {
+ return this.options[key];
+ }
+
+ return undefined;
+ };
+
+ /**
+ * Remove option.
+ *
+ * @param {int|string} key Option key
+ *
+ * @return {boo}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Options.prototype.remove = function (key)
+ {
+ if (typeof this.options[key] !== 'undefined') {
+ delete this.options[key];
+
+ return true;
+ }
+
+ return false;
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Controllers/Form.js b/Controllers/Form.js
new file mode 100644
index 0000000..e69de29
diff --git a/DataStorage/CacheManager.js b/DataStorage/CacheManager.js
new file mode 100644
index 0000000..a8c888e
--- /dev/null
+++ b/DataStorage/CacheManager.js
@@ -0,0 +1,6 @@
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.CacheManager = function ()
+ {
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/DataStorage/CookieJar.js b/DataStorage/CookieJar.js
new file mode 100644
index 0000000..fd13695
--- /dev/null
+++ b/DataStorage/CookieJar.js
@@ -0,0 +1,82 @@
+/**
+ * CookieJar class.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.CookieJar = function ()
+ {
+ };
+
+ /**
+ * Saving data to cookie
+ *
+ * @param {string} cName Cookie name
+ * @param {string} value Value to save
+ * @param {number} exdays Lifetime for the cookie
+ * @param {string} domain Domain for the cookie
+ * @param {string} path Path for the cookie
+ *
+ * @return array
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.CookieJar.prototype.setCookie = function (cName, value, exdays, domain, path)
+ {
+ var exdate = new Date();
+ exdate.setDate(exdate.getDate() + exdays);
+ var cValue = encodeURI(value) + ((exdays === null) ? "" : "; expires=" + exdate.toUTCString()) + ";domain=" + domain + ";path=" + path;
+ document.cookie = cName + "=" + cValue;
+ };
+
+ /**
+ * Loading cookie data
+ *
+ * @param {string} cName Cookie name
+ *
+ * @return {string}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.CookieJar.prototype.getCookie = function (cName)
+ {
+ var cValue = document.cookie;
+ var cStart = cValue.indexOf(" " + cName + "=");
+
+ if (cStart === -1) {
+ cStart = cValue.indexOf(cName + "=");
+ }
+
+ if (cStart === -1) {
+ cValue = null;
+ } else {
+ cStart = cValue.indexOf("=", cStart) + 1;
+ var cEnd = cValue.indexOf(";", cStart);
+
+ if (cEnd === -1) {
+ cEnd = cValue.length;
+ }
+
+ cValue = decodeURI(cValue.substring(cStart, cEnd));
+ }
+ return cValue;
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/DataStorage/LocalStorage.js b/DataStorage/LocalStorage.js
new file mode 100644
index 0000000..5a4e7c2
--- /dev/null
+++ b/DataStorage/LocalStorage.js
@@ -0,0 +1,41 @@
+/**
+ * LocalStorage class.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.LocalStorage = function ()
+ {
+ };
+
+ /**
+ * Is local storage available?
+ *
+ * @return {boo}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.LocalStorage.prototype.available = function ()
+ {
+ try {
+ return 'localStorage' in window && window.localStorage !== null;
+ } catch (e) {
+ return false;
+ }
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/DataStorage/StorageManager.js b/DataStorage/StorageManager.js
new file mode 100644
index 0000000..6354a72
--- /dev/null
+++ b/DataStorage/StorageManager.js
@@ -0,0 +1,5 @@
+(function (jsOMS, undefined) {
+ jsOMS.StorageManager = function ()
+ {
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Dispatcher/Dispatcher.js b/Dispatcher/Dispatcher.js
new file mode 100644
index 0000000..7bb5da6
--- /dev/null
+++ b/Dispatcher/Dispatcher.js
@@ -0,0 +1,5 @@
+(function (jsOMS, undefined) {
+ jsOMS.Dispatcher = function ()
+ {
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Event/EventManager.js b/Event/EventManager.js
new file mode 100644
index 0000000..8a1617c
--- /dev/null
+++ b/Event/EventManager.js
@@ -0,0 +1,4 @@
+(function (jsOMS, undefined) {
+ jsOMS.EventManager = function () {
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Localization/README.md b/Localization/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/Math/MathProcessor.js b/Math/MathProcessor.js
new file mode 100644
index 0000000..b7efe97
--- /dev/null
+++ b/Math/MathProcessor.js
@@ -0,0 +1,138 @@
+//+ Jonas Raoni Soares Silva
+//@ http://jsfromhell.com/classes/math-processor [rev. #1]
+
+var MathProcessor = function () {
+ var o = this;
+ o.o = {
+ "+": function (a, b) {
+ return +a + b;
+ },
+ "-": function (a, b) {
+ return a - b;
+ },
+ "%": function (a, b) {
+ return a % b;
+ },
+ "/": function (a, b) {
+ return a / b;
+ },
+ "*": function (a, b) {
+ return a * b;
+ },
+ "^": function (a, b) {
+ return Math.pow(a, b);
+ },
+ "~": function (a, b) {
+ return Math.sqrt(a, b);
+ }
+ };
+ o.s = {"^": 3, "~": 3, "*": 2, "/": 2, "%": 1, "+": 0, "-": 0};
+ o.u = {"+": 1, "-": -1}, o.p = {"(": 1, ")": -1};
+};
+with ({p: MathProcessor.prototype}) {
+ p.methods = {
+ div: function (a, b) {
+ return parseInt(a / b);
+ },
+ fra: function (a) {
+ return a - parseInt(a);
+ },
+ sum: function (n1, n2, n3, n) {
+ for (var r = 0, a, l = (a = arguments).length; l; r += a[--l]) {
+ ;
+ }
+ return r;
+ },
+ medium: function (n1, n2, n3, n) {
+ for (var r = 0, a, l = (a = arguments).length; l; r += a[--l]) {
+ ;
+ }
+ return r / a.length;
+ }
+ };
+ p.parse = function (e) {
+ for (var n, x, _ = this, o = [], s = [x = _.RPN(e.replace(/ /g, "").split(""))]; s.length;) {
+ for ((n = s[s.length - 1], --s.length); n[2]; o[o.length] = n, s[s.length] = n[3], n = n[2]) {
+ ;
+ }
+ }
+ for (; (n = o.pop()) != undefined; n[0] = _.o[n[0]](isNaN(n[2][0]) ? _.f(n[2][0]) : n[2][0], isNaN(n[3][0]) ? _.f(n[3][0]) : n[3][0])) {
+ ;
+ }
+ return +x[0];
+ };
+ p.RPN = function (e) {
+ var x, r, _ = this, c = r = [, , , 0];
+ if (e[0] in _.u || !e.unshift("+")) {
+ for (; e[1] in _.u; e[0] = _.u[e.shift()] * _.u[e[0]] + 1 ? "+" : "-") {
+ ;
+ }
+ }
+ (c[3] = [_.u[e.shift()], c, , 0])[1][0] = "*", (r = [, , c, 0])[2][1] = r;
+ (c[2] = _.v(e))[1] = c;
+ (!e.length && (r = c)) || (e[0] in _.s && ((c = r)[0] = e.shift(), !e.length && _.error()));
+ while (e.length) {
+ if (e[0] in _.u) {
+ for (; e[1] in _.u; e[0] = _.u[e.shift()] * _.u[e[0]] + 1 ? "+" : "-") {
+ ;
+ }
+ (c = c[3] = ["*", c, , 0])[2] = [-1, c, , 0];
+ }
+ (c[3] = _.v(e))[1] = c;
+ e[0] in _.s && (c = _.s[e[0]] > _.s[c[0]] ?
+ ((c[3] = (x = c[3], c[2]))[1][2] = [e.shift(), c, x, 0])[2][1] = c[2]
+ : r == c ? (r = [e.shift(), , c, 0])[2][1] = r
+ : ((r[2] = (x = r[2], [e.shift(), r, , 0]))[2] = x)[1] = r[2]);
+ }
+ return r;
+ };
+ p.v = function (e) {
+ var i, j, l, _ = this;
+ if ("0123456789.".indexOf(e[0]) + 1) {
+ for (i = -1, l = e.length; ++i < l && "0123456789.".indexOf(e[i]) + 1;) {
+ ;
+ }
+ return [+e.splice(0, i).join(""), , , 0];
+ }
+ else if (e[0] == "(") {
+ for (i = 0, l = e.length, j = 1; ++i < l && (e[i] in _.p && (j += _.p[e[i]]), j);) {
+ ;
+ }
+ return _.RPN(l = e.splice(0, i), l.shift(), !j && e.shift());
+ }
+ else {
+ if (((j = e[0].toLowerCase()) >= "a" && j <= "z") || j == "_") {
+ for (i = 0; ((j = e[++i].toLowerCase()) >= "a" && j <= "z") || j == "_" || (j >= 0 && j <= 9);) {
+ ;
+ }
+ if (j == "(") {
+ for (var l = e.length, j = 1; ++i < l && (e[i] in _.p && (j += _.p[e[i]]), j);) {
+ ;
+ }
+ return [e.splice(0, i + 1).join(""), , , 0];
+ }
+ }
+ }
+ _.error();
+ };
+ p.f = function (e) {
+ var n, i = 0, _ = this;
+ if (((e = e.split(""))[i] >= "a" && e[i] <= "z") || e[i] == "_") {
+ while ((e[++i] >= "a" && e[i] <= "z") || e[i] == "_" || (e[i] >= 0 && e[i] <= 9)) {
+ ;
+ }
+ if (e[i] == "(") {
+ !_.methods[n = e.splice(0, i).join("")] && _.error("Function \"" + n + "\" not found"), e.shift();
+ for (var a = [], i = -1, j = 1; e[++i] && (e[i] in _.p && (j += _.p[e[i]]), j);) {
+ j == 1 && e[i] == "," && (a.push(_.parse(e.splice(0, i).join(""))), e.shift(), i = -1);
+ }
+ a.push(_.parse(e.splice(0, i).join(""))), !j && e.shift();
+ }
+ return _.methods[n].apply(_, a);
+ }
+ };
+ p.error = function (s) {
+ return;
+ //throw new Error("MathProcessor: " + (s || "Wrong expression"));
+ };
+}
diff --git a/Media/Audio/UISound.js b/Media/Audio/UISound.js
new file mode 100644
index 0000000..e69de29
diff --git a/Media/README.md b/Media/README.md
new file mode 100644
index 0000000..27f632f
--- /dev/null
+++ b/Media/README.md
@@ -0,0 +1 @@
+# Media #
diff --git a/Message/Request/Request.js b/Message/Request/Request.js
new file mode 100644
index 0000000..336dcd1
--- /dev/null
+++ b/Message/Request/Request.js
@@ -0,0 +1,302 @@
+/**
+ * Request class.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request = function ()
+ {
+ this.uri = null;
+ this.method = null;
+ this.requestHeader = [];
+ this.success = null;
+ this.type = jsOMS.EnumRequestMethod.GET;
+ this.data = {};
+
+ this.xhr = new XMLHttpRequest();
+ };
+
+ /**
+ * Set request method.
+ *
+ * EnumRequestMethod
+ *
+ * @param {string} method Method type
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.setMethod = function (method)
+ {
+ this.method = method;
+ };
+
+ /**
+ * Get request method.
+ *
+ * EnumRequestMethod
+ *
+ * @return {string}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.getMethod = function ()
+ {
+ return this.method;
+ };
+
+ /**
+ * Set response type.
+ *
+ * EnumResponseType
+ *
+ * @param {string} method Method type
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.setResponseType = function (type)
+ {
+ this.xhr.responseType = type;
+ };
+
+ /**
+ * Get response type.
+ *
+ * EnumResponseType
+ *
+ * @return {string}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.getResponseType = function ()
+ {
+ return this.responseType;
+ };
+
+ /**
+ * Set request header.
+ *
+ * @param {string} type Request type
+ * @param {string} header Request header
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.setRequestHeader = function (type, header)
+ {
+ this.requestHeader[type] = header;
+ };
+
+ /**
+ * Get request header.
+ *
+ * @return {string}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.getRequestHeader = function ()
+ {
+ return this.requestHeader;
+ };
+
+ /**
+ * Set request uri.
+ *
+ * @param {string} uri Request uri
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.setUri = function (uri)
+ {
+ this.uri = uri;
+ };
+
+ /**
+ * Get request uri.
+ *
+ * @return {string}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.getUri = function ()
+ {
+ return this.uri;
+ };
+
+ /**
+ * Set success callback.
+ *
+ * @param {requestCallback} success Success callback
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.setSuccess = function (callback)
+ {
+ this.success = callback;
+ };
+
+ /**
+ * Set request data.
+ *
+ * @param {Array} data Request data
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.setData = function (data)
+ {
+ this.data = data;
+ };
+
+ /**
+ * Get request data.
+ *
+ * @return {Array}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.getData = function ()
+ {
+ return this.data
+ };
+
+ /**
+ * Set request type.
+ *
+ * EnumRequestType
+ *
+ * @param {string} method Method type
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.setType = function (type)
+ {
+ this.type = type;
+ };
+
+ /**
+ * Get request type.
+ *
+ * EnumRequestType
+ *
+ * @return {string}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.getType = function ()
+ {
+ return this.type;
+ };
+
+ /**
+ * Create query from object.
+ *
+ * @return {string}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.queryfy = function (obj)
+ {
+ var str = [];
+ for (var p in obj) {
+ if (obj.hasOwnProperty(p)) {
+ str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
+ }
+ }
+ return str.join("&");
+ };
+
+ /**
+ * Get request data.
+ *
+ * @return {Array}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Request.prototype.send = function ()
+ {
+ var self = this;
+
+ if (self.xhr.readyState !== 1) {
+ self.xhr.open(this.method, this.uri);
+
+ for (var p in this.requestHeader) {
+ if (this.requestHeader.hasOwnProperty(p)) {
+ self.xhr.setRequestHeader(p, this.requestHeader[p]);
+ }
+ }
+ }
+
+ self.xhr.onreadystatechange = function ()
+ {
+ if (self.xhr.readyState === 4 && self.xhr.status === 200) {
+ self.success(self.xhr);
+ }
+ };
+
+ if (this.type === jsOMS.EnumRequestType.JSON) {
+ if (typeof this.requestHeader !== 'undefined' && this.requestHeader['Content-Type'] === 'application/json') {
+ console.log(JSON.stringify(this.data));
+ self.xhr.send(JSON.stringify(this.data));
+ } else {
+ self.xhr.send(this.queryfy(this.data));
+ }
+ } else if (this.type === jsOMS.EnumRequestType.RAW) {
+ self.xhr.send(this.data);
+ }
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Message/Request/RequestData.enum.js b/Message/Request/RequestData.enum.js
new file mode 100644
index 0000000..b866749
--- /dev/null
+++ b/Message/Request/RequestData.enum.js
@@ -0,0 +1,16 @@
+/**
+ * Request data enum.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+ jsOMS.EnumLinkRequestData = Object.freeze({
+ NORMAL: 'normal',
+ OBJECT: 'object'
+ });
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Message/Request/RequestManager.js b/Message/Request/RequestManager.js
new file mode 100644
index 0000000..16002ea
--- /dev/null
+++ b/Message/Request/RequestManager.js
@@ -0,0 +1,24 @@
+/**
+ * Request manager class.
+ *
+ * Used for pooling requests.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.RequestManager = function ()
+ {
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Message/Request/RequestMethod.enum.js b/Message/Request/RequestMethod.enum.js
new file mode 100644
index 0000000..fc9ccfd
--- /dev/null
+++ b/Message/Request/RequestMethod.enum.js
@@ -0,0 +1,19 @@
+/**
+ * Http request method.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+ jsOMS.EnumRequestMethod = Object.freeze({
+ POST: 'POST',
+ GET: 'GET',
+ PUT: 'PUT',
+ DELETE: 'DELETE',
+ HEAD: 'HEAD'
+ });
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Message/Request/RequestType.enum.js b/Message/Request/RequestType.enum.js
new file mode 100644
index 0000000..d08817d
--- /dev/null
+++ b/Message/Request/RequestType.enum.js
@@ -0,0 +1,16 @@
+/**
+ * Request type enum.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+ jsOMS.EnumRequestType = Object.freeze({
+ JSON: 'json',
+ RAW: 'raw'
+ });
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Message/Response/ResponseManager.js b/Message/Response/ResponseManager.js
new file mode 100644
index 0000000..ff9cb1c
--- /dev/null
+++ b/Message/Response/ResponseManager.js
@@ -0,0 +1,75 @@
+/**
+ * Response manager class.
+ *
+ * Used for auto handling different responses.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.ResponseManager = function ()
+ {
+ this.messages = {};
+ };
+
+ /**
+ * Add response handler.
+ *
+ * This allows the response handler to generally handle responses and also handle specific requests if defined.
+ *
+ * @param {string} key Response key
+ * @param {requestCallback} message Callback for message
+ * @param {string} [request=any] Request id in order to only handle a specific request
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.ResponseManager.prototype.add = function (key, message, request)
+ {
+ request = typeof request !== 'undefined' ? request : 'any';
+ if (typeof this.messages[key] === 'undefined') {
+ this.messages[key] = [];
+ }
+
+ this.messages[key][request] = message;
+ };
+
+ /**
+ * Execute a predefined callback.
+ *
+ * Tries to execute a request specific callback or otherwise a general callback if defined.
+ *
+ * @param {string} key Response key
+ * @param {Array|Object} data Date to use in callback
+ * @param {string} [request] Request id for request specific execution
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.ResponseManager.prototype.execute = function (key, data, request)
+ {
+ console.log(data);
+ if (typeof request !== 'undefined' && typeof this.messages[key][request] !== 'undefined') {
+ this.messages[key][request](data);
+ } else if (typeof this.messages[key] !== 'undefined') {
+ this.messages[key].any(data);
+ } else {
+ console.log('does not exist');
+ }
+ }
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Message/Response/ResponseResultType.enum.js b/Message/Response/ResponseResultType.enum.js
new file mode 100644
index 0000000..6b71086
--- /dev/null
+++ b/Message/Response/ResponseResultType.enum.js
@@ -0,0 +1,19 @@
+/**
+ * Response result type enum.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+ jsOMS.EnumResponseResultType = Object.freeze({
+ MULTI: 0,
+ MESSAGE: 1,
+ INFO: 2,
+ DATA: 3,
+ LIST: 4
+ });
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Message/Response/ResponseType.enum.js b/Message/Response/ResponseType.enum.js
new file mode 100644
index 0000000..83cd396
--- /dev/null
+++ b/Message/Response/ResponseType.enum.js
@@ -0,0 +1,20 @@
+/**
+ * Response type enum.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+ jsOMS.EnumResponseType = Object.freeze({
+ TEXT: 'text',
+ JSON: 'json',
+ DOCUMENT: 'document',
+ BLOB: 'blob',
+ ARRAYBUFFER: 'arraybuffer',
+ DEFAULT: ''
+ });
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Models/Account.js b/Models/Account.js
new file mode 100644
index 0000000..6a1a8e1
--- /dev/null
+++ b/Models/Account.js
@@ -0,0 +1,8 @@
+(function (jsOMS, undefined) {
+ jsOMS.Account = function () {
+ this.login = '';
+ this.password = '';
+ this.id = 0;
+ this.auth = null;
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Module/ModuleFactory.js b/Module/ModuleFactory.js
new file mode 100644
index 0000000..6b7e038
--- /dev/null
+++ b/Module/ModuleFactory.js
@@ -0,0 +1,40 @@
+/**
+ * Module factory.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.ModuleFactory = function ()
+ {
+ };
+
+ /**
+ * Get module instance.
+ *
+ * @param {string} module Module name
+ * @param {Object} app Application reference
+ *
+ * @return {Object}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.ModuleFactory.getInstance = function (module, app)
+ {
+ return new window['jsOMS']['Modules'][module](app);
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Module/ModuleManager.js b/Module/ModuleManager.js
new file mode 100644
index 0000000..91b190b
--- /dev/null
+++ b/Module/ModuleManager.js
@@ -0,0 +1,47 @@
+/**
+ * Module factory.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+ jsOMS.Modules = {};
+ jsOMS.Modules.Models = {};
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.ModuleManager = function (app)
+ {
+ this.modules = {};
+ this.app = app;
+ };
+
+ /**
+ * Get module.
+ *
+ * @param {string} module Module name
+ *
+ * @return {Object}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.ModuleManager.prototype.get = function (module)
+ {
+ if (this.modules[module] === 'undefined') {
+ this.modules[module] = jsOMS.ModuleFactory.getInstance(module, this.app);
+ }
+
+ return this.modules[module];
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Route/Route.js b/Route/Route.js
new file mode 100644
index 0000000..a52310a
--- /dev/null
+++ b/Route/Route.js
@@ -0,0 +1,15 @@
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.Route = function ()
+ {
+ this.routes = null;
+ };
+
+ // TODO: create comments
+ jsOMS.Route.prototype.add = function (path, callback, exact)
+ {
+ exact = typeof exact !== 'undefined' ? exact : true;
+
+ // todo: create array key path like i did for php
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Security/Hash/Sha1.js b/Security/Hash/Sha1.js
new file mode 100644
index 0000000..64035e8
--- /dev/null
+++ b/Security/Hash/Sha1.js
@@ -0,0 +1,58 @@
+SHA1 = function (l)
+{
+ function p(b, a)
+ {
+ return b << a | b >>> 32 - a
+ }
+
+ l += '';
+ for (var n = Math, c = [1518500249, 1859775393, 2400959708, 3395469782, 1732584193, 4023233417, 2562383102, 271733878, 3285377520, 4294967295], s = n.ceil(l.length / 4) + 2, q = n.ceil(s / 16), g = [], a = 0, h = [], j, d, e, f, m, i, b, k; a < q; a++) {
+ g[a] = [];
+ for (k = 0; k < 16; k++) {
+ function o(b, c)
+ {
+ return l.charCodeAt(a * 64 + k * 4 + b) << c
+ }
+
+ g[a][k] = o(0, 24) | o(1, 16) | o(2, 8) | o(3, 0)
+ }
+ }
+ i = l.length * 8 - 8;
+ a = q - 1;
+ g[a][14] = i / (c[9] + 1);
+ g[a][14] = n.floor(g[a][14]);
+ g[a][15] = i & c[9];
+ for (a = 0; a < q; a++) {
+ for (b = 0; b < 16; b++) {
+ h[b] = g[a][b];
+ }
+ for (b = 16; b < 80; b++) {
+ h[b] = p(h[b - 3] ^ h[b - 8] ^ h[b - 14] ^ h[b - 16], 1);
+ }
+ j = c[4];
+ d = c[5];
+ e = c[6];
+ f = c[7];
+ m = c[8];
+ for (b = 0; b < 80; b++) {
+ var r = n.floor(b / 20), t = p(j, 5) + (r < 1 ? d & e ^ ~d & f : r == 2 ? d & e ^ d & f ^ e & f : d ^ e ^ f) + m + c[r] + h[b] & c[9];
+ m = f;
+ f = e;
+ e = p(d, 30);
+ d = j;
+ j = t
+ }
+ c[4] += j;
+ c[5] += d;
+ c[6] += e;
+ c[7] += f;
+ c[8] += m
+ }
+ i = "";
+ for (z = 4; z < 9; z++) {
+ for (a = 7; a >= 0; a--) {
+ i += ((c[z] & c[9]) >>> a * 4 & 15).toString(16);
+ }
+ }
+ return i;
+};
diff --git a/Security/Hash/Sha1b.js b/Security/Hash/Sha1b.js
new file mode 100644
index 0000000..c772009
--- /dev/null
+++ b/Security/Hash/Sha1b.js
@@ -0,0 +1,84 @@
+function SHA1(s)
+{
+ function U(a, b, c)
+ {
+ while (0 < c--) {
+ a.push(b)
+ }
+ }
+
+ function L(a, b)
+ {
+ return (a << b) | (a >>> (32 - b))
+ }
+
+ function P(a, b, c)
+ {
+ return a ^ b ^ c
+ }
+
+ function A(a, b)
+ {
+ var c = (b & 0xFFFF) + (a & 0xFFFF), d = (b >>> 16) + (a >>> 16) + (c >>> 16);
+ return ((d & 0xFFFF) << 16) | (c & 0xFFFF)
+ }
+
+ var B = '0123456789abcdef';
+ return (function (a)
+ {
+ var c = [], d = a.length * 4, e;
+ for (var i = 0; i < d; i++) {
+ e = a[i >> 2] >> ((3 - (i % 4)) * 8);
+ c.push(B.charAt((e >> 4) & 0xF) + B.charAt(e & 0xF))
+ }
+ return c.join('')
+ }((function (a, b)
+ {
+ var c, d, e, f, g, h = a.length, v = 0x67452301, w = 0xefcdab89, x = 0x98badcfe, y = 0x10325476, z = 0xc3d2e1f0, M = [];
+ U(M, 0x5a827999, 20);
+ U(M, 0x6ed9eba1, 20);
+ U(M, 0x8f1bbcdc, 20);
+ U(M, 0xca62c1d6, 20);
+ a[b >> 5] |= 0x80 << (24 - (b % 32));
+ a[(((b + 65) >> 9) << 4) + 15] = b;
+ for (var i = 0; i < h; i += 16) {
+ c = v;
+ d = w;
+ e = x;
+ f = y;
+ g = z;
+ for (var j = 0, O = []; j < 80; j++) {
+ O[j] = j < 16 ? a[j + i] : L(O[j - 3] ^ O[j - 8] ^ O[j - 14] ^ O[j - 16], 1);
+ var k = (function (a, b, c, d, e)
+ {
+ var f = (e & 0xFFFF) + (a & 0xFFFF) + (b & 0xFFFF) + (c & 0xFFFF) + (d & 0xFFFF), g = (e >>> 16) + (a >>> 16) + (b >>> 16) + (c >>> 16) + (d >>> 16) + (f >>> 16);
+ return ((g & 0xFFFF) << 16) | (f & 0xFFFF)
+ })(j < 20 ? (function (t, a, b)
+ {
+ return (t & a) ^ (~t & b)
+ }(d, e, f)) : j < 40 ? P(d, e, f) : j < 60 ? (function (t, a, b)
+ {
+ return (t & a) ^ (t & b) ^ (a & b)
+ }(d, e, f)) : P(d, e, f), g, M[j], O[j], L(c, 5));
+ g = f;
+ f = e;
+ e = L(d, 30);
+ d = c;
+ c = k
+ }
+ v = A(v, c);
+ w = A(w, d);
+ x = A(x, e);
+ y = A(y, f);
+ z = A(z, g)
+ }
+ return [v, w, x, y, z]
+ }((function (t)
+ {
+ var a = [], b = 255, c = t.length * 8;
+ for (var i = 0; i < c; i += 8) {
+ a[i >> 5] |= (t.charCodeAt(i / 8) & b) << (24 - (i % 32))
+ }
+ return a
+ }(s)).slice(), s.length * 8))))
+}
diff --git a/Socket/Client/Client.js b/Socket/Client/Client.js
new file mode 100644
index 0000000..a5e6e60
--- /dev/null
+++ b/Socket/Client/Client.js
@@ -0,0 +1,44 @@
+(function (jsOMS, undefined) {
+ jsOMS.Client = function () {
+ this.port = 80;
+ this.ip = '127.0.0.1';
+ this.protocol = '';
+ this.connection = null;
+ this.messages = [];
+ };
+
+ jsOMS.Client.prototype.setMessage = function(id, callback) {
+ this.messages[id] = callback;
+ };
+
+ jsOMS.Client.prototype.setIp = function(ip) {
+ this.ip = ip;
+ };
+
+ jsOMS.Client.prototype.setPort = function(port) {
+ this.port = port;
+ };
+
+ jsOMS.Client.prototype.setProtocol = function(protocol) {
+ this.protocol = protocol;
+ };
+
+ jsOMS.Client.prototype.connect = function() {
+ var self = this;
+ this.connection = new WebSocket(this.ip, this.protocol);
+
+ this.connection.onmessage = function(event) {
+ var msg = JSON.parse(event.data);
+
+ self.messages[msg.type](msg);
+ }
+ };
+
+ jsOMS.Client.prototype.send = function(msg) {
+ this.connection.send(JSON.stringify(msg));
+ };
+
+ jsOMS.Client.prototype.close = function() {
+ this.connection.close();
+ }
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Stdlib/README.md b/Stdlib/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/System/README.md b/System/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/UI/FormManager.js b/UI/FormManager.js
new file mode 100644
index 0000000..56f32e4
--- /dev/null
+++ b/UI/FormManager.js
@@ -0,0 +1,408 @@
+/**
+ * Form manager class.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.FormManager = function (responseManager)
+ {
+ this.responseManager = responseManager;
+ this.ignore = [];
+ this.success = [];
+ this.injectSelector = [];
+ };
+
+ /**
+ * Ignore form from handling.
+ *
+ * @param {string} [id] Form id
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.FormManager.prototype.ignore = function (id)
+ {
+ this.ignore.push(id);
+ };
+
+ /**
+ * Add submit callback.
+ *
+ * Used for calling callback before form is submitted. If there is a submit injection the injection itself has to execute the submit since only the injection knows when it finished.
+ *
+ * @todo: maybe let the injected callback call a continue() function in here which then continues the form submit process.
+ *
+ * @param {string} selector Form id
+ * @param {requestCallback} callback Callback to execute before submit
+ *
+ * @return {bool}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.FormManager.prototype.injectSubmit = function (selector, callback)
+ {
+ if (!(selector in this.injectSelector)) {
+ this.injectSelector[selector] = callback;
+
+ return true;
+ }
+
+ return false;
+ };
+
+ /**
+ * Set success callback for form.
+ *
+ * @param {string} id Form id
+ * @param {requestCallback} callback Callback for success
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.FormManager.prototype.setSuccess = function (id, callback)
+ {
+ this.success[id] = callback;
+ };
+
+ /**
+ * Bind form.
+ *
+ * @param {string} [id] Form id
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.FormManager.prototype.bind = function (id)
+ {
+ if (typeof id !== 'undefined' && this.ignore.indexOf(id) === -1) {
+ this.bindElement(document.getElementById(id));
+ } else {
+ var forms = document.getElementsByTagName('form');
+
+ for (var i = 0; i < forms.length; i++) {
+ if (this.ignore.indexOf(forms[i].id) === -1) {
+ this.bindElement(forms[i]);
+ }
+ }
+ }
+ };
+
+ /**
+ * Validating form element.
+ *
+ * @param {Object} e Form element
+ *
+ * @return {bool}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.FormManager.prototype.validateFormElement = function (e)
+ {
+ /** Validate on change */
+ if (typeof e.dataset.validate !== 'undefined') {
+ if (!(new RegExp(e.dataset.validate)).test(e.value)) {
+ return false;
+ }
+ }
+
+ return true;
+ };
+
+ /**
+ * Submit data.
+ *
+ * @param {Object} e Form element
+ * @param {Object} data Data to submit
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.FormManager.prototype.submit = function (e, data)
+ {
+ var request = new jsOMS.Request(),
+ self = this;
+
+ request.setData(data);
+ request.setType('json');
+ request.setUri(e.action);
+ request.setMethod(e.method);
+ request.setRequestHeader('Content-Type', 'application/json');
+ request.setSuccess(function (xhr)
+ {
+ console.log(xhr); // TODO: remove this is for error checking
+ try {
+ var o = JSON.parse(xhr.response),
+ response = Object.keys(o).map(function (k)
+ {
+ return o[k]
+ });
+
+ for (var k = 0; k < response.length; k++) {
+ if (response[k] !== null) {
+ console.log(response[k]);
+
+ /* Handle success */
+ if (!self.success[e.id]) {
+ self.responseManager.execute(response[k].type, response[k]);
+ } else {
+ self.success[e.id](response[k].type, response[k]);
+ }
+ }
+ }
+ } catch (exception) {
+ console.log('No valid json');
+ return false;
+ }
+ });
+
+ request.send();
+ };
+
+ /**
+ * Collect all data associated with the form.
+ *
+ * @param {Object} e Form element
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.FormManager.prototype.getData = function (e)
+ {
+ var input = e.getElementsByTagName('input'),
+ select = e.getElementsByTagName('select'),
+ textarea = e.getElementsByTagName('textarea'),
+ datalist = e.getElementsByTagName('datalist'),
+ formelements = Array.prototype.slice.call(input).concat(Array.prototype.slice.call(select), Array.prototype.slice.call(textarea), Array.prototype.slice.call(datalist)),
+ self = this;
+
+ var validForm = true,
+ submitdata = {};
+
+ for (var k = 0; k < formelements.length; k++) {
+ if (!self.validateFormElement(e)) {
+ validForm = false;
+ // TODO: maybe jump out here since invalid and the elements get checked on changed by default
+ // will this change in the future? if yes then I need to check all and also add markup/styles here
+ }
+
+ submitdata[formelements[k].getAttribute('name')] = formelements[k].value;
+ }
+
+ if (!validForm) {
+ console.log('Form contains invalid data');
+ }
+
+ if (typeof e.dataset.formfields !== 'undefined') {
+ try {
+ var formdata = JSON.parse(e.dataset.formfields);
+
+ Object.keys(formdata).forEach(function (key)
+ {
+ if (formdata[key].startsWith('.') || formdata[key].startsWith('#')) {
+ var formElement = document.querySelector(formdata[key]);
+
+ if (formElement.type === 'checkbox') {
+ submitdata[key] = formElement.checked;
+ } else {
+ submitdata[key] = formElement.value;
+ }
+ }
+ });
+ } catch (exception) {
+ }
+ }
+
+ return submitdata;
+ };
+
+ /**
+ * Bind form.
+ *
+ * @param {Object} e Form element
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.FormManager.prototype.bindElement = function (e)
+ {
+ var input = e.getElementsByTagName('input'),
+ select = e.getElementsByTagName('select'),
+ textarea = e.getElementsByTagName('textarea'),
+ datalist = e.getElementsByTagName('datalist'),
+ buttons = (Array.prototype.slice.call(e.getElementsByTagName('button'))).concat(Array.prototype.slice.call(e.querySelectorAll('input[type=button]'))),
+ submits = e.querySelectorAll('input[type=submit]'),
+ self = this,
+ submitdata = {};
+
+ /** Handle submits */
+ for (var j = 0; j < submits.length; j++) {
+ submits[j].addEventListener('click', function (event)
+ {
+ submitdata = self.getData(e);
+
+ /* Handle injection */
+ var injected = false;
+
+ for (var key in self.injectSelector) {
+ if (e.id === key) {
+ // This calls the injection callback which in returns executes the form submit afterwards
+ // @todo: maybe let provide a continue() function here which continues the execution;
+ self.injectSelector[key](e);
+
+ injected = true;
+ }
+ }
+
+ if (!injected) {
+ self.submit(e, submitdata);
+ }
+
+ jsOMS.preventAll(event);
+ });
+ }
+
+ var i;
+ /** Handle input */
+ for (i = 0; i < input.length; i++) {
+ /** Validate on change */
+ if (typeof input[i].dataset.validate !== 'undefined') {
+ var validator = new RegExp(input[i].dataset.validate);
+
+ input[i].onkeyup = function (e)
+ {
+ var selfL = this;
+ jsOMS.watcher(function (e)
+ {
+ if (!validator.test(selfL.value)) {
+ jsOMS.addClass(selfL, 'invalid');
+ console.log('wrong input:' + i);
+ }
+ }, 500);
+ };
+ }
+
+ /** Request on change */
+ if (typeof input[i].dataset.request !== 'undefined') {
+ // handle request during typing
+ }
+ }
+
+ /** Handle select */
+ for (i = 0; i < select.length; i++) {
+ /** Redirect on change */
+ if (typeof select[i].dataset.redirect !== 'undefined') {
+ select[i].onchange = function ()
+ {
+ // TODO: use URI factory (which i still have to create :))
+ window.document.href = e.action.replace('{' + select[i].dataset.redirect + '}', select[i].value);
+ };
+ }
+ }
+
+ /** Handle button */
+ for (i = 0; i < buttons.length; i++) {
+ /** Redirect in new window on click */
+ if (typeof buttons[i].dataset.ropen !== 'undefined' || typeof buttons[i].dataset.redirect !== 'undefined') {
+ buttons[i].addEventListener('click', function (event)
+ {
+ var ropen = typeof this.dataset.ropen !== 'undefined' ? this.dataset.ropen : this.dataset.redirect,
+ matches = ropen.match(new RegExp("\{[#\?\.a-zA-Z0-9]*\}", "gi")),
+ current = jsOMS.Uri.parse_url(window.location.href),
+ value = null;
+
+ // TODO: find a way to use existing query parameters as well and just overwrite them if defined differently here
+ // eg. use &? in dummy urls to indicate that the url should use existing query parameters as well if not overwritten
+ for (var c = 0; c < matches.length; c++) {
+ var match = matches[c].substring(1, matches[c].length - 1);
+ if (match.indexOf('#') === 0) {
+ value = document.getElementById(match.substring(1, match.length)).value;
+ } else if (match.indexOf('.') === 0) {
+
+ } else if (match.indexOf('?') === 0) {
+ value = jsOMS.Uri.getUriQueryParameter(current.query, match.substring(1, match.length));
+ }
+
+ ropen = ropen.replace(matches[c], value);
+ }
+
+ if (typeof this.dataset.ropen !== 'undefined') {
+ var win = window.open(ropen, '_blank');
+ win.focus();
+ } else {
+ window.document.href = ropen;
+ }
+ });
+ } else if (jsOMS.hasClass(buttons[i], 'form-list') && buttons[i].dataset.name !== 'undefined') {
+
+ // TODO: maybe validate input value??? if not done during typing
+ // TODO: maybe use id here instead? then this needs to get changed in the form builder
+ var inputButton = document.querySelector('input[name=' + buttons[i].dataset.name + ']'),
+ list = document.querySelector('ul[data-name=l-' + buttons[i].dataset.name + ']'),
+ hidden = document.querySelector('input[type=hidden][name=h-' + buttons[i].dataset.name + ']');
+ buttons[i].addEventListener('click', function (event)
+ {
+
+ if (hidden.bind === undefined) {
+ hidden.bind = [];
+ }
+
+ hidden.bind.push(inputButton.bind ? inputButton.bind : inputButton.value);
+ hidden.value = JSON.stringify(hidden.bind);
+
+ var element = document.createElement('li');
+ element.appendChild(document.createTextNode(inputButton.value));
+ list.appendChild(element);
+ });
+ } else if (jsOMS.hasClass(buttons[i], 'form-table') && buttons[i].dataset.name !== 'undefined') {
+ // TODO: maybe use id here instead? then this needs to get changed in the form builder
+ var inputButton = document.querySelector('input[name=' + buttons[i].dataset.name + ']'),
+ table = document.querySelector('table[data-name=l-' + buttons[i].dataset.name + ']'),
+ hidden = document.querySelector('input[type=hidden][name=h-' + buttons[i].dataset.name + ']');
+
+ buttons[i].addEventListener('click', function (event)
+ {
+ // TODO: maybe validate input value??? if not done during typing
+
+ if (hidden.bind === undefined) {
+ hidden.bind = [];
+ }
+
+ hidden.bind.push(inputButton.bind ? inputButton.bind : inputButton.value);
+ hidden.value = JSON.stringify(hidden.bind);
+
+ // TODO: handle table add
+ });
+ }
+ }
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/UI/Input/InputManager.js b/UI/Input/InputManager.js
new file mode 100644
index 0000000..5fca112
--- /dev/null
+++ b/UI/Input/InputManager.js
@@ -0,0 +1,5 @@
+(function (jsOMS, undefined) {
+ jsOMS.InputManager = function ()
+ {
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/UI/Input/Keyboard/KeyboardManager.js b/UI/Input/Keyboard/KeyboardManager.js
new file mode 100644
index 0000000..b75d0cf
--- /dev/null
+++ b/UI/Input/Keyboard/KeyboardManager.js
@@ -0,0 +1,11 @@
+(function (jsOMS, undefined) {
+ jsOMS.KeyboardManager = function ()
+ {
+ };
+
+ jsOMS.KeyboardManager.prototype.attach = function (element, keys, callback) {
+ };
+
+ jsOMS.KeyboardManager.prototype.detach = function (eventId) {
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/UI/Input/Math/Evaluator.class.js b/UI/Input/Math/Evaluator.class.js
new file mode 100644
index 0000000..465a063
--- /dev/null
+++ b/UI/Input/Math/Evaluator.class.js
@@ -0,0 +1,22 @@
+var MathEvaluator = function () {
+
+};
+
+MathEvaluator.prototype.attach = function () {
+
+};
+
+MathEvaluator.prototype.detach = function () {
+
+};
+
+MathEvaluator.prototype.trigger = function (node) {
+ var value = node.value;
+
+ if (!value.slice(0, 1) == '=') {
+ return;
+ }
+
+ var processor = new MathProcessor();
+ return processor.parse(value);
+};
diff --git a/UI/Input/Mouse/ClickType.enum.js b/UI/Input/Mouse/ClickType.enum.js
new file mode 100644
index 0000000..9f9bf17
--- /dev/null
+++ b/UI/Input/Mouse/ClickType.enum.js
@@ -0,0 +1,5 @@
+var MouseClickType = Object.freeze({
+ LEFT: 1,
+ MIDDLE: 2,
+ RIGHT: 3
+});
diff --git a/UI/Input/Mouse/MouseManager.js b/UI/Input/Mouse/MouseManager.js
new file mode 100644
index 0000000..db07d83
--- /dev/null
+++ b/UI/Input/Mouse/MouseManager.js
@@ -0,0 +1,11 @@
+(function (jsOMS, undefined) {
+ jsOMS.MouseManager = function ()
+ {
+ };
+
+ jsOMS.MouseManager.prototype.attach = function (clickType, element, callback) {
+ };
+
+ jsOMS.MouseManager.prototype.detach = function (eventId) {
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/UI/LinkManager.js b/UI/LinkManager.js
new file mode 100644
index 0000000..e69de29
diff --git a/UI/Loader.js b/UI/Loader.js
new file mode 100644
index 0000000..ec38ab4
--- /dev/null
+++ b/UI/Loader.js
@@ -0,0 +1 @@
+/* responsible for loading external ui elements (css,html,js) */
\ No newline at end of file
diff --git a/UI/TabManager.js b/UI/TabManager.js
new file mode 100644
index 0000000..e988670
--- /dev/null
+++ b/UI/TabManager.js
@@ -0,0 +1,77 @@
+/**
+ * Tab manager class.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.TabManager = function (responseManager)
+ {
+ this.responseManager = responseManager;
+ };
+
+ /**
+ * Bind & rebind UI elements.
+ *
+ * @param {string} [id] Element id
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.TabManager.prototype.bind = function (id)
+ {
+ if (typeof id !== 'undefined') {
+ this.bindElement(document.getElementById(id));
+ } else {
+ var tabs = document.querySelectorAll('.tabview');
+
+ for (var i = 0; i < tabs.length; i++) {
+ this.bindElement(tabs[i]);
+ }
+ }
+ };
+
+ /**
+ * Bind & rebind UI element.
+ *
+ * @param {Object} [e] Element id
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.TabManager.prototype.bindElement = function (e)
+ {
+ var nodes = e.querySelectorAll('.tab-links a');
+
+ nodes.addEventListener('click', function (evt)
+ {
+ /* Change Tab */
+ var attr = this.getAttribute('href').substring(1),
+ cont = this.parentNode.parentNode.parentNode.children[1];
+
+ jsOMS.removeClass(jsOMS.getByClass(this.parentNode.parentNode, 'active'), 'active');
+ jsOMS.addClass(this.parentNode, 'active');
+ jsOMS.removeClass(jsOMS.getByClass(cont, 'active'), 'active');
+ jsOMS.addClass(jsOMS.getByClass(cont, attr), 'active');
+
+ /* Modify url */
+
+ jsOMS.preventAll(evt);
+ });
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/UI/TableManager.js b/UI/TableManager.js
new file mode 100644
index 0000000..f426a17
--- /dev/null
+++ b/UI/TableManager.js
@@ -0,0 +1,60 @@
+/**
+ * Table manager class.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.TableManager = function (responseManager)
+ {
+ this.responseManager = responseManager;
+ };
+
+ /**
+ * Bind & rebind UI elements.
+ *
+ * @param {string} [id] Element id
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.TableManager.prototype.bind = function (id)
+ {
+ if (typeof id !== 'undefined') {
+ this.bindElement(document.getElementById(id));
+ } else {
+ var tables = document.querySelectorAll('.tables');
+
+ for (var i = 0; i < tabs.length; i++) {
+ this.bindElement(tables[i]);
+ }
+ }
+ };
+
+ /**
+ * Bind & rebind UI element.
+ *
+ * @param {Object} [e] Element id
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.TableManager.prototype.bindElement = function (e)
+ {
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/UI/UIManager.js b/UI/UIManager.js
new file mode 100644
index 0000000..3257337
--- /dev/null
+++ b/UI/UIManager.js
@@ -0,0 +1,100 @@
+/**
+ * UI manager for handling basic ui elements.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.UIManager = function (app)
+ {
+ this.app = app;
+ this.formManager = new jsOMS.FormManager(this.app.responseManager);
+ this.tabManager = new jsOMS.TabManager(this.app.responseManager);
+ this.tableManager = new jsOMS.TableManager(this.app.responseManager);
+ };
+
+ /**
+ * Bind & rebind UI elements.
+ *
+ * @param {string} [id] Element id
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.UIManager.prototype.bind = function (id)
+ {
+ if (typeof id === 'undefined') {
+ this.formManager.bind();
+ this.tabManager.bind();
+ this.tableManager.bind();
+ } else {
+ var tag = document.getElementById(id);
+
+ if (tag.tagName === 'form') {
+ this.formManager.bind(id);
+ } else if (tag.tagName === 'table') {
+ this.tableManager.bind(id);
+ } else if (tag.tagName === 'div') {
+ // Todo: be more specific in order to handle tab
+ }
+ }
+ };
+
+ /**
+ * Get tab manager.
+ *
+ * @return {Object}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.UIManager.prototype.getFormManager = function ()
+ {
+ return this.formManager;
+ };
+
+ /**
+ * Get tab manager.
+ *
+ * @return {Object}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.UIManager.prototype.getTabManager = function ()
+ {
+ return this.tabManager;
+ };
+
+ /**
+ * Get table manager.
+ *
+ * @return {Object}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.UIManager.prototype.getTableManager = function ()
+ {
+ return this.tabManager;
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Uri/Uri.js b/Uri/Uri.js
new file mode 100644
index 0000000..0afff17
--- /dev/null
+++ b/Uri/Uri.js
@@ -0,0 +1,106 @@
+/**
+ * UI manager for handling basic ui elements.
+ *
+ * @author OMS Development Team
+ * @author Dennis Eichhorn
+ * @copyright 2013 Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0 * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * @constructor
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Uri = function ()
+ {
+ };
+
+ /**
+ * Prases a url.
+ *
+ * @param {string} str Url string
+ * @param {string} [component] I have no idea ?!?!??!?!
+ *
+ * @return {Object}
+ *
+ * @todo: fix this some parts are not used like components, mode, ini etc.
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Uri.parseUrl = function (str, component)
+ {
+ var query, key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port',
+ 'relative', 'path', 'directory', 'file', 'query', 'fragment'
+ ],
+ ini = (this.phpJs && this.phpJs.ini) || {},
+ mode = (ini['phpjs.parseUrl.mode'] &&
+ ini['phpjs.parseUrl.mode'].local_value) || 'php',
+ parser = {
+ php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
+ strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
+ loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-scheme to catch file:/// (should restrict this)
+ };
+
+ var m = parser[mode].exec(str),
+ uri = {},
+ i = 14;
+
+ while (i--) {
+ if (m[i]) {
+ uri[key[i]] = m[i];
+ }
+ }
+
+ if (component) {
+ return uri[component.replace('PHP_URL_', '')
+ .toLowerCase()];
+ }
+
+ if (mode !== 'php') {
+ var name = (ini['phpjs.parseUrl.queryKey'] &&
+ ini['phpjs.parseUrl.queryKey'].local_value) || 'queryKey';
+ parser = /(?:^|&)([^&=]*)=?([^&]*)/g;
+ uri[name] = {};
+ query = uri[key[12]] || '';
+ query.replace(parser, function ($0, $1, $2)
+ {
+ if ($1) {
+ uri[name][$1] = $2;
+ }
+ });
+ }
+
+ delete uri.source;
+
+ return uri;
+ };
+
+ /**
+ * Get Uri query parameters.
+ *
+ * @param {string} query Uri query
+ * @param {string} name Name of the query to return
+ *
+ * @return {null|string}
+ *
+ * @method
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.Uri.getUriQueryParameter = function (query, name)
+ {
+ name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
+ var regex = new RegExp("[\\?&]*" + name + "=([^]*)"),
+ results = regex.exec(query);
+ return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Uri/UriFactory.js b/Uri/UriFactory.js
new file mode 100644
index 0000000..30d1572
--- /dev/null
+++ b/Uri/UriFactory.js
@@ -0,0 +1,3 @@
+(function (uriFactory, undefined) {
+
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Utils/Markdown/Markdown.js b/Utils/Markdown/Markdown.js
new file mode 100644
index 0000000..ea3b7b0
--- /dev/null
+++ b/Utils/Markdown/Markdown.js
@@ -0,0 +1,82 @@
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.Markdown = function (source, destination) {
+ this.source = document.querySelector(source);
+ this.dest = document.querySelector(destination);
+
+ var self = this;
+
+ var timer = 0;
+ this.source.addEventListener('input', function () {
+ maybeUpdateFromInput(this.value);
+ }, false);
+
+ // todo: maybe export to own olib function?!
+ function maybeUpdateFromInput(val) {
+ if (timer) {
+ clearTimeout(timer);
+ }
+
+ timer = setTimeout(function () {
+ self.dest.value = self.parse(self.source.value);
+ timer = 0;
+ }, 500);
+ }
+ };
+
+ jsOMS.Markdown.prototype.parse = function (plain) {
+ plain = plain.replace('\r\n', '\n');
+ plain = plain.replace('\r', '\n');
+ plain = plain.replace('\t', ' ');
+ plain = plain.trim();
+ plain = plain.split('\n');
+ plain = this.lines(plain);
+ plain = plain.trim();
+
+ return plain;
+ };
+
+
+ jsOMS.Markdown.prototype.lines = function (lines) {
+ var escaped = false;
+ var line = '';
+
+ for (var i = 0; i < lines.length; i++) {
+ line = lines[i];
+
+ if ((line = line.trim()) === '') {
+ line += '
';
+ } else if (i === 0) {
+ line = '
' + line;
+ } else if(i === liens.length - 1) {
+ line += '
';
+ }
+
+ var indent = 0;
+
+ while (line[indent] && line[lindent] === '') {
+ indent++;
+ }
+
+ var text = indent > 0 ? line.substr(indent) : line;
+
+ for(var j = 0; j < text.length; j++) {
+ if(text[j] === '*' && !escaped) {
+
+ } else if(text[j] === '_' && !escaped) {}
+ else if(text[j] === '-' && !escaped) {}
+ else if(text[j] === '#' && !escaped) {}
+ else if(['1', '2', '3' , '4', '5', '6', '7', '8', '9', '0'].indexOf(text[j]) !== -1 && !escaped) {}
+ else if(text[j] === '`' && !escaped) {}
+ else if(text[j] === '"' && !escaped) {}
+ else if(text[j] === '[' && !escaped) {}
+ else if(text[j] === '\\' && !escaped) {
+ escaped = true;
+ }
+ else {
+ escaped = false;
+ }
+ }
+ }
+ }
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Utils/oLib.js b/Utils/oLib.js
new file mode 100644
index 0000000..957e45c
--- /dev/null
+++ b/Utils/oLib.js
@@ -0,0 +1,271 @@
+/**
+ * Core JS functionality
+ *
+ * This logic is supposed to minimize coding and support core javascript functionality.
+ *
+ * @since 1.0.0
+ */
+(function (jsOMS, undefined)
+{
+
+ /**
+ * Class finder
+ *
+ * Checking if a element has a class
+ *
+ * @param {Object} ele DOM Element
+ * @param {string} cls Class to find
+ *
+ * @return {bool}
+ *
+ * @function
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.hasClass = function (ele, cls)
+ {
+ return ele !== undefined && ele !== null && ele.className !== undefined && ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
+ };
+
+ /**
+ * Add class
+ *
+ * Adding a class to an element
+ *
+ * @param ele DOM Element
+ * @param cls Class to add
+ *
+ * @function
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.addClass = function (ele, cls)
+ {
+ if (!jsOMS.hasClass(ele, cls)) {
+ ele.className += " " + cls;
+ }
+ };
+
+ /**
+ * Remove class
+ *
+ * Removing a class form an element
+ *
+ * @param ele DOM Element
+ * @param cls Class to remove
+ *
+ * @function
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.removeClass = function (ele, cls)
+ {
+ if (jsOMS.hasClass(ele, cls)) {
+ var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
+ ele.className = ele.className.replace(reg, '');
+ }
+ };
+
+ /**
+ * Delayed watcher
+ *
+ * Used to fire event after delay
+ *
+ * @function
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.watcher = function ()
+ {
+ var timer = 0;
+ return function (callback, ms)
+ {
+ clearTimeout(timer);
+ timer = setTimeout(callback, ms);
+ };
+ }();
+
+ /**
+ * Action prevent
+ *
+ * Preventing event from firering and passing through
+ *
+ * @param event Event Event to stop
+ *
+ * @function
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.preventAll = function (event)
+ {
+ if (event.stopPropagation) {
+ event.stopPropagation();
+ } else {
+ event.cancelBubble = true;
+ }
+
+ event.preventDefault();
+ };
+
+ /**
+ * Ready invoke
+ *
+ * Invoking a function after page load
+ *
+ * @param func Callback function
+ *
+ * @function
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.ready = function (func)
+ {
+ // TODO: IE problems? + Maybe interactive + loaded can cause problems since elements might not be loaded yet?!!?!!?!
+ if (document.readyState === 'complete' || document.readyState === 'loaded' || document.readyState === 'interactive') {
+ func();
+ } else {
+ document.addEventListener("DOMContentLoaded", function (event)
+ {
+ func();
+ });
+ }
+ };
+
+ /**
+ * Empty element
+ *
+ * Deleting content from element
+ *
+ * @param ele DOM Element
+ *
+ * @function
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.empty = function (ele)
+ {
+ while (ele.firstChild) {
+ ele.removeChild(ele.firstChild);
+ }
+ };
+
+ jsOMS.hash = function (str)
+ {
+ var res = 0,
+ len = str.length;
+ for (var i = 0; i < len; i++) {
+ res = res * 31 + str.charCodeAt(i);
+ }
+ return res;
+ };
+
+ /**
+ * Check node
+ *
+ * Checking if a selection is a node
+ *
+ * @param ele DOM Node
+ *
+ * @return {bool}
+ *
+ * @function
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.isNode = function (ele)
+ {
+ return (
+ typeof Node === "object" ? ele instanceof Node :
+ ele && typeof ele === "object" && typeof ele.nodeType === "number" && typeof ele.nodeName === "string"
+ );
+ };
+
+ /**
+ * Check element
+ *
+ * Checking if a selection is a element
+ *
+ * @param o DOM Element
+ *
+ * @return {bool}
+ *
+ * @function
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.isElement = function (o)
+ {
+ return (
+ typeof HTMLElement === "object" ? o instanceof HTMLElement : o && typeof o === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string"
+ );
+ };
+
+ /**
+ * Getting element by class
+ *
+ * Getting a element by class in the first level
+ *
+ * @param ele DOM Element
+ * @param cls Class to find
+ *
+ * @return Element
+ *
+ * @function
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.getByClass = function (ele, cls)
+ {
+ var length = ele.childNodes.length;
+
+ for (var i = 0; i < length; i++) {
+ if (jsOMS.hasClass(ele.childNodes[i], cls)) {
+ return ele.childNodes[i];
+ }
+ }
+
+ return null;
+ };
+
+ /**
+ * Merging two arrays recursively
+ *
+ * @param target Target array
+ * @param source Source array
+ *
+ * @return Array
+ *
+ * @function
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.merge = function (target, source)
+ {
+ for (var p in source) {
+ try {
+ if (source[p].constructor == Object) {
+ target[p] = merge(target[p], source[p]);
+
+ } else {
+ target[p] = source[p];
+ }
+
+ } catch (e) {
+ target[p] = source[p];
+ }
+ }
+
+ return target;
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Validattion/ValidateDate.class.js b/Validattion/ValidateDate.class.js
new file mode 100644
index 0000000..e69de29
diff --git a/Validattion/ValidateMath.class.js b/Validattion/ValidateMath.class.js
new file mode 100644
index 0000000..e69de29
diff --git a/Validattion/ValidateNumber.class.js b/Validattion/ValidateNumber.class.js
new file mode 100644
index 0000000..e69de29
diff --git a/Validattion/ValidateString.class.js b/Validattion/ValidateString.class.js
new file mode 100644
index 0000000..e69de29
diff --git a/Validattion/Validation.js b/Validattion/Validation.js
new file mode 100644
index 0000000..874e410
--- /dev/null
+++ b/Validattion/Validation.js
@@ -0,0 +1,9 @@
+(function (jsOMS, undefined) {
+ jsOMS.Validation = function () {
+
+ };
+
+ jsOMS.Validation.prototype.addInput = function () {
+
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Views/FormView.js b/Views/FormView.js
new file mode 100644
index 0000000..4291be6
--- /dev/null
+++ b/Views/FormView.js
@@ -0,0 +1,14 @@
+(function (jsOMS, undefined) {
+ jsOMS.FormView = function (node) {
+ if (node) {
+ this.setNode(node);
+ }
+ };
+
+ jsOMS.FormView.prototype.setNode = function () {
+ };
+
+ jsOMS.FormView.prototype.submit = function () {
+
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Views/TableView.js b/Views/TableView.js
new file mode 100644
index 0000000..89997fa
--- /dev/null
+++ b/Views/TableView.js
@@ -0,0 +1,36 @@
+(function (jsOMS, undefined) {
+ jsOMS.TableView = function () {
+ this.table = null;
+ };
+
+ /**
+ * None, Pagination, Infinite
+ */
+ jsOMS.TableView.prototype.setExtensible = function () {
+
+ };
+
+ jsOMS.TableView.prototype.add = function (element) {
+
+ };
+
+ jsOMS.TableView.prototype.addCollection = function (collection) {
+
+ };
+
+ jsOMS.TableView.prototype.remove = function (id) {
+
+ };
+
+ jsOMS.TableView.prototype.get = function (id) {
+
+ };
+
+ jsOMS.TableView.prototype.filter = function (id) {
+
+ };
+
+ jsOMS.TableView.prototype.request = function (filter) {
+
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Views/ViewAbstract.js b/Views/ViewAbstract.js
new file mode 100644
index 0000000..af7c215
--- /dev/null
+++ b/Views/ViewAbstract.js
@@ -0,0 +1,30 @@
+(function (jsOMS, undefined) {
+ jsOMS.ViewAbstract = function ()
+ {
+ this.element = null;
+ this.data = [];
+ };
+
+ jsOMS.ViewAbstract.prototype.bind = function (node)
+ {
+ this.element = node;
+ };
+
+ jsOMS.ViewAbstract.prototype.addData = function(id, data, overwrite)
+ {
+ overwrite = typeof overwrite !== 'undefined' ? overwrite : false;
+
+ if(typeof this.data[id] === 'undefined' || overwrite) {
+ this.data[id] = data;
+
+ return true;
+ }
+
+ return false;
+ };
+
+ jsOMS.ViewAbstract.prototype.getData = function(id)
+ {
+ return typeof this.data[id] !== 'undefined' ? this.data[id] : undefined;
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/oms.min.js b/oms.min.js
new file mode 100644
index 0000000..f79a1e8
--- /dev/null
+++ b/oms.min.js
@@ -0,0 +1,1979 @@
+/**
+ * Core JS functionality
+ *
+ * This logic is supposed to minimize coding and support core javascript functionality.
+ *
+ * @category App
+ * @package Framework
+ * @since 1.0.0
+ */
+(function (jsOMS, undefined) {
+
+ /**
+ * Property loader
+ *
+ * @param {Object} ele DOM Element
+ * @param {string} value Property to get
+ *
+ * @return string
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.getPropertyValue = function (ele, value) {
+ return window.getComputedStyle(ele, null).getPropertyValue(value);
+ };
+
+ /**
+ * Class finder
+ *
+ * Checking if a element has a class
+ *
+ * @param {Object} ele DOM Element
+ * @param {string} cls Class to find
+ *
+ * @return boolean
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.hasClass = function (ele, cls) {
+ return ele !== undefined && ele !== null && ele.className !== undefined && ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
+ };
+
+ /**
+ * Add class
+ *
+ * Adding a class to an element
+ *
+ * @param ele DOM Element
+ * @param cls Class to add
+ *
+ * @return void
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.addClass = function (ele, cls) {
+ if (!jsOMS.hasClass(ele, cls)) {
+ ele.className += " " + cls;
+ }
+ };
+
+ /**
+ * Remove class
+ *
+ * Removing a class form an element
+ *
+ * @param ele DOM Element
+ * @param cls Class to remove
+ *
+ * @return void
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.removeClass = function (ele, cls) {
+ if (jsOMS.hasClass(ele, cls)) {
+ var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
+ ele.className = ele.className.replace(reg, '');
+ }
+ };
+
+ /**
+ * Delayed watcher
+ *
+ * Used to fire event after delay
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.watcher = function () {
+ var timer = 0;
+ return function (callback, ms) {
+ clearTimeout(timer);
+ timer = setTimeout(callback, ms);
+ };
+ }();
+
+ /**
+ * Action prevent
+ *
+ * Preventing event from firering and passing through
+ *
+ * @param event Event Event to stop
+ *
+ * @return void
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.preventAll = function(event) {
+ if (event.stopPropagation) {
+ event.stopPropagation();
+ } else {
+ event.cancelBubble = true;
+ }
+
+ event.preventDefault();
+ };
+
+ /**
+ * Ready invoke
+ *
+ * Invoking a function after page load
+ *
+ * @param func Callback function
+ *
+ * @return void
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.ready = function (func) {
+ // TODO: IE problems? + Maybe interactive + loaded can cause problems since elements might not be loaded yet?!!?!!?!
+ if (document.readyState === 'complete' || document.readyState === 'loaded' || document.readyState === 'interactive') {
+ func();
+ } else {
+ document.addEventListener("DOMContentLoaded", function (event) {
+ func();
+ });
+ }
+ };
+
+ /**
+ * Each loop
+ *
+ * Looping over a node array and performing a task with these nodes
+ *
+ * @param nodes DOM Nodes
+ * @param func Callback function
+ *
+ * @return void
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.each = function (nodes, func) {
+ var length = nodes.length;
+
+ for (var i = 0; i < length; i++) {
+ func(nodes[i]);
+ }
+ };
+
+ /**
+ * Empty element
+ *
+ * Deleting content from element
+ *
+ * @param ele DOM Element
+ *
+ * @return void
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.empty = function (ele) {
+ while (ele.firstChild) {
+ ele.removeChild(ele.firstChild);
+ }
+ };
+
+ jsOMS.hash = function (str) {
+ var res = 0,
+ len = str.length;
+ for (var i = 0; i < len; i++) {
+ res = res * 31 + str.charCodeAt(i);
+ }
+ return res;
+ };
+
+ /**
+ * Check node
+ *
+ * Checking if a selection is a node
+ *
+ * @param ele DOM Node
+ *
+ * @return boolean
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.isNode = function (ele) {
+ return (
+ typeof Node === "object" ? ele instanceof Node :
+ ele && typeof ele === "object" && typeof ele.nodeType === "number" && typeof ele.nodeName === "string"
+ );
+ };
+
+ /**
+ * Check element
+ *
+ * Checking if a selection is a element
+ *
+ * @param o DOM Element
+ *
+ * @return boolean
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.isElement = function (o) {
+ return (
+ typeof HTMLElement === "object" ? o instanceof HTMLElement : o && typeof o === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string"
+ );
+ };
+
+ /**
+ * Getting element by class
+ *
+ * Getting a element by class in the first level
+ *
+ * @param ele DOM Element
+ * @param cls Class to find
+ *
+ * @return Element
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.getByClass = function (ele, cls) {
+ var length = ele.childNodes.length;
+
+ for (var i = 0; i < length; i++) {
+ if (jsOMS.hasClass(ele.childNodes[i], cls)) {
+ return ele.childNodes[i];
+ }
+ }
+
+ return null;
+ };
+
+ /**
+ * Getting element by tag
+ *
+ * Getting a element by tag in the first level
+ *
+ * @param ele DOM Element
+ * @param tag Tag to find
+ *
+ * @return Element
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.getByTag = function (ele, tag) {
+ return ele.getElementsByTagName(tag);
+ };
+
+ /**
+ * Merging two arrays recursively
+ *
+ * @param target Target array
+ * @param source Source array
+ *
+ * @return array
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.merge = function (target, source) {
+ for (var p in source) {
+ try {
+ if (source[p].constructor == Object) {
+ target[p] = merge(target[p], source[p]);
+
+ } else {
+ target[p] = source[p];
+ }
+
+ } catch (e) {
+ target[p] = source[p];
+
+ }
+ }
+
+ return target;
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.Options = function ()
+ {
+ this.options = {};
+ };
+
+ // TODO: create comments
+ jsOMS.Options.prototype.set = function (key, value, overwrite)
+ {
+ overwrite = typeof overwrite === bool ? overwrite : true;
+
+ if (overwrite || !options[key]) {
+ options[key] = value;
+ }
+
+ // TODO: return boolean for success
+ };
+
+ // TODO: create comments
+ jsOMS.Options.prototype.get = function (key)
+ {
+ // TODO: handle isset
+ return options[key];
+ };
+
+ // TODO: create comments
+ jsOMS.Options.prototype.remove = function (key)
+ {
+ // TODO: Handle isset and return boolean
+ delete options[key];
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.AccountManager = function ()
+ {
+ this.accounts = [];
+ };
+
+ // TODO: create comments
+ jsOMS.AccountManager.prototype.add = function(account)
+ {
+ this.accounts[account.getId()] = account;
+ };
+
+ // TODO: create comments
+ jsOMS.AccountManager.prototype.remove = function(id)
+ {
+ if (typeof this.accounts[id] !== 'undefined') {
+ delete this.accounts[id];
+
+ return true;
+ }
+
+ return false;
+ };
+
+ // TODO: create comments
+ jsOMS.AccountManager.prototype.get = function(id)
+ {
+ if (this.accounts[id]) {
+ return this.accounts[id];
+ }
+
+ return undefined;
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.Auth = function (uri)
+ {
+ this.account = null;
+ this.uri = uri;
+ };
+
+ // TODO: create comments
+ jsOMS.Auth.prototype.setAccount = function (account)
+ {
+ this.account = account;
+ };
+
+ // TODO: create comments
+ jsOMS.Auth.prototype.getAccount = function () {
+ return this.account;
+ };
+
+ // TODO: create comments
+ jsOMS.Auth.prototype.login = function ()
+ {
+ var authRequest = new jsOMS.Request();
+ authRequest.setUri(this.uri);
+ authRequest.setMethod(jsOMS.EnumRequestMethod.POST);
+ authRequest.setResponseType(jsOMS.EnumRequestType.JSON);
+ authRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+ authRequest.setSuccess(function (xhr) {
+ this.loginResult(xhr);
+ });
+
+ authRequest.send();
+ };
+
+ // TODO: create comments
+ jsOMS.Auth.prototype.logout = function ()
+ {
+ this.refresh();
+ };
+
+ // TODO: create comments
+ jsOMS.Auth.prototype.loginResult = function (xhr)
+ {
+ console.log(xhr);
+ location.reload();
+ };
+
+ // TODO: create comments
+ jsOMS.Auth.prototype.handshake = function ()
+ {
+
+ };
+
+ // TODO: create comments
+ jsOMS.Auth.prototype.setAuthKey = function ()
+ {
+
+ };
+
+ // TODO: create comments
+ jsOMS.Auth.prototype.getAuthKey = function ()
+ {
+
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.Uri = function ()
+ {
+ };
+
+ // TODO: create comments
+ jsOMS.Uri.parseUrl = function(str, component) {
+ var query, key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port',
+ 'relative', 'path', 'directory', 'file', 'query', 'fragment'
+ ],
+ ini = (this.phpJs && this.phpJs.ini) || {},
+ mode = (ini['phpjs.parseUrl.mode'] &&
+ ini['phpjs.parseUrl.mode'].local_value) || 'php',
+ parser = {
+ php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
+ strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
+ loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-scheme to catch file:/// (should restrict this)
+ };
+
+ var m = parser[mode].exec(str),
+ uri = {},
+ i = 14;
+
+ while (i--) {
+ if (m[i]) {
+ uri[key[i]] = m[i];
+ }
+ }
+
+ if (component) {
+ return uri[component.replace('PHP_URL_', '')
+ .toLowerCase()];
+ }
+
+ if (mode !== 'php') {
+ var name = (ini['phpjs.parseUrl.queryKey'] &&
+ ini['phpjs.parseUrl.queryKey'].local_value) || 'queryKey';
+ parser = /(?:^|&)([^&=]*)=?([^&]*)/g;
+ uri[name] = {};
+ query = uri[key[12]] || '';
+ query.replace(parser, function($0, $1, $2) {
+ if ($1) {
+ uri[name][$1] = $2;
+ }
+ });
+ }
+
+ delete uri.source;
+
+ return uri;
+ };
+
+ // TODO: create comments
+ jsOMS.Uri.getUriQueryParameter = function(query, name) {
+ name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
+ var regex = new RegExp("[\\?&]*" + name + "=([^]*)"),
+ results = regex.exec(query);
+ return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (uriFactory, undefined) {
+
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.FormView = function (node) {
+ if (node) {
+ this.setNode(node);
+ }
+ };
+
+ jsOMS.FormView.prototype.setNode = function () {
+ };
+
+ jsOMS.FormView.prototype.submit = function () {
+
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.TableView = function () {
+ this.table = null;
+ };
+
+ /**
+ * None, Pagination, Infinite
+ */
+ jsOMS.TableView.prototype.setExtensible = function () {
+
+ };
+
+ jsOMS.TableView.prototype.add = function (element) {
+
+ };
+
+ jsOMS.TableView.prototype.addCollection = function (collection) {
+
+ };
+
+ jsOMS.TableView.prototype.remove = function (id) {
+
+ };
+
+ jsOMS.TableView.prototype.get = function (id) {
+
+ };
+
+ jsOMS.TableView.prototype.filter = function (id) {
+
+ };
+
+ jsOMS.TableView.prototype.request = function (filter) {
+
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.ViewAbstract = function ()
+ {
+ this.element = null;
+ this.data = [];
+ };
+
+ jsOMS.ViewAbstract.prototype.bind = function (node)
+ {
+ this.element = node;
+ };
+
+ jsOMS.ViewAbstract.prototype.addData = function(id, data, overwrite)
+ {
+ overwrite = typeof overwrite !== 'undefined' ? overwrite : false;
+
+ if(typeof this.data[id] === 'undefined' || overwrite) {
+ this.data[id] = data;
+
+ return true;
+ }
+
+ return false;
+ };
+
+ jsOMS.ViewAbstract.prototype.getData = function(id)
+ {
+ return typeof this.data[id] !== 'undefined' ? this.data[id] : undefined;
+ }
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.Account = function () {
+ this.login = '';
+ this.password = '';
+ this.id = 0;
+ this.auth = null;
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.CacheManager = function ()
+ {
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.CookieJar = function () {
+ };
+
+ /**
+ * Saving data to cookie
+ *
+ * @param {string} cName Cookie name
+ * @param {string} value Value to save
+ * @param {number} exdays Lifetime for the cookie
+ * @param {string} domain Domain for the cookie
+ * @param {string} path Path for the cookie
+ *
+ * @return array
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.CookieJar.prototype.setCookie = function (cName, value, exdays, domain, path) {
+ var exdate = new Date();
+ exdate.setDate(exdate.getDate() + exdays);
+ var cValue = encodeURI(value) + ((exdays === null) ? "" : "; expires=" + exdate.toUTCString()) + ";domain=" + domain + ";path=" + path;
+ document.cookie = cName + "=" + cValue;
+ };
+
+ /**
+ * Loading cookie data
+ *
+ * @param {string} cName Cookie name
+ *
+ * @return {string}
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+ jsOMS.CookieJar.prototype.getCookie = function (cName) {
+ var cValue = document.cookie;
+ var cStart = cValue.indexOf(" " + cName + "=");
+
+ if (cStart === -1) {
+ cStart = cValue.indexOf(cName + "=");
+ }
+
+ if (cStart === -1) {
+ cValue = null;
+ } else {
+ cStart = cValue.indexOf("=", cStart) + 1;
+ var cEnd = cValue.indexOf(";", cStart);
+
+ if (cEnd === -1) {
+ cEnd = cValue.length;
+ }
+
+ cValue = decodeURI(cValue.substring(cStart, cEnd));
+ }
+ return cValue;
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.LocalStorage = function () {
+ };
+
+ // TODO: create comments
+ jsOMS.LocalStorage.prototype.available = function () {
+ try {
+ return 'localStorage' in window && window.localStorage !== null;
+ } catch (e) {
+ return false;
+ }
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.StorageManager = function ()
+ {
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.ModuleFactory = function() {};
+
+ // TODO: create comments
+ jsOMS.ModuleFactory.getInstance = function (module, app)
+ {
+ return new window['jsOMS']['Modules'][module](app)
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.Modules = {};
+ jsOMS.Modules.Models = {};
+
+ // TODO: create comments
+ jsOMS.ModuleManager = function (app)
+ {
+ this.modules = {};
+ this.app = app;
+ };
+
+ // TODO: create comments
+ jsOMS.ModuleManager.prototype.initModule = function (module)
+ {
+ this.modules[module] = jsOMS.ModuleFactory.getInstance(module, this.app);
+ };
+
+ // TODO: create comments
+ jsOMS.ModuleManager.prototype.get = function (module)
+ {
+ return this.modules[module];
+ };
+}(window.jsOMS = window.jsOMS || {}));
+//+ Jonas Raoni Soares Silva
+//@ http://jsfromhell.com/classes/math-processor [rev. #1]
+
+var MathProcessor = function () {
+ var o = this;
+ o.o = {
+ "+": function (a, b) {
+ return +a + b;
+ },
+ "-": function (a, b) {
+ return a - b;
+ },
+ "%": function (a, b) {
+ return a % b;
+ },
+ "/": function (a, b) {
+ return a / b;
+ },
+ "*": function (a, b) {
+ return a * b;
+ },
+ "^": function (a, b) {
+ return Math.pow(a, b);
+ },
+ "~": function (a, b) {
+ return Math.sqrt(a, b);
+ }
+ };
+ o.s = {"^": 3, "~": 3, "*": 2, "/": 2, "%": 1, "+": 0, "-": 0};
+ o.u = {"+": 1, "-": -1}, o.p = {"(": 1, ")": -1};
+};
+with ({p: MathProcessor.prototype}) {
+ p.methods = {
+ div: function (a, b) {
+ return parseInt(a / b);
+ },
+ fra: function (a) {
+ return a - parseInt(a);
+ },
+ sum: function (n1, n2, n3, n) {
+ for (var r = 0, a, l = (a = arguments).length; l; r += a[--l]) {
+ ;
+ }
+ return r;
+ },
+ medium: function (n1, n2, n3, n) {
+ for (var r = 0, a, l = (a = arguments).length; l; r += a[--l]) {
+ ;
+ }
+ return r / a.length;
+ }
+ };
+ p.parse = function (e) {
+ for (var n, x, _ = this, o = [], s = [x = _.RPN(e.replace(/ /g, "").split(""))]; s.length;) {
+ for ((n = s[s.length - 1], --s.length); n[2]; o[o.length] = n, s[s.length] = n[3], n = n[2]) {
+ ;
+ }
+ }
+ for (; (n = o.pop()) != undefined; n[0] = _.o[n[0]](isNaN(n[2][0]) ? _.f(n[2][0]) : n[2][0], isNaN(n[3][0]) ? _.f(n[3][0]) : n[3][0])) {
+ ;
+ }
+ return +x[0];
+ };
+ p.RPN = function (e) {
+ var x, r, _ = this, c = r = [, , , 0];
+ if (e[0] in _.u || !e.unshift("+")) {
+ for (; e[1] in _.u; e[0] = _.u[e.shift()] * _.u[e[0]] + 1 ? "+" : "-") {
+ ;
+ }
+ }
+ (c[3] = [_.u[e.shift()], c, , 0])[1][0] = "*", (r = [, , c, 0])[2][1] = r;
+ (c[2] = _.v(e))[1] = c;
+ (!e.length && (r = c)) || (e[0] in _.s && ((c = r)[0] = e.shift(), !e.length && _.error()));
+ while (e.length) {
+ if (e[0] in _.u) {
+ for (; e[1] in _.u; e[0] = _.u[e.shift()] * _.u[e[0]] + 1 ? "+" : "-") {
+ ;
+ }
+ (c = c[3] = ["*", c, , 0])[2] = [-1, c, , 0];
+ }
+ (c[3] = _.v(e))[1] = c;
+ e[0] in _.s && (c = _.s[e[0]] > _.s[c[0]] ?
+ ((c[3] = (x = c[3], c[2]))[1][2] = [e.shift(), c, x, 0])[2][1] = c[2]
+ : r == c ? (r = [e.shift(), , c, 0])[2][1] = r
+ : ((r[2] = (x = r[2], [e.shift(), r, , 0]))[2] = x)[1] = r[2]);
+ }
+ return r;
+ };
+ p.v = function (e) {
+ var i, j, l, _ = this;
+ if ("0123456789.".indexOf(e[0]) + 1) {
+ for (i = -1, l = e.length; ++i < l && "0123456789.".indexOf(e[i]) + 1;) {
+ ;
+ }
+ return [+e.splice(0, i).join(""), , , 0];
+ }
+ else if (e[0] == "(") {
+ for (i = 0, l = e.length, j = 1; ++i < l && (e[i] in _.p && (j += _.p[e[i]]), j);) {
+ ;
+ }
+ return _.RPN(l = e.splice(0, i), l.shift(), !j && e.shift());
+ }
+ else {
+ if (((j = e[0].toLowerCase()) >= "a" && j <= "z") || j == "_") {
+ for (i = 0; ((j = e[++i].toLowerCase()) >= "a" && j <= "z") || j == "_" || (j >= 0 && j <= 9);) {
+ ;
+ }
+ if (j == "(") {
+ for (var l = e.length, j = 1; ++i < l && (e[i] in _.p && (j += _.p[e[i]]), j);) {
+ ;
+ }
+ return [e.splice(0, i + 1).join(""), , , 0];
+ }
+ }
+ }
+ _.error();
+ };
+ p.f = function (e) {
+ var n, i = 0, _ = this;
+ if (((e = e.split(""))[i] >= "a" && e[i] <= "z") || e[i] == "_") {
+ while ((e[++i] >= "a" && e[i] <= "z") || e[i] == "_" || (e[i] >= 0 && e[i] <= 9)) {
+ ;
+ }
+ if (e[i] == "(") {
+ !_.methods[n = e.splice(0, i).join("")] && _.error("Function \"" + n + "\" not found"), e.shift();
+ for (var a = [], i = -1, j = 1; e[++i] && (e[i] in _.p && (j += _.p[e[i]]), j);) {
+ j == 1 && e[i] == "," && (a.push(_.parse(e.splice(0, i).join(""))), e.shift(), i = -1);
+ }
+ a.push(_.parse(e.splice(0, i).join(""))), !j && e.shift();
+ }
+ return _.methods[n].apply(_, a);
+ }
+ };
+ p.error = function (s) {
+ return;
+ //throw new Error("MathProcessor: " + (s || "Wrong expression"));
+ };
+}
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.Route = function ()
+ {
+ this.routes = null;
+ };
+
+ // TODO: create comments
+ jsOMS.Route.prototype.add = function (path, callback, exact)
+ {
+ exact = typeof exact !== 'undefined' ? exact : true;
+
+ // todo: create array key path like i did for php
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.Dispatcher = function ()
+ {
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.Request = function ()
+ {
+ this.uri = null;
+ this.method = null;
+ this.requestHeader = [];
+ this.success = null;
+ this.type = 'GET';
+ this.data = {};
+
+ this.xhr = new XMLHttpRequest();
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.setMethod = function (method)
+ {
+ this.method = method;
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.getMethod = function ()
+ {
+ return this.method;
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.setResponseType = function (type)
+ {
+ this.xhr.responseType = type;
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.getResponseType = function ()
+ {
+ return this.responseType;
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.setRequestHeader = function (type, header)
+ {
+ this.requestHeader[type] = header;
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.getRequestHeader = function ()
+ {
+ return this.requestHeader;
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.setUri = function (uri)
+ {
+ this.uri = uri;
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.getUri = function ()
+ {
+ return this.uri;
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.setSuccess = function (callback)
+ {
+ this.success = callback;
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.setData = function (data)
+ {
+ this.data = data;
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.getData = function ()
+ {
+
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.setType = function (type)
+ {
+ this.type = type;
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.getType = function ()
+ {
+
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.serializeData = function ()
+ {
+
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.queryfy = function (obj)
+ {
+ var str = [];
+ for (var p in obj) {
+ if (obj.hasOwnProperty(p)) {
+ str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
+ }
+ }
+ return str.join("&");
+ };
+
+ // TODO: create comments
+ jsOMS.Request.prototype.send = function ()
+ {
+ var self = this;
+
+ if(self.xhr.readyState !== 1) {
+ self.xhr.open(this.method, this.uri);
+
+ for (var p in this.requestHeader) {
+ if(this.requestHeader.hasOwnProperty(p)) {
+ self.xhr.setRequestHeader(p, this.requestHeader[p]);
+ }
+ }
+ }
+
+ self.xhr.onreadystatechange = function () {
+ if (self.xhr.readyState === 4 && self.xhr.status === 200) {
+ self.success(self.xhr);
+ }
+ };
+
+ if(this.type === 'json') {
+ if (typeof this.requestHeader !== 'undefined' && this.requestHeader['Content-Type'] === 'application/json') {
+ console.log(JSON.stringify(this.data));
+ self.xhr.send(JSON.stringify(this.data));
+ } else {
+ self.xhr.send(this.queryfy(this.data));
+ }
+ } else if(this.type === 'raw') {
+ self.xhr.send(this.data);
+ }
+ };
+
+ /**
+ * AJAX
+ *
+ * @param obj AJAX variables
+ *
+ * The following obj variables are expected:
+ * responseType - Type of the response
+ * requestHeader - Header description for the request
+ * success - Success callback function
+ * error - Error callback function
+ * type - GET, PUT, DELETE, POST type
+ * url - Request url
+ * data - Data to send
+ *
+ * @since 1.0.0
+ * @author Dennis Eichhorn
+ */
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.EnumLinkRequestData = Object.freeze({
+ NORMAL: 'normal',
+ OBJECT: 'object'
+ });
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.RequestManager = function ()
+ {
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.EnumRequestMethod = Object.freeze({
+ POST: 'POST',
+ GET: 'GET',
+ PUT: 'PUT',
+ DELETE: 'DELETE',
+ HEAD: 'HEAD'
+ });
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.ResponseManager = function ()
+ {
+ this.messages = {};
+ };
+
+ // TODO: create comments
+ jsOMS.ResponseManager.prototype.add = function (key, message, request)
+ {
+ request = typeof request !== 'undefined' ? request : 'any';
+ if (typeof this.messages[key] === 'undefined') {
+ this.messages[key] = [];
+ }
+
+ this.messages[key][request] = message;
+ };
+
+ // TODO: create comments
+ jsOMS.ResponseManager.prototype.execute = function (key, data, request)
+ {
+ console.log(data);
+ if (typeof request !== 'undefined' && typeof this.messages[key][request] !== 'undefined') {
+ this.messages[key][request](data);
+ } else if(typeof this.messages[key] !== 'undefined') {
+ this.messages[key].any(data);
+ } else {
+ console.log('does not exist');
+ }
+ }
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.EnumResponseResultType = Object.freeze({
+ MULTI: 0,
+ MESSAGE: 1,
+ INFO: 2,
+ DATA: 3,
+ LIST: 4
+ });
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.EnumRequestType = Object.freeze({
+ TEXT: 'text',
+ JSON: 'json',
+ DOCUMENT: 'document',
+ BLOB: 'blob',
+ ARRAYBUFFER: 'arraybuffer',
+ DEFAULT: ''
+ });
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.EventManager = function () {
+ };
+}(window.jsOMS = window.jsOMS || {}));
+SHA1 = function (l) {
+ function p(b, a) {
+ return b << a | b >>> 32 - a
+ }
+
+ l += "";
+ for (var n = Math, c = [1518500249, 1859775393, 2400959708, 3395469782, 1732584193, 4023233417, 2562383102, 271733878, 3285377520, 4294967295], s = n.ceil(l.length / 4) + 2, q = n.ceil(s / 16), g = [], a = 0, h = [], j, d, e, f, m, i, b, k; a < q; a++) {
+ g[a] = [];
+ for (k = 0; k < 16; k++) {
+ function o(b, c) {
+ return l.charCodeAt(a * 64 + k * 4 + b) << c
+ }
+
+ g[a][k] = o(0, 24) | o(1, 16) | o(2, 8) | o(3, 0)
+ }
+ }
+ i = l.length * 8 - 8;
+ a = q - 1;
+ g[a][14] = i / (c[9] + 1);
+ g[a][14] = n.floor(g[a][14]);
+ g[a][15] = i & c[9];
+ for (a = 0; a < q; a++) {
+ for (b = 0; b < 16; b++) {
+ h[b] = g[a][b];
+ }
+ for (b = 16; b < 80; b++) {
+ h[b] = p(h[b - 3] ^ h[b - 8] ^ h[b - 14] ^ h[b - 16], 1);
+ }
+ j = c[4];
+ d = c[5];
+ e = c[6];
+ f = c[7];
+ m = c[8];
+ for (b = 0; b < 80; b++) {
+ var r = n.floor(b / 20), t = p(j, 5) + (r < 1 ? d & e ^ ~d & f : r == 2 ? d & e ^ d & f ^ e & f : d ^ e ^ f) + m + c[r] + h[b] & c[9];
+ m = f;
+ f = e;
+ e = p(d, 30);
+ d = j;
+ j = t
+ }
+ c[4] += j;
+ c[5] += d;
+ c[6] += e;
+ c[7] += f;
+ c[8] += m
+ }
+ i = "";
+ for (z = 4; z < 9; z++) {
+ for (a = 7; a >= 0; a--) {
+ i += ((c[z] & c[9]) >>> a * 4 & 15).toString(16);
+ }
+ }
+ return i;
+};
+function SHA1(s) {
+ function U(a, b, c) {
+ while (0 < c--) {
+ a.push(b)
+ }
+ }
+
+ function L(a, b) {
+ return (a << b) | (a >>> (32 - b))
+ }
+
+ function P(a, b, c) {
+ return a ^ b ^ c
+ }
+
+ function A(a, b) {
+ var c = (b & 0xFFFF) + (a & 0xFFFF), d = (b >>> 16) + (a >>> 16) + (c >>> 16);
+ return ((d & 0xFFFF) << 16) | (c & 0xFFFF)
+ }
+
+ var B = "0123456789abcdef";
+ return (function (a) {
+ var c = [], d = a.length * 4, e;
+ for (var i = 0; i < d; i++) {
+ e = a[i >> 2] >> ((3 - (i % 4)) * 8);
+ c.push(B.charAt((e >> 4) & 0xF) + B.charAt(e & 0xF))
+ }
+ return c.join('')
+ }((function (a, b) {
+ var c, d, e, f, g, h = a.length, v = 0x67452301, w = 0xefcdab89, x = 0x98badcfe, y = 0x10325476, z = 0xc3d2e1f0, M = [];
+ U(M, 0x5a827999, 20);
+ U(M, 0x6ed9eba1, 20);
+ U(M, 0x8f1bbcdc, 20);
+ U(M, 0xca62c1d6, 20);
+ a[b >> 5] |= 0x80 << (24 - (b % 32));
+ a[(((b + 65) >> 9) << 4) + 15] = b;
+ for (var i = 0; i < h; i += 16) {
+ c = v;
+ d = w;
+ e = x;
+ f = y;
+ g = z;
+ for (var j = 0, O = []; j < 80; j++) {
+ O[j] = j < 16 ? a[j + i] : L(O[j - 3] ^ O[j - 8] ^ O[j - 14] ^ O[j - 16], 1);
+ var k = (function (a, b, c, d, e) {
+ var f = (e & 0xFFFF) + (a & 0xFFFF) + (b & 0xFFFF) + (c & 0xFFFF) + (d & 0xFFFF), g = (e >>> 16) + (a >>> 16) + (b >>> 16) + (c >>> 16) + (d >>> 16) + (f >>> 16);
+ return ((g & 0xFFFF) << 16) | (f & 0xFFFF)
+ })(j < 20 ? (function (t, a, b) {
+ return (t & a) ^ (~t & b)
+ }(d, e, f)) : j < 40 ? P(d, e, f) : j < 60 ? (function (t, a, b) {
+ return (t & a) ^ (t & b) ^ (a & b)
+ }(d, e, f)) : P(d, e, f), g, M[j], O[j], L(c, 5));
+ g = f;
+ f = e;
+ e = L(d, 30);
+ d = c;
+ c = k
+ }
+ v = A(v, c);
+ w = A(w, d);
+ x = A(x, e);
+ y = A(y, f);
+ z = A(z, g)
+ }
+ return [v, w, x, y, z]
+ }((function (t) {
+ var a = [], b = 255, c = t.length * 8;
+ for (var i = 0; i < c; i += 8) {
+ a[i >> 5] |= (t.charCodeAt(i / 8) & b) << (24 - (i % 32))
+ }
+ return a
+ }(s)).slice(), s.length * 8))))
+}
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.AssetManager = function ()
+ {
+ this.assets = {};
+ };
+
+ // TODO: create comments
+ jsOMS.AssetManager.prototype.load = function (path, filename, filetype, callback)
+ {
+ var hash;
+
+ if (!this.assets[(hash = jsOMS.hash(path + '/' + filename))]) {
+ var fileref = null;
+
+ if (filetype === 'js') {
+ fileref = document.createElement('script');
+ fileref.setAttribute('type', 'text/javascript');
+ fileref.setAttribute('src', path + '/' + filename);
+
+ if (typeof fileref !== 'undefined') {
+ document.getElementsByTagName('head')[0].appendChild(fileref);
+ }
+
+ this.assets[hash] = path + '/' + filename;
+ } else if (filetype === 'css') {
+ fileref = document.createElement('link');
+ fileref.setAttribute('rel', 'stylesheet');
+ fileref.setAttribute('type', 'text/css');
+ fileref.setAttribute('href', path + '/' + filename);
+
+ if (typeof fileref !== 'undefined') {
+ document.getElementsByTagName('head')[0].appendChild(fileref);
+ }
+
+ this.assets[hash] = path + '/' + filename;
+ } else if (filetype === 'img') {
+ this.assets[hash] = new Image();
+ this.assets[hash].src = path + '/' + filename;
+ } else if (filetype === 'audio') {
+ // TODO: implement audio asset
+ } else if (filetype === 'video') {
+ // TODO: implement video asset
+ }
+
+ if (callback) {
+ fileref.onreadystatechange = function () {
+ if (this.readyState == 'complete') {
+ callback();
+ }
+ };
+
+ fileref.onload = callback();
+ }
+
+ return hash;
+ }
+
+ return false;
+ };
+
+ // TODO: create comments
+ jsOMS.AssetManager.prototype.get = function (id)
+ {
+ if (this.assets[id]) {
+ return this.assets[id];
+ }
+
+ return undefined;
+ };
+
+ // TODO: create comments
+ jsOMS.AssetManager.prototype.unload = function (key)
+ {
+ if (typeof this.assets[key] !== 'undefined') {
+ delete this.assets[key];
+
+ return true;
+ }
+
+ return false;
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.FormManager = function (responseManager)
+ {
+ this.responseManager = responseManager;
+ this.ignore = [];
+ this.success = [];
+ this.injectSelector = [];
+ };
+
+ // TODO: create comments
+ jsOMS.FormManager.prototype.ignore = function (id)
+ {
+ this.ignore.push(id);
+ };
+
+ // TODO: create comments
+ jsOMS.FormManager.prototype.injectSubmit = function (selector, callback)
+ {
+ if (!(selector in this.injectSelector)) {
+ this.injectSelector[selector] = callback;
+ return true;
+ }
+
+ return false;
+ };
+
+ // TODO: create comments
+ jsOMS.FormManager.prototype.setSuccess = function (id, callback)
+ {
+ this.success[id] = callback;
+ };
+
+ jsOMS.FormManager.prototype.bind = function (id)
+ {
+ if (typeof id !== 'undefined' && this.ignore.indexOf(id) === -1) {
+ this.bindElement(document.getElementById(id));
+ } else {
+ var forms = document.getElementsByTagName('form');
+
+ for (var i = 0; i < forms.length; i++) {
+ if (this.ignore.indexOf(forms[i].id) === -1) {
+ this.bindElement(forms[i]);
+ }
+ }
+ }
+ };
+
+ // TODO: create comments
+ jsOMS.FormManager.prototype.validateFormElement = function (e)
+ {
+ /** Validate on change */
+ if (typeof e.dataset.validate !== 'undefined') {
+ if (!(new RegExp(e.dataset.validate)).test(e.value)) {
+ return false;
+ }
+ }
+
+ return true;
+ };
+
+ // TODO: create comments
+ jsOMS.FormManager.prototype.submit = function (e, data)
+ {
+ var request = new jsOMS.Request(),
+ self = this;
+
+ request.setData(data);
+ request.setType('json');
+ request.setUri(e.action);
+ request.setMethod(e.method);
+ request.setRequestHeader('Content-Type', 'application/json');
+ request.setSuccess(function (xhr) {
+ console.log(xhr); // TODO: remove this is for error checking
+ try {
+ var o = JSON.parse(xhr.response),
+ response = Object.keys(o).map(function (k) {
+ return o[k]
+ });
+
+ for (var k = 0; k < response.length; k++) {
+ if (response[k] !== null) {
+ console.log(response[k]);
+
+ /* Handle success */
+ if (!self.success[e.id]) {
+ self.responseManager.execute(response[k].type, response[k]);
+ } else {
+ self.success[e.id](response[k].type, response[k]);
+ }
+ }
+ }
+ } catch (exception) {
+ console.log('No valid json');
+ return false;
+ }
+ });
+
+ request.send();
+ };
+
+ // TODO: create comments
+ jsOMS.FormManager.prototype.getData = function (e)
+ {
+ var input = e.getElementsByTagName('input'),
+ select = e.getElementsByTagName('select'),
+ textarea = e.getElementsByTagName('textarea'),
+ datalist = e.getElementsByTagName('datalist'),
+ formelements = Array.prototype.slice.call(input).concat(Array.prototype.slice.call(select), Array.prototype.slice.call(textarea), Array.prototype.slice.call(datalist)),
+ self = this;
+
+ var validForm = true,
+ submitdata = {};
+
+ for (var k = 0; k < formelements.length; k++) {
+ if (!self.validateFormElement(e)) {
+ validForm = false;
+ // TODO: maybe jump out here since invalid and the elements get checked on changed by default
+ // will this change in the future? if yes then I need to check all and also add markup/styles here
+ }
+
+ submitdata[formelements[k].getAttribute('name')] = formelements[k].value;
+ }
+
+ if(!validForm) {
+ console.log('Form contains invalid data');
+ }
+
+ if(typeof e.dataset.formfields !== 'undefined') {
+ try {
+ var formdata = JSON.parse(e.dataset.formfields);
+
+ Object.keys(formdata).forEach(function(key) {
+ if(formdata[key].startsWith('.') || formdata[key].startsWith('#')) {
+ var formElement = document.querySelector(formdata[key]);
+
+ if(formElement.type === 'checkbox') {
+ submitdata[key] = formElement.checked;
+ } else {
+ submitdata[key] = formElement.value;
+ }
+ }
+ });
+ } catch(exception) {
+ }
+ }
+
+ return submitdata;
+ };
+
+ // TODO: create comments
+ jsOMS.FormManager.prototype.bindElement = function (e)
+ {
+ var input = e.getElementsByTagName('input'),
+ select = e.getElementsByTagName('select'),
+ textarea = e.getElementsByTagName('textarea'),
+ datalist = e.getElementsByTagName('datalist'),
+ buttons = (Array.prototype.slice.call(e.getElementsByTagName('button'))).concat(Array.prototype.slice.call(e.querySelectorAll('input[type=button]'))),
+ submits = e.querySelectorAll('input[type=submit]'),
+ self = this,
+ submitdata = {};
+
+ /** Handle submits */
+ for (var j = 0; j < submits.length; j++) {
+ submits[j].addEventListener('click', function (event) {
+ submitdata = self.getData(e);
+
+ /* Handle injection */
+ var injected = false;
+
+ for (var key in self.injectSelector) {
+ if (e.id === key) {
+ self.injectSelector[key](e);
+
+ injected = true;
+ }
+ }
+
+ if(!injected) {
+ self.submit(e, submitdata);
+ }
+
+ jsOMS.preventAll(event);
+ });
+ };
+
+ /** Handle input */
+ for (var i = 0; i < input.length; i++) {
+ /** Validate on change */
+ if (typeof input[i].dataset.validate !== 'undefined') {
+ var validator = new RegExp(input[i].dataset.validate);
+
+ input[i].onkeyup = function (e) {
+ var selfL = this;
+ jsOMS.watcher(function (e) {
+ if (!validator.test(selfL.value)) {
+ jsOMS.addClass(selfL, 'invalid');
+ console.log('wrong input:' + i);
+ }
+ }, 500);
+ };
+ }
+
+ /** Request on change */
+ if (typeof input[i].dataset.request !== 'undefined') {
+ // handle request during typing
+ }
+ }
+
+ /** Handle select */
+ for (var i = 0; i < select.length; i++) {
+ /** Redirect on change */
+ if (typeof select[i].dataset.redirect !== 'undefined') {
+ select[i].onchange = function () {
+ // TODO: use URI factory (which i still have to create :))
+ window.document.href = e.action.replace('{' + select[i].dataset.redirect + '}', select[i].value);
+ };
+ }
+ }
+
+ /** Handle button */
+ for (var i = 0; i < buttons.length; i++) {
+ /** Redirect in new window on click */
+ if (typeof buttons[i].dataset.ropen !== 'undefined' || typeof buttons[i].dataset.redirect !== 'undefined') {
+ buttons[i].addEventListener('click', function (event) {
+ var ropen = typeof this.dataset.ropen !== 'undefined' ? this.dataset.ropen : this.dataset.redirect,
+ matches = ropen.match(new RegExp("\{[#\?\.a-zA-Z0-9]*\}", "gi")),
+ current = jsOMS.Uri.parse_url(window.location.href),
+ value = null;
+
+ // TODO: find a way to use existing query parameters as well and just overwrite them if defined differently here
+ // eg. use &? in dummy urls to indicate that the url should use existing query parameters as well if not overwritten
+ for (var c = 0; c < matches.length; c++) {
+ var match = matches[c].substring(1, matches[c].length - 1);
+ if (match.indexOf('#') === 0) {
+ value = document.getElementById(match.substring(1, match.length)).value;
+ } else if (match.indexOf('.') === 0) {
+
+ } else if (match.indexOf('?') === 0) {
+ value = jsOMS.Uri.getUriQueryParameter(current.query, match.substring(1, match.length));
+ }
+
+ ropen = ropen.replace(matches[c], value);
+ }
+
+ if (typeof this.dataset.ropen !== 'undefined') {
+ var win = window.open(ropen, '_blank');
+ win.focus();
+ } else {
+ window.document.href = ropen;
+ }
+ });
+ } else if (jsOMS.hasClass(buttons[i], 'form-list') && buttons[i].dataset.name !== 'undefined') {
+ // TODO: maybe use id here instead? then this needs to get changed in the form builder
+ var inputButton = document.querySelector('input[name=' + buttons[i].dataset.name + ']'),
+ list = document.querySelector('ul[data-name=l-' + buttons[i].dataset.name + ']'),
+ hidden = document.querySelector('input[type=hidden][name=h-' + buttons[i].dataset.name + ']');
+
+ buttons[i].addEventListener('click', function (event) {
+ // TODO: maybe validate input value??? if not done during typing
+
+ if (hidden.bind === undefined) {
+ hidden.bind = [];
+ }
+
+ hidden.bind.push(inputButton.bind ? inputButton.bind : inputButton.value);
+ hidden.value = JSON.stringify(hidden.bind);
+
+ var element = document.createElement('li');
+ element.appendChild(document.createTextNode(inputButton.value));
+ list.appendChild(element);
+ });
+ } else if (jsOMS.hasClass(buttons[i], 'form-table') && buttons[i].dataset.name !== 'undefined') {
+ // TODO: maybe use id here instead? then this needs to get changed in the form builder
+ var inputButton = document.querySelector('input[name=' + buttons[i].dataset.name + ']'),
+ table = document.querySelector('table[data-name=l-' + buttons[i].dataset.name + ']'),
+ hidden = document.querySelector('input[type=hidden][name=h-' + buttons[i].dataset.name + ']');
+
+ buttons[i].addEventListener('click', function (event) {
+ // TODO: maybe validate input value??? if not done during typing
+
+ if (hidden.bind === undefined) {
+ hidden.bind = [];
+ }
+
+ hidden.bind.push(inputButton.bind ? inputButton.bind : inputButton.value);
+ hidden.value = JSON.stringify(hidden.bind);
+
+ // TODO: handle table add
+ });
+ }
+ }
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.InputManager = function ()
+ {
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ jsOMS.KeyboardManager = function ()
+ {
+ };
+
+ jsOMS.KeyboardManager.prototype.attach = function (element, keys, callback) {
+ };
+
+ jsOMS.KeyboardManager.prototype.detach = function (eventId) {
+ };
+}(window.jsOMS = window.jsOMS || {}));
+var MathEvaluator = function () {
+
+};
+
+MathEvaluator.prototype.attach = function () {
+
+};
+
+MathEvaluator.prototype.detach = function () {
+
+};
+
+MathEvaluator.prototype.trigger = function (node) {
+ var value = node.value;
+
+ if (!value.slice(0, 1) == '=') {
+ return;
+ }
+
+ var processor = new MathProcessor();
+ return processor.parse(value);
+};
+var MouseClickType = Object.freeze({
+ LEFT: 1,
+ MIDDLE: 2,
+ RIGHT: 3
+});
+(function (jsOMS, undefined) {
+ jsOMS.MouseManager = function ()
+ {
+ };
+
+ jsOMS.MouseManager.prototype.attach = function (clickType, element, callback) {
+ };
+
+ jsOMS.MouseManager.prototype.detach = function (eventId) {
+ };
+}(window.jsOMS = window.jsOMS || {}));
+/* responsible for loading external ui elements (css,html,js) */(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.TabManager = function (responseManager) {
+ this.responseManager = responseManager;
+ };
+
+ // TODO: create comments
+ jsOMS.TabManager.prototype.bind = function (id) {
+ if (typeof id !== 'undefined') {
+ this.bindElement(document.getElementById(id));
+ } else {
+ var tabs = document.querySelectorAll('.tabview');
+
+ for (var i = 0; i < tabs.length; i++) {
+ this.bindElement(tabs[i]);
+ }
+ }
+ };
+
+ // TODO: create comments
+ jsOMS.TabManager.prototype.bindElement = function (e) {
+ var nodes = e.querySelectorAll('.tab-links a');
+
+ nodes.addEventListener('click', function (evt) {
+ /* Change Tab */
+ var attr = this.getAttribute('href').substring(1),
+ cont = this.parentNode.parentNode.parentNode.children[1];
+
+ jsOMS.removeClass(jsOMS.getByClass(this.parentNode.parentNode, 'active'), 'active');
+ jsOMS.addClass(this.parentNode, 'active');
+ jsOMS.removeClass(jsOMS.getByClass(cont, 'active'), 'active');
+ jsOMS.addClass(jsOMS.getByClass(cont, attr), 'active');
+
+ /* Modify url */
+
+ jsOMS.preventAll(evt);
+ });
+ };
+}(window.jsOMS = window.jsOMS || {}));
+(function (jsOMS, undefined) {
+ // TODO: create comments
+ jsOMS.UIManager = function (app)
+ {
+ this.app = app;
+ this.formManager = new jsOMS.FormManager(this.app.responseManager);
+ this.tabManager = new jsOMS.TabManager(this.app.responseManager);
+ };
+
+ // TODO: create comments
+ jsOMS.UIManager.prototype.bind = function()
+ {
+ this.formManager.bind();
+ this.tabManager.bind();
+ }
+
+ // TODO: create comments
+ jsOMS.UIManager.prototype.getFormManager = function()
+ {
+ return this.formManager;
+ }
+}(window.jsOMS = window.jsOMS || {}));
+/* Handle minimize and maximize logic for boxes */
+var nodes = document.querySelectorAll('.b > h1 .max, .b > h2 .max');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ var box = jsOMS.getByClass(e.parentNode.parentNode, 'bc-1');
+ jsOMS.removeClass(box, 'vh');
+ });
+});
+
+nodes = document.querySelectorAll('.b > h1 .min, .b > h2 .min');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ var box = jsOMS.getByClass(e.parentNode.parentNode, 'bc-1');
+ jsOMS.addClass(box, 'vh');
+ });
+});
+/*
+ * Handle global min/max logic.
+ * This switches min/max visibility on click.
+ */
+var nodes = document.getElementsByClassName('min');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ jsOMS.addClass(e, 'vh');
+ jsOMS.removeClass(jsOMS.getByClass(e.parentNode, 'max'), 'vh');
+ });
+});
+
+nodes = document.getElementsByClassName('max');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ jsOMS.addClass(e, 'vh');
+ jsOMS.removeClass(jsOMS.getByClass(e.parentNode, 'min'), 'vh');
+ });
+});
+
+/*
+ * Handle global dim
+ * This allows to activate and deactivate the background dim on certain elements/classes
+ */
+/* Deactivate dim if click on class .close or .save */
+var dim = document.getElementById('dim');
+nodes = document.querySelectorAll('.close, .save');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ jsOMS.addClass(e.parentNode.parentNode.parentNode, 'vh');
+
+ jsOMS.addClass(dim, 'vh')
+ });
+});
+
+/* Activate dim if click on element with class dim */
+nodes = document.getElementsByClassName('dim');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ jsOMS.removeClass(dim, 'vh')
+ });
+});
+/*
+ * Handle special case link and button clicks.
+ * This is usefull in order to support ajax calls and dynamic page changes without reloads
+ */
+var nodes = document.querySelectorAll('a, button, input[type=submit]');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ if (!e.hasAttribute('data-request') || !e.hasAttribute('data-http')) {
+ return true;
+ }
+
+ // TODO: create request object
+
+ var requestType = e.getAttribute('data-request'),
+ httpType = e.getAttribute('data-http'),
+ requestUri = '',
+ requestData = e.getAttribute('data-json');
+
+ if (requestType === 'URL') {
+ requestUri = e.getAttribute('href');
+ } else {
+ requestUri = e.getAttribute('data-uri');
+ }
+
+ jsOMS.ajax({
+ type: httpType,
+ url: URL + requestUri,
+ data: requestData,
+ requestHeader: "application/json; charset=utf-8",
+ responseType: "text",
+ success: function (ret) {
+ console.log(ret);
+ },
+ error: function (ret) {
+ console.log('error');
+ }
+ });
+
+ evt.preventDefault();
+ return false;
+ });
+});
+/* Handling minimizing */
+var nodes = document.querySelectorAll('thead .min');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ var body = jsOMS.getByTag(e.parentNode.parentNode.parentNode.parentNode, 'tbody');
+ jsOMS.addClass(body[0], 'vh');
+ });
+});
+
+/* Handling maximizing */
+nodes = document.querySelectorAll('thead .max');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ var body = jsOMS.getByTag(e.parentNode.parentNode.parentNode.parentNode, 'tbody');
+ jsOMS.removeClass(body[0], 'vh');
+ });
+});
+
+/* Handling header element click */
+nodes = document.querySelectorAll('thead span');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ var filter = e.parentNode.childNodes[4];
+
+ if (jsOMS.hasClass(filter, 'vh')) {
+ jsOMS.removeClass(filter, 'vh');
+ jsOMS.removeClass(e.parentNode.childNodes[1], 'vh');
+ }
+ });
+});
+
+/* Handling sort click */
+nodes = document.querySelectorAll('thead td :nth-child(2)');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ jsOMS.addClass(e, 'vh');
+ jsOMS.removeClass(e.parentNode.childNodes[2], 'vh');
+ });
+});
+
+/* Handling sort click */
+nodes = document.querySelectorAll('thead td :nth-child(3)');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ jsOMS.addClass(e, 'vh');
+ jsOMS.removeClass(e.parentNode.childNodes[3], 'vh');
+ });
+});
+
+/* Handling sort click */
+nodes = document.querySelectorAll('thead td :nth-child(4)');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ jsOMS.addClass(e, 'vh');
+ jsOMS.removeClass(e.parentNode.childNodes[1], 'vh');
+ });
+});
+
+/* Handling sort close click */
+nodes = document.querySelectorAll('thead td :nth-child(5)');
+jsOMS.each(nodes, function (ele) {
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ var iParent = e.parentNode;
+ jsOMS.addClass(iParent.childNodes[1], 'vh');
+ jsOMS.addClass(iParent.childNodes[2], 'vh');
+ jsOMS.addClass(iParent.childNodes[3], 'vh');
+ jsOMS.addClass(iParent.childNodes[4], 'vh');
+ });
+});
+
+/* Handling filter view (creating and saving data) */
+var list_filter_arr = [
+ []
+];
+
+nodes = document.querySelectorAll('thead .f');
+jsOMS.each(nodes, function (ele) {
+ var c = 0;
+
+ jsOMS.listenEvent(ele, 'click', function (evt, e) {
+ var table = e.parentNode.parentNode.parentNode.childNodes[2],
+ filter = document.getElementById('t-f'),
+ flist = document.querySelectorAll('#tf ul');
+
+ jsOMS.empty(flist);
+
+ var titles = jsOMS.getByTag(table, 'td');
+
+ jsOMS.each(titles, function (t) {
+ c++;
+
+ var val = '',
+ tid = e.parentNode.parentNode.parentNode.parentNode.getAttribute('id');
+
+ if ((tid in list_filter_arr) && ('i-' + c in list_filter_arr[tid])) {
+ val = list_filter_arr[tid]['i-' + c];
+ }
+
+ /* Still not working */
+ flist.innerHTML += '' + '';
+ });
+
+ jsOMS.removeClass(filter, 'vh');
+ });
+});
+var formValidationMessage = function (data) {
+ var form = document.getElementById(data.form),
+ eEles = document.getElementsByClassName('i-' + data.form);
+
+ while (eEles.length > 0) {
+ eEles[0].parentNode.removeChild(eEles[0]);
+ }
+
+ data.errors.forEach(function (error) {
+ var eEle = document.getElementById(error.id),
+ msgEle = document.createElement('i'),
+ msg = document.createTextNode(error.msg);
+
+ msgEle.id = 'i-' + error.id;
+ msgEle.class = 'i-' + data.form;
+ msgEle.appendChild(msg);
+ eEle.parentNode.insertBefore(msgEle, eEle.nextSibling);
+ });
+};
+var notifyMessage = function (data) {
+ setTimeout(function () {
+ var notify = document.createElement('div'),
+ h = document.createElement('h1'),
+ inner = document.createElement('div'),
+ title = document.createTextNode(data.title),
+ content = document.createTextNode(data.content);
+
+ notify.id = 'notify';
+ notify.class = data.level;
+ h.appendChild(title);
+ inner.appendChild(content);
+ notify.appendChild(h);
+ notify.appendChild(inner);
+
+ if (data.stay > 0) {
+ setTimeout(function () {
+ notify.parentElement.removeChild(notify);
+ }, data.stay);
+ }
+ }, parseInt(data.delay));
+};
+(function (jsOMS, undefined) {
+ jsOMS.EnumNotifyType = Object.freeze({
+ BINARY: 0,
+ INFO: 1,
+ WARNING: 2,
+ ERROR: 3,
+ FATAL: 4
+ });
+}(window.jsOMS = window.jsOMS || {}));
+var redirectMessage = function (data) {
+ setTimeout(function () {
+ document.location.href = data.url;
+ }, parseInt(data.delay));
+};
+var reloadMessage = function (data) {
+ setTimeout(function () {
+ document.location.reload(true);
+ }, parseInt(data.delay));
+};