- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register


Click here to create your own public paste ~ ~ click to duplicate and edit this paste


TitleEdit of P#34631 - Untitled Paste
TypeDenizen Script
Date2016/07/08 20:06:47 UTC-07:00
ByMorphan1
Other
Paste
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
5300
  html_code<!DOCTYPE html>
            <html>
                <head>
                    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
                    <script>
                        var lastData;
                        var existing;
                        $(document).ready(function() {
                            window.setInterval(function() {
                                $.get('%address%',
                                    function(data) {
                                        data = data.valueOf();
                                        if (data != lastData) {
                                            var useless = document.createElement('div');
                                            useless.innerHTML = data;
                                            var elements = useless.childNodes;
                                            var div = document.getElementById('your-div-here');
                                            var hiccup = [];
                                            for (i = 0; i < elements.length; i++) {
                                                var element = elements[i];
                                                hiccup.push(element.id);
                                                console.log("hiccuping: " + element.id);
                                                if (document.getElementById(element.id) === null) {
                                                    console.log("appending hiccup'd");
                                                    div.appendChild(element);
                                                }
                                            }
                                            for (key in existing) {
                                                console.log("key " + key + ": " + existing[key]);
                                                console.log(hiccup.indexOf(existing[key]);
                                                if (hiccup.indexOf(existing[key]) === -1) {
                                                    console.log("does not have");
                                                    var removing = document.getElementById(existing[key]);
                                                    removing.pause();
                                                    removing.src ="";
                                                    removing.load();
                                                    div.removeChild(removing);
                                                }
                                            }
                                            existing = hiccup;
                                            lastData = data;
                                        }
                                    }
                                );
                            },1000);
                        });
                    </script>
                </head>
                <body>
                    <div id="your-div-here"></div>
                </body>
            </html>



RawRaw



Pastes made: 55854