mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-01-11 09:58:39 +00:00
Init
This commit is contained in:
parent
685f37e832
commit
a6f9aeebc9
80
Account/AccountManager.js
Normal file
80
Account/AccountManager.js
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* Account Manager.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.AccountManager = function ()
|
||||
{
|
||||
this.accounts = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Add account.
|
||||
*
|
||||
* @param {Object} account Account
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.AccountManager.prototype.get = function (id)
|
||||
{
|
||||
if (this.accounts[id]) {
|
||||
return this.accounts[id];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
16
Account/AccountType.enum.js
Normal file
16
Account/AccountType.enum.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Account type.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 || {}));
|
||||
136
Asset/AssetManager.js
Normal file
136
Asset/AssetManager.js
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/**
|
||||
* Asset manager.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.AssetManager.prototype.remove = function (key)
|
||||
{
|
||||
if (typeof this.assets[key] !== 'undefined') {
|
||||
delete this.assets[key];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
104
Auth/Auth.js
Normal file
104
Auth/Auth.js
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/**
|
||||
* Auth class.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Auth.prototype.setAccount = function (account)
|
||||
{
|
||||
this.account = account;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get account.
|
||||
*
|
||||
* @return {Object}
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Auth.prototype.getAccount = function ()
|
||||
{
|
||||
return this.account;
|
||||
};
|
||||
|
||||
/**
|
||||
* Login account.
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Auth.prototype.logout = function ()
|
||||
{
|
||||
location.reload();
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle login result.
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Auth.prototype.loginResult = function (xhr)
|
||||
{
|
||||
console.log(xhr);
|
||||
location.reload();
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
0
Chart/BarChart.js
Normal file
0
Chart/BarChart.js
Normal file
67
Chart/Chart.js
vendored
Normal file
67
Chart/Chart.js
vendored
Normal file
|
|
@ -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 || {}));
|
||||
47
Chart/ChartLegend.js
Normal file
47
Chart/ChartLegend.js
Normal file
|
|
@ -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 || {}));
|
||||
0
Chart/DonutChart.js
Normal file
0
Chart/DonutChart.js
Normal file
31
Chart/LineChart.js
Normal file
31
Chart/LineChart.js
Normal file
|
|
@ -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 || {}));
|
||||
0
Chart/PieChart.js
Normal file
0
Chart/PieChart.js
Normal file
0
Chart/PositionEnum.js
Normal file
0
Chart/PositionEnum.js
Normal file
94
Config/Options.js
Normal file
94
Config/Options.js
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/**
|
||||
* Options class.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Options.prototype.remove = function (key)
|
||||
{
|
||||
if (typeof this.options[key] !== 'undefined') {
|
||||
delete this.options[key];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
0
Controllers/Form.js
Normal file
0
Controllers/Form.js
Normal file
6
DataStorage/CacheManager.js
Normal file
6
DataStorage/CacheManager.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(function (jsOMS, undefined) {
|
||||
// TODO: create comments
|
||||
jsOMS.CacheManager = function ()
|
||||
{
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
82
DataStorage/CookieJar.js
Normal file
82
DataStorage/CookieJar.js
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
* CookieJar class.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 || {}));
|
||||
41
DataStorage/LocalStorage.js
Normal file
41
DataStorage/LocalStorage.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* LocalStorage class.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.LocalStorage = function ()
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* Is local storage available?
|
||||
*
|
||||
* @return {boo}
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.LocalStorage.prototype.available = function ()
|
||||
{
|
||||
try {
|
||||
return 'localStorage' in window && window.localStorage !== null;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
5
DataStorage/StorageManager.js
Normal file
5
DataStorage/StorageManager.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(function (jsOMS, undefined) {
|
||||
jsOMS.StorageManager = function ()
|
||||
{
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
5
Dispatcher/Dispatcher.js
Normal file
5
Dispatcher/Dispatcher.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(function (jsOMS, undefined) {
|
||||
jsOMS.Dispatcher = function ()
|
||||
{
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
4
Event/EventManager.js
Normal file
4
Event/EventManager.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(function (jsOMS, undefined) {
|
||||
jsOMS.EventManager = function () {
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
0
Localization/README.md
Normal file
0
Localization/README.md
Normal file
138
Math/MathProcessor.js
Normal file
138
Math/MathProcessor.js
Normal file
|
|
@ -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"));
|
||||
};
|
||||
}
|
||||
0
Media/Audio/UISound.js
Normal file
0
Media/Audio/UISound.js
Normal file
1
Media/README.md
Normal file
1
Media/README.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Media #
|
||||
302
Message/Request/Request.js
Normal file
302
Message/Request/Request.js
Normal file
|
|
@ -0,0 +1,302 @@
|
|||
/**
|
||||
* Request class.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Request.prototype.setMethod = function (method)
|
||||
{
|
||||
this.method = method;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get request method.
|
||||
*
|
||||
* EnumRequestMethod
|
||||
*
|
||||
* @return {string}
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Request.prototype.setResponseType = function (type)
|
||||
{
|
||||
this.xhr.responseType = type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get response type.
|
||||
*
|
||||
* EnumResponseType
|
||||
*
|
||||
* @return {string}
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Request.prototype.setRequestHeader = function (type, header)
|
||||
{
|
||||
this.requestHeader[type] = header;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get request header.
|
||||
*
|
||||
* @return {string}
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Request.prototype.getRequestHeader = function ()
|
||||
{
|
||||
return this.requestHeader;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set request uri.
|
||||
*
|
||||
* @param {string} uri Request uri
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Request.prototype.setUri = function (uri)
|
||||
{
|
||||
this.uri = uri;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get request uri.
|
||||
*
|
||||
* @return {string}
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Request.prototype.getUri = function ()
|
||||
{
|
||||
return this.uri;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set success callback.
|
||||
*
|
||||
* @param {requestCallback} success Success callback
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Request.prototype.setData = function (data)
|
||||
{
|
||||
this.data = data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get request data.
|
||||
*
|
||||
* @return {Array}
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Request.prototype.setType = function (type)
|
||||
{
|
||||
this.type = type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get request type.
|
||||
*
|
||||
* EnumRequestType
|
||||
*
|
||||
* @return {string}
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.Request.prototype.getType = function ()
|
||||
{
|
||||
return this.type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create query from object.
|
||||
*
|
||||
* @return {string}
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 || {}));
|
||||
16
Message/Request/RequestData.enum.js
Normal file
16
Message/Request/RequestData.enum.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Request data enum.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 || {}));
|
||||
24
Message/Request/RequestManager.js
Normal file
24
Message/Request/RequestManager.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Request manager class.
|
||||
*
|
||||
* Used for pooling requests.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.RequestManager = function ()
|
||||
{
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
19
Message/Request/RequestMethod.enum.js
Normal file
19
Message/Request/RequestMethod.enum.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* Http request method.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 || {}));
|
||||
16
Message/Request/RequestType.enum.js
Normal file
16
Message/Request/RequestType.enum.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Request type enum.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 || {}));
|
||||
75
Message/Response/ResponseManager.js
Normal file
75
Message/Response/ResponseManager.js
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
* Response manager class.
|
||||
*
|
||||
* Used for auto handling different responses.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 || {}));
|
||||
19
Message/Response/ResponseResultType.enum.js
Normal file
19
Message/Response/ResponseResultType.enum.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* Response result type enum.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 || {}));
|
||||
20
Message/Response/ResponseType.enum.js
Normal file
20
Message/Response/ResponseType.enum.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* Response type enum.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 || {}));
|
||||
8
Models/Account.js
Normal file
8
Models/Account.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(function (jsOMS, undefined) {
|
||||
jsOMS.Account = function () {
|
||||
this.login = '';
|
||||
this.password = '';
|
||||
this.id = 0;
|
||||
this.auth = null;
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
40
Module/ModuleFactory.js
Normal file
40
Module/ModuleFactory.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* Module factory.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.ModuleFactory.getInstance = function (module, app)
|
||||
{
|
||||
return new window['jsOMS']['Modules'][module](app);
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
47
Module/ModuleManager.js
Normal file
47
Module/ModuleManager.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
* Module factory.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 || {}));
|
||||
15
Route/Route.js
Normal file
15
Route/Route.js
Normal file
|
|
@ -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 || {}));
|
||||
58
Security/Hash/Sha1.js
Normal file
58
Security/Hash/Sha1.js
Normal file
|
|
@ -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;
|
||||
};
|
||||
84
Security/Hash/Sha1b.js
Normal file
84
Security/Hash/Sha1b.js
Normal file
|
|
@ -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))))
|
||||
}
|
||||
44
Socket/Client/Client.js
Normal file
44
Socket/Client/Client.js
Normal file
|
|
@ -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 || {}));
|
||||
0
Stdlib/README.md
Normal file
0
Stdlib/README.md
Normal file
0
System/README.md
Normal file
0
System/README.md
Normal file
408
UI/FormManager.js
Normal file
408
UI/FormManager.js
Normal file
|
|
@ -0,0 +1,408 @@
|
|||
/**
|
||||
* Form manager class.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 || {}));
|
||||
5
UI/Input/InputManager.js
Normal file
5
UI/Input/InputManager.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(function (jsOMS, undefined) {
|
||||
jsOMS.InputManager = function ()
|
||||
{
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
11
UI/Input/Keyboard/KeyboardManager.js
Normal file
11
UI/Input/Keyboard/KeyboardManager.js
Normal file
|
|
@ -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 || {}));
|
||||
22
UI/Input/Math/Evaluator.class.js
Normal file
22
UI/Input/Math/Evaluator.class.js
Normal file
|
|
@ -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);
|
||||
};
|
||||
5
UI/Input/Mouse/ClickType.enum.js
Normal file
5
UI/Input/Mouse/ClickType.enum.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
var MouseClickType = Object.freeze({
|
||||
LEFT: 1,
|
||||
MIDDLE: 2,
|
||||
RIGHT: 3
|
||||
});
|
||||
11
UI/Input/Mouse/MouseManager.js
Normal file
11
UI/Input/Mouse/MouseManager.js
Normal file
|
|
@ -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 || {}));
|
||||
0
UI/LinkManager.js
Normal file
0
UI/LinkManager.js
Normal file
1
UI/Loader.js
Normal file
1
UI/Loader.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
/* responsible for loading external ui elements (css,html,js) */
|
||||
77
UI/TabManager.js
Normal file
77
UI/TabManager.js
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* Tab manager class.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.TabManager = function (responseManager)
|
||||
{
|
||||
this.responseManager = responseManager;
|
||||
};
|
||||
|
||||
/**
|
||||
* Bind & rebind UI elements.
|
||||
*
|
||||
* @param {string} [id] Element id
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 || {}));
|
||||
60
UI/TableManager.js
Normal file
60
UI/TableManager.js
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* Table manager class.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.TableManager = function (responseManager)
|
||||
{
|
||||
this.responseManager = responseManager;
|
||||
};
|
||||
|
||||
/**
|
||||
* Bind & rebind UI elements.
|
||||
*
|
||||
* @param {string} [id] Element id
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.TableManager.prototype.bindElement = function (e)
|
||||
{
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
100
UI/UIManager.js
Normal file
100
UI/UIManager.js
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
/**
|
||||
* UI manager for handling basic ui elements.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UIManager.prototype.getFormManager = function ()
|
||||
{
|
||||
return this.formManager;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get tab manager.
|
||||
*
|
||||
* @return {Object}
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UIManager.prototype.getTabManager = function ()
|
||||
{
|
||||
return this.tabManager;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get table manager.
|
||||
*
|
||||
* @return {Object}
|
||||
*
|
||||
* @method
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UIManager.prototype.getTableManager = function ()
|
||||
{
|
||||
return this.tabManager;
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
106
Uri/Uri.js
Normal file
106
Uri/Uri.js
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
/**
|
||||
* UI manager for handling basic ui elements.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 || {}));
|
||||
3
Uri/UriFactory.js
Normal file
3
Uri/UriFactory.js
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(function (uriFactory, undefined) {
|
||||
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
82
Utils/Markdown/Markdown.js
Normal file
82
Utils/Markdown/Markdown.js
Normal file
|
|
@ -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 += '</p><p>';
|
||||
} else if (i === 0) {
|
||||
line = '<p>' + line;
|
||||
} else if(i === liens.length - 1) {
|
||||
line += '</p>';
|
||||
}
|
||||
|
||||
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 || {}));
|
||||
271
Utils/oLib.js
Normal file
271
Utils/oLib.js
Normal file
|
|
@ -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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 <d.eichhorn@oms.com>
|
||||
*/
|
||||
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 || {}));
|
||||
0
Validattion/ValidateDate.class.js
Normal file
0
Validattion/ValidateDate.class.js
Normal file
0
Validattion/ValidateMath.class.js
Normal file
0
Validattion/ValidateMath.class.js
Normal file
0
Validattion/ValidateNumber.class.js
Normal file
0
Validattion/ValidateNumber.class.js
Normal file
0
Validattion/ValidateString.class.js
Normal file
0
Validattion/ValidateString.class.js
Normal file
9
Validattion/Validation.js
Normal file
9
Validattion/Validation.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(function (jsOMS, undefined) {
|
||||
jsOMS.Validation = function () {
|
||||
|
||||
};
|
||||
|
||||
jsOMS.Validation.prototype.addInput = function () {
|
||||
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
14
Views/FormView.js
Normal file
14
Views/FormView.js
Normal file
|
|
@ -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 || {}));
|
||||
36
Views/TableView.js
Normal file
36
Views/TableView.js
Normal file
|
|
@ -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 || {}));
|
||||
30
Views/ViewAbstract.js
Normal file
30
Views/ViewAbstract.js
Normal file
|
|
@ -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 || {}));
|
||||
1979
oms.min.js
vendored
Normal file
1979
oms.min.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user