-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchat.html
587 lines (520 loc) Β· 15.6 KB
/
chat.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="https://github.com/tebahpla/tebahpla.github.io/blob/master/stuff/chat/ooglechaticon.png?raw=true" />
<title>Oogle chat</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<link rel='stylesheet prefetch' href='https://fonts.googleapis.com/icon?family=Material+Icons'>
<style>
input.switch {
font-size: 10px;
position: relative;
display: inline-block;
appearance: none;
width: 3em;
height: 1.6em;
line-height: 1.6em;
border-radius: 0.8em;
margin: 0;
padding: 0;
box-shadow: inset 0 0 0 0.2em #eee;
outline: 1px solid transparent !important;
cursor: pointer;
border: none;
background: transparent;
user-select: none;
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none;
transition: box-shadow .3s ease-in-out, padding .25s ease-in-out;
transition-delay: .1s, 0s;
/* Animations if supported */
}
input.switch:checked {
transition-delay: 0s, 0s;
box-shadow: inset 0 0 0 0.91429em #00c169 !important;
padding-left: 1.4em;
}
input.switch.hit {
animation: slide-off .35s ease both;
}
input.switch.hit:checked {
animation: slide-on .35s ease both .05s;
}
input.switch::before, input.switch::after {
content: "";
}
input.switch::after {
/* Increases hit area */
position: absolute;
top: -0.4em;
left: -0.4em;
bottom: -0.4em;
right: -0.4em;
}
input.switch::before {
display: inline-block;
height: 1.2em;
width: 1.2em;
margin: 0.2em 0 0 0.2em;
background-color: #fff;
border-radius: 0.6em;
box-shadow: 0 0.2em 0.4em 0 rgba(0, 0, 0, 0.2), 0 0 0.1em 0.1em rgba(0, 0, 0, 0.1);
transition: all .1s ease .1s;
}
input.switch:active::before {
transition: all .1s ease .05s;
}
input.switch.touch:hover::before {
transition: all .0s ease .00s;
}
input.switch:active::before, input.switch.touch:hover::before {
width: 2em;
}
input.switch:active:checked::before, input.switch.touch:hover:checked::before {
margin-left: -0.6em;
}
@keyframes slide-on {
0% {
padding-left: 0em;
}
60% {
padding-left: 1.8em;
}
100% {
padding-left: 1.4em;
}
}
@keyframes slide-off {
0% {
padding-left: 1.4em;
text-indent: 0;
}
60% {
padding-left: 0em;
text-indent: -0.4em;
}
100% {
padding-left: 0em;
text-indent: 0;
}
}
html {
height: 100%;
}
body {
padding: 0;
margin: 0;
}
header {
background: #fff;
border-bottom-color: #eee;
}
h1,
h2,
h3 {
margin: 0;
text-rendering: optimizeLegibility;
}
h1 {
font-size: 2.4em;
line-height: 1.6em;
text-align: center;
font-weight: normal;
}
h2 {
font-size: 1.2em;
line-height: 1.4em;
text-align: center;
font-weight: normal;
text-transform: uppercase;
}
input[type=text],
button {
-webkit-appearance: none;
-moz-appearance: none;
border: 1px solid #ddd;
color: #333;
font-size: 1em;
padding: .7em 1em;
margin-bottom: 1em;
position: relative;
vertical-align: middle;
}
input[type=text] {
margin-left: 85px;
width: calc(100% - 225px);
}
button {
background: #e6e6e6;
text-shadow: 0 1px 0 #f3f3f3;
margin: .5em 0 2em 0;
width: 120px;
}
#main {
margin: 2em 1em 1em;
}
#main > h2 {
font-weight: normal;
font-size: 1.2em;
margin-bottom: 1.5em;
}
#main > p {
color: #ce1126;
}
.chat {
height: 85px;
position: relative;
}
.chat i {
font-size: 75px;
position: absolute;
}
.output p {
font-size: 1.2em;
margin: 0.6em;
position: relative;
}
.output i {
font-size: 40px;
position: absolute;
top: -5px;
}
.output i + span {
position: relative;
margin-left: 40px;
}
/* Font Icons */
[class^="face"],
[class*=" face"] {
font-family: 'Material Icons';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.face-1:before {
content: "face";
}
.face-2:before {
content: "favorite";
}
.face-3:before {
content: "adb";
}
.face-4:before {
content: "cake";
}
.face-5:before {
content: "whatshot";
}
.face-6:before {
content: "invert_colors";
}
.face-7:before {
content: "stars";
}
.face-8:before {
content: "mood_bad";
}
.face-9:before {
content: "mood";
}
.face-10:before {
content: "star";
}
.face-11:before {
content: "directions_bike";
}
.face-12:before {
content: "star_half";
}
.face-13:before {
content: "school";
}
.color-1 {
color: #393b79;
}
.color-2 {
color: #6b6ecf;
}
.color-3 {
color: #637939;
}
.color-4 {
color: #b5cf6b;
}
.color-5 {
color: #8c6d31;
}
.color-6 {
color: #e7ba52;
}
.color-7 {
color: #843c39;
}
.color-8 {
color: #d6616b;
}
.color-9 {
color: #7b4173;
}
.color-10 {
color: #ce6dbd;
}
img.avavav{
left: 0px !important;
display: left !important;
margin-left: 0 !important;
vertical-align: middle !important;
}
.avavav{
left: 0px !important;
display: left !important;
margin-left: 0 !important;
vertical-align: middle !important;
}
#main{
background:white;
}
.pooemoji {
width: 20px;
height: 20px;
}
</style>
</head>
<body translate="no" >
<meta name="google-signin-client_id" content="273615037515-ebr6473ifcvjvs306tt9hq4ekt1d0q9l.apps.googleusercontent.com">
<html itemscope="" itemtype="http://schema.org/WebPage" lang="en-CA"><head><section><a href="chat"><meta content="https://github.com/tebahpla/tebahpla.github.io/blob/master/stuff/chat/ooglechat.png?raw=true" itemprop="image">
<img src="https://github.com/tebahpla/tebahpla.github.io/blob/master/stuff/chat/ooglechat.png?raw=true" class="floatin_oogle">
</a><np id="greeting" translate="no" onclick='responsiveVoice.speak(document.getElementById("greeting").innerHTML)'></np></section><br>
<script>
function askForNott(){
Notification.requestPermission().then(function(result) {
console.log(result);
});
Notification.requestPermission();
}
function setCookie(cname,cvalue,exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
var user = "Example Name";
function checkCookie() {
askForNott()
user=getCookie("username");
if (user != "") {
document.getElementById("greeting").innerHTML="So " + user+", are your ganna chat or did you comes here by mistake?";
document.getElementById("setr").innerHTML="Change Name";
} else {
user = "Example Name"
}
}
function setGreet(){
user = prompt("What would you like Oogle to call you?",user);
if (user != "" && user != null) {
setCookie("username", user, 300);
document.getElementById("greeting").innerHTML="Welcome, " + user+".";
document.getElementById("setr").innerHTML="Change Name";
}
}
function translater(){
var x = document.getElementById("myForm");
var text = "";
var i;
for (i = 0; i < x.length ;i++) {
text += x.elements[i].value;
}
document.getElementById('translator').innerHTML=text;
}
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(element).text()).select();
document.execCommand("copy");
$temp.remove();
}
</script>
<header>
</header>
<section id="main" role="main" style="white-space:nowrap">
<div class="chat" style="white-space:nowrap">
<nobr nowrap>
<i class="avatar" class="face12" id='avatar'></i>
<div style="display:inline; white-space:nowrap;">
<input type="text" placeholder="Type your message...">
<button>Send</button>
</div>
</nobr>
</div>
<p class="presence" style="color:red;"></p><p title='If you are have this open in a different tab, Oogle Chat will make a notification sound.'>Sound <input type="checkbox" class="switch" id="switch-1"/></p>
<div class="output"></div>
</section>
<br><br><br><p> <br><nobr><p nowrap> <br><nobr><p nowrap> <br><a href="newerhome">Search</a> | <a href="translate">Translate</a> | <a href="https://tebahpla.github.io/drive">Drive</a> | <a href='https://vincens2005.github.io/t-rex-runner/'>Dinosaur Game</a> | <a href="calc">Calculator</a> | <a href="maps">Maps</a> | <a href="roamos">Roam OS</a> | <a href="https://tebahpla.github.io/powerpoop/PowerPoop">PowerPoop</a> | <a href='https://tebahpla.github.io/beerie/beerie.html' title='Beerie hates you'>Beerie</a> | <a href='https://goo.gl/forms/5tRUz5boe0ZnzfjX2'>Submit a Doodle</a> | <a href='https://goo.gl/forms/dIXI2c9yeTW2wF213'>Report a bug</a> | <a onclick="flipoff('πππππ')" >Support</a><jibber id='sss'></jibber><nobr> <div class="g-signin2" data-onsuccess="onSignIn" data-longtitle="true" id='logg' title='Ironically, you can sign in with Google.' nowrap></div></p></nobr><br><br><br><br><br><br><br><br>
<section id="add" translate="no"><iframe src="https://docs.google.com/document/d/1tMcUEiUVSwaTo51Fa3otCdPMgKWPMxufmwhvaDs41Vk/pub?embedded=true" width="1000" height="1000" frameborder="0"></iframe></section>
<title translate="no">Oogle Translate</title><div id="mySidenav" class="sidenav">
<a class='deployLink' href="#add" id="about" target='blank' translate="no"> Add Oogle to Chrome</a>
<a id="setr" onclick="setGreet()" translate="no">Set Name</a>
</div>
<link href="https://tebahpla.github.io/style.css" rel="stylesheet"><body onload="checkCookie()"><!-- Go to www.addthis.com/dashboard to customize your tools --> <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-58f14f9d42d58017"></script> </body>
<script src="//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js"></script>
<script src='https://cdn.pubnub.com/pubnub-3.7.13.min.js'></script>
<script src='https://apis.google.com/js/platform.js'></script>
<script src='https://code.responsivevoice.org/responsivevoice.js'></script>
<script >
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 output = document.querySelector('.output'),
input = document.querySelector('input'),
button = document.querySelector('button'),
avatar = document.querySelector('.avatar'),
presence = document.querySelector('.presence');
var channel = 'simple-chat';
// Assign a random avatar in random color
avatar.className = 'face-' + ((Math.random() * 13 + 1) >>> 0) + ' color-' + ((Math.random() * 10 + 1) >>> 0);
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')){
output.innerHTML = '<p><i class="avavav"><img src="'+m.avatar+'" class="avavav" width="40" /></i><span>' + m.text + '</span></p><br>' + output.innerHTML;
if(document.visibilityState == "hidden"){
spawnNotification(m.text, m.avatar, "Oogle Chat Message");
if( document.getElementById('switch-1').checked){
var audio = new Audio("https://tebahpla.github.io/stuff/Cukmekerb's song.mp3");
audio.play();
}
}
}
else{
output.innerHTML = '<p><i class="' + m.avatar + '"></i><span>' + m.text + '</span></p><br>' + output.innerHTML;
if(document.visibilityState == "hidden"){
spawnNotification(m.text, "https://tebahpla.github.io/stuff/chat/ooglechaticon.png", "Oogle Chat Message");
if( document.getElementById('switch-1').checked){
var audio = new Audio("https://tebahpla.github.io/stuff/Cukmekerb's song.mp3");
audio.play();
}
}
}
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("image ")){
var newtext = m.text.replace("image ","")
var thecode = output.innerHTML
output.innerHTML = thecode.replace(new RegExp(m.text, 'g'), '<img src="'+newtext+'" />');
}
else if(m.text.includes("π©")){
var newtext = m.text.replace(new RegExp("π©", 'g'),"<img src='https://tebahpla.github.io/stuff/chat/Pile-of-poo_1f4a9.png' class='pooemoji' />")
var thecode = output.innerHTML
output.innerHTML = thecode.replace(new RegExp(m.text, 'g'), newtext);
}
else if(m.text.includes("delete ")){
var newtext = m.text.replace("delete ","")
var thecode = output.innerHTML
output.innerHTML = thecode.replace(new RegExp(newtext, 'g'), '');
}
},
presence: function(m) {
if (m.occupancy > 1) {
presence.textContent = m.occupancy + ' people online';
} else {
presence.textContent = 'Nobody else is online';
}
}
});
input.addEventListener('keyup', function(e) {
(e.keyCode || e.charCode) === 13 && send()
}, false);
button.addEventListener('click', send, false);
function send() {
if(document.getElementById('avatar').innerHTML.includes('img')){
p.publish({
channel: channel,
message: {
avatar: document.getElementById('profile').src,
text: input.value
},
callback: function(){input.value = '';}
});
}
else{
p.publish({
channel: channel,
message: {
avatar: avatar.className,
text: input.value
},
callback: function(){input.value = '';}
});
}
}
})();
var output = document.querySelector('.output'),
input = document.querySelector('input'),
button = document.querySelector('button'),
avatar = document.querySelector('.avatar'),
presence = document.querySelector('.presence');
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
document.getElementById('sss').innerHTML=' | <a href="#" onclick="signOut();" >Sign out</a> ';
document.getElementById('logg').style.display = 'none';
document.getElementById('avatar').innerHTML = '<img src="'+profile.getImageUrl()+'" class="avavav" width="80" id="profile"/>'
document.getElementById('avatar').className = 'avavav';
document.getElementById('avatar').style.content = 'none';
user = profile.getName();
if(getCookie("signed") == null || getCookie("signed") == "" || getCookie("signed") == ' '){
user = profile.getName();
document.getElementById("greeting").innerHTML="Welcome, " + user+".";
setCookie("username", user, 3000);
setCookie("signed", "yes", 3000);
}
document.getElementById('sss').innerHTML=' | <a href="#" onclick="signOut();" >Sign out</a> ';
document.getElementById('logg').style.display = 'none';
}
//# sourceURL=pen.js
</script>
</body>
</html>