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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
function initFullscreen(){
Room = "dumpfm";
refresh()
ImageCache = []
SeenImages = {}
$('#tools-button').click(toolsToggle);
}
function toolsToggle(){
if ($("#msgInputDiv").css("display") == "none")
toolsShow()
else
toolsHide()
}
function toolsShow(){
$("#msgInputDiv").css("display", "block")
}
function toolsHide(){
$("#msgInputDiv").css("display", "none")
}
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
});
}
|