forked from mixedpuppy/socialapi-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatWindow.html
52 lines (48 loc) · 1.7 KB
/
chatWindow.html
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
<!DOCTYPE html>
<html>
<head>
<link id="siteicon" rel="icon" href="./icon.png"/>
<link rel="stylesheet" href="./panel.css"/>
<title>Me!</title>
<script src="./panel.js" type="text/javascript"></script>
<script>
// we can update the icon and title of the chat through normal web
// functionality
var origTitle = document.title;
var counter = 0;
function changeTitle() {
document.title = origTitle + "("+(++counter)+")";
}
function changeSiteIcon() {
var icon = document.getElementById("siteicon");
icon.parentNode.removeChild(icon);
if (icon.getAttribute("href")== "./icon.png")
icon.setAttribute("href", "./message.png");
else
icon.setAttribute("href", "./icon.png");
document.getElementsByTagName('head')[0].appendChild(icon);
}
function notifyActivity() {
changeSiteIcon();
changeTitle();
// this event is used to indicate to Firefox that some chat activity
// has occured. Firefox updates UI based on this event.
var evt = document.createEvent("CustomEvent");
evt.initCustomEvent("socialChatActivity", true, true, {});
document.documentElement.dispatchEvent(evt);
}
function startActivity() {
window.setInterval(notifyActivity, 3000);
}
</script>
</head>
<body onload="onLoad()">
<div id="content">
<input />
<!-- this is just a way to test the icon, title and activity notification -->
<button onclick="startActivity()">start activity interval</button>
<!-- we can simply use window.close if we want to close this panel -->
<button onclick="window.close()">close panel</button>
</div>
</body>
</html>