PageSourceSearch

https://www.learningstrategies.com/WebResource.axd?d=iw1oKMaxwat68…tJSAii6P171Fc_xoMcW-D0&t=638750451468418249

js learningstrategies.com collected 2026-09-24 09:34:23 UTC 9,560 bytes, 366 lines download raw bytes

1// SLICKBACK
2//
3
4SlickBackHandler.prototype.bind = function(object, method) 
5{
6    return function() 
7    {
8        return method.apply(object);
9    }
10}
11
12SlickBackHandler.prototype.setProgressDisplay = function(theForm, visibility)
13{
14    var progressDivIDs = theForm.__SLICKBACKPROGRESS.value
15    if (progressDivIDs != null && progressDivIDs.length > 0)
16    {
17        var divIDs = progressDivIDs.split(',');
18        
19        var i;
20        for (i=0; i<divIDs.length; i++)
21        {
22            var div = document.getElementById(divIDs[i]);
23            if (!div)
24                continue;
25                
26            div.style.visibility = visibility;
27        }
28    }
29}
30
31SlickBackHandler.prototype.runSubmitScripts = function (theForm) {
32    var result = true;
33    var scripts = theForm.__SLICKBACKSUBMIT.value
34    if (scripts != null && scripts.length > 0) {
35        var a = new Array();
36        eval(scripts);
37
38        var i;
39        for (i = 0; i < a.length; i++) {
40            var f;
41            eval('f = function () {' + a[i] + '}');
42            var r = f();
43            if (typeof r != "undefined" && !r)
44                result = false;
45        }
46    }
47
48    return result;
49}
50
51SlickBackHandler.prototype.fire = function(eventTarget, eventArgument, notify)
52{
53    // Store notification handler
54    this.notify = notify;
55
56    // Set slickback values
57    var theForm = SlickBack.getForm();
58    if (!theForm)
59        return;
60
61    theForm.__SLICKBACKTARGET.value = eventTarget.split("$").join(":");
62    theForm.__SLICKBACKARGUMENT.value = eventArgument;
63
64    // Make request
65    if (this.supportsXMLHttpRequest())
66    {  
67        // Reflect loading status
68        this.setProgressDisplay(theForm, '');
69        
70        // Run submit scripts
71        if (!this.runSubmitScripts(theForm))
72            return;
73
74        // Use XMLHttpRequest
75        theForm.__SLICKBACKTYPE.value = '2';
76
77        var body = this.processFormElements(theForm);
78        this.postXMLDoc(theForm.action, body);
79
80        // Reset values since the page isn't refreshed
81        theForm.__SLICKBACKTARGET.value = '';
82        theForm.__SLICKBACKARGUMENT.value = '';
83        theForm.__SLICKBACKTYPE.value = '';
84    }
85    else
86    {
87        // Use vanilla post
88        theForm.__SLICKBACKTYPE.value = '0';
89        
90        theForm.submit();
91    }
92}
93
94SlickBackHandler.prototype.post = function (eventTarget, eventArgument, notify) 
95{
96    // Store notification handler
97    this.notify = notify;
98
99    // Set slickback values
100    var theForm = SlickBack.getForm();
101    if (!theForm)
102        return;
103
104    theForm.__EVENTTARGET.value = eventTarget;
105    theForm.__EVENTARGUMENT.value = eventArgument;
106
107    // Make request
108    if (this.supportsXMLHttpRequest()) {
109        // Reflect loading status
110        this.setProgressDisplay(theForm, '');
111
112        // Run submit scripts
113        if (!this.runSubmitScripts(theForm))
114            return;
115
116        // Use XMLHttpRequest
117        theForm.__SLICKBACKTYPE.value = '2';
118
119        var body = this.processFormElements(theForm);
120        this.postXMLDoc(theForm.action, body);
121
122        // Reset values since the page isn't refreshed
123        theForm.__EVENTTARGET.value = '';
124        theForm.__EVENTARGUMENT.value = '';
125        theForm.__SLICKBACKTYPE.value = '';
126    }
127    else {
128        // Use vanilla post
129        theForm.__SLICKBACKTYPE.value = '0';
130
131        theForm.submit();
132    }
133}
134
135SlickBackHandler.prototype.getUrl = function(url, notify) 
136{
137    if (!this.supportsXMLHttpRequest())
138        return;
139
140    // Store notification handler
141    this.notify = notify;
142
143    var theForm = SlickBack.getForm();
144    if (theForm)
145    {
146        // Reflect loading status
147        this.setProgressDisplay(theForm, '');
148
149        // Run submit scripts
150        if (!this.runSubmitScripts(theForm))
151            return;
152    }
153
154    // Make request
155    this.postXMLDoc(url, '__SLICKBACKTYPE=1');
156}
157
158SlickBackHandler.prototype.processFormElements = function(theForm) 
159{
160    var r = '';
161    var count = theForm.elements.length;
162
163    var i;
164    for (i=0; i<count; i++)
165    {
166        var element = theForm.elements[i];
167        var elementName = element.tagName.toLowerCase();
168        var elementID = element.name;
169        
170        if (elementName == "input") 
171        {
172            if (element.type == "submit" || element.type == "image")
173                continue;
174
175            if (element.type == "checkbox" || element.type == "radio")
176            {
177                if (!element.checked)
178                    continue;
179            }
180
181            r += elementID + "=" + encodeURIComponent(element.value) + "&";
182        }
183        else if (elementName == "textarea")
184        {
185            r += elementID + "=" + encodeURIComponent(element.value) + "&";
186        }
187        else if (elementName == "select") 
188        {
189            var selectCount = element.options.length;
190
191            var j;
192            for (j=0; j<selectCount; j++) 
193            {
194                var option = element.options[j];
195
196                if (option.selected == true)
197                    r += elementID + "=" + encodeURIComponent(option.value) + "&";
198            }
199        }
200    }
201
202    return r;
203}
204
205SlickBackHandler.prototype.supportsXMLHttpRequest = function() 
206{
207    if (window.XMLHttpRequest)
208        return true;
209
210    if (window.ActiveXObject) 
211    {
212        if (new ActiveXObject("Microsoft.XMLHTTP"))
213            return true;
214    }
215
216    return false;
217}
218
219SlickBackHandler.prototype.postXMLDoc = function(url, body) 
220{
221    if (url == '')
222        url = '.';
223        
224    this.client = window.XMLHttpRequest 
225        ? new XMLHttpRequest() 
226        : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : null);
227    
228    if (this.client)
229    {
230        this.client.onreadystatechange = this.bind(this, this.xmlRequestChange);
231        this.client.open("POST", url, true);
232        this.client.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");            
233        this.client.send(body);
234    }
235}
236
237SlickBackHandler.prototype.xmlRequestChange = function() 
238{
239    // Loaded
240    if (this.client.readyState == 4) 
241    {
242        if (this.client.status == 200) 
243        {
244            this.xmlRequestDone();
245        } 
246        else 
247        {
248            document.body.innerHTML = this.client.responseText;
249        }
250    }
251}
252
253SlickBackHandler.prototype.xmlRequestDone = function()
254{
255    //alert(this.client.responseText);
256    //return;
257
258    var i;
259    var root = this.client.responseXML.documentElement;  
260
261    var redirect = SlickBack.childValue(root, 'redirect');
262    if (redirect)
263    {
264        window.location = redirect;
265        return;
266    }
267
268    var theForm = SlickBack.getForm();
269    if (theForm)
270    {
271        var inputValues = root.getElementsByTagName('inputValue');
272        for (i=0; i<inputValues.length; i++)
273        {
274            var inputValue = inputValues.item(i);
275            var inputID = inputValue.getAttribute('id');
276            var input = theForm.elements[inputID];
277            if (input)
278                input.value = SlickBack.nodeValue(inputValue);
279        }
280    }
281    
282    var payloads = root.getElementsByTagName('payload');
283    for (i=0; i<payloads.length; i++)
284    {
285        var payload = payloads.item(i);
286        var handler = payload.getAttribute('handler');
287        eval(handler + '(payload)');
288    }
289
290    // Reflect loading status
291    if (theForm)
292    {
293        this.setProgressDisplay(theForm, 'hidden');
294    }
295    
296    // Send notification
297    if (this.notify)
298        this.notify();
299}
300
301function SlickBackHandler()
302{
303    this.client = null;
304    this.notify = null;
305}
306
307var SlickBack = {
308    fire: function(eventTarget, eventArgument, notify)
309    {
310        var handler = new SlickBackHandler();
311        handler.fire(eventTarget, eventArgument, notify);
312    },
313    post: function(eventTarget, eventArgument)
314    {
315        var handler = new SlickBackHandler();
316        handler.post(eventTarget, eventArgument);
317    },
318    getUrl: function(url, notify)
319    {
320        var handler = new SlickBackHandler();
321        handler.getUrl(url, notify);
322    },
323    handleContent: function(node)
324    {
325        var contents = node.getElementsByTagName('content');
326
327        var i;
328        for (i=0; i<contents.length; i++)
329        {
330            var content = contents.item(i);
331            var divID = content.getAttribute('id');
332            var div = document.getElementById(divID);
333            if (div)
334                div.innerHTML = SlickBack.nodeValue(content);
335        }
336    },
337    handleOnLoad: function(node)
338    {
339        eval(SlickBack.nodeValue(node));
340    },
341    childValue: function(node, tagName)
342    {
343        var elements = node.getElementsByTagName(tagName);
344        if (elements.length == 0)
345            return null;
346
347        var item = elements.item(0).firstChild;
348        return (item == null) ? '' : item.nodeValue;
349    },
350    nodeValue: function(node)
351    {
352        return (node.firstChild == null) ? '' : node.firstChild.nodeValue
353    },
354    getForm: function()
355    {
356        var i;
357        var fs = document.forms;
358        for (i=0; i<fs.length; i++)
359        {
360            if (fs[i].__SLICKBACKARGUMENT)
361                return fs[i];
362        }
363        
364        return null;
365    }
366}

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.