Przeglądaj źródła

printer screenshot page with javascript

Thomas Buck 6 lat temu
rodzic
commit
6d53a425f6
1 zmienionych plików z 61 dodań i 3 usunięć
  1. 61
    3
      input/unlisted/printer.md

+ 61
- 3
input/unlisted/printer.md Wyświetl plik

@@ -4,15 +4,73 @@ parent: none
4 4
 position: 0
5 5
 ---
6 6
 
7
+<script type="text/javascript">
8
+function LastModUsingHeader(sFile, callback) {
9
+    try {
10
+        var x = new XMLHttpRequest;
11
+        x.responseType = "blob";
12
+        x.onreadystatechange = function() {
13
+            if (x.readyState === 4 && x.status === 200) {
14
+                var dt = new Date(x.getResponseHeader('Last-Modified'))
15
+                callback(x.response, dt.toLocaleString());
16
+            }
17
+        };
18
+        x.open('GET', sFile, true);
19
+        x.send();
20
+    } catch(y) {  }
21
+}
22
+</script>
23
+
7 24
 # {{ page.title }}
8 25
 
9
-This page contains live-updating photos from the Webcams on my 3D printers.
26
+This page contains photos from the Webcams on my 3D printers, live-updated every 5 minutes.
10 27
 
11 28
 ## Fabrikator Mini V1.5
12 29
 
13
-<img id="p1" src="//xythobuz.de/printer.jpg" alt="Fabrikator Mini V1.5">
30
+<div id="date-1">
31
+    <noscript>
32
+        <img src="//xythobuz.de/printer.jpg" alt="Fabrikator Mini V1.5">
33
+    </noscript>
34
+</div>
35
+
36
+<script type="text/javascript">
37
+    var rt = LastModUsingHeader("//xythobuz.de/printer.jpg", function(i, u) {
38
+        var img = document.createElement("img");
39
+        img.src = window.URL.createObjectURL(i);
40
+        img.alt = "Fabrikator Mini V1.5";
41
+
42
+        var up = document.createElement("p");
43
+        up.appendChild(document.createTextNode("Upload Date: " + u));
44
+
45
+        var dt = document.getElementById("date-1");
46
+        dt.appendChild(img);
47
+        dt.appendChild(up);
48
+    });
49
+</script>
50
+
51
+<hr>
14 52
 
15 53
 ## CTC i3 Pro B
16 54
 
17
-<img style="transform: rotate(180deg);" src="//xythobuz.de/printer-2.jpg" alt="CTC i3 Pro B">
55
+<div id="date-2">
56
+    <noscript>
57
+        <img style="transform: rotate(180deg);" src="//xythobuz.de/printer-2.jpg" alt="CTC i3 Pro B">
58
+    </noscript>
59
+</div>
60
+
61
+<script type="text/javascript">
62
+    var rt = LastModUsingHeader("//xythobuz.de/printer-2.jpg", function(i, u) {
63
+        var img = document.createElement("img");
64
+        img.src = window.URL.createObjectURL(i);
65
+        img.alt = "CTC i3 Pro B";
66
+        img.style = "transform: rotate(180deg);";
67
+
68
+        var up = document.createElement("p");
69
+        up.appendChild(document.createTextNode("Upload Date: " + u));
70
+
71
+        var dt = document.getElementById("date-2");
72
+        dt.appendChild(img);
73
+        dt.appendChild(up);
74
+    });
75
+</script>
18 76
 

Ładowanie…
Anuluj
Zapisz