PageSourceSearch

https://childrenshomes.org.uk/js/w3.js

js childrenshomes.org.uk collected 2026-10-02 06:45:14 UTC 12,374 bytes, 400 lines download raw bytes

1/* W3.JS 1.04 April 2019 by w3schools.com */
2"use strict";
3var w3 = {};
4w3.hide = function (sel) {
5  w3.hideElements(w3.getElements(sel));
6};
7w3.hideElements = function (elements) {
8  var i, l = elements.length;
9  for (i = 0; i < l; i++) {
10    w3.hideElement(elements[i]);
11  }
12};
13w3.hideElement = function (element) {
14  w3.styleElement(element, "display", "none");
15};
16w3.show = function (sel, a) {
17  var elements = w3.getElements(sel);
18  if (a) {w3.hideElements(elements);}
19  w3.showElements(elements);
20};
21w3.showElements = function (elements) {
22  var i, l = elements.length;
23  for (i = 0; i < l; i++) {
24    w3.showElement(elements[i]);
25  }
26};
27w3.showElement = function (element) {
28  w3.styleElement(element, "display", "block");
29};
30w3.addStyle = function (sel, prop, val) {
31  w3.styleElements(w3.getElements(sel), prop, val);
32};
33w3.styleElements = function (elements, prop, val) {
34  var i, l = elements.length;
35  for (i = 0; i < l; i++) {    
36    w3.styleElement(elements[i], prop, val);
37  }
38};
39w3.styleElement = function (element, prop, val) {
40  element.style.setProperty(prop, val);
41};
42w3.toggleShow = function (sel) {
43  var i, x = w3.getElements(sel), l = x.length;
44  for (i = 0; i < l; i++) {    
45    if (x[i].style.display == "none") {
46      w3.styleElement(x[i], "display", "block");
47    } else {
48      w3.styleElement(x[i], "display", "none");
49    }
50  }
51};
52w3.addClass = function (sel, name) {
53  w3.addClassElements(w3.getElements(sel), name);
54};
55w3.addClassElements = function (elements, name) {
56  var i, l = elements.length;
57  for (i = 0; i < l; i++) {
58    w3.addClassElement(elements[i], name);
59  }
60};
61w3.addClassElement = function (element, name) {
62  var i, arr1, arr2;
63  arr1 = element.className.split(" ");
64  arr2 = name.split(" ");
65  for (i = 0; i < arr2.length; i++) {
66    if (arr1.indexOf(arr2[i]) == -1) {element.className += " " + arr2[i];}
67  }
68};
69w3.removeClass = function (sel, name) {
70  w3.removeClassElements(w3.getElements(sel), name);
71};
72w3.removeClassElements = function (elements, name) {
73  var i, l = elements.length, arr1, arr2, j;
74  for (i = 0; i < l; i++) {
75    w3.removeClassElement(elements[i], name);
76  }
77};
78w3.removeClassElement = function (element, name) {
79  var i, arr1, arr2;
80  arr1 = element.className.split(" ");
81  arr2 = name.split(" ");
82  for (i = 0; i < arr2.length; i++) {
83    while (arr1.indexOf(arr2[i]) > -1) {
84      arr1.splice(arr1.indexOf(arr2[i]), 1);     
85    }
86  }
87  element.className = arr1.join(" ");
88};
89w3.toggleClass = function (sel, c1, c2) {
90  w3.toggleClassElements(w3.getElements(sel), c1, c2);
91};
92w3.toggleClassElements = function (elements, c1, c2) {
93  var i, l = elements.length;
94  for (i = 0; i < l; i++) {    
95    w3.toggleClassElement(elements[i], c1, c2);
96  }
97};
98w3.toggleClassElement = function (element, c1, c2) {
99  var t1, t2, t1Arr, t2Arr, j, arr, allPresent;
100  t1 = (c1 || "");
101  t2 = (c2 || "");
102  t1Arr = t1.split(" ");
103  t2Arr = t2.split(" ");
104  arr = element.className.split(" ");
105  if (t2Arr.length == 0) {
106    allPresent = true;
107    for (j = 0; j < t1Arr.length; j++) {
108      if (arr.indexOf(t1Arr[j]) == -1) {allPresent = false;}
109    }
110    if (allPresent) {
111      w3.removeClassElement(element, t1);
112    } else {
113      w3.addClassElement(element, t1);
114    }
115  } else {
116    allPresent = true;
117    for (j = 0; j < t1Arr.length; j++) {
118      if (arr.indexOf(t1Arr[j]) == -1) {allPresent = false;}
119    }
120    if (allPresent) {
121      w3.removeClassElement(element, t1);
122      w3.addClassElement(element, t2);          
123    } else {
124      w3.removeClassElement(element, t2);        
125      w3.addClassElement(element, t1);
126    }
127  }
128};
129w3.getElements = function (id) {
130  if (typeof id == "object") {
131    return [id];
132  } else {
133    return document.querySelectorAll(id);
134  }
135};
136w3.filterHTML = function(id, sel, filter) {
137  var a, b, c, i, ii, iii, hit;
138  a = w3.getElements(id);
139  for (i = 0; i < a.length; i++) {
140    b = a[i].querySelectorAll(sel);
141    for (ii = 0; ii < b.length; ii++) {
142      hit = 0;
143      if (b[ii].innerText.toUpperCase().indexOf(filter.toUpperCase()) > -1) {
144        hit = 1;
145      }
146      c = b[ii].getElementsByTagName("*");
147      for (iii = 0; iii < c.length; iii++) {
148        if (c[iii].innerText.toUpperCase().indexOf(filter.toUpperCase()) > -1) {
149          hit = 1;
150        }
151      }
152      if (hit == 1) {
153        b[ii].style.display = "";
154      } else {
155        b[ii].style.display = "none";
156      }
157    }
158  }
159};
160w3.sortHTML = function(id, sel, sortvalue) {
161  var a, b, i, ii, y, bytt, v1, v2, cc, j;
162  a = w3.getElements(id);
163  for (i = 0; i < a.length; i++) {
164    for (j = 0; j < 2; j++) {
165      cc = 0;
166      y = 1;
167      while (y == 1) {
168        y = 0;
169        b = a[i].querySelectorAll(sel);
170        for (ii = 0; ii < (b.length - 1); ii++) {
171          bytt = 0;
172          if (sortvalue) {
173            v1 = b[ii].querySelector(sortvalue).innerText;
174            v2 = b[ii + 1].querySelector(sortvalue).innerText;
175          } else {
176            v1 = b[ii].innerText;
177            v2 = b[ii + 1].innerText;
178          }
179          v1 = v1.toLowerCase();
180          v2 = v2.toLowerCase();
181          if ((j == 0 && (v1 > v2)) || (j == 1 && (v1 < v2))) {
182            bytt = 1;
183            break;
184          }
185        }
186        if (bytt == 1) {
187          b[ii].parentNode.insertBefore(b[ii + 1], b[ii]);
188          y = 1;
189          cc++;
190        }
191      }
192      if (cc > 0) {break;}
193    }
194  }
195};
196w3.slideshow = function (sel, ms, func) {
197  var i, ss, x = w3.getElements(sel), l = x.length;
198  ss = {};
199  ss.current = 1;
200  ss.x = x;
201  ss.ondisplaychange = func;
202  if (!isNaN(ms) || ms == 0) {
203    ss.milliseconds = ms;
204  } else {
205    ss.milliseconds = 1000;
206  }
207  ss.start = function() {
208    ss.display(ss.current)
209    if (ss.ondisplaychange) {ss.ondisplaychange();}
210    if (ss.milliseconds > 0) {
211      window.clearTimeout(ss.timeout);
212      ss.timeout = window.setTimeout(ss.next, ss.milliseconds);
213    }
214  };
215  ss.next = function() {
216    ss.current += 1;
217    if (ss.current > ss.x.length) {ss.current = 1;}
218    ss.start();
219  };
220  ss.previous = function() {
221    ss.current -= 1;
222    if (ss.current < 1) {ss.current = ss.x.length;}
223    ss.start();
224  };
225  ss.display = function (n) {
226    w3.styleElements(ss.x, "display", "none");
227    w3.styleElement(ss.x[n - 1], "display", "block");
228  }
229  ss.start();
230  return ss;
231};
232w3.includeHTML = function(cb) {
233  var z, i, elmnt, file, xhttp;
234  z = document.getElementsByTagName("*");
235  for (i = 0; i < z.length; i++) {
236    elmnt = z[i];
237    file = elmnt.getAttribute("w3-include-html");
238    if (file) {
239      xhttp = new XMLHttpRequest();
240      xhttp.onreadystatechange = function() {
241        if (this.readyState == 4) {
242          if (this.status == 200) {elmnt.innerHTML = this.responseText;}
243          if (this.status == 404) {elmnt.innerHTML = "Page not found.";}
244          elmnt.removeAttribute("w3-include-html");
245          w3.includeHTML(cb);
246        }
247      }      
248      xhttp.open("GET", file, true);
249      xhttp.send();
250      return;
251    }
252  }
253  if (cb) cb();
254};
255w3.getHttpData = function (file, func) {
256  w3.http(file, function () {
257    if (this.readyState == 4 && this.status == 200) {
258      func(this.responseText);
259    }
260  });
261};
262w3.getHttpObject = function (file, func) {
263  w3.http(file, function () {
264    if (this.readyState == 4 && this.status == 200) {
265      func(JSON.parse(this.responseText));
266    }
267  });
268};
269w3.displayHttp = function (id, file) {
270  w3.http(file, function () {
271    if (this.readyState == 4 && this.status == 200) {
272      w3.displayObject(id, JSON.parse(this.responseText));
273    }
274  });
275};
276w3.http = function (target, readyfunc, xml, method) {
277  var httpObj;
278  if (!method) {method = "GET"; }
279  if (window.XMLHttpRequest) {
280    httpObj = new XMLHttpRequest();
281  } else if (window.ActiveXObject) {
282    httpObj = new ActiveXObject("Microsoft.XMLHTTP");
283  }
284  if (httpObj) {
285    if (readyfunc) {httpObj.onreadystatechange = readyfunc;}
286    httpObj.open(method, target, true);
287    httpObj.send(xml);
288  }
289};
290w3.getElementsByAttribute = function (x, att) {
291  var arr = [], arrCount = -1, i, l, y = x.getElementsByTagName("*"), z = att.toUpperCase();
292  l = y.length;
293  for (i = -1; i < l; i += 1) {
294    if (i == -1) {y[i] = x;}
295    if (y[i].getAttribute(z) !== null) {arrCount += 1; arr[arrCount] = y[i];}
296  }
297  return arr;
298};  
299w3.dataObject = {},
300w3.displayObject = function (id, data) {
301  var htmlObj, htmlTemplate, html, arr = [], a, l, rowClone, x, j, i, ii, cc, repeat, repeatObj, repeatX = "";
302  htmlObj = document.getElementById(id);
303  htmlTemplate = init_template(id, htmlObj);
304  html = htmlTemplate.cloneNode(true);
305  arr = w3.getElementsByAttribute(html, "w3-repeat");
306  l = arr.length;
307  for (j = (l - 1); j >= 0; j -= 1) {
308    cc = arr[j].getAttribute("w3-repeat").split(" ");
309    if (cc.length == 1) {
310      repeat = cc[0];
311    } else {
312      repeatX = cc[0];
313      repeat = cc[2];
314    }
315    arr[j].removeAttribute("w3-repeat");
316    repeatObj = data[repeat];
317    if (repeatObj && typeof repeatObj == "object" && repeatObj.length != "undefined") {
318      i = 0;
319      for (x in repeatObj) {
320        i += 1;
321        rowClone = arr[j];
322        rowClone = w3_replace_curly(rowClone, "element", repeatX, repeatObj[x]);
323        a = rowClone.attributes;
324        for (ii = 0; ii < a.length; ii += 1) {
325          a[ii].value = w3_replace_curly(a[ii], "attribute", repeatX, repeatObj[x]).value;
326        }
327        (i === repeatObj.length) ? arr[j].parentNode.replaceChild(rowClone, arr[j]) : arr[j].parentNode.insertBefore(rowClone, arr[j]);
328      }
329    } else {
330      console.log("w3-repeat must be an array. " + repeat + " is not an array.");
331      continue;
332    }
333  }
334  html = w3_replace_curly(html, "element");
335  htmlObj.parentNode.replaceChild(html, htmlObj);
336  function init_template(id, obj) {
337    var template;
338    template = obj.cloneNode(true);
339    if (w3.dataObject.hasOwnProperty(id)) {return w3.dataObject[id];}
340    w3.dataObject[id] = template;
341    return template;
342  }
343  function w3_replace_curly(elmnt, typ, repeatX, x) {
344    var value, rowClone, pos1, pos2, originalHTML, lookFor, lookForARR = [], i, cc, r;
345    rowClone = elmnt.cloneNode(true);
346    pos1 = 0;
347    while (pos1 > -1) {
348      originalHTML = (typ == "attribute") ? rowClone.value : rowClone.innerHTML;
349      pos1 = originalHTML.indexOf("{{", pos1);
350      if (pos1 === -1) {break;}
351      pos2 = originalHTML.indexOf("}}", pos1 + 1);
352      lookFor = originalHTML.substring(pos1 + 2, pos2);
353      lookForARR = lookFor.split("||");
354      value = undefined;
355      for (i = 0; i < lookForARR.length; i += 1) {
356        lookForARR[i] = lookForARR[i].replace(/^\s+|\s+$/gm, ''); //trim
357        if (x) {value = x[lookForARR[i]];}
358        if (value == undefined && data) {value = data[lookForARR[i]];}
359        if (value == undefined) {
360          cc = lookForARR[i].split(".");
361          if (cc[0] == repeatX) {value = x[cc[1]]; }
362        }
363        if (value == undefined) {
364          if (lookForARR[i] == repeatX) {value = x;}
365        }
366        if (value == undefined) {
367          if (lookForARR[i].substr(0, 1) == '"') {
368            value = lookForARR[i].replace(/"/g, "");
369          } else if (lookForARR[i].substr(0,1) == "'") {
370            value = lookForARR[i].replace(/'/g, "");
371          }
372        }
373        if (value != undefined) {break;}
374      }
375      if (value != undefined) {
376        r = "{{" + lookFor + "}}";
377        if (typ == "attribute") {
378          rowClone.value = rowClone.value.replace(r, value);
379        } else {
380          w3_replace_html(rowClone, r, value);
381        }
382      }
383      pos1 = pos1 + 1;
384    }
385    return rowClone;
386  }
387  function w3_replace_html(a, r, result) {
388    var b, l, i, a, x, j;
389    if (a.hasAttributes()) {
390      b = a.attributes;
391      l = b.length;
392      for (i = 0; i < l; i += 1) {
393        if (b[i].value.indexOf(r) > -1) {b[i].value = b[i].value.replace(r, result);}
394      }
395    }
396    x = a.getElementsByTagName("*");
397    l = x.length;
398    a.innerHTML = a.innerHTML.replace(r, result);
399  }
400};

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.