From c15a1573a233a99b7395867ecfe4ba9115a1e7d5 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 2 Oct 2018 21:22:44 +0200 Subject: [PATCH] Move models to framework --- Model/Action/Dom/Datalist/Append.js | 26 +++++++++ Model/Action/Dom/Datalist/Clear.js | 20 +++++++ Model/Action/Dom/Focus.js | 14 +++++ Model/Action/Dom/GetValue.js | 33 ++++++++++++ Model/Action/Dom/Hide.js | 15 ++++++ Model/Action/Dom/Popup.js | 81 +++++++++++++++++++++++++++++ Model/Action/Dom/Remove.js | 43 +++++++++++++++ Model/Action/Dom/RemoveValue.js | 38 ++++++++++++++ Model/Action/Dom/SetValue.js | 68 ++++++++++++++++++++++++ Model/Action/Dom/Show.js | 15 ++++++ Model/Action/Dom/Table/Append.js | 45 ++++++++++++++++ Model/Action/Dom/Table/Clear.js | 20 +++++++ Model/Action/Message/Log.js | 22 ++++++++ Model/Action/Message/Request.js | 26 +++++++++ Model/Action/Utils/DataCollector.js | 33 ++++++++++++ Model/Action/Utils/Timer.js | 23 ++++++++ Model/Action/Validate/Keypress.js | 22 ++++++++ Model/Message/Dom.js | 0 Model/Message/DomAction.js | 27 ++++++++++ Model/Message/DomActionType.js | 15 ++++++ Model/Message/FormValidation.js | 39 ++++++++++++++ Model/Message/Notify.js | 37 +++++++++++++ Model/Message/NotifyType.js | 11 ++++ Model/Message/Redirect.js | 15 ++++++ Model/Message/Reload.js | 12 +++++ 25 files changed, 700 insertions(+) create mode 100644 Model/Action/Dom/Datalist/Append.js create mode 100644 Model/Action/Dom/Datalist/Clear.js create mode 100644 Model/Action/Dom/Focus.js create mode 100644 Model/Action/Dom/GetValue.js create mode 100644 Model/Action/Dom/Hide.js create mode 100644 Model/Action/Dom/Popup.js create mode 100644 Model/Action/Dom/Remove.js create mode 100644 Model/Action/Dom/RemoveValue.js create mode 100644 Model/Action/Dom/SetValue.js create mode 100644 Model/Action/Dom/Show.js create mode 100644 Model/Action/Dom/Table/Append.js create mode 100644 Model/Action/Dom/Table/Clear.js create mode 100644 Model/Action/Message/Log.js create mode 100644 Model/Action/Message/Request.js create mode 100644 Model/Action/Utils/DataCollector.js create mode 100644 Model/Action/Utils/Timer.js create mode 100644 Model/Action/Validate/Keypress.js create mode 100644 Model/Message/Dom.js create mode 100644 Model/Message/DomAction.js create mode 100644 Model/Message/DomActionType.js create mode 100644 Model/Message/FormValidation.js create mode 100644 Model/Message/Notify.js create mode 100644 Model/Message/NotifyType.js create mode 100644 Model/Message/Redirect.js create mode 100644 Model/Message/Reload.js diff --git a/Model/Action/Dom/Datalist/Append.js b/Model/Action/Dom/Datalist/Append.js new file mode 100644 index 0000000..8f1c4f9 --- /dev/null +++ b/Model/Action/Dom/Datalist/Append.js @@ -0,0 +1,26 @@ +/** + * Set message. + * + * @param {{title:string},{content:string},{level:int},{delay:int},{stay:int}} action Message data + * @param {function} callback Callback + * + * @since 1.0.0 + */ +const datalistAppend = function (action, callback) +{ + "use strict"; + + const datalist = document.getElementById(action.id), + dataLength = action.data.length; + + let option; + + for (let i = 0; i < dataLength; i++) { + option = document.createElement('option'); + option.value = action.data[i][action.text]; + option.setAttribute('data-value', action.data[i][action.value]); + datalist.appendChild(option); + } + + callback(); +}; diff --git a/Model/Action/Dom/Datalist/Clear.js b/Model/Action/Dom/Datalist/Clear.js new file mode 100644 index 0000000..fa36d44 --- /dev/null +++ b/Model/Action/Dom/Datalist/Clear.js @@ -0,0 +1,20 @@ +/** + * Set message. + * + * @param {{title:string},{content:string},{level:int},{delay:int},{stay:int}} action Message data + * @param {function} callback Callback + * + * @since 1.0.0 + */ +const datalistClear = function (action, callback) +{ + "use strict"; + + const e = document.getElementById(action.id); + + while (e.firstChild) { + e.removeChild(e.firstChild); + } + + callback(); +}; diff --git a/Model/Action/Dom/Focus.js b/Model/Action/Dom/Focus.js new file mode 100644 index 0000000..975f288 --- /dev/null +++ b/Model/Action/Dom/Focus.js @@ -0,0 +1,14 @@ +const focusAction = function (action, callback) +{ + "use strict"; + + const focus = document.getElementById(action.id); + + if (!focus) { + return; + } + + focus.focus(); + + callback(); +}; \ No newline at end of file diff --git a/Model/Action/Dom/GetValue.js b/Model/Action/Dom/GetValue.js new file mode 100644 index 0000000..eddfe51 --- /dev/null +++ b/Model/Action/Dom/GetValue.js @@ -0,0 +1,33 @@ +/** + * Set message. + * + * @param {Object} action Action data + * @param {function} callback Callback + * @param {string} id Action element + * + * @since 1.0.0 + */ +const domGetValue = function (action, callback, id) +{ + "use strict"; + + const e = action.base === 'self' ? (action.selector === '' || typeof action.selector === 'undefined' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector); + let value = []; + + for (let i in e) { + /** global: HTMLElement */ + if (!e.hasOwnProperty(i) || !(e[i] instanceof HTMLElement)) { + continue; + } + + let eId = (typeof e[i].name !== 'undefined' && e[i].name !== '') ? e[i].name : e[i].id; + + if (e[i].tagName === 'INPUT' || e[i].tagName === 'SELECTS' || e[i].tagName === 'BUTTON') { + value[eId] = e[i].value; + } else { + value[eId] = e[i].getAttribute('data-id'); + } + } + + callback(value); +}; \ No newline at end of file diff --git a/Model/Action/Dom/Hide.js b/Model/Action/Dom/Hide.js new file mode 100644 index 0000000..cf26b44 --- /dev/null +++ b/Model/Action/Dom/Hide.js @@ -0,0 +1,15 @@ +const hideAction = function (action, callback) +{ + "use strict"; + + const hide = document.getElementById(action.id); + + if (!hide) { + return; + } + + /** global: jsOMS */ + jsOMS.addClass(hide, 'vh'); + + callback(); +}; \ No newline at end of file diff --git a/Model/Action/Dom/Popup.js b/Model/Action/Dom/Popup.js new file mode 100644 index 0000000..cbeb591 --- /dev/null +++ b/Model/Action/Dom/Popup.js @@ -0,0 +1,81 @@ +/** + * Set message. + * + * @param {Object} action Action data + * @param {function} callback Callback + * @param {id} element Action element + * + * @since 1.0.0 + */ +const popupButtonAction = function (action, callback, id) +{ + "use strict"; + + const popup = action.base === 'self' ? (action.selector === '' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector); + + for(let i in popup) { + /** global: HTMLElement */ + if(!popup.hasOwnProperty(i) || !popup[i] || !(popup[i] instanceof HTMLElement)) { + continue; + } + + const clone = document.importNode(popup[i].content, true); + const dim = document.getElementById('dim'); + + if(dim) { + document.getElementById('dim').classList.remove('vh'); + } + + for(let j in clone) { + if(!clone.hasOwnProperty(j) || !(clone[j] instanceof HTMLElement)) { + continue; + } + + clone[j].innerHTML = clone[j].innerHTML.replace(/\{\$id\}/g, action.id); + } + + document.body.insertBefore(clone, document.body.firstChild); + + let e = document.getElementById(popup[i].id.substr(0, popup[i].id.length - 4)); + + if(!e) { + continue; + } + + window.omsApp.uiManager.getActionManager().bind(e.querySelectorAll('[data-action]')); + + e.classList.add('animated'); + if (typeof action.aniIn !== 'undefined') { + e.classList.add(action.aniIn); + } + + if (action.stay > 0) { + setTimeout(function () + { + let out = 0; + if (typeof action.aniOut !== 'undefined') { + e.classList.remove(action.aniIn); + e.classList.add(action.aniOut); + out = 200; + } + + setTimeout(function () + { + if (typeof action.aniOut !== 'undefined') { + e.classList.add(action.aniOut); + } + + e.parentElement.removeChild(e); + + const dim = document.getElementById('dim'); + + if (dim) { + document.getElementById('dim').classList.add('vh'); + } + }, out); + }, action.stay); + } + } + + callback(); +}; diff --git a/Model/Action/Dom/Remove.js b/Model/Action/Dom/Remove.js new file mode 100644 index 0000000..ecd5cac --- /dev/null +++ b/Model/Action/Dom/Remove.js @@ -0,0 +1,43 @@ +/** + * Set message. + * + * @param {Object} action Action data + * @param {function} callback Callback + * @param {string} id Action element + * + * @since 1.0.0 + */ +const removeButtonAction = function (action, callback, id) +{ + "use strict"; + + const e = action.base === 'self' ? (action.selector === '' || typeof action.selector === 'undefined' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector); + const dim = document.getElementById('dim'); + + for (let i in e) { + /** global: HTMLElement */ + if (!e.hasOwnProperty(i) || !e[i] || !(e[i] instanceof HTMLElement)) { + continue; + } + + if (typeof action.aniOut !== 'undefined') { + e[i].classList.add(action.aniOut); + } + + // todo: here is a problem with removing elements. after removing the first element in a list the second one cannot be deleted. maybe this is because the action event gets removed for sister elements after one is deleted? + setTimeout(function () + { + if (e[i].parentElement === null) { + return; + } + + e[i].parentElement.removeChild(e[i]); + + if (dim) { + document.getElementById('dim').classList.add('vh'); + } + }, 200); + } + + callback(); +}; diff --git a/Model/Action/Dom/RemoveValue.js b/Model/Action/Dom/RemoveValue.js new file mode 100644 index 0000000..87579f9 --- /dev/null +++ b/Model/Action/Dom/RemoveValue.js @@ -0,0 +1,38 @@ +/** + * Set message. + * + * @param {Object} action Action data + * @param {function} callback Callback + * @param {string} id Action element + * + * @since 1.0.0 + */ +const domRemoveValue = function (action, callback, id) +{ + "use strict"; + + const e = action.base === 'self' ? (action.selector === '' || typeof action.selector === 'undefined' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector); + + for (let i in e) { + /** global: HTMLElement */ + if (!e.hasOwnProperty(i) || !(e[i] instanceof HTMLElement)) { + continue; + } + + if (e[i].value === action.data) { + e[i].value = ''; + } else { + e[i].value = e[i].value.replace(', ' + action.data + ',', ','); + + if (e[i].value.startsWith(action.data + ', ')) { + e[i].value = e[i].value.substring((action.data + ', ').length); + } + + if (e[i].value.endsWith(', ' + action.data)) { + e[i].value = e[i].value.substring(0, e[i].value.length - (', ' + action.data).length); + } + } + } + + callback(); +}; \ No newline at end of file diff --git a/Model/Action/Dom/SetValue.js b/Model/Action/Dom/SetValue.js new file mode 100644 index 0000000..1b190a3 --- /dev/null +++ b/Model/Action/Dom/SetValue.js @@ -0,0 +1,68 @@ +/** + * Set message. + * + * @param {Object} action Action data + * @param {function} callback Callback + * @param {id} element Action element + * + * @since 1.0.0 + */ +const domSetValue = function (action, callback, id) +{ + "use strict"; + + let dataPath = action['value'], + path = '', + tempDataValue = '', + values = [], + replaceText = '', + start = 0, + end = 0; + + while ((start = dataPath.indexOf('{', start)) !== -1) { + end = dataPath.indexOf('}', start); + start++; + + path = dataPath.substring(start, end); + /** global: jsOMS */ + tempDataValue = jsOMS.getArray(path, action.data, '/'); + + replaceText = '{' + path + '}'; + dataPath = dataPath.replace(new RegExp(replaceText.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), tempDataValue); + } + + const fill = action.base === 'self' ? (action.selector === '' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector); + + for (let i in fill) { + /** global: HTMLElement */ + if (!fill.hasOwnProperty(i) || !(fill[i] instanceof HTMLElement)) { + continue; + } + + if (fill[i].tagName.toLowerCase() === 'div' + || fill[i].tagName.toLowerCase() === 'span' + ) { + if (!fill[i].innerHTML.includes(dataPath)) { + if (action.overwrite) { + fill[i].innerHTML = dataPath; + } else if (!action.overwrite) { + fill[i].innerHTML += dataPath; + } + } + } else { + if (fill[i].value !== dataPath + && !fill[i].value.includes(', ' + dataPath + ',') + && !fill[i].value.endsWith(', ' + dataPath) + && !fill[i].value.startsWith(dataPath + ',') + ) { + if (action.overwrite) { + fill[i].value = dataPath; + } else { + fill[i].value += (fill[i].value !== '' ? ', ' : '') + dataPath; + } + } + } + } + + callback(action.data); +}; \ No newline at end of file diff --git a/Model/Action/Dom/Show.js b/Model/Action/Dom/Show.js new file mode 100644 index 0000000..8cec817 --- /dev/null +++ b/Model/Action/Dom/Show.js @@ -0,0 +1,15 @@ +const showAction = function (action, callback) +{ + "use strict"; + + const show = document.getElementById(action.id); + + if (!show) { + return; + } + + /** global: jsOMS */ + jsOMS.removeClass(show, 'vh'); + + callback(); +}; \ No newline at end of file diff --git a/Model/Action/Dom/Table/Append.js b/Model/Action/Dom/Table/Append.js new file mode 100644 index 0000000..a024b6b --- /dev/null +++ b/Model/Action/Dom/Table/Append.js @@ -0,0 +1,45 @@ +/** + * Set message. + * + * @param {Object} action Action data + * @param {function} callback Callback + * + * @since 1.0.0 + */ +const tableAppend = function (action, callback) +{ + "use strict"; + + const table = document.getElementById(action.id), + tbody = table !== null && typeof table !== 'undefined' ? table.getElementsByTagName('tbody')[0] : null, + headers = table !== null && typeof table !== 'undefined' ? table.getElementsByTagName('thead')[0].getElementsByTagName('th') : null, + dataLength = action.data.length, + headerLength = headers !== null && typeof headers !== 'undefined' ? headers.length : 0; + + let row, cell, text, rawText; + + for (let i = 0; i < dataLength; i++) { + if (tbody === null) { + break; + } + + row = tbody.insertRow(tbody.rows.length); + + for (let j = 0; j < headerLength; j++) { + if (row === null) { + break; + } + + cell = row.insertCell(j); + rawText = action.data[i][headers[j].getAttribute('data-name')]; + + if (typeof rawText === 'undefined') { + rawText = ''; + } + + cell.appendChild(document.createTextNode(rawText)); + } + } + + callback(); +}; diff --git a/Model/Action/Dom/Table/Clear.js b/Model/Action/Dom/Table/Clear.js new file mode 100644 index 0000000..59d4012 --- /dev/null +++ b/Model/Action/Dom/Table/Clear.js @@ -0,0 +1,20 @@ +/** + * Set message. + * + * @param {{title:string},{content:string},{level:int},{delay:int},{stay:int}} action Message data + * @param {function} callback Callback + * + * @since 1.0.0 + */ +const tableClear = function (action, callback) +{ + "use strict"; + + const e = document.getElementById(action.id).getElementsByTagName('tbody')[0]; + + while (e.firstChild) { + e.removeChild(e.firstChild); + } + + callback(); +}; diff --git a/Model/Action/Message/Log.js b/Model/Action/Message/Log.js new file mode 100644 index 0000000..71bec28 --- /dev/null +++ b/Model/Action/Message/Log.js @@ -0,0 +1,22 @@ +/** + * Log. + * + * @param {Object} action Action data + * @param {function} callback Callback + * + * @since 1.0.0 + */ +const logAction = function (action, callback) +{ + "use strict"; + + window.omsApp.notifyManager.send( + new jsOMS.Message.Notification.NotificationMessage( + action.data.status, + action.data.title, + action.data.message + ), jsOMS.Message.Notification.NotificationType.APP_NOTIFICATION + ); + + callback(); +}; diff --git a/Model/Action/Message/Request.js b/Model/Action/Message/Request.js new file mode 100644 index 0000000..b0a9729 --- /dev/null +++ b/Model/Action/Message/Request.js @@ -0,0 +1,26 @@ +/** + * Set message. + * + * @param {Object} action Action data + * @param {function} callback Callback + * + * @since 1.0.0 + */ +const requestAction = function (action, callback) +{ + "use strict"; + + /** global: jsOMS */ + const request = new jsOMS.Message.Request.Request(action.uri, action.method, action.request_type); + + request.setSuccess(function(xhr) { + console.log(xhr.responseText); + callback(JSON.parse(xhr.responseText)); + }); + + if (typeof action.data !== 'undefined') { + request.setData(action.data); + } + + request.send(); +}; diff --git a/Model/Action/Utils/DataCollector.js b/Model/Action/Utils/DataCollector.js new file mode 100644 index 0000000..48a80e9 --- /dev/null +++ b/Model/Action/Utils/DataCollector.js @@ -0,0 +1,33 @@ +/** + * Collect data. + * + * @param {Object} action Action data + * @param {function} callback Callback + * + * @since 1.0.0 + */ +const dataCollectionAction = function (action, callback) +{ + "use strict"; + + let elements, data = {}; + + for (let selector in action.collect) { + if (!action.collect.hasOwnProperty(selector)) { + continue; + } + + elements = document.querySelectorAll(action.collect[selector]); + + for (let e in elements) { + if(!elements.hasOwnProperty(e)) { + continue; + } + + // todo: different types of elements have differnt forms of storing values (input, textarea etc.) + data[selector].push(e.value); + } + } + + callback(data); +}; diff --git a/Model/Action/Utils/Timer.js b/Model/Action/Utils/Timer.js new file mode 100644 index 0000000..7d36229 --- /dev/null +++ b/Model/Action/Utils/Timer.js @@ -0,0 +1,23 @@ +/** + * Set message. + * + * @param {Object} action Action data + * @param {function} callback Callback + * + * @since 1.0.0 + */ +const timerActionDelay = {}; +const timerAction = function (action, callback) +{ + "use strict"; + + if (timerActionDelay[action.id]) { + clearTimeout(timerActionDelay[action.id]); + delete timerActionDelay[action.id] + } + + timerActionDelay[action.id] = setTimeout(function() { + delete timerActionDelay[action.id]; + callback(); + }, action.delay); +}; diff --git a/Model/Action/Validate/Keypress.js b/Model/Action/Validate/Keypress.js new file mode 100644 index 0000000..e5088ad --- /dev/null +++ b/Model/Action/Validate/Keypress.js @@ -0,0 +1,22 @@ +/** + * Validate Keypress. + * + * @param {Object} action Action data + * @param {function} callback Callback + * + * @since 1.0.0 + */ +const validateKeypress = function (action, callback) +{ + "use strict"; + + const invertValidate = action.pressed.startsWith('!'), + keyPressCheck = invertValidate ? action.pressed.split('!') : action.pressed.split('|'); + + if (typeof action.data.keyCode !== 'undefined' + && ((!invertValidate && keyPressCheck.indexOf(action.data.keyCode.toString()) !== -1) + || (invertValidate && keyPressCheck.indexOf(action.data.keyCode.toString()) === -1)) + ) { + callback(); + } +}; diff --git a/Model/Message/Dom.js b/Model/Message/Dom.js new file mode 100644 index 0000000..e69de29 diff --git a/Model/Message/DomAction.js b/Model/Message/DomAction.js new file mode 100644 index 0000000..52f68ca --- /dev/null +++ b/Model/Message/DomAction.js @@ -0,0 +1,27 @@ +/** + * Perform DOM action. + * + * @param {{delay:int},{type:int}} data DOM action data + * + * @since 1.0.0 + */ +const domAction = function (data) +{ + /** global: jsOMS */ + setTimeout(function () + { + switch (data.type) { + case jsOMS.EnumDomActionType.SHOW: + break; + case jsOMS.EnumDomActionType.HIDE: + break; + } + }, parseInt(data.delay)); +}; + +/** + * Show/Hide + * identifier: #element or .elements or query + * anim: someclass + * delay: 0 + */ \ No newline at end of file diff --git a/Model/Message/DomActionType.js b/Model/Message/DomActionType.js new file mode 100644 index 0000000..a006d1e --- /dev/null +++ b/Model/Message/DomActionType.js @@ -0,0 +1,15 @@ +(function (jsOMS) { + "use strict"; + + jsOMS.EnumDomActionType = Object.freeze({ + CREATE_BEFORE: 0, + CREATE_AFTER: 1, + DELETE: 2, + REPLACE: 3, + MODIFY: 4, + SHOW: 5, + HIDE: 6, + ACTIVATE: 7, + DEACTIVATE: 8 + }); +} (window.jsOMS = window.jsOMS || {})); diff --git a/Model/Message/FormValidation.js b/Model/Message/FormValidation.js new file mode 100644 index 0000000..e6d7b46 --- /dev/null +++ b/Model/Message/FormValidation.js @@ -0,0 +1,39 @@ +/** + * Set message. + * + * @param {{delay:int},{errors:string},{form:string}} data Message data + * + * @since 1.0.0 + */ +const formValidationMessage = function (data) { + const form = document.getElementById(data.form); + + if(!form) { + return; + } + + const eEles = document.getElementsByClassName('i-' + data.form); + + while (eEles.length > 0) { + eEles[0].parentNode.removeChild(eEles[0]); + } + + /** + * @param {{msg:string}} error Error data + */ + data.errors.forEach(function (error) { + const eEle = document.getElementById(error.id); + + if (!eEle) { + return; + } + + const msgEle = document.createElement('i'), + msg = document.createTextNode(error.msg); + + msgEle.id = 'i-' + error.id; + msgEle.class = 'i-' + data.form; + msgEle.appendChild(msg); + eEle.parentNode.insertBefore(msgEle, eEle.nextSibling); + }); +}; diff --git a/Model/Message/Notify.js b/Model/Message/Notify.js new file mode 100644 index 0000000..efdc8b1 --- /dev/null +++ b/Model/Message/Notify.js @@ -0,0 +1,37 @@ +/** + * Set message. + * + * @param {{title:string},{content:string},{level:int},{delay:int},{stay:int}} data Message data + * + * @since 1.0.0 + */ +const notifyMessage = function (data) +{ + setTimeout(function () + { + const notify = document.createElement('div'), + h = document.createElement('h1'), + inner = document.createElement('div'), + title = document.createTextNode(data.title), + content = document.createTextNode(data.msg); + + notify.id = 'notify'; + notify.class = data.level; + h.appendChild(title); + inner.appendChild(content); + notify.appendChild(h); + notify.appendChild(inner); + document.body.appendChild(notify); + + if (data.stay <= 0) { + data.stay = 5000; + } + + if (data.stay > 0) { + setTimeout(function () + { + notify.parentElement.removeChild(notify); + }, data.stay); + } + }, parseInt(data.delay)); +}; diff --git a/Model/Message/NotifyType.js b/Model/Message/NotifyType.js new file mode 100644 index 0000000..67d8b1b --- /dev/null +++ b/Model/Message/NotifyType.js @@ -0,0 +1,11 @@ +(function (jsOMS) { + "use strict"; + + jsOMS.EnumNotifyType = Object.freeze({ + BINARY: 0, + INFO: 1, + WARNING: 2, + ERROR: 3, + FATAL: 4 + }); +}(window.jsOMS = window.jsOMS || {})); diff --git a/Model/Message/Redirect.js b/Model/Message/Redirect.js new file mode 100644 index 0000000..45a256f --- /dev/null +++ b/Model/Message/Redirect.js @@ -0,0 +1,15 @@ +/** + * Set message. + * + * @param {{delay:int},{url:string}} data Message data + * + * @since 1.0.0 + */ +const redirectMessage = function (data) +{ + setTimeout(function () + { + /** global: jsOMS */ + window.location = jsOMS.Uri.UriFactory.build(data.uri); + }, parseInt(data.delay)); +}; diff --git a/Model/Message/Reload.js b/Model/Message/Reload.js new file mode 100644 index 0000000..f80e400 --- /dev/null +++ b/Model/Message/Reload.js @@ -0,0 +1,12 @@ +/** + * Set message. + * + * @param {{delay:int}} data Message data + * + * @since 1.0.0 + */ +const reloadMessage = function (data) { + setTimeout(function () { + document.location.reload(true); + }, parseInt(data.delay)); +};