@@ 1-57 (lines=57) @@ | ||
1 | function includeHtml(url, target, error, success) { |
|
2 | var xhttp; |
|
3 | ||
4 | var el = new E(target); |
|
5 | var elmnt = el.first(); |
|
6 | ||
7 | if (typeof success !== 'function') { |
|
8 | success = function () { |
|
9 | console.log('includeHtml success', "included"); |
|
10 | } |
|
11 | } |
|
12 | ||
13 | if (typeof error !== 'function') { |
|
14 | error = function () { |
|
15 | console.log('includeHtml error', "Page not found."); |
|
16 | } |
|
17 | } |
|
18 | console.log('includeHtml url', url); |
|
19 | ||
20 | if (url) { |
|
21 | /* Make an HTTP request using the attribute value as the url name: */ |
|
22 | xhttp = new XMLHttpRequest(); |
|
23 | xhttp.onreadystatechange = function () { |
|
24 | console.log('includeHtml el_id', target); |
|
25 | ||
26 | if (this.readyState == 4) { |
|
27 | if (this.status == 200) { |
|
28 | // console.log('elmnt', elmnt); |
|
29 | // console.log('responseText', this.responseText); |
|
30 | // elmnt.innerHTML = this.responseText; |
|
31 | // elmnt.appendChild(this.responseText); |
|
32 | // elmnt.insertAdjacentHTML('beforeend', this.responseText); |
|
33 | // var e = document.createElement('div'); |
|
34 | // e.innerHTML = this.responseText; |
|
35 | // while(e.firstChild) { |
|
36 | // elmnt.appendChild(e); |
|
37 | // } |
|
38 | ||
39 | // elmnt.insertAdjacentHTML('afterend', this.responseText); |
|
40 | elmnt.insertAdjacentHTML('beforeend', this.responseText); |
|
41 | ||
42 | success(this); |
|
43 | } |
|
44 | if (this.status == 404) { |
|
45 | elmnt.innerHTML = "includeHtml Page not found."; |
|
46 | error(this); |
|
47 | } |
|
48 | /* Remove the attribute, and call this function once more: */ |
|
49 | // includeHtml(url, success, error); |
|
50 | } |
|
51 | } |
|
52 | xhttp.open("GET", url, true); |
|
53 | xhttp.send(); |
|
54 | /* Exit the function: */ |
|
55 | return this; |
|
56 | } |
|
57 | } |
|
58 |
@@ 310-368 (lines=59) @@ | ||
307 | } |
|
308 | ||
309 | ||
310 | function includeHtml(url, target, success, error) { |
|
311 | var xhttp; |
|
312 | ||
313 | var el = new E(target); |
|
314 | var elmnt = el.first(); |
|
315 | ||
316 | if (typeof success !== 'function') { |
|
317 | success = function () { |
|
318 | console.log('includeHtml success', "included"); |
|
319 | } |
|
320 | } |
|
321 | ||
322 | if (typeof error !== 'function') { |
|
323 | error = function () { |
|
324 | console.log('includeHtml error', "Page not found."); |
|
325 | } |
|
326 | } |
|
327 | console.log('includeHtml url', url); |
|
328 | ||
329 | if (url) { |
|
330 | /* Make an HTTP request using the attribute value as the url name: */ |
|
331 | xhttp = new XMLHttpRequest(); |
|
332 | xhttp.onreadystatechange = function () { |
|
333 | console.log('includeHtml el_id', target); |
|
334 | ||
335 | if (this.readyState == 4) { |
|
336 | if (this.status == 200) { |
|
337 | ||
338 | elmnt.insertAdjacentHTML('beforeend', this.responseText); |
|
339 | ||
340 | success(this); |
|
341 | } |
|
342 | if (this.status == 404) { |
|
343 | elmnt.innerHTML = "includeHtml Page not found."; |
|
344 | error(this); |
|
345 | } |
|
346 | /* Remove the attribute, and call this function once more: */ |
|
347 | // includeHtml(url, success, error); |
|
348 | } |
|
349 | } |
|
350 | xhttp.open("GET", url, true); |
|
351 | xhttp.send(); |
|
352 | /* Exit the function: */ |
|
353 | return this; |
|
354 | } |
|
355 | return false; |
|
356 | ||
357 | } |
|
358 | ||
359 | // function includeImage(url, target, success, error) { |
|
360 | ||
361 | function includeImage(url, target) { |
|
362 | console.log('includeImg url: ', url); |
|
363 | var el = new E(target); |
|
364 | var elmnt = el.first(); |
|
365 | ||
366 | let img = new Image; |
|
367 | img.onload = function () { |
|
368 | console.log("includeImg onload: ", url); |
|
369 | elmnt.appendChild(img); |
|
370 | }; |
|
371 |