Fixing namesapces

This commit is contained in:
Dennis Eichhorn 2016-03-25 21:37:21 +01:00
parent ef72b23a50
commit cabb3937e4
18 changed files with 150 additions and 119 deletions

View File

@ -9,7 +9,7 @@
*/ */
(function (jsOMS, undefined) (function (jsOMS, undefined)
{ {
jsOMS.EnumAccountType = Object.freeze({ jsOMS.Account.EnumAccountType = Object.freeze({
USER: 0, USER: 0,
GROUP: 1 GROUP: 1
}); });

View File

@ -16,7 +16,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.AssetManager = function () jsOMS.Asset.AssetManager = function ()
{ {
this.assets = {}; this.assets = {};
}; };
@ -36,7 +36,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.AssetManager.prototype.load = function (path, filename, filetype, callback) jsOMS.Asset.AssetManager.prototype.load = function (path, filename, filetype, callback)
{ {
var hash; var hash;
@ -102,7 +102,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.AssetManager.prototype.get = function (id) jsOMS.Asset.AssetManager.prototype.get = function (id)
{ {
if (this.assets[id]) { if (this.assets[id]) {
return this.assets[id]; return this.assets[id];
@ -123,7 +123,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.AssetManager.prototype.remove = function (key) jsOMS.Asset.AssetManager.prototype.remove = function (key)
{ {
if (typeof this.assets[key] !== 'undefined') { if (typeof this.assets[key] !== 'undefined') {
delete this.assets[key]; delete this.assets[key];

View File

@ -16,7 +16,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Auth = function (uri) jsOMS.Auth.Auth = function (uri)
{ {
this.account = null; this.account = null;
this.uri = uri; this.uri = uri;
@ -32,7 +32,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Auth.prototype.setAccount = function (account) jsOMS.Auth.Auth.prototype.setAccount = function (account)
{ {
this.account = account; this.account = account;
}; };
@ -47,7 +47,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Auth.prototype.getAccount = function () jsOMS.Auth.Auth.prototype.getAccount = function ()
{ {
return this.account; return this.account;
}; };
@ -60,12 +60,12 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Auth.prototype.login = function () jsOMS.Auth.Auth.prototype.login = function ()
{ {
var authRequest = new jsOMS.Message.Request(); var authRequest = new jsOMS.Message.Request();
authRequest.setUri(this.uri); authRequest.setUri(this.uri);
authRequest.setMethod(jsOMS.EnumRequestMethod.POST); authRequest.setMethod(jsOMS.Message.Request.RequestMethod.POST);
authRequest.setResponseType(jsOMS.EnumRequestType.JSON); authRequest.setResponseType(jsOMS.Message.Request.RequestType.JSON);
authRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); authRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
authRequest.setSuccess(function (xhr) authRequest.setSuccess(function (xhr)
{ {
@ -83,7 +83,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Auth.prototype.logout = function () jsOMS.Auth.Auth.prototype.logout = function ()
{ {
location.reload(); location.reload();
}; };
@ -96,7 +96,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Auth.prototype.loginResult = function (xhr) jsOMS.Auth.Auth.prototype.loginResult = function (xhr)
{ {
console.log(xhr); console.log(xhr);
location.reload(); location.reload();

View File

@ -16,7 +16,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Options = function () jsOMS.Config.Options = function ()
{ {
this.options = {}; this.options = {};
}; };
@ -35,7 +35,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Options.prototype.set = function (key, value, overwrite) jsOMS.Config.Options.prototype.set = function (key, value, overwrite)
{ {
overwrite = typeof overwrite === bool ? overwrite : true; overwrite = typeof overwrite === bool ? overwrite : true;
@ -60,7 +60,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Options.prototype.get = function (key) jsOMS.Config.Options.prototype.get = function (key)
{ {
if (typeof this.options[key] !== 'undefined') { if (typeof this.options[key] !== 'undefined') {
return this.options[key]; return this.options[key];
@ -81,7 +81,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Options.prototype.remove = function (key) jsOMS.Config.Options.prototype.remove = function (key)
{ {
if (typeof this.options[key] !== 'undefined') { if (typeof this.options[key] !== 'undefined') {
delete this.options[key]; delete this.options[key];

View File

@ -16,7 +16,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.CookieJar = function () jsOMS.DataStorage.CookieJar = function ()
{ {
}; };
@ -36,7 +36,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.CookieJar.prototype.setCookie = function (cName, value, exdays, domain, path) jsOMS.DataStorage.CookieJar.prototype.setCookie = function (cName, value, exdays, domain, path)
{ {
var exdate = new Date(); var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays); exdate.setDate(exdate.getDate() + exdays);
@ -56,7 +56,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.CookieJar.prototype.getCookie = function (cName) jsOMS.DataStorage.CookieJar.prototype.getCookie = function (cName)
{ {
var cValue = document.cookie; var cValue = document.cookie;
var cStart = cValue.indexOf(" " + cName + "="); var cStart = cValue.indexOf(" " + cName + "=");

View File

@ -16,7 +16,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.LocalStorage = function () jsOMS.DataStorage.LocalStorage = function ()
{ {
}; };
@ -30,7 +30,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.LocalStorage.prototype.available = function () jsOMS.DataStorage.LocalStorage.prototype.available = function ()
{ {
try { try {
return 'localStorage' in window && window.localStorage !== null; return 'localStorage' in window && window.localStorage !== null;

View File

@ -9,7 +9,7 @@
*/ */
(function (jsOMS, undefined) (function (jsOMS, undefined)
{ {
jsOMS.EnumLogLevel = Object.freeze({ jsOMS.Log.LogLevel = Object.freeze({
EMERGENCY: 'normal', EMERGENCY: 'normal',
ALERT: 'normal', ALERT: 'normal',
CRITICAL: 'normal', CRITICAL: 'normal',

View File

@ -11,8 +11,6 @@
{ {
"use strict"; "use strict";
jsOMS.Logger.layout = '{datetime}; {level}; {version}; {os}; {browser}; {path}; {message}';
/** /**
* @constructor * @constructor
* *
@ -26,9 +24,11 @@
this.remote = typeof remote !== 'undefined' ? remote : false; this.remote = typeof remote !== 'undefined' ? remote : false;
}; };
jsOMS.FormManager.prototype.interpolate = function(message, context, level) jsOMS.Log.Logger.layout = '{datetime}; {level}; {version}; {os}; {browser}; {path}; {message}';
jsOMS.Log.Logger.prototype.interpolate = function(message, context, level)
{ {
let newMessage = jsOMS.Logger.layout; let newMessage = jsOMS.Log.Logger.layout;
for(replace in context) { for(replace in context) {
newMessage = newMessage.replace('{'+replace+'}', context[replace]); newMessage = newMessage.replace('{'+replace+'}', context[replace]);
@ -37,7 +37,7 @@
return newMessage; return newMessage;
}; };
jsOMS.FormManager.prototype.createContext = function(message, context, level) jsOMS.Log.Logger.prototype.createContext = function(message, context, level)
{ {
context['datetime'] = (new Date()).toISOString(); context['datetime'] = (new Date()).toISOString();
context['version'] = '1.0.0'; context['version'] = '1.0.0';
@ -50,7 +50,7 @@
return context; return context;
} }
jsOMS.FormManager.prototype.write = function(message, context, level) jsOMS.Log.Logger.prototype.write = function(message, context, level)
{ {
context = this.createContext(message, context, level); context = this.createContext(message, context, level);
@ -65,62 +65,62 @@
if(this.remote) { if(this.remote) {
let request = new jsOMS.Message.Request(), let request = new jsOMS.Message.Request(),
request.setData(context); request.setData(context);
request.setType(jsOMS.EnumResponseType.JSON); request.setType(jsOMS.Message.Response.ResponseType.JSON);
request.setUri('/{/lang}/api/log'); request.setUri('/{/lang}/api/log');
request.setMethod(jsOMS.EnumRequestMethod.POST); request.setMethod(jsOMS.Message.Request.RequestMethod.POST);
request.setRequestHeader('Content-Type', 'application/json'); request.setRequestHeader('Content-Type', 'application/json');
request.setSuccess(function (xhr) {}); request.setSuccess(function (xhr) {});
request.send(); request.send();
} }
}; };
jsOMS.FormManager.prototype.emergency = function(message, context) jsOMS.Log.Logger.prototype.emergency = function(message, context)
{ {
this.write(message, context, jsOMS.EnumLogLevel.EMERGENCY) this.write(message, context, jsOMS.Log.LogLevel.EMERGENCY)
}; };
jsOMS.FormManager.prototype.alert = function(message, context) jsOMS.Log.Logger.prototype.alert = function(message, context)
{ {
this.write(message, context, jsOMS.EnumLogLevel.ALERT) this.write(message, context, jsOMS.Log.LogLevel.ALERT)
}; };
jsOMS.FormManager.prototype.critical = function(message, context) jsOMS.Log.Logger.prototype.critical = function(message, context)
{ {
this.write(message, context, jsOMS.EnumLogLevel.CRITICAL) this.write(message, context, jsOMS.Log.LogLevel.CRITICAL)
}; };
jsOMS.FormManager.prototype.error = function(message, context) jsOMS.Log.Logger.prototype.error = function(message, context)
{ {
this.write(message, context, jsOMS.EnumLogLevel.ERROR) this.write(message, context, jsOMS.Log.LogLevel.ERROR)
}; };
jsOMS.FormManager.prototype.warning = function(message, context) jsOMS.Log.Logger.prototype.warning = function(message, context)
{ {
this.write(message, context, jsOMS.EnumLogLevel.WARNING) this.write(message, context, jsOMS.Log.LogLevel.WARNING)
}; };
jsOMS.FormManager.prototype.notice = function(message, context) jsOMS.Log.Logger.prototype.notice = function(message, context)
{ {
this.write(message, context, jsOMS.EnumLogLevel.NOTICE) this.write(message, context, jsOMS.Log.LogLevel.NOTICE)
}; };
jsOMS.FormManager.prototype.info = function(message, context) jsOMS.Log.Logger.prototype.info = function(message, context)
{ {
this.write(message, context, jsOMS.EnumLogLevel.INFO) this.write(message, context, jsOMS.Log.LogLevel.INFO)
}; };
jsOMS.FormManager.prototype.debug = function(message, context) jsOMS.Log.Logger.prototype.debug = function(message, context)
{ {
this.write(message, context, jsOMS.EnumLogLevel.DEBUG) this.write(message, context, jsOMS.Log.LogLevel.DEBUG)
}; };
jsOMS.FormManager.prototype.log = function(level, message, context) jsOMS.Log.Logger.prototype.log = function(level, message, context)
{ {
this.write(message, context, context) this.write(message, context, context)
}; };
jsOMS.FormManager.prototype.console = function(level, message, context) jsOMS.Log.Logger.prototype.console = function(level, message, context)
{ {
this.write(message, context, jsOMS.EnumLogLevel.INFO) this.write(message, context, jsOMS.Log.LogLevel.INFO)
}; };
}(window.jsOMS = window.jsOMS || {})); }(window.jsOMS = window.jsOMS || {}));

View File

@ -9,7 +9,7 @@
*/ */
(function (jsOMS, undefined) (function (jsOMS, undefined)
{ {
jsOMS.EnumBrowserType = Object.freeze({ jsOMS.Message.Request.BrowserType = Object.freeze({
OPERA: 'opera', OPERA: 'opera',
FIREFOX: 'firefox', FIREFOX: 'firefox',
SAFARI: 'safari', SAFARI: 'safari',

View File

@ -16,13 +16,13 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request = function (uri, method, type) jsOMS.Message.Request.Request = function (uri, method, type)
{ {
this.uri = typeof uri !== 'undefined' ? uri : null; this.uri = typeof uri !== 'undefined' ? uri : null;
this.method = typeof method !== 'undefined' ? method : jsOMS.EnumRequestMethod.GET; this.method = typeof method !== 'undefined' ? method : jsOMS.Message.Request.RequestMethod.GET;
this.requestHeader = []; this.requestHeader = [];
this.success = null; this.success = null;
this.type = typeof type !== 'undefined' ? type : jsOMS.EnumResponseType.JSON; this.type = typeof type !== 'undefined' ? type : jsOMS.Message.Response.ResponseType.JSON;
this.data = {}; this.data = {};
@ -30,7 +30,7 @@
this.xhr = new XMLHttpRequest(); this.xhr = new XMLHttpRequest();
}; };
jsOMS.Message.Request.getBrowser = function() jsOMS.Message.Request.Request.getBrowser = function()
{ {
if((!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0) { if((!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0) {
return jsOMS.EnumBrowser.OPERA; return jsOMS.EnumBrowser.OPERA;
@ -49,11 +49,11 @@
} }
}; };
jsOMS.Message.Request.getOS = function() jsOMS.Message.Request.Request.getOS = function()
{ {
for(let os in jsOMS.EnumOSType) { for(let os in jsOMS.Message.Request.OSType) {
if(navigator.appversion.indexOf(jsOMS.EnumOSType[os]) !== -1) { if(navigator.appversion.indexOf(jsOMS.Message.Request.OSType[os]) !== -1) {
return jsOMS.EnumOSType[os]; return jsOMS.Message.Request.OSType[os];
} }
} }
}; };
@ -70,7 +70,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.setMethod = function (method) jsOMS.Message.Request.Request.prototype.setMethod = function (method)
{ {
this.method = method; this.method = method;
}; };
@ -87,7 +87,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.getMethod = function () jsOMS.Message.Request.Request.prototype.getMethod = function ()
{ {
return this.method; return this.method;
}; };
@ -104,7 +104,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.setResponseType = function (type) jsOMS.Message.Request.Request.prototype.setResponseType = function (type)
{ {
this.xhr.responseType = type; this.xhr.responseType = type;
}; };
@ -121,7 +121,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.getResponseType = function () jsOMS.Message.Request.Request.prototype.getResponseType = function ()
{ {
return this.responseType; return this.responseType;
}; };
@ -137,7 +137,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.setRequestHeader = function (type, header) jsOMS.Message.Request.Request.prototype.setRequestHeader = function (type, header)
{ {
this.requestHeader[type] = header; this.requestHeader[type] = header;
}; };
@ -152,7 +152,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.getRequestHeader = function () jsOMS.Message.Request.Request.prototype.getRequestHeader = function ()
{ {
return this.requestHeader; return this.requestHeader;
}; };
@ -167,7 +167,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.setUri = function (uri) jsOMS.Message.Request.Request.prototype.setUri = function (uri)
{ {
this.uri = uri; this.uri = uri;
}; };
@ -182,7 +182,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.getUri = function () jsOMS.Message.Request.Request.prototype.getUri = function ()
{ {
return this.uri; return this.uri;
}; };
@ -197,7 +197,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.setSuccess = function (callback) jsOMS.Message.Request.Request.prototype.setSuccess = function (callback)
{ {
this.success = callback; this.success = callback;
}; };
@ -212,7 +212,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.setData = function (data) jsOMS.Message.Request.Request.prototype.setData = function (data)
{ {
this.data = data; this.data = data;
}; };
@ -227,7 +227,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.getData = function () jsOMS.Message.Request.Request.prototype.getData = function ()
{ {
return this.data return this.data
}; };
@ -244,7 +244,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.setType = function (type) jsOMS.Message.Request.Request.prototype.setType = function (type)
{ {
this.type = type; this.type = type;
}; };
@ -261,7 +261,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.getType = function () jsOMS.Message.Request.Request.prototype.getType = function ()
{ {
return this.type; return this.type;
}; };
@ -276,7 +276,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.queryfy = function (obj) jsOMS.Message.Request.Request.prototype.queryfy = function (obj)
{ {
let str = []; let str = [];
for (let p in obj) { for (let p in obj) {
@ -297,7 +297,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.Request.prototype.send = function () jsOMS.Message.Request.Request.prototype.send = function ()
{ {
let self = this; let self = this;
@ -318,14 +318,14 @@
} }
}; };
if (this.type === jsOMS.EnumRequestType.JSON) { if (this.type === jsOMS.Message.Request.RequestType.JSON) {
if (typeof this.requestHeader !== 'undefined' && this.requestHeader['Content-Type'] === 'application/json') { if (typeof this.requestHeader !== 'undefined' && this.requestHeader['Content-Type'] === 'application/json') {
console.log(JSON.stringify(this.data)); console.log(JSON.stringify(this.data));
self.xhr.send(JSON.stringify(this.data)); self.xhr.send(JSON.stringify(this.data));
} else { } else {
self.xhr.send(this.queryfy(this.data)); self.xhr.send(this.queryfy(this.data));
} }
} else if (this.type === jsOMS.EnumRequestType.RAW) { } else if (this.type === jsOMS.Message.Request.RequestType.RAW) {
self.xhr.send(this.data); self.xhr.send(this.data);
} }
}; };

View File

@ -18,7 +18,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.ResponseManager = function () jsOMS.Message.Response.ResponseManager = function ()
{ {
this.messages = {}; this.messages = {};
}; };
@ -37,7 +37,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.ResponseManager.prototype.add = function (key, message, request) jsOMS.Message.Response.ResponseManager.prototype.add = function (key, message, request)
{ {
request = typeof request !== 'undefined' ? request : 'any'; request = typeof request !== 'undefined' ? request : 'any';
if (typeof this.messages[key] === 'undefined') { if (typeof this.messages[key] === 'undefined') {
@ -61,7 +61,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.Message.ResponseManager.prototype.execute = function (key, data, request) jsOMS.Message.Response.ResponseManager.prototype.execute = function (key, data, request)
{ {
console.log(data); console.log(data);
if (typeof request !== 'undefined' && typeof this.messages[key][request] !== 'undefined') { if (typeof request !== 'undefined' && typeof this.messages[key][request] !== 'undefined') {

View File

@ -16,7 +16,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.ModuleFactory = function () jsOMS.Module.ModuleFactory = function ()
{ {
}; };
@ -33,7 +33,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.ModuleFactory.getInstance = function (module, app) jsOMS.Module.ModuleFactory.getInstance = function (module, app)
{ {
return new window['jsOMS']['Modules'][module](app); return new window['jsOMS']['Modules'][module](app);
}; };

View File

@ -18,7 +18,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.ModuleManager = function (app) jsOMS.Module.ModuleManager = function (app)
{ {
this.modules = {}; this.modules = {};
this.app = app; this.app = app;
@ -36,7 +36,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.ModuleManager.prototype.get = function (module) jsOMS.Module.ModuleManager.prototype.get = function (module)
{ {
if (this.modules[module] === undefined) { if (this.modules[module] === undefined) {
this.modules[module] = jsOMS.ModuleFactory.getInstance(module, this.app); this.modules[module] = jsOMS.ModuleFactory.getInstance(module, this.app);

View File

@ -1,11 +1,20 @@
(function (jsOMS, undefined) { (function (jsOMS, undefined) {
jsOMS.KeyboardManager = function () jsOMS.UI.Input.KeyboardManager = function ()
{ {
}; };
jsOMS.KeyboardManager.prototype.attach = function (element, keys, callback) { jsOMS.UI.Input.KeyboardManager.prototype.bind = function (element, keys, callback)
{
element.addEventListener('keyup', function keyBind(event) {
if(event.keyCode === keys.keyCode) {
callback();
}
});
}; };
jsOMS.KeyboardManager.prototype.detach = function (eventId) { jsOMS.UI.Input.KeyboardManager.prototype.unbind = function (element)
{
element.removeEventListener('keyup', keyBind, false);
}; };
}(window.jsOMS = window.jsOMS || {})); }(window.jsOMS = window.jsOMS || {}));

0
UI/Select.js Normal file
View File

View File

@ -1,8 +1,8 @@
(function (uriFactory, undefined) { (function (uriFactory, undefined) {
jsOMS.UriFactory = {}; jsOMS.Uri.UriFactory = {};
jsOMS.UriFactory.uri = {}; jsOMS.Uri.UriFactory.uri = {};
jsOMS.UriFactory.parseUrl = function (str, component) jsOMS.Uri.UriFactory.parseUrl = function (str, component)
{ {
let query, key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port', let query, key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port',
'relative', 'path', 'directory', 'file', 'query', 'fragment' 'relative', 'path', 'directory', 'file', 'query', 'fragment'
@ -61,7 +61,7 @@
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
jsOMS.UriFactory.getUriQueryParameter = function (query, name) jsOMS.Uri.UriFactory.getUriQueryParameter = function (query, name)
{ {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
@ -71,12 +71,12 @@
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}; };
jsOMS.UriFactory.setQuery = function(key, value, overwrite) jsOMS.Uri.UriFactory.setQuery = function(key, value, overwrite)
{ {
overwrite = typeof overwrite !== 'undefined' ? overwrite : true; overwrite = typeof overwrite !== 'undefined' ? overwrite : true;
if(overwrite || !jsOMS.UriFactory.uri.hasProperty(key)) { if(overwrite || !jsOMS.Uri.UriFactory.uri.hasProperty(key)) {
jsOMS.UriFactory.uri[key] = value; jsOMS.Uri.UriFactory.uri[key] = value;
return true; return true;
} }
@ -84,9 +84,9 @@
return false; return false;
}; };
jsOMS.UriFactory.build = function(uri, toMatch) jsOMS.Uri.UriFactory.build = function(uri, toMatch)
{ {
let current = jsOMS.UriFactory.parseUrl(window.location.href); let current = jsOMS.Uri.UriFactory.parseUrl(window.location.href);
// match(new RegExp("\{[#\?\.a-zA-Z0-9]*\}", "gi")); // match(new RegExp("\{[#\?\.a-zA-Z0-9]*\}", "gi"));
return uri.replace('\{[\/#\?@\.\$][a-zA-Z0-9]*\}' function(match) { return uri.replace('\{[\/#\?@\.\$][a-zA-Z0-9]*\}' function(match) {
@ -94,12 +94,12 @@
if(toMatch.hasProperty(match)) { if(toMatch.hasProperty(match)) {
return toMatch[match]; return toMatch[match];
} else if(jsOMS.UriFactory.uri[match] !== 'undefined') { } else if(jsOMS.Uri.UriFactory.uri[match] !== 'undefined') {
return jsOMS.UriFactory.uri[match]; return jsOMS.Uri.UriFactory.uri[match];
} else if (match.indexOf('#') === 0) { } else if (match.indexOf('#') === 0) {
return document.getElementById(match.substring(1, match.length)).value; return document.getElementById(match.substring(1, match.length)).value;
} else if(match.indexOf('?') === 0) { } else if(match.indexOf('?') === 0) {
return jsOMS.UriFactory.getUriQueryParameter(current.query, match.substring(1, match.length)); return jsOMS.Uri.UriFactory.getUriQueryParameter(current.query, match.substring(1, match.length));
} else if(match.indexOf('/') === 0) { } else if(match.indexOf('/') === 0) {
// todo: second match should return second path // todo: second match should return second path
return 'ERROR PATH'; return 'ERROR PATH';

View File

@ -1,49 +1,57 @@
(function (jsOMS, undefined) { (function (jsOMS, undefined) {
"use strict"; "use strict";
jsOMS.FormView = function (id) { jsOMS.Views.FormView = function (id) {
this.id = id; this.id = id;
this.initializeMembers(); this.initializeMembers();
this.bind(); this.bind();
}; };
jsOMS.FormView.prototype.initializeMembers = function() jsOMS.Views.FormView.prototype.initializeMembers = function()
{ {
this.submitInjects = {}; this.submitInjects = {};
this.method = 'POST'; this.method = 'POST';
this.action = ''; this.action = '';
}; };
jsOMS.FormView.prototype.getMethod = function() jsOMS.Views.FormView.prototype.getMethod = function()
{ {
return this.method; return this.method;
}; };
jsOMS.FormView.prototype.getAction = function() jsOMS.Views.FormView.prototype.getAction = function()
{ {
return this.action; return this.action;
}; };
jsOMS.FormView.prototype.getSubmit = function() jsOMS.Views.FormView.prototype.getSubmit = function()
{ {
return document.getElementById(this.id).querySelectorAll('input[type=submit]')[0]; return document.getElementById(this.id).querySelectorAll('input[type=submit]')[0];
}; };
jsOMS.FormView.prototype.injectSubmit = function(id, callback) jsOMS.Views.FormView.prototype.injectSubmit = function(id, callback)
{ {
this.submitInjects[id] = callback; this.submitInjects[id] = callback;
}; };
jsOMS.FormView.prototype.getData = function() jsOMS.Views.FormView.prototype.getFormElements = function(id)
{ {
let data = {}, let form = document.getElementById(id),
form = document.getElementById(this.id),
selects = form.getElementsByTagName('select'), selects = form.getElementsByTagName('select'),
textareas = form.getElementsByTagName('textarea'), textareas = form.getElementsByTagName('textarea'),
inputs = form.getElementsByTagName('input'), inputs = form.getElementsByTagName('input'),
external = document.querySelectorAll('[form='+this.id+']'), external = document.querySelectorAll('[form='+id+']'),
elements = Array.prototype.slice.call(inputs).concat(Array.prototype.slice.call(selects), Array.prototype.slice.call(textareas), Array.prototype.slice.call(external)), elements = Array.prototype.slice.call(inputs).concat(Array.prototype.slice.call(selects), Array.prototype.slice.call(textareas), Array.prototype.slice.call(external)),
length = elements.length;
return elements;
}
jsOMS.Views.FormView.prototype.getData = function()
{
let data = {},
elements = this.getFormElements(this.id),
length = elements.length, length = elements.length,
i = 0; i = 0;
@ -54,24 +62,19 @@
return data; return data;
}; };
jsOMS.FormView.prototype.getSubmitInjects = function() jsOMS.Views.FormView.prototype.getSubmitInjects = function()
{ {
return this.submitInjects; return this.submitInjects;
}; };
jsOMS.FormView.prototype.bind = function() jsOMS.Views.FormView.prototype.bind = function()
{ {
this.clean(); this.clean();
this.method = document.getElementById(this.id).method; this.method = document.getElementById(this.id).method;
this.action = document.getElementById(this.id).action; this.action = document.getElementById(this.id).action;
let form = document.getElementById(this.id), let elements = this.getFormElements(this.id),
selects = form.getElementsByTagName('select'),
textareas = form.getElementsByTagName('textarea'),
inputs = form.getElementsByTagName('input'),
external = document.querySelectorAll('[form='+this.id+']'),
elements = Array.prototype.slice.call(inputs).concat(Array.prototype.slice.call(selects), Array.prototype.slice.call(textareas), Array.prototype.slice.call(external)),
length = elements.length, length = elements.length,
i = 0; i = 0;
@ -93,12 +96,31 @@
} }
}; };
jsOMS.FormView.prototype.unbind = function() jsOMS.Views.FormView.prototype.unbind = function()
{ {
let elements = this.getFormElements(this.id),
length = elements.length,
i = 0;
for(i = 0; i < length; i++) {
switch(elements[i].tagName) {
case 'input':
jsOMS.UI.Input.unbind(elements[i])
break;
case 'select':
this.bindSelect(elements[i]);
break;
case 'textarea':
this.bindTextarea(elements[i]);
break;
case 'button':
this.bindButton(elements[i]);
break;
};
}
}; };
jsOMS.FormView.prototype.clean = function() jsOMS.Views.FormView.prototype.clean = function()
{ {
this.unbind(); this.unbind();
this.initializeMembers(); this.initializeMembers();