summaryrefslogtreecommitdiff
path: root/static/js/fullscreen.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/js/fullscreen.js')
-rw-r--r--static/js/fullscreen.js50
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