jsOMS/Model/Action/Dom/Reload.js
2024-01-12 00:30:21 +00:00

31 lines
947 B
JavaScript
Executable File

import { UriFactory } from '../../../Uri/UriFactory.js';
/**
* Reload page.
*
* @param {Object} action Action data
* @param {function} callback Callback
* @param {string} id Action element
*
* @since 1.0.0
*/
export function reloadButtonAction (action, callback, id)
{
'use strict';
setTimeout(function () {
if (action.src) {
console.log(document.getElementById(action.src).hasAttribute('data-src'));
console.log(UriFactory.build(document.getElementById(action.src).getAttribute('data-src')));
document.getElementById(action.src).src = document.getElementById(action.src).hasAttribute('data-src')
? UriFactory.build(document.getElementById(action.src).getAttribute('data-src'))
: document.getElementById(action.src).src;
} else {
document.location.reload();
}
}, parseInt(action.delay));
callback();
};