Fixing global variables

This commit is contained in:
Dennis Eichhorn 2016-05-31 23:21:09 +02:00
parent 2deb520fb9
commit 80b9dbdf9f
8 changed files with 14 additions and 8 deletions

View File

@ -54,6 +54,8 @@
length = scripts.length;
for (let i = 0; i < length; i++) {
/** global: URL */
/** @var {string} URL */
scripts[i].src.replace(URL + '/', '');
if (jsOMS.Autoloader.loaded.indexOf(scripts[i].src) === -1) {

View File

@ -26,6 +26,6 @@
throw 'Division zero';
}
return values.reduce((a, b) => a + b, 0) / count;
return values.reduce((a, b) => a + b, 0) / length;
};
}(window.jsOMS = window.jsOMS || {}));

View File

@ -26,6 +26,8 @@
this.success = null;
this.type = typeof type !== 'undefined' ? type : jsOMS.Message.Response.ResponseType.JSON;
this.data = {};
/** global: XMLHttpRequest */
this.xhr = new XMLHttpRequest();
};

View File

@ -9,7 +9,7 @@
* @license OMS License 1.0
* @version 1.0.0 * @since 1.0.0
*/
(function (uriFactory, undefined)
(function (jsOMS)
{
/** @namespace jsOMS.Message.Response */
jsOMS.Autoloader.defineNamespace('jsOMS.Message.Response');

View File

@ -64,7 +64,6 @@
case 'table':
break;
}
;
}
});
@ -92,7 +91,7 @@
{
this.clearDatalistOptions(datalist);
let request = new Request();
let request = new jsOMS.Message.Request();
request.setData(input.value);
request.setType(jsOMS.Message.Response.ResponseType.JSON);
request.setUri(datalist.getAttribute('data-list-src'));
@ -102,7 +101,7 @@
{
try {
let o = JSON.parse(xhr.response),
response = new Response(o),
response = new jsOMS.Message.Response(o),
responseLength = response.count(),
tempResponse = null,
success = null;

View File

@ -66,7 +66,7 @@
document.addEventListener('keyup', function keyBind(event)
{
if (self.down.length > 0) {
self.run(element);
self.run(element, event);
self.down = [];
}
});
@ -76,11 +76,12 @@
* Execute callback based on key presses.
*
* @param {string} element Container id
* @param {Object} event Key event
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
jsOMS.UI.Input.Keyboard.KeyboardManager.prototype.run = function (element)
jsOMS.UI.Input.Keyboard.KeyboardManager.prototype.run = function (element, event)
{
if (typeof this.elements[element] === 'undefined') {
throw 'Unexpected elmenet!';

View File

@ -7,7 +7,7 @@
* @license OMS License 1.0
* @version 1.0.0 * @since 1.0.0
*/
(function (uriFactory, undefined)
(function (jsOMS)
{
/** @namespace jsOMS.Uri.UriFactory */
jsOMS.Autoloader.defineNamespace('jsOMS.Uri.UriFactory');

View File

@ -194,6 +194,7 @@
*/
jsOMS.isNode = function (ele)
{
/** global: Node */
return (
typeof Node === "object" ? ele instanceof Node :
ele && typeof ele === "object" && typeof ele.nodeType === "number" && typeof ele.nodeName === "string"
@ -216,6 +217,7 @@
*/
jsOMS.isElement = function (o)
{
/** global: HTMLElement */
return (
typeof HTMLElement === "object" ? o instanceof HTMLElement : o && typeof o === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string"
);