diff options
| author | Scott Ostler <scottbot9000@gmail.com> | 2010-08-15 04:17:13 -0400 |
|---|---|---|
| committer | Scott Ostler <scottbot9000@gmail.com> | 2010-08-15 04:17:13 -0400 |
| commit | 5d478aaeadd4608a31474090e50fb08786662bb5 (patch) | |
| tree | 60fd6c4719ce1da8f1641673c253be666b629212 /static/js/fullscreen.js | |
| parent | 07a3e9044ec9805d987ed5f8b28cc6fedaf203f2 (diff) | |
| parent | db03f7ccb8c6929354a1f033e03708a450aab8ce (diff) | |
Merge branch 'master' of ssh://dump.fm/pichat/repo
Diffstat (limited to 'static/js/fullscreen.js')
| -rw-r--r-- | static/js/fullscreen.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/static/js/fullscreen.js b/static/js/fullscreen.js new file mode 100644 index 0000000..2cce5a1 --- /dev/null +++ b/static/js/fullscreen.js @@ -0,0 +1,50 @@ +function initFullscreen(){ + Room = "dumpfm"; + refresh() + ImageCache = [] + SeenImages = {} +} + +function scanMessagesForImages(messages){ + for(var m=0; m<messages.length; m++) { + var images = getImagesAsArray(messages[m].content) + for (var i = 0; i<images.length; i++){ + NextImage = new Image() + NextImage.onload = displayImage + NextImage.src = images[i] + } + } +} + +function displayImage(){ + $("#big-image").html('<img src="'+this.src+'">') +} + +function refresh() { + var onSuccess = function(json) { + try { + if (json.messages && json.messages.length) + scanMessagesForImages(json.messages); + Timestamp = json.timestamp; + } catch(e) { + + } + + setTimeout(refresh, 1000); + }; + + var onError = function(resp, textStatus, errorThrown) { + setTimeout(refresh, 1000); + }; + + $.ajax({ + type: 'GET', + timeout: 5000, + url: '/refresh', + data: { 'room': Room, 'since': Timestamp }, + cache: false, + dataType: 'json', + success: onSuccess, + error: onError + }); +}
\ No newline at end of file |
