diff --git a/bin/Matter.adp b/bin/Matter.adp index 7d2489c..c4d9363 100755 Binary files a/bin/Matter.adp and b/bin/Matter.adp differ diff --git a/config.xml b/config.xml index 235c8d6..c92d1f4 100755 --- a/config.xml +++ b/config.xml @@ -7,8 +7,8 @@ Matter 10926820-e66b-4e74-9ed0-ef116a75fc29 - 3.7.0 - 2026-04-20 + 3.7.1 + 2026-04-27 askia Paul McDuffee Nevin Vincent Tellier]]> diff --git a/resources/static/askia.ajax.js b/resources/static/askia.ajax.js index f029ea4..768f40b 100755 --- a/resources/static/askia.ajax.js +++ b/resources/static/askia.ajax.js @@ -1,389 +1,394 @@ -(function () { - function CustomEvent ( event, params ) { - params = params || { bubbles: false, cancelable: false, detail: undefined }; - var evt = document.createEvent( 'CustomEvent' ); - evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); - return evt; - } - - CustomEvent.prototype = window.Event.prototype; - - window.CustomEvent = CustomEvent; -})(); -(function () { - //if (!window.arrLiveRoutingInputCode || window.arrLiveRoutingInputCode.length <= 0 ) { - // return; - //} - if (window.AskiaScript) { - AskiaScript.executeLiveRouting = function () {}; - } - // Augment or create the public `askia` namespace - var askia = window.askia || {}; - if (!window.askia) { - window.askia = askia; - } - - /* ---======== Utilities ========--- */ - - /** - * Capitalize the first letter of the string and return the new string - * - * @param {String} str String to capitalize - */ - function capitalize (str) { - return str.charAt(0).toUpperCase() + str.slice(1); - } - - /** - * Iterate over all submittable elements of a form - * )This method was inspired from jQuery.serializeArray) - * - * @param {HTMLElement} elForm Form element to parse - * @param {Function} fn Function called for each submittable elements - * @param {HTMLElement} fn.element Submittable element - */ - function forEachSubmittableElements (elForm, fn) { - if (typeof fn !== 'function') { - return; - } - - // Don't submit all input submittable - var rgSubmitter = /^(?:submit|button|image|reset|file)$/i; - // Submittable elements - var rgSubmittable = /^(?:input|select|textarea|keygen)/i; - // Elements that have a checked state - var rgCheckable = /^(?:checkbox|radio)$/i; - // List of elements - var els = elForm.elements; - var i; - - for (i = 0, l = els.length; i < l; i += 1) { - var el = els[i]; - - if (!el.name || el.disabled || el.value === null || - rgSubmitter.test(el.type) || - !rgSubmittable.test(el.nodeName) || - (rgCheckable.test(el.type) && !el.checked)) { - - continue; - } - - fn(el); - } - } - - /** - * Serialize the Askia Form to an object - * - * @param {HTMLElement} elForm Form element to serialize - * @param {String} [action] Action to use instead of the regular form action - * @return {String} Return the form data that should normally be send to the server-side - */ - askia.serializeForm = function serializeForm (elForm, action) { - var params = []; - forEachSubmittableElements(elForm, function (el) { - var name = el.name - var value = el.value.replace(/\r?\n/gi, '\r\n'); - if (action && /^(?:action)$/i.test(el.name)) { - value = action.replace(/\r?\n/gi, '\r\n'); - } - params.push(encodeURIComponent(name) + '=' + encodeURIComponent(value)); - }); - return params.join('&'); - }; - - /** - * Execute an AJAX query - * - * @param {Object} query AJAX query to execute - * @param {String} query.url URL of the server-side management - * @param {"GET"|"POST"|string} [query.method="POST"] Request method to use - * @param {String} [query.data=null] Data to send to the server side - * @param {Function} [query.success] Callback on success - * @param {String} query.success.text Text of the response - * @param {XMLHttpRequest} query.success.xhr XMLHTTPRequest used - * @param {Function} [query.error] Callback on error - * @param {String} query.error.text Text of the response - * @param {XMLHttpRequest} query.error.xhr XMLHTTPRequest used - * @param {Function} [query.complete] Callback on query complete (success or error) - * @param {String} query.complete.text Text of the response - * @param {XMLHttpRequest} query.complete.xhr XMLHTTPRequest used - */ - askia.ajax = function ajax (query) { - if (!query) { - (console && console.warn('The `query` argument must be a valid object for askia.ajax()')); - return; - } - if (!query.url || typeof query.url !== 'string') { - (console && console.warn('The `query.url` argument must be a valid string for askia.ajax()')); - return; - } - - query.method = ((query.method && query.method.toString()) || 'POST').toUpperCase(); - if (!/^(?:GET|POST|PUT|DELETE|HEAD|OPTIONS|TRACE|CONNECT)$/.test(query.method)) { - (console && console.warn('The `query.method` argument must be a valid HTTP method for askia.ajax()')); - return; - } - - var xhr = new XMLHttpRequest(); - xhr.open(query.method, query.url, true); - xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); - xhr.onload = function onXhrLoad () { - var text = xhr.responseText; - if (xhr.status >= 200 && xhr.status < 400) { - if (typeof query.success === 'function') { - query.success(text, xhr); - } - } else { - if (typeof query.error === 'function') { - query.error(text, xhr); - } - } - - if (typeof query.complete === 'function') { - query.complete(text, xhr); - } - }; - - xhr.onerror = function () { - if (typeof query.error === 'function') { - query.error(text, xhr); - } - if (typeof query.complete === 'function') { - query.complete(text, xhr); - } - }; - - xhr.send(query.data || null); - }; - - - /* ---======== Askia Events Management ========--- */ - - askia.defaultEventActions = { - askiaAnswer: executeLiveRouting, - askiaShowQuestion: executeShowHideQuestion, - askiaHideQuestion: executeShowHideQuestion, - askiaShowResponses: null, - askiaHideResponses: null, - askiaReload: executeReload, - askiaSetValue: executeSetValue, - askiaShowMessage: null, - askiaChangeQuestionsOrder: null, - askiaChangeResponsesOrder: null, - askiaInfo: null, - askiaUpdateCaption: executeUpdateCaption - }; - - - /** - * Trigger an arbitrary event - * - * @param {String} eventName Name of the event to trigger - * @param {Object} detail Detail associated with the event - */ - askia.triggerEvent = function triggerEvent (eventName, detail) { - var eventInit = detail !== undefined ? { detail: detail } : undefined; - var event = new CustomEvent(eventName, eventInit); - return document.dispatchEvent(event); - }; - - /** - * Trigger an event when the respondent is answering - */ - askia.triggerAnswer = function triggerAnswer () { - if (!askia.triggerEvent('askiaAnswer')) { - return false; // preventDefault() has been called - } - - // Default behaviour - askia.defaultEventActions.askiaAnswer(); - }; - - /* ---======== Default Events Management ========--- */ - - /** - * Show or hide an entire question - * - * @param {Object} data Definition of the action to do - * @param {"showQuestion"|"hideQuestion"} data.action Action to execute - * @param {Number} data.inputCode Input code associated with the question - */ - function executeShowHideQuestion (data) { - if (!(data.question.inputCode >= 0)) { - return; - } - var isShow = /^(?:show)/i.test(data.action); - var className = '.askia-question-' + data.question.inputCode; - var elements = document.querySelectorAll(className); - var i; - var l; - for (i = 0, l = elements.length; i < l; i += 1) { - elements[i].style.display = isShow ? '' : 'none'; - } - } - - /** - * Update a live caption - * - * @param {Object} data Definition of the action to do - * @param {"updateCaption"} data.action Action to execute - * @param {String} data.selector The selector is a CSS Class (prefix `.`) or and HTML identifier (prefix `#`) - * @param {String} data.caption The updated caption - */ - function executeUpdateCaption (data) { - if (data.selector === '') { - return; - } - var className = data.selector; - var caption = data.caption; - var elements = document.querySelectorAll(className); - var i; - var l; - for (i = 0, l = elements.length; i < l; i += 1) { - elements[i].innerHTML = caption; - } - } - - /** - * Reload the page - */ - function executeReload () { - if (isPreventReload) return; - window.location.reload(); - } - - /** - * Set value Ajax - */ - function executeSetValue (data) { - let val = data.value; - if (Array.isArray(val)){ - for (var i = 0; i < val.length; i++) { - let checkEl = document.querySelector('#askia-input' + data.question.inputCode + '_' + val[i].inputCode); - if (checkEl) - checkEl.checked = true; - } - } else { - if (typeof val === 'string'){ - let openEl = document.querySelector('input[name="S'+ data.question.inputCode +'"]'); - if (openEl) openEl.value = '', openEl.value = val; - } else { - let numberEl = document.querySelector('input[name="C'+ data.question.inputCode +'"]'); - if (numberEl) numberEl.value = val; - } - } - } - - /* ---======== Live Routing Management ========--- */ - - var isExecutingLiveRouting = false; // Flag to avoid several live routing request - var shouldReExecuteLiveRouting = false; // Flag to re-execute the live routing - var isPreventReload = true; // Flag to prevent the page to reload on loop - - /** - * Execute the AJAX query to do a live routing - */ - function executeLiveRouting () { - if (isExecutingLiveRouting) { - shouldReExecuteLiveRouting = true; - return; - } - isExecutingLiveRouting = true; - shouldReExecuteLiveRouting = false; - askia.ajax({ - url: '../cgi-bin/AskiaExt.dll' + window.location.search, - data: askia.serializeForm(document.forms[0], 'DoLiveRouting'), - success: onLiveRoutingSuccess, - complete: onLiveRoutingComplete - }); - } - - /** - * Manage the live routing AJAX - success - */ - function onLiveRoutingSuccess (text) { - var json = JSON.parse(text); - var actions = json.actions || []; - var i; - var l; - var itemAction; - var eventName; - for (i = 0, l = actions.length; i < l; i += 1) { - itemAction = actions[i]; - eventName = 'askia' + capitalize(itemAction.action); - if (!askia.triggerEvent(eventName, itemAction)) { - continue; // preventDefault(); - } - // Default behaviour - if (typeof askia.defaultEventActions[eventName] === 'function') { - askia.defaultEventActions[eventName](itemAction); - } - } - } - - /** - * Manage the live routing AJAX - complete - */ - function onLiveRoutingComplete () { - isExecutingLiveRouting = false; - isPreventReload = false; - if (!shouldReExecuteLiveRouting) { - return; - } - setTimeout(executeLiveRouting, 250); - } - - /** - * Manage the live routing for classical askia form (Non ADCs) - * Trigger the answers to the server side on the event change or input - */ - document.addEventListener('DOMContentLoaded', function (){ - - /** - * Change event listener for the closed question form controls - */ - document.addEventListener('change', function (event){ - var el = event.target || event.srcElement; - // Retrieve the InputCode number of the question - var rg = /^[a-z]+([0-9]+)(?:\s*|\_*)/i.exec(el.name); - if (rg && (window.arrLiveRoutingInputCode.indexOf(rg[1]) > -1) && - (((el.nodeName === 'INPUT') && - (el.parentElement.className.indexOf('askia-response') >= 0 || - el.parentElement.className.indexOf('askia-control') >= 0 || - el.parentElement.className.indexOf('askia-grid-row') >= 0 || - el.parentElement.parentElement.className.indexOf('askia-grid-row') >= 0) && - (el.type === 'radio' || el.type === 'checkbox')) || el.nodeName === 'SELECT')) { - setTimeout(function(){ askia.triggerAnswer(); }, 150); - } - }); - /** - * Input event listener for the numerical and open ended question form controls - */ - document.addEventListener('input', function (event){ - var el = event.target || event.srcElement; - // Retrieve the InputCode number of the question - var rg = /^[a-z]+([0-9]+)(?:\s*|\_*)/i.exec(el.name); - if (rg && (window.arrLiveRoutingInputCode.indexOf(rg[1]) > -1) && - (((el.nodeName === 'TEXTAREA') || - ((el.nodeName === 'INPUT') && (el.type === 'color' || - el.type === 'date' || el.type === 'datetime' || - el.type === 'email' || el.type === 'month' || - el.type === 'number' || el.type === 'password' || - el.type === 'range' || el.type === 'search' || - el.type === 'tel' || el.type === 'text' || - el.type === 'time' || el.type === 'url' || el.type === 'week'))) && - (el.parentElement.className.indexOf('askia-response') >= 0 || - el.parentElement.className.indexOf('askia-control') >= 0 || - el.parentElement.className.indexOf('askia-grid-row') >= 0 || - el.parentElement.parentElement.className.indexOf('askia-grid-row') >= 0 || - el.className.indexOf('askia-live') >= 0))) { - askia.triggerAnswer(); - } - }); - if (window.arrLiveRoutingShortcut && window.arrLiveRoutingShortcut.length >= 1) { - askia.triggerAnswer(); - } - }); - -}()); +(function () { + function CustomEvent ( event, params ) { + params = params || { bubbles: false, cancelable: false, detail: undefined }; + var evt = document.createEvent( 'CustomEvent' ); + evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); + return evt; + } + + CustomEvent.prototype = window.Event.prototype; + + window.CustomEvent = CustomEvent; +})(); +(function () { + //if (!window.arrLiveRoutingInputCode || window.arrLiveRoutingInputCode.length <= 0 ) { + // return; + //} + if (window.AskiaScript) { + AskiaScript.executeLiveRouting = function () {}; + } + // Augment or create the public `askia` namespace + var askia = window.askia || {}; + if (!window.askia) { + window.askia = askia; + } + + /* ---======== Utilities ========--- */ + + /** + * Capitalize the first letter of the string and return the new string + * + * @param {String} str String to capitalize + */ + function capitalize (str) { + return str.charAt(0).toUpperCase() + str.slice(1); + } + + /** + * Iterate over all submittable elements of a form + * )This method was inspired from jQuery.serializeArray) + * + * @param {HTMLElement} elForm Form element to parse + * @param {Function} fn Function called for each submittable elements + * @param {HTMLElement} fn.element Submittable element + */ + function forEachSubmittableElements (elForm, fn) { + if (typeof fn !== 'function') { + return; + } + + // Don't submit all input submittable + var rgSubmitter = /^(?:submit|button|image|reset|file)$/i; + // Submittable elements + var rgSubmittable = /^(?:input|select|textarea|keygen)/i; + // Elements that have a checked state + var rgCheckable = /^(?:checkbox|radio)$/i; + // List of elements + var els = elForm.elements; + var i; + + for (i = 0, l = els.length; i < l; i += 1) { + var el = els[i]; + + if (!el.name || el.disabled || el.value === null || + rgSubmitter.test(el.type) || + !rgSubmittable.test(el.nodeName) || + (rgCheckable.test(el.type) && !el.checked)) { + + continue; + } + + fn(el); + } + } + + /** + * Serialize the Askia Form to an object + * + * @param {HTMLElement} elForm Form element to serialize + * @param {String} [action] Action to use instead of the regular form action + * @return {String} Return the form data that should normally be send to the server-side + */ + askia.serializeForm = function serializeForm (elForm, action) { + var params = []; + forEachSubmittableElements(elForm, function (el) { + var name = el.name + var value = el.value.replace(/\r?\n/gi, '\r\n'); + if (action && /^(?:action)$/i.test(el.name)) { + value = action.replace(/\r?\n/gi, '\r\n'); + } + params.push(encodeURIComponent(name) + '=' + encodeURIComponent(value)); + }); + return params.join('&'); + }; + + /** + * Execute an AJAX query + * + * @param {Object} query AJAX query to execute + * @param {String} query.url URL of the server-side management + * @param {"GET"|"POST"|string} [query.method="POST"] Request method to use + * @param {String} [query.data=null] Data to send to the server side + * @param {Function} [query.success] Callback on success + * @param {String} query.success.text Text of the response + * @param {XMLHttpRequest} query.success.xhr XMLHTTPRequest used + * @param {Function} [query.error] Callback on error + * @param {String} query.error.text Text of the response + * @param {XMLHttpRequest} query.error.xhr XMLHTTPRequest used + * @param {Function} [query.complete] Callback on query complete (success or error) + * @param {String} query.complete.text Text of the response + * @param {XMLHttpRequest} query.complete.xhr XMLHTTPRequest used + */ + askia.ajax = function ajax (query) { + if (!query) { + (console && console.warn('The `query` argument must be a valid object for askia.ajax()')); + return; + } + if (!query.url || typeof query.url !== 'string') { + (console && console.warn('The `query.url` argument must be a valid string for askia.ajax()')); + return; + } + + query.method = ((query.method && query.method.toString()) || 'POST').toUpperCase(); + if (!/^(?:GET|POST|PUT|DELETE|HEAD|OPTIONS|TRACE|CONNECT)$/.test(query.method)) { + (console && console.warn('The `query.method` argument must be a valid HTTP method for askia.ajax()')); + return; + } + + var xhr = new XMLHttpRequest(); + xhr.open(query.method, query.url, true); + xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); + xhr.onload = function onXhrLoad () { + var text = xhr.responseText; + if (xhr.status >= 200 && xhr.status < 400) { + if (typeof query.success === 'function') { + query.success(text, xhr); + } + } else { + if (typeof query.error === 'function') { + query.error(text, xhr); + } + } + + if (typeof query.complete === 'function') { + query.complete(text, xhr); + } + }; + + xhr.onerror = function () { + if (typeof query.error === 'function') { + query.error(text, xhr); + } + if (typeof query.complete === 'function') { + query.complete(text, xhr); + } + }; + + xhr.send(query.data || null); + }; + + // Assign a version for future patches management + askia.ajax.version = "2.0"; + + + /* ---======== Askia Events Management ========--- */ + + askia.defaultEventActions = { + askiaAnswer: executeLiveRouting, + askiaShowQuestion: executeShowHideQuestion, + askiaHideQuestion: executeShowHideQuestion, + askiaShowResponses: null, + askiaHideResponses: null, + askiaReload: executeReload, + askiaSetValue: executeSetValue, + askiaShowMessage: null, + askiaChangeQuestionsOrder: null, + askiaChangeResponsesOrder: null, + askiaInfo: null, + askiaUpdateCaption: executeUpdateCaption + }; + + + /** + * Trigger an arbitrary event + * + * @param {String} eventName Name of the event to trigger + * @param {Object} detail Detail associated with the event + */ + askia.triggerEvent = function triggerEvent (eventName, detail) { + var eventInit = detail !== undefined ? { detail: detail } : undefined; + var event = new CustomEvent(eventName, eventInit); + return document.dispatchEvent(event); + }; + + /** + * Trigger an event when the respondent is answering + */ + askia.triggerAnswer = function triggerAnswer () { + if (!askia.triggerEvent('askiaAnswer')) { + return false; // preventDefault() has been called + } + + // Default behaviour + askia.defaultEventActions.askiaAnswer(); + }; + + /* ---======== Default Events Management ========--- */ + + /** + * Show or hide an entire question + * + * @param {Object} data Definition of the action to do + * @param {"showQuestion"|"hideQuestion"} data.action Action to execute + * @param {Number} data.inputCode Input code associated with the question + */ + function executeShowHideQuestion (data) { + if (!(data.question.inputCode >= 0)) { + return; + } + var isShow = /^(?:show)/i.test(data.action); + var className = '.askia-question-' + data.question.inputCode; + var elements = document.querySelectorAll(className); + var i; + var l; + for (i = 0, l = elements.length; i < l; i += 1) { + elements[i].style.display = isShow ? '' : 'none'; + } + } + + /** + * Update a live caption + * + * @param {Object} data Definition of the action to do + * @param {"updateCaption"} data.action Action to execute + * @param {String} data.selector The selector is a CSS Class (prefix `.`) or and HTML identifier (prefix `#`) + * @param {String} data.caption The updated caption + */ + function executeUpdateCaption (data) { + if (data.selector === '') { + return; + } + var className = data.selector; + var caption = data.caption; + var elements = document.querySelectorAll(className); + var i; + var l; + for (i = 0, l = elements.length; i < l; i += 1) { + elements[i].innerHTML = caption; + } + } + + /** + * Reload the page + */ + function executeReload () { + if (isPreventReload) return; + window.location.reload(); + } + + /** + * Set value Ajax + */ + function executeSetValue (data) { + let val = data.value; + if (Array.isArray(val)){ + for (var i = 0; i < val.length; i++) { + let checkEl = document.querySelector('#askia-input' + data.question.inputCode + '_' + val[i].inputCode); + if (checkEl) + checkEl.checked = true; + } + } else { + if (typeof val === 'string'){ + let openEl = document.querySelector('input[name="S'+ data.question.inputCode +'"]'); + if (openEl) openEl.value = '', openEl.value = val; + } else { + let numberEl = document.querySelector('input[name="C'+ data.question.inputCode +'"]'); + if (numberEl) numberEl.value = val; + } + } + } + + /* ---======== Live Routing Management ========--- */ + + var isExecutingLiveRouting = false; // Flag to avoid several live routing request + var shouldReExecuteLiveRouting = false; // Flag to re-execute the live routing + var isPreventReload = true; // Flag to prevent the page to reload on loop + + /** + * Execute the AJAX query to do a live routing + */ + function executeLiveRouting () { + if (isExecutingLiveRouting) { + shouldReExecuteLiveRouting = true; + return; + } + isExecutingLiveRouting = true; + shouldReExecuteLiveRouting = false; + askia.ajax({ + url: '../cgi-bin/AskiaExt.dll' + window.location.search, + data: askia.serializeForm(document.forms[0], 'DoLiveRouting'), + success: onLiveRoutingSuccess, + complete: onLiveRoutingComplete + }); + } + + /** + * Manage the live routing AJAX - success + */ + function onLiveRoutingSuccess (text) { + var json = JSON.parse(text); + var actions = json.actions || []; + var i, l, itmeAction, eventName; + var mri = json.mri || null; + var mriEl = document.querySelector('input[name="Mri"]'); + if (mri && mriEl) { + mriEl.value = mri; + } + for (i = 0, l = actions.length; i < l; i += 1) { + itemAction = actions[i]; + eventName = 'askia' + capitalize(itemAction.action); + if (!askia.triggerEvent(eventName, itemAction)) { + continue; // preventDefault(); + } + // Default behaviour + if (typeof askia.defaultEventActions[eventName] === 'function') { + askia.defaultEventActions[eventName](itemAction); + } + } + } + + /** + * Manage the live routing AJAX - complete + */ + function onLiveRoutingComplete () { + isExecutingLiveRouting = false; + isPreventReload = false; + if (!shouldReExecuteLiveRouting) { + return; + } + setTimeout(executeLiveRouting, 250); + } + + /** + * Manage the live routing for classical askia form (Non ADCs) + * Trigger the answers to the server side on the event change or input + */ + document.addEventListener('DOMContentLoaded', function (){ + + /** + * Change event listener for the closed question form controls + */ + document.addEventListener('change', function (event){ + var el = event.target || event.srcElement; + // Retrieve the InputCode number of the question + var rg = /^[a-z]+([0-9]+)(?:\s*|\_*)/i.exec(el.name); + if (rg && (window.arrLiveRoutingInputCode.indexOf(rg[1]) > -1) && + (((el.nodeName === 'INPUT') && + (el.parentElement.className.indexOf('askia-response') >= 0 || + el.parentElement.className.indexOf('askia-control') >= 0 || + el.parentElement.className.indexOf('askia-grid-row') >= 0 || + el.parentElement.parentElement.className.indexOf('askia-grid-row') >= 0) && + (el.type === 'radio' || el.type === 'checkbox')) || el.nodeName === 'SELECT')) { + setTimeout(function(){ askia.triggerAnswer(); }, 150); + } + }); + /** + * Input event listener for the numerical and open ended question form controls + */ + document.addEventListener('input', function (event){ + var el = event.target || event.srcElement; + // Retrieve the InputCode number of the question + var rg = /^[a-z]+([0-9]+)(?:\s*|\_*)/i.exec(el.name); + if (rg && (window.arrLiveRoutingInputCode.indexOf(rg[1]) > -1) && + (((el.nodeName === 'TEXTAREA') || + ((el.nodeName === 'INPUT') && (el.type === 'color' || + el.type === 'date' || el.type === 'datetime' || + el.type === 'email' || el.type === 'month' || + el.type === 'number' || el.type === 'password' || + el.type === 'range' || el.type === 'search' || + el.type === 'tel' || el.type === 'text' || + el.type === 'time' || el.type === 'url' || el.type === 'week'))) && + (el.parentElement.className.indexOf('askia-response') >= 0 || + el.parentElement.className.indexOf('askia-control') >= 0 || + el.parentElement.className.indexOf('askia-grid-row') >= 0 || + el.parentElement.parentElement.className.indexOf('askia-grid-row') >= 0 || + el.className.indexOf('askia-live') >= 0))) { + askia.triggerAnswer(); + } + }); + if (window.arrLiveRoutingShortcut && window.arrLiveRoutingShortcut.length >= 1) { + askia.triggerAnswer(); + } + }); + +}()); diff --git a/resources/static/askia.ajax.min.js b/resources/static/askia.ajax.min.js index 884e64b..2c1367d 100755 --- a/resources/static/askia.ajax.min.js +++ b/resources/static/askia.ajax.min.js @@ -1 +1,30 @@ -!function(){function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}e.prototype=window.Event.prototype,window.CustomEvent=e}(),function(){window.AskiaScript&&(AskiaScript.executeLiveRouting=function(){});var e=window.askia||{};function t(e){if(e.question.inputCode>=0){var t,n,a=/^(?:show)/i.test(e.action),o=".askia-question-"+e.question.inputCode,i=document.querySelectorAll(o);for(t=0,n=i.length;t=200&&t.status<400?"function"==typeof e.success&&e.success(n,t):"function"==typeof e.error&&e.error(n,t),"function"==typeof e.complete&&e.complete(n,t)},t.onerror=function(){"function"==typeof e.error&&e.error(text,t),"function"==typeof e.complete&&e.complete(text,t)},t.send(e.data||null)}else console&&console.warn("The `query.method` argument must be a valid HTTP method for askia.ajax()");else console&&console.warn("The `query.url` argument must be a valid string for askia.ajax()");else console&&console.warn("The `query` argument must be a valid object for askia.ajax()")},e.defaultEventActions={askiaAnswer:i,askiaShowQuestion:t,askiaHideQuestion:t,askiaShowResponses:null,askiaHideResponses:null,askiaReload:function(){if(o)return;window.location.reload()},askiaSetValue:function(e){let t=e.value;if(Array.isArray(t))for(var n=0;n-1&&("INPUT"===n.nodeName&&(n.parentElement.className.indexOf("askia-response")>=0||n.parentElement.className.indexOf("askia-control")>=0||n.parentElement.className.indexOf("askia-grid-row")>=0||n.parentElement.parentElement.className.indexOf("askia-grid-row")>=0)&&("radio"===n.type||"checkbox"===n.type)||"SELECT"===n.nodeName)&&setTimeout(function(){e.triggerAnswer()},150)}),document.addEventListener("input",function(t){var n=t.target||t.srcElement,a=/^[a-z]+([0-9]+)(?:\s*|\_*)/i.exec(n.name);a&&window.arrLiveRoutingInputCode.indexOf(a[1])>-1&&("TEXTAREA"===n.nodeName||"INPUT"===n.nodeName&&("color"===n.type||"date"===n.type||"datetime"===n.type||"email"===n.type||"month"===n.type||"number"===n.type||"password"===n.type||"range"===n.type||"search"===n.type||"tel"===n.type||"text"===n.type||"time"===n.type||"url"===n.type||"week"===n.type))&&(n.parentElement.className.indexOf("askia-response")>=0||n.parentElement.className.indexOf("askia-control")>=0||n.parentElement.className.indexOf("askia-grid-row")>=0||n.parentElement.parentElement.className.indexOf("askia-grid-row")>=0||n.className.indexOf("askia-live")>=0)&&e.triggerAnswer()}),window.arrLiveRoutingShortcut&&window.arrLiveRoutingShortcut.length>=1&&e.triggerAnswer()})}(); +(function(){function CustomEvent(event,params){params=params||{bubbles:!1,cancelable:!1,detail:undefined};var evt=document.createEvent('CustomEvent');evt.initCustomEvent(event,params.bubbles,params.cancelable,params.detail);return evt} +CustomEvent.prototype=window.Event.prototype;window.CustomEvent=CustomEvent})();(function(){if(window.AskiaScript){AskiaScript.executeLiveRouting=function(){}} +var askia=window.askia||{};if(!window.askia){window.askia=askia} +function capitalize(str){return str.charAt(0).toUpperCase()+str.slice(1)} +function forEachSubmittableElements(elForm,fn){if(typeof fn!=='function'){return} +var rgSubmitter=/^(?:submit|button|image|reset|file)$/i;var rgSubmittable=/^(?:input|select|textarea|keygen)/i;var rgCheckable=/^(?:checkbox|radio)$/i;var els=elForm.elements;var i;for(i=0,l=els.length;i=200&&xhr.status<400){if(typeof query.success==='function'){query.success(text,xhr)}}else{if(typeof query.error==='function'){query.error(text,xhr)}} +if(typeof query.complete==='function'){query.complete(text,xhr)}};xhr.onerror=function(){if(typeof query.error==='function'){query.error(text,xhr)} +if(typeof query.complete==='function'){query.complete(text,xhr)}};xhr.send(query.data||null)};askia.ajax.version="2.0";askia.defaultEventActions={askiaAnswer:executeLiveRouting,askiaShowQuestion:executeShowHideQuestion,askiaHideQuestion:executeShowHideQuestion,askiaShowResponses:null,askiaHideResponses:null,askiaReload:executeReload,askiaSetValue:executeSetValue,askiaShowMessage:null,askiaChangeQuestionsOrder:null,askiaChangeResponsesOrder:null,askiaInfo:null,askiaUpdateCaption:executeUpdateCaption};askia.triggerEvent=function triggerEvent(eventName,detail){var eventInit=detail!==undefined?{detail:detail}:undefined;var event=new CustomEvent(eventName,eventInit);return document.dispatchEvent(event)};askia.triggerAnswer=function triggerAnswer(){if(!askia.triggerEvent('askiaAnswer')){return!1} +askia.defaultEventActions.askiaAnswer()};function executeShowHideQuestion(data){if(!(data.question.inputCode>=0)){return} +var isShow=/^(?:show)/i.test(data.action);var className='.askia-question-'+data.question.inputCode;var elements=document.querySelectorAll(className);var i;var l;for(i=0,l=elements.length;i-1)&&(((el.nodeName==='INPUT')&&(el.parentElement.className.indexOf('askia-response')>=0||el.parentElement.className.indexOf('askia-control')>=0||el.parentElement.className.indexOf('askia-grid-row')>=0||el.parentElement.parentElement.className.indexOf('askia-grid-row')>=0)&&(el.type==='radio'||el.type==='checkbox'))||el.nodeName==='SELECT')){setTimeout(function(){askia.triggerAnswer()},150)}});document.addEventListener('input',function(event){var el=event.target||event.srcElement;var rg=/^[a-z]+([0-9]+)(?:\s*|\_*)/i.exec(el.name);if(rg&&(window.arrLiveRoutingInputCode.indexOf(rg[1])>-1)&&(((el.nodeName==='TEXTAREA')||((el.nodeName==='INPUT')&&(el.type==='color'||el.type==='date'||el.type==='datetime'||el.type==='email'||el.type==='month'||el.type==='number'||el.type==='password'||el.type==='range'||el.type==='search'||el.type==='tel'||el.type==='text'||el.type==='time'||el.type==='url'||el.type==='week')))&&(el.parentElement.className.indexOf('askia-response')>=0||el.parentElement.className.indexOf('askia-control')>=0||el.parentElement.className.indexOf('askia-grid-row')>=0||el.parentElement.parentElement.className.indexOf('askia-grid-row')>=0||el.className.indexOf('askia-live')>=0))){askia.triggerAnswer()}});if(window.arrLiveRoutingShortcut&&window.arrLiveRoutingShortcut.length>=1){askia.triggerAnswer()}})}())