PageSourceSearch

https://survey.digitalkonzept.at/tmp/assets/b1ff852c/survey_runtime.js

js digitalkonzept.at collected 2026-10-06 07:08:08 UTC 9,466 bytes, 313 lines download raw bytes

1/*
2 * JavaScript functions in survey taking
3 *
4 * This file is part of LimeSurvey
5 * Copyright (C) 2007-2013 The LimeSurvey Project Team
6 * All rights reserved.
7 * License: GNU/GPL License v2 or later, see LICENSE.php
8 * LimeSurvey is free software. This version may have been modified pursuant
9 * to the GNU General Public License, and as distributed it includes or
10 * is derivative of works licensed under the GNU General Public License or
11 * other free or open source software licenses.
12 * See COPYRIGHT.php for copyright notices and details.
13 */
14
15// Some function can be launch before document ready (and seems intersting)
16// But put it in ready : allowing update by template.js (before moving at end of HTML : best place */
17$(document).on('ready pjax:scriptcomplete',function()
18{
19    tableCellAdapters();
20    doToolTipTable();
21
22    if (typeof LEMsetTabIndexes === 'function') { LEMsetTabIndexes(); }
23    if (typeof checkconditions!='undefined') checkconditions();
24    if (typeof template_onload!='undefined') template_onload();
25    if (typeof(focus_element) != 'undefined')
26    {
27        $(focus_element).focus();
28    }
29
30    // Keypad functions
31    var kp = $("input.num-keypad");
32    if(kp.length)
33    {
34        kp.keypad({
35            showAnim: 'fadeIn', keypadOnly: false,
36            onKeypress: function(key, value, inst) {
37                $(this).trigger('keyup');
38            }
39        });
40    }
41    kp = $(".text-keypad");
42    if(kp.length)
43    {
44        var spacer = $.keypad.HALF_SPACE;
45        for(var i = 0; i != 8; ++i) spacer += $.keypad.SPACE;
46        kp.keypad({
47            showAnim: 'fadeIn',
48            keypadOnly: false,
49            layout: [
50                spacer + $.keypad.CLEAR + $.keypad.CLOSE, $.keypad.SPACE,
51                '!@#$%^&*()_=' + $.keypad.HALF_SPACE + $.keypad.BACK,
52                $.keypad.HALF_SPACE + '`~[]{}<>\\|/' + $.keypad.SPACE + $.keypad.SPACE + '789',
53                'qwertyuiop\'"' + $.keypad.HALF_SPACE + $.keypad.SPACE + '456',
54                $.keypad.HALF_SPACE + 'asdfghjkl;:' + $.keypad.SPACE + $.keypad.SPACE + '123',
55                $.keypad.SPACE + 'zxcvbnm,.?' + $.keypad.SPACE + $.keypad.SPACE + $.keypad.HALF_SPACE + '-0+',
56                $.keypad.SHIFT + $.keypad.SPACE_BAR + $.keypad.ENTER],
57                onKeypress: function(key, value, inst) {
58                    $(this).trigger('keyup');
59                }
60            });
61    }
62
63    // Maxlength for textareas TODO limit to not CSS3 compatible browser
64    maxlengthtextarea();
65
66});
67
68/**
69 * setJsVar : Get all global used var
70 * @deprecated in 3.0.0 not lauched under certain condition … …
71 */
72function setJsVar(){
73    bFixNumAuto=LSvar.bFixNumAuto;
74    bNumRealValue=LSvar.bNumRealValue;
75    LEMradix=LSvar.sLEMradix;
76    numRegex = new RegExp('[^-\.,0-9]','g');
77    intRegex = new RegExp('[^-0-9]','g');
78}
79
80/**
81 * Adapt cell to have a click on cell do a click on input:radio or input:checkbox (if unique)
82 * Using delegate the can be outside document.ready (using .on is possible but on $(document) then : less readbale
83 * @author Denis Chenu / Shnoulle
84 */
85function tableCellAdapters()
86{
87    $(".ls-answers tbody").on('click',' td',function(event) {// 'table.question tbody td' or 'td.radio-item,td.checkbox-item': maybe less js here
88        var eventTarget=$(event.target).prop("tagName");// Alternative us data
89        var eventActivate=$(this).find("input:radio,input:checkbox");
90        if(eventActivate.length==1 && (eventTarget!='INPUT' && eventTarget!='LABEL' ) )
91        {
92            $(eventActivate).click();
93            $(eventActivate).triggerHandler("click");
94            // Why not use trigger('click'); only ?
95        }
96    });
97}
98
99Array.prototype.push = function()
100{
101    var n = this.length >>> 0;
102    for (var i = 0; i < arguments.length; i++)
103    {
104        this[n] = arguments[i];
105        n = n + 1 >>> 0;
106    }
107    this.length = n;
108    return n;
109};
110
111Array.prototype.pop = function() {
112    var n = this.length >>> 0, value;
113    if (n) {
114        value = this[--n];
115        delete this[n];
116    }
117    this.length = n;
118    return value;
119};
120
121
122//defined in group.php & question.php & survey.php, but a static function
123function inArray(needle, haystack)
124{
125    for (h in haystack)
126    {
127        if (haystack[h] == needle)
128        {
129            return true;
130        }
131    }
132    return false;
133}
134
135//defined in group.php & survey.php, but a static function
136function match_regex(testedstring,str_regexp)
137{
138    // Regular expression test
139    if (str_regexp == '' || testedstring == '') return false;
140    pattern = new RegExp(str_regexp);
141    return pattern.test(testedstring)
142}
143
144function addHiddenField(theform,thename,thevalue)
145{
146    var myel = document.createElement('input');
147    myel.type = 'hidden';
148    myel.name = thename;
149    theform.appendChild(myel);
150    myel.value = thevalue;
151}
152
153function cancelBubbleThis(eventObject)
154{
155    if (!eventObject) var eventObject = window.event;
156    eventObject.cancelBubble = true;
157    if (eventObject && eventObject.stopPropagation) {
158        eventObject.stopPropagation();
159    }
160}
161
162function cancelEvent(e)
163{
164  e = e ? e : window.event;
165  if(e.stopPropagation)
166    e.stopPropagation();
167  if(e.preventDefault)
168    e.preventDefault();
169  e.cancelBubble = true;
170  e.cancel = true;
171  e.returnValue = false;
172  return false;
173}
174
175function hookEvent(element, eventName, callback)
176{
177  if(typeof(element) == "string")
178    element = document.getElementById(element);
179  if(element == null)
180    return;
181  if(element.addEventListener)
182  {
183    if(eventName == 'mousewheel')
184      element.addEventListener('DOMMouseScroll', callback, false);
185    element.addEventListener(eventName, callback, false);
186  }
187  else if(element.attachEvent)
188    element.attachEvent("on" + eventName, callback);
189}
190
191function noScroll(e)
192{
193  e = e ? e : window.event;
194  cancelEvent(e);
195}
196
197
198function getkey(e)
199{
200   if (window.event) return window.event.keyCode;
201    else if (e) return e.which; else return null;
202}
203
204function goodchars(e, goods)
205{
206    var key, keychar;
207    key = getkey(e);
208    if (key == null) return true;
209
210    // get character
211    keychar = String.fromCharCode(key);
212    keychar = keychar.toLowerCase();
213    goods = goods.toLowerCase();
214
215   // check goodkeys
216    if (goods.indexOf(keychar) != -1)
217        return true;
218
219    // control keys
220    if ( key==null || key==0 || key==8 || key==9  || key==27 )
221      return true;
222
223    // else return false
224    return false;
225}
226
227function show_hide_group(group_id)
228{
229    var questionCount;
230
231    // First let's show the group description, otherwise, all its childs would have the hidden status
232    $("#group-" + group_id).show();
233    // If all questions in this group are conditionnal
234    // Count visible questions in this group
235        questionCount=$("div#group-" + group_id).find("div[id^='question']:visible").size();
236
237        if( questionCount == 0 )
238        {
239            $("#group-" + group_id).hide();
240        }
241}
242
243// round function from phpjs.org
244function round (value, precision, mode) {
245    // http://kevin.vanzonneveld.net
246    var m, f, isHalf, sgn; // helper variables
247    precision |= 0; // making sure precision is integer
248    m = Math.pow(10, precision);
249    value *= m;
250    sgn = (value > 0) | -(value < 0); // sign of the number
251    isHalf = value % 1 === 0.5 * sgn;
252    f = Math.floor(value);
253
254    if (isHalf) {
255        switch (mode) {
256        case 'PHP_ROUND_HALF_DOWN':
257            value = f + (sgn < 0); // rounds .5 toward zero
258            break;
259        case 'PHP_ROUND_HALF_EVEN':
260            value = f + (f % 2 * sgn); // rouds .5 towards the next even integer
261            break;
262        case 'PHP_ROUND_HALF_ODD':
263            value = f + !(f % 2); // rounds .5 towards the next odd integer
264            break;
265        default:
266            value = f + (sgn > 0); // rounds .5 away from zero
267        }
268    }
269
270    return (isHalf ? value : Math.round(value)) / m;
271}
272
273/* Maxlengt on textarea */
274function maxlengthtextarea(){
275    // Calling this function at document.ready : use maxlength attribute on textarea
276    // Can be replaced by inline javascript
277    $("textarea[maxlength]").change(function(){ // global solution
278        var maxlen=$(this).attr("maxlength");
279        if ($(this).val().length > maxlen) {
280            $(this).val($(this).val().substring(0, maxlen));
281        }
282    });
283    $("textarea[maxlength]").keyup(function(){ // For copy/paste (not for all browser)
284        var maxlen=$(this).attr("maxlength");
285        if ($(this).val().length > maxlen) {
286            $(this).val($(this).val().substring(0, maxlen));
287        }
288    });
289    $("textarea[maxlength]").keydown(function(event){ // No new key after maxlength
290        var maxlen=$(this).attr("maxlength");
291        var k =event.keyCode;
292        if (($(this).val().length >= maxlen) &&
293         !(k == null ||k==0||k==8||k==9||k==13||k==27||k==37||k==38||k==39||k==40||k==46)) {
294            // Don't accept new key except NULL,Backspace,Tab,Enter,Esc,arrows,Delete
295            return false;
296        }
297    });
298}
299/**
300 * Add a title on cell with answer
301 * Title must be updated because label can be updated by expression : mouseover do it only if needed. Accessibility must use aria-labelledby
302 **/
303function doToolTipTable()
304{
305    $(document).on("mouseover"," td.answer-item",function() {
306        var text = $(this).find('label').text().trim();
307        if(text!==""){
308            $(this).attr('title', text);
309        }else{
310            $(this).removeAttr('title');
311        }
312    });
313}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.