Fixing bugs after restructure

Reporter is main test module
This commit is contained in:
Dennis Eichhorn 2016-04-30 22:49:42 +02:00
parent 93dfa09e31
commit cd3b8a221a
10 changed files with 81 additions and 2031 deletions

View File

@ -49,14 +49,36 @@
context['message'] = message;
return context;
}
};
jsOMS.Log.Logger.prototype.write = function(message, context, level)
{
context = this.createContext(message, context, level);
if(this.verbose) {
console.log('%c' + this.interpolate(message, context, level), 'color: #FFA600');
let color = '000';
switch(level) {
case 'info':
case 'notice':
case 'log':
color = '000';
break;
case 'debug':
color = '289E39';
break;
case 'warning':
case 'alert':
color = 'FFA600';
break;
case 'error':
case 'critical':
case 'emergency':
color = 'CF304A';
break;
}
console.log('%c' + this.interpolate(message, context, level), 'color: #' + color);
}
if(this.ui) {

View File

@ -12,6 +12,7 @@
jsOMS.Autoloader.defineNamespace('jsOMS.Message.Request');
jsOMS.Message.Request.OSType = Object.freeze({
WINDOWS_10: 'windows nt 10.0', /* Windows 10 */
WINDOWS_81: 'windows nt 6.3', /* Windows 8.1 */
WINDOWS_8: 'windows nt 6.2', /* Windows 8 */
WINDOWS_7: 'windows nt 6.1', /* Windows 7 */

View File

@ -25,9 +25,6 @@
this.success = null;
this.type = typeof type !== 'undefined' ? type : jsOMS.Message.Response.ResponseType.JSON;
this.data = {};
this.xhr = new XMLHttpRequest();
};
@ -191,7 +188,8 @@
/**
* Set success callback.
*
* @param {requestCallback} callback Success callback
* @callback requestCallback
* @param {requestCallback} callback - Success callback
*
* @method
*

View File

@ -36,6 +36,6 @@
*/
jsOMS.Module.ModuleFactory.getInstance = function (module, app)
{
return new window['jsOMS']['Modules'][module](app);
return new jsOMS.Modules[module](app);
};
}(window.jsOMS = window.jsOMS || {}));

View File

@ -38,7 +38,7 @@
jsOMS.Module.ModuleManager.prototype.get = function (module)
{
if (this.modules[module] === undefined) {
this.modules[module] = jsOMS.ModuleFactory.getInstance(module, this.app);
this.modules[module] = jsOMS.Module.ModuleFactory.getInstance(module, this.app);
}
return this.modules[module];

View File

@ -71,8 +71,8 @@
}
this.forms[id].getSubmit().addEventListener('click', function(event) {
self.submit(self.forms[id]);
jsOMS.preventAll(event);
self.submit(self.forms[id]);
});
};
@ -93,10 +93,15 @@
jsOMS.UI.FormManager.prototype.submit = function(form)
{
if(!form.isValid()) {
this.app.logger.debug('Form "' + form.getId() + '" has invalid values.');
return;
}
/* Handle injects */
let injects = form.getSubmitInjects();
for(let property in injects) {
property();
injects[property](form.getElement());
}
/* Handle default submit */
@ -128,7 +133,7 @@
}
}
} catch (exception) {
self.app.logger.error('Invalid Login response: ' + JSON.stringify(xhr));
self.app.logger.error('Invalid form response: ' + JSON.stringify(xhr));
return false;
}

View File

@ -51,7 +51,7 @@
case 'table':
this.tableManager.bind(id);
break;
};
}
}
};

View File

@ -1,12 +1,13 @@
(function (uriFactory, undefined) {
jsOMS.Autoloader.defineNamespace('jsOMS.Uri.UriFactory');
jsOMS.Uri.UriFactory.parseUrl = function (str, component)
jsOMS.Uri.UriFactory.uri = {};
jsOMS.Uri.UriFactory.parseUrl = function (str)
{
let query, key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port',
'relative', 'path', 'directory', 'file', 'query', 'fragment'
],
ini = {},
mode = 'php',
parser = {
php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
@ -24,24 +25,6 @@
}
}
if (component) {
return uri[component.replace('PHP_URL_', '').toLowerCase()];
}
if (mode !== 'php') {
let name = '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;
@ -86,12 +69,11 @@
jsOMS.Uri.UriFactory.build = function(uri, toMatch)
{
let current = jsOMS.Uri.UriFactory.parseUrl(window.location.href);
// match(new RegExp("\{[#\?\.a-zA-Z0-9]*\}", "gi"));
return uri.replace('\{[\/#\?@\.\$][a-zA-Z0-9]*\}', function(match) {
match = substr(match[0], 1, match[0].length - 2);
return uri.replace(new RegExp('\{[\/#\?@\.\$][a-zA-Z0-9]*\}', 'g'), function(match) {
match = match.substr(1, match.length - 2);
if(toMatch.hasProperty(match)) {
if(typeof toMatch !== 'undefined' && toMatch.hasProperty(match)) {
return toMatch[match];
} else if(jsOMS.Uri.UriFactory.uri[match] !== 'undefined') {
return jsOMS.Uri.UriFactory.uri[match];

View File

@ -12,7 +12,7 @@
jsOMS.Views.FormView.prototype.initializeMembers = function()
{
this.submitInjects = {};
this.submitInjects = [];
this.method = 'POST';
this.action = '';
};
@ -44,41 +44,62 @@
jsOMS.Views.FormView.prototype.injectSubmit = function(id, callback)
{
this.submitInjects[id] = callback;
this.submitInjects.push(callback);
};
jsOMS.Views.FormView.prototype.getFormElements = function(id)
jsOMS.Views.FormView.prototype.getFormElements = function()
{
let form = document.getElementById(id),
let form = document.getElementById(this.id),
selects = form.getElementsByTagName('select'),
textareas = form.getElementsByTagName('textarea'),
inputs = form.getElementsByTagName('input'),
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)),
length = elements.length;
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));
return elements;
}
};
jsOMS.Views.FormView.prototype.getData = function()
{
let data = {},
elements = this.getFormElements(this.id),
elements = this.getFormElements(),
length = elements.length,
i = 0;
for(i = 0; i < length; i++) {
data[this.getElementId(elements[i])] = elements[i].value;
data[jsOMS.Views.FormView.getElementId(elements[i])] = elements[i].value;
}
return data;
};
jsOMS.Views.FormView.prototype.getElementId = function(e)
jsOMS.Views.FormView.prototype.getId = function()
{
let id = null;
return this.id;
};
id = e.getAttribute('name');
jsOMS.Views.FormView.prototype.isValid = function()
{
let elements = this.getFormElements(),
length = elements.length;
for(let i = 0; i < length; i++) {
if((elements[i].required && elements[i].value === '') || (typeof elements[i].pattern !== 'undefined' && elements[i].pattern !== '' && (new RegExp(elements[i].pattern)).test(elements[i].value))) {
return false;
}
}
return true;
};
jsOMS.Views.FormView.prototype.getElement = function()
{
return document.getElementById(this.getId());
};
jsOMS.Views.FormView.getElementId = function(e)
{
let id = e.getAttribute('name');
if(id === null) {
id = e.getAttribute('id');
@ -93,7 +114,7 @@
}
return id;
}
};
jsOMS.Views.FormView.prototype.getSubmitInjects = function()
{
@ -107,7 +128,7 @@
this.method = document.getElementById(this.id).method;
this.action = document.getElementById(this.id).action;
let elements = this.getFormElements(this.id),
let elements = this.getFormElements(),
length = elements.length,
i = 0;
@ -131,7 +152,7 @@
jsOMS.Views.FormView.prototype.unbind = function()
{
let elements = this.getFormElements(this.id),
let elements = this.getFormElements(),
length = elements.length,
i = 0;

1979
oms.min.js vendored

File diff suppressed because it is too large Load Diff