mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-02-11 23:28:41 +00:00
Fixing bugs after restructure
Reporter is main test module
This commit is contained in:
parent
93dfa09e31
commit
cd3b8a221a
|
|
@ -49,14 +49,36 @@
|
||||||
context['message'] = message;
|
context['message'] = message;
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
};
|
||||||
|
|
||||||
jsOMS.Log.Logger.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);
|
||||||
|
|
||||||
if(this.verbose) {
|
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) {
|
if(this.ui) {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
jsOMS.Autoloader.defineNamespace('jsOMS.Message.Request');
|
jsOMS.Autoloader.defineNamespace('jsOMS.Message.Request');
|
||||||
|
|
||||||
jsOMS.Message.Request.OSType = Object.freeze({
|
jsOMS.Message.Request.OSType = Object.freeze({
|
||||||
|
WINDOWS_10: 'windows nt 10.0', /* Windows 10 */
|
||||||
WINDOWS_81: 'windows nt 6.3', /* Windows 8.1 */
|
WINDOWS_81: 'windows nt 6.3', /* Windows 8.1 */
|
||||||
WINDOWS_8: 'windows nt 6.2', /* Windows 8 */
|
WINDOWS_8: 'windows nt 6.2', /* Windows 8 */
|
||||||
WINDOWS_7: 'windows nt 6.1', /* Windows 7 */
|
WINDOWS_7: 'windows nt 6.1', /* Windows 7 */
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,6 @@
|
||||||
this.success = null;
|
this.success = null;
|
||||||
this.type = typeof type !== 'undefined' ? type : jsOMS.Message.Response.ResponseType.JSON;
|
this.type = typeof type !== 'undefined' ? type : jsOMS.Message.Response.ResponseType.JSON;
|
||||||
this.data = {};
|
this.data = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.xhr = new XMLHttpRequest();
|
this.xhr = new XMLHttpRequest();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -191,7 +188,8 @@
|
||||||
/**
|
/**
|
||||||
* Set success callback.
|
* Set success callback.
|
||||||
*
|
*
|
||||||
* @param {requestCallback} callback Success callback
|
* @callback requestCallback
|
||||||
|
* @param {requestCallback} callback - Success callback
|
||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,6 @@
|
||||||
*/
|
*/
|
||||||
jsOMS.Module.ModuleFactory.getInstance = function (module, app)
|
jsOMS.Module.ModuleFactory.getInstance = function (module, app)
|
||||||
{
|
{
|
||||||
return new window['jsOMS']['Modules'][module](app);
|
return new jsOMS.Modules[module](app);
|
||||||
};
|
};
|
||||||
}(window.jsOMS = window.jsOMS || {}));
|
}(window.jsOMS = window.jsOMS || {}));
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
jsOMS.Module.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.Module.ModuleFactory.getInstance(module, this.app);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.modules[module];
|
return this.modules[module];
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.forms[id].getSubmit().addEventListener('click', function(event) {
|
this.forms[id].getSubmit().addEventListener('click', function(event) {
|
||||||
self.submit(self.forms[id]);
|
|
||||||
jsOMS.preventAll(event);
|
jsOMS.preventAll(event);
|
||||||
|
self.submit(self.forms[id]);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -93,10 +93,15 @@
|
||||||
|
|
||||||
jsOMS.UI.FormManager.prototype.submit = function(form)
|
jsOMS.UI.FormManager.prototype.submit = function(form)
|
||||||
{
|
{
|
||||||
|
if(!form.isValid()) {
|
||||||
|
this.app.logger.debug('Form "' + form.getId() + '" has invalid values.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Handle injects */
|
/* Handle injects */
|
||||||
let injects = form.getSubmitInjects();
|
let injects = form.getSubmitInjects();
|
||||||
for(let property in injects) {
|
for(let property in injects) {
|
||||||
property();
|
injects[property](form.getElement());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle default submit */
|
/* Handle default submit */
|
||||||
|
|
@ -128,7 +133,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
self.app.logger.error('Invalid Login response: ' + JSON.stringify(xhr));
|
self.app.logger.error('Invalid form response: ' + JSON.stringify(xhr));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
case 'table':
|
case 'table':
|
||||||
this.tableManager.bind(id);
|
this.tableManager.bind(id);
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
(function (uriFactory, undefined) {
|
(function (uriFactory, undefined) {
|
||||||
jsOMS.Autoloader.defineNamespace('jsOMS.Uri.UriFactory');
|
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',
|
let query, key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port',
|
||||||
'relative', 'path', 'directory', 'file', 'query', 'fragment'
|
'relative', 'path', 'directory', 'file', 'query', 'fragment'
|
||||||
],
|
],
|
||||||
ini = {},
|
|
||||||
mode = 'php',
|
mode = 'php',
|
||||||
parser = {
|
parser = {
|
||||||
php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
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;
|
delete uri.source;
|
||||||
|
|
||||||
return uri;
|
return uri;
|
||||||
|
|
@ -86,12 +69,11 @@
|
||||||
jsOMS.Uri.UriFactory.build = function(uri, toMatch)
|
jsOMS.Uri.UriFactory.build = function(uri, toMatch)
|
||||||
{
|
{
|
||||||
let current = jsOMS.Uri.UriFactory.parseUrl(window.location.href);
|
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) {
|
return uri.replace(new RegExp('\{[\/#\?@\.\$][a-zA-Z0-9]*\}', 'g'), function(match) {
|
||||||
match = substr(match[0], 1, match[0].length - 2);
|
match = match.substr(1, match.length - 2);
|
||||||
|
|
||||||
if(toMatch.hasProperty(match)) {
|
if(typeof toMatch !== 'undefined' && toMatch.hasProperty(match)) {
|
||||||
return toMatch[match];
|
return toMatch[match];
|
||||||
} else if(jsOMS.Uri.UriFactory.uri[match] !== 'undefined') {
|
} else if(jsOMS.Uri.UriFactory.uri[match] !== 'undefined') {
|
||||||
return jsOMS.Uri.UriFactory.uri[match];
|
return jsOMS.Uri.UriFactory.uri[match];
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
jsOMS.Views.FormView.prototype.initializeMembers = function()
|
jsOMS.Views.FormView.prototype.initializeMembers = function()
|
||||||
{
|
{
|
||||||
this.submitInjects = {};
|
this.submitInjects = [];
|
||||||
this.method = 'POST';
|
this.method = 'POST';
|
||||||
this.action = '';
|
this.action = '';
|
||||||
};
|
};
|
||||||
|
|
@ -44,41 +44,62 @@
|
||||||
|
|
||||||
jsOMS.Views.FormView.prototype.injectSubmit = function(id, callback)
|
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'),
|
selects = form.getElementsByTagName('select'),
|
||||||
textareas = form.getElementsByTagName('textarea'),
|
textareas = form.getElementsByTagName('textarea'),
|
||||||
inputs = form.getElementsByTagName('input'),
|
inputs = form.getElementsByTagName('input'),
|
||||||
external = document.querySelectorAll('[form='+id+']'),
|
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)),
|
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;
|
return elements;
|
||||||
}
|
};
|
||||||
|
|
||||||
jsOMS.Views.FormView.prototype.getData = function()
|
jsOMS.Views.FormView.prototype.getData = function()
|
||||||
{
|
{
|
||||||
let data = {},
|
let data = {},
|
||||||
elements = this.getFormElements(this.id),
|
elements = this.getFormElements(),
|
||||||
length = elements.length,
|
length = elements.length,
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for(i = 0; i < length; i++) {
|
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;
|
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) {
|
if(id === null) {
|
||||||
id = e.getAttribute('id');
|
id = e.getAttribute('id');
|
||||||
|
|
@ -93,7 +114,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
};
|
||||||
|
|
||||||
jsOMS.Views.FormView.prototype.getSubmitInjects = function()
|
jsOMS.Views.FormView.prototype.getSubmitInjects = function()
|
||||||
{
|
{
|
||||||
|
|
@ -107,7 +128,7 @@
|
||||||
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 elements = this.getFormElements(this.id),
|
let elements = this.getFormElements(),
|
||||||
length = elements.length,
|
length = elements.length,
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
|
|
@ -131,7 +152,7 @@
|
||||||
|
|
||||||
jsOMS.Views.FormView.prototype.unbind = function()
|
jsOMS.Views.FormView.prototype.unbind = function()
|
||||||
{
|
{
|
||||||
let elements = this.getFormElements(this.id),
|
let elements = this.getFormElements(),
|
||||||
length = elements.length,
|
length = elements.length,
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
|
|
|
||||||
1979
oms.min.js
vendored
1979
oms.min.js
vendored
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user