PageSourceSearch

https://www.easygoingsurvey.com/ajaxpro/core.ashx?VID=63836332747153

js easygoingsurvey.com collected 2026-10-07 15:49:38 UTC 21,167 bytes, 684 lines download raw bytes

1//--------------------------------------------------------------
2// Copyright (C) 2021 Michael Schwarz (http://www.ajaxpro.info).
3// All rights reserved.
4//--------------------------------------------------------------
5
6// core.js
7Object.extend(Function.prototype, {
8    getArguments: function ()
9    {
10        var args = [];
11        for (var i = 0; i < this.arguments.length; i++)
12        {
13            args.push(this.arguments[i]);
14        }
15        return args;
16    }
17}, false);
18
19var MS = { "Browser": {} };
20
21Object.extend(MS.Browser, {
22    isIE: navigator.userAgent.indexOf('MSIE') != -1,
23    isFirefox: navigator.userAgent.indexOf('Firefox') != -1,
24    isOpera: window.opera != null
25}, false);
26
27var AjaxPro = {};
28
29AjaxPro.IFrameXmlHttp = function () { };
30AjaxPro.IFrameXmlHttp.prototype = {
31    onreadystatechange: null, headers: [], method: "POST", url: null, async: true, iframe: null,
32    status: 0, readyState: 0, responseText: null,
33    abort: function ()
34    {
35    },
36    readystatechanged: function ()
37    {
38        var doc = this.iframe.contentDocument || this.iframe.document;
39        if (doc != null && doc.readyState == "complete" && doc.body != null && doc.body.res != null)
40        {
41            this.status = 200;
42            this.statusText = "OK";
43            this.readyState = 4;
44            this.responseText = doc.body.res;
45            this.onreadystatechange();
46            return;
47        }
48        setTimeout(this.readystatechanged.bind(this), 10);
49    },
50    open: function (method, url, async)
51    {
52        if (async == false)
53        {
54            alert("Synchronous call using IFrameXMLHttp is not supported.");
55            return;
56        }
57        if (this.iframe == null)
58        {
59            var iframeID = "hans";
60            if (document.createElement && document.documentElement &&
61                (window.opera || navigator.userAgent.indexOf('MSIE 5.0') == -1))
62            {
63                var ifr = document.createElement('iframe');
64                ifr.setAttribute('id', iframeID);
65                ifr.style.visibility = 'hidden';
66                ifr.style.position = 'absolute';
67                ifr.style.width = ifr.style.height = ifr.borderWidth = '0px';
68
69                this.iframe = document.getElementsByTagName('body')[0].appendChild(ifr);
70            }
71            else if (document.body && document.body.insertAdjacentHTML)
72            {
73                document.body.insertAdjacentHTML('beforeEnd', '<iframe name="' + iframeID + '" id="' + iframeID + '" style="border:1px solid black;display:none"></iframe>');
74            }
75            if (window.frames && window.frames[iframeID])
76            {
77                this.iframe = window.frames[iframeID];
78            }
79            this.iframe.name = iframeID;
80            this.iframe.document.open();
81            this.iframe.document.write("<" + "html><" + "body></" + "body></" + "html>");
82            this.iframe.document.close();
83        }
84        this.method = method;
85        this.url = url;
86        this.async = async;
87    },
88    setRequestHeader: function (name, value)
89    {
90        for (var i = 0; i < this.headers.length; i++)
91        {
92            if (this.headers[i].name == name)
93            {
94                this.headers[i].value = value;
95                return;
96            }
97        }
98        this.headers.push({ "name": name, "value": value });
99    },
100    getResponseHeader: function (name, value)
101    {
102        return null;
103    },
104    addInput: function (doc, form, name, value)
105    {
106        var ele;
107        var tag = "input";
108        if (value.indexOf("\n") >= 0)
109        {
110            tag = "textarea";
111        }
112
113        if (doc.all)
114        {
115            ele = doc.createElement("<" + tag + " name=\"" + name + "\" />");
116        } else
117        {
118            ele = doc.createElement(tag);
119            ele.setAttribute("name", name);
120        }
121        ele.setAttribute("value", value);
122        form.appendChild(ele);
123        ele = null;
124    },
125    send: function (data)
126    {
127        if (this.iframe == null)
128        {
129            return;
130        }
131        var doc = this.iframe.contentDocument || this.iframe.document;
132        var form = doc.createElement("form");
133
134        doc.body.appendChild(form);
135
136        form.setAttribute("action", this.url);
137        form.setAttribute("method", this.method);
138        form.setAttribute("enctype", "application/x-www-form-urlencoded");
139
140        for (var i = 0; i < this.headers.length; i++)
141        {
142            switch (this.headers[i].name.toLowerCase())
143            {
144                case "content-length":
145                case "accept-encoding":
146                case "content-type":
147                    break;
148                default:
149                    this.addInput(doc, form, this.headers[i].name, this.headers[i].value);
150            }
151        }
152        this.addInput(doc, form, "data", data);
153        form.submit();
154
155        setTimeout(this.readystatechanged.bind(this), 0);
156    }
157};
158
159var progids = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
160var progid = null;
161
162if (typeof ActiveXObject != "undefined")
163{
164    var ie7xmlhttp = false;
165    if (typeof XMLHttpRequest == "object")
166    {
167        try { var o = new XMLHttpRequest(); ie7xmlhttp = true; } catch (e) { }
168    }
169    if (typeof XMLHttpRequest == "undefined" || !ie7xmlhttp)
170    {
171        XMLHttpRequest = function ()
172        {
173            var xmlHttp = null;
174            if (!AjaxPro.noActiveX)
175            {
176                if (progid != null)
177                {
178                    return new ActiveXObject(progid);
179                }
180                for (var i = 0; i < progids.length && xmlHttp == null; i++)
181                {
182                    try
183                    {
184                        xmlHttp = new ActiveXObject(progids[i]);
185                        progid = progids[i];
186
187                    } catch (e) { }
188                }
189            }
190            if (xmlHttp == null && MS.Browser.isIE)
191            {
192                return new AjaxPro.IFrameXmlHttp();
193            }
194            return xmlHttp;
195        };
196    }
197}
198
199Object.extend(AjaxPro, {
200    noOperation: function () { },
201    onLoading: function () { },
202    onError: function () { },
203    onTimeout: function () { return true; },
204    onStateChanged: function () { },
205    cryptProvider: null,
206    queue: null,
207    token: "",
208    version: "22.3.20.1",
209    ID: "AjaxPro",
210    noActiveX: false,
211    timeoutPeriod: 15 * 1000,
212    queue: null,
213    noUtcTime: false,
214    regExDate: function (str, p1, p2, offset, s)
215    {
216        var date = str.substring(1).replace('"', '');
217        if (date.substring(0, 7) == "\\\/Date(")
218        {
219            var d = date.match(/Date\((.*?)\)/)[1];
220            return "new Date(" + parseInt(d) + ")";
221        }
222        /*else
223        { // ISO Date 2007-12-31T23:59:59Z                                     
224            var matches = date.split(/[-,:,T,Z]/);
225            if (matches.length == 7)
226            {
227                matches[1] = (parseInt(matches[1], 0) - 1).toString();
228                var isDate = true;
229                var s = "";
230                for (var i = 0; i < matches.length; i++)
231                {
232                    if (isNaN(parseInt(matches[i], 10)))
233                    {
234                        isDate = false;
235                        break;
236                    }
237                    if (i > 0)
238                    {
239                        s += ",";
240                    }
241                    s += parseInt(matches[i], 10);
242                    console.log(s);
243                }
244                if (isDate)
245                {
246                    return "new Date(Date.UTC(" + s + "))";
247                }
248            }
249        }*/
250        return str;
251    },
252    parse: function (text)
253    {
254        text = text.replace(/(\"\\\/Date\(\d+\)\\\/")/g, this.regExDate);
255        return eval('(' + text + ')');
256    },
257    m: {
258        '\b': '\\b',
259        '\t': '\\t',
260        '\n': '\\n',
261        '\f': '\\f',
262        '\r': '\\r',
263        '"': '\\"',
264        '\\': '\\\\'
265    },
266    toJSON: function (o)
267    {
268        if (o == null)
269        {
270            return "null";
271        }
272        var v = [];
273        var i;
274        var c = o.constructor;
275        if (c == Number)
276        {
277            return isFinite(o) ? o.toString() : AjaxPro.toJSON(null);
278        } else if (c == Boolean)
279        {
280            return o.toString();
281        } else if (c == String)
282        {
283            if (/["\\\x00-\x1f]/.test(o))
284            {
285                o = o.replace(/([\x00-\x1f\\"])/g, function (a, b)
286                {
287                    var c = AjaxPro.m[b];
288                    if (c)
289                    {
290                        return c;
291                    }
292                    c = b.charCodeAt();
293                    return '\\u00' +
294                        Math.floor(c / 16).toString(16) +
295                        (c % 16).toString(16);
296                });
297            }
298            return '"' + o + '"';
299        } else if (c == Array)
300        {
301            for (i = 0; i < o.length; i++)
302            {
303                v.push(AjaxPro.toJSON(o[i]));
304            }
305            return "[" + v.join(",") + "]";
306        } else if (c == Date)
307        {
308            return AjaxPro.toJSON("/Date(" + new Date(Date.UTC(o.getUTCFullYear(), o.getUTCMonth(), o.getUTCDate(), o.getUTCHours(), o.getUTCMinutes(), o.getUTCSeconds(), o.getUTCMilliseconds())).getTime() + ")/");
309        }
310        if (typeof o.toJSON == "function")
311        {
312            return o.toJSON();
313        }
314        if (typeof o == "object")
315        {
316            for (var attr in o)
317            {
318                if (typeof o[attr] != "function")
319                {
320                    v.push('"' + attr + '":' + AjaxPro.toJSON(o[attr]));
321                }
322            }
323            if (v.length > 0)
324            {
325                return "{" + v.join(",") + "}";
326            }
327            return "{}";
328        }
329        return o.toString();
330    },
331    dispose: function ()
332    {
333        if (AjaxPro.queue != null)
334        {
335            AjaxPro.queue.dispose();
336        }
337    }
338}, false);
339
340addEvent(window, "unload", AjaxPro.dispose);
341AjaxPro.Request = function (url)
342{
343    this.url = url;
344    this.xmlHttp = null;
345};
346
347AjaxPro.Request.prototype = {
348    url: null,
349    callback: null,
350    onLoading: null,
351    onError: null,
352    onTimeout: null,
353    onStateChanged: null,
354    args: null,
355    context: null,
356    isRunning: false,
357    abort: function ()
358    {
359        if (this.timeoutTimer != null)
360        {
361            clearTimeout(this.timeoutTimer);
362        }
363        if (this.xmlHttp)
364        {
365            this.xmlHttp.onreadystatechange = AjaxPro.noOperation;
366            this.xmlHttp.abort();
367        }
368        if (this.isRunning)
369        {
370            this.isRunning = false;
371            if (this.onLoading !== null)
372            {
373                this.onLoading(false);
374            }
375        }
376    },
377    dispose: function ()
378    {
379        this.abort();
380    },
381    getEmptyRes: function ()
382    {
383        return {
384            error: null,
385            value: null,
386            request: { method: this.method, args: this.args },
387            context: this.context,
388            duration: this.duration
389        };
390    },
391    endRequest: function (res)
392    {
393        this.abort();
394        if (res.error != null)
395        {
396            this.onError(res.error, this);
397        }
398
399        if (typeof this.callback == "function")
400        {
401            this.callback(res, this);
402        }
403    },
404    mozerror: function ()
405    {
406        if (this.timeoutTimer != null)
407        {
408            clearTimeout(this.timeoutTimer);
409        }
410        var res = this.getEmptyRes();
411        res.error = { Message: "Unknown", Type: "ConnectFailure", Status: 0 };
412        this.endRequest(res);
413    },
414    doStateChange: function ()
415    {
416        this.onStateChanged(this.xmlHttp.readyState, this);
417        if (this.xmlHttp.readyState != 4 || !this.isRunning)
418        {
419            return;
420        }
421        this.duration = new Date().getTime() - this.__start;
422        if (this.timeoutTimer != null)
423        {
424            clearTimeout(this.timeoutTimer);
425        }
426        var res = this.getEmptyRes();
427        //Ignore empty statustext to be http2 compatible
428        //if (this.xmlHttp.status == 200 || !this.xmlHttp.statusText)  Esto es lo que tiene en Ajax.NET-Professional, pero a mi no me convence.
429        if (this.xmlHttp.status == 200)
430        {
431            res = this.createResponse(res);
432        } else
433        {
434            res = this.createResponse(res, true);
435            res.error = { Message: this.xmlHttp.statusText, Type: "ConnectFailure", Status: this.xmlHttp.status };
436        }
437
438        this.endRequest(res);
439    },
440    createResponse: function (r, noContent)
441    {
442        if (!noContent)
443        {
444            if (typeof (this.xmlHttp.responseText) == "unknown")
445            {
446                r.error = { Message: "XmlHttpRequest error reading property responseText.", Type: "XmlHttpRequestException" };
447                return r;
448            }
449
450            var responseText = "" + this.xmlHttp.responseText;
451
452            if (AjaxPro.cryptProvider != null && typeof AjaxPro.cryptProvider.decrypt == "function")
453            {
454                responseText = AjaxPro.cryptProvider.decrypt(responseText);
455            }
456
457            if (this.xmlHttp.getResponseHeader("Content-Type") == "text/xml")
458            {
459                r.value = this.xmlHttp.responseXML;
460            } else
461            {
462                if (responseText != null && responseText.trim().length > 0)
463                {
464                    r.json = responseText;
465                    var v = null;
466                    v = AjaxPro.parse(responseText);
467                    if (v != null)
468                    {
469                        if (typeof v.value != "undefined") r.value = v.value;
470                        else if (typeof v.error != "undefined") r.error = v.error;
471                    }
472                }
473            }
474        }
475        /* if(this.xmlHttp.getResponseHeader("X-" + AjaxPro.ID + "-Cache") == "server") {
476            r.isCached = true;
477        } */
478        return r;
479    },
480    timeout: function ()
481    {
482        this.duration = new Date().getTime() - this.__start;
483        if (this.onTimeout == null || typeof (this.onTimeout) != "function")
484        {
485            this.abort();
486        } else
487        {
488            var r = this.onTimeout(this.duration, this);
489            if (typeof r == "undefined" || r != false)
490            {
491                this.abort();
492            } else
493            {
494                this.timeoutTimer = setTimeout(this.timeout.bind(this), AjaxPro.timeoutPeriod);
495            }
496        }
497    },
498    invoke: function (method, args, callback, context)
499    {
500        this.__start = new Date().getTime();
501
502        // if(this.xmlHttp == null) {
503        this.xmlHttp = new XMLHttpRequest();
504        // }
505
506        this.isRunning = true;
507        this.method = method;
508        this.args = args;
509        this.callback = callback;
510        this.context = context;
511
512        var async = typeof (callback) == "function" && callback != AjaxPro.noOperation;
513
514        if (async)
515        {
516            if (MS.Browser.isIE)
517            {
518                this.xmlHttp.onreadystatechange = this.doStateChange.bind(this);
519            } else
520            {
521                this.xmlHttp.onload = this.doStateChange.bind(this);
522                this.xmlHttp.onerror = this.mozerror.bind(this);
523            }
524            this.onLoading(true);
525        }
526
527        var json = AjaxPro.toJSON(args) + "";
528        if (AjaxPro.cryptProvider != null && typeof AjaxPro.cryptProvider.encrypt == "function")
529        {
530            json = AjaxPro.cryptProvider.encrypt(json);
531        }
532
533        this.xmlHttp.open("POST", this.url, async);
534        this.xmlHttp.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
535        this.xmlHttp.setRequestHeader("X-" + AjaxPro.ID + "-Method", method);
536
537        if (AjaxPro.token != null && AjaxPro.token.length > 0)
538        {
539            this.xmlHttp.setRequestHeader("X-" + AjaxPro.ID + "-Token", AjaxPro.token);
540        }
541
542        /* if(!MS.Browser.isIE) {
543            this.xmlHttp.setRequestHeader("Connection", "close");
544        } */
545
546        this.timeoutTimer = setTimeout(this.timeout.bind(this), AjaxPro.timeoutPeriod);
547
548        try { this.xmlHttp.send(json); } catch (e) { }	// IE offline exception
549
550        if (!async)
551        {
552            return this.createResponse({ error: null, value: null });
553        }
554
555        return true;
556    }
557};
558
559AjaxPro.RequestQueue = function (conc)
560{
561    this.queue = [];
562    this.requests = [];
563    this.timer = null;
564
565    if (isNaN(conc)) { conc = 2; }
566
567    for (var i = 0; i < conc; i++)
568    {		// max 2 http connections
569        this.requests[i] = new AjaxPro.Request();
570        this.requests[i].callback = function (res)
571        {
572            var r = res.context;
573            res.context = r[3][1];
574
575            //            if (res.error && window.console)
576            //                console.log("Error en método AJAX: " + res.request.method + " con " + AjaxPro.toJSON(res.request.args) + ". Error: " + res.error)
577            if (res.error != undefined && res.error.Type != undefined && res.error.Type === "ES.Util.Web.AjaxRequestValidationException")
578            {
579                window.location.href = res.error.Redirect;
580            }
581
582            r[3][0](res, this);
583        };
584        this.requests[i].callbackHandle = this.requests[i].callback.bind(this.requests[i]);
585    }
586
587    this.processHandle = this.process.bind(this);
588};
589
590AjaxPro.RequestQueue.prototype = {
591    process: function ()
592    {
593        this.timer = null;
594        if (this.queue.length == 0)
595        {
596            return;
597        }
598        for (var i = 0; i < this.requests.length && this.queue.length > 0; i++)
599        {
600            if (this.requests[i].isRunning == false)
601            {
602                var r = this.queue.shift();
603
604                this.requests[i].url = r[0];
605                this.requests[i].onLoading = r[3].length > 2 && r[3][2] != null && typeof r[3][2] == "function" ? r[3][2] : AjaxPro.onLoading;
606                this.requests[i].onError = r[3].length > 3 && r[3][3] != null && typeof r[3][3] == "function" ? r[3][3] : AjaxPro.onError;
607                this.requests[i].onTimeout = r[3].length > 4 && r[3][4] != null && typeof r[3][4] == "function" ? r[3][4] : AjaxPro.onTimeout;
608                this.requests[i].onStateChanged = r[3].length > 5 && r[3][5] != null && typeof r[3][5] == "function" ? r[3][5] : AjaxPro.onStateChanged;
609
610                this.requests[i].invoke(r[1], r[2], this.requests[i].callbackHandle, r);
611                r = null;
612            }
613        }
614        if (this.queue.length > 0 && this.timer == null)
615        {
616            this.timer = setTimeout(this.processHandle, 0);
617        }
618    },
619    add: function (url, method, args, e)
620    {
621        this.queue.push([url, method, args, e]);
622        if (this.timer == null)
623        {
624            this.timer = setTimeout(this.processHandle, 0);
625        }
626        // this.process();
627    },
628    abort: function ()
629    {
630        this.queue.length = 0;
631        if (this.timer != null)
632        {
633            clearTimeout(this.timer);
634        }
635        this.timer = null;
636        for (var i = 0; i < this.requests.length; i++)
637        {
638            if (this.requests[i].isRunning == true)
639            {
640                this.requests[i].abort();
641            }
642        }
643    },
644    dispose: function ()
645    {
646        for (var i = 0; i < this.requests.length; i++)
647        {
648            var r = this.requests[i];
649            r.dispose();
650        }
651        this.requests.clear();
652    }
653};
654
655AjaxPro.queue = new AjaxPro.RequestQueue(2);	// max 2 http connections
656
657AjaxPro.AjaxClass = function (url)
658{
659    this.url = url;
660};
661
662AjaxPro.AjaxClass.prototype = {
663    invoke: function (method, args, e)
664    {
665
666        if (e != null)
667        {
668            if (e.length != 6)
669            {
670                for (; e.length < 6;) { e.push(null); }
671            }
672            if (e[0] != null && typeof (e[0]) == "function")
673            {
674                return AjaxPro.queue.add(this.url, method, args, e);
675            }
676        }
677        var r = new AjaxPro.Request();
678        // r.onLoading = AjaxPro.onLoading;
679        r.url = this.url;
680        var res = r.invoke(method, args);
681        r.abort();
682        return res;
683    }
684};

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.