From 9a3bee28d2594199f862005a841e01adc9531dc6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 1 Nov 2019 13:38:09 -0400 Subject: [PATCH] add logging and handling of oninput and oninput-this --- web/skins/classic/js/skin.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index 8a592826f..bdef6d4dd 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -181,6 +181,7 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() { console.error("Nothing found to bind to " + fnName); return; } + console.log('Setting onlick to ' + fnName + ' for ' + el.name); el.onclick = function() { window[fnName](); }; @@ -193,6 +194,7 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() { console.error("Nothing found to bind to " + fnName); return; } + console.log('Setting onclick-true to ' + fnName + ' for ' + el.name); el.onclick = function() { window[fnName](true); }; @@ -205,6 +207,7 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() { console.error("Nothing found to bind to " + fnName); return; } + console.log('Setting onchange-this to ' + fnName + ' for ' + el.name); el.onchange = window[fnName].bind(el, el); }); @@ -215,8 +218,31 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() { console.error("Nothing found to bind to " + fnName); return; } + console.log('Setting onchange to ' + fnName + ' for ' + el.name); el.onchange = window[fnName]; }); + + // 'data-on-input' adds an event listener for the global function in the attribute value when an input happens. + document.querySelectorAll("input[data-on-input]").forEach(function(el) { + var fnName = el.getAttribute("data-on-input"); + if ( !window[fnName] ) { + console.error("Nothing found to bind to " + fnName); + return; + } + console.log('Setting oninput to ' + fnName + ' for ' + el.name); + el.oninput = window[fnName]; + }); + + // 'data-on-input-this' calls the global function in the attribute value with the element when an input happens. + document.querySelectorAll("input[data-on-input-this]").forEach(function(el) { + var fnName = el.getAttribute("data-on-input-this"); + if ( !window[fnName] ) { + console.error("Nothing found to bind to " + fnName); + return; + } + console.log('Setting oninput-this to ' + fnName + ' for ' + el.name); + el.onchange = window[fnName].bind(el, el); + }); }); function createEventPopup( eventId, eventFilter, width, height ) {