mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
chat app with emoji examples
This commit is contained in:
parent
0e8e9d7dba
commit
fd5e6185ac
41
examples/basic/emoji.html
Normal file
41
examples/basic/emoji.html
Normal file
@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
</head>
|
||||
<body>
|
||||
<ul id='list'>
|
||||
</ul>
|
||||
<form id='form'>
|
||||
<input id='who' placeholder='name'>
|
||||
<input id='input' placeholder='say'>
|
||||
<input type='submit' value='send'>
|
||||
</form>
|
||||
<script src="../../../gun/gun.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/emojione@4.0.0/lib/js/emojione.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/emojione@4.0.0/extras/css/emojione.min.css"/>
|
||||
<script>
|
||||
var gun = Gun(location.origin + '/gun');
|
||||
|
||||
var chat = gun.get("chat/" + location.hash.slice(1));
|
||||
|
||||
form.onsubmit = function(eve){
|
||||
eve.preventDefault();
|
||||
chat.set(who.value +": "+ input.value);
|
||||
input.value = "";
|
||||
}
|
||||
|
||||
chat.map().once(function(msg){ render(msg) });
|
||||
|
||||
function render(msg, li, beep){ // render emoji, scroll to bottom, and notify sound!
|
||||
(li = document.createElement("li")).innerText = emojione.shortnameToUnicode(msg);
|
||||
list.appendChild(li);
|
||||
window.scroll(0, list.offsetHeight);
|
||||
(beep = new SpeechSynthesisUtterance()).text = "new";
|
||||
beep.rate = 10; beep.pitch = 2;
|
||||
window.speechSynthesis.speak(beep);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -308,7 +308,6 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
});
|
||||
|
||||
});
|
||||
return;
|
||||
|
||||
var ntmp = names;
|
||||
describe('RAD + GUN', function(){
|
||||
@ -330,7 +329,7 @@ var names = ["Adalard","Adora","Aia","Albertina","Alfie","Allyn","Amabil","Ammam
|
||||
done();
|
||||
})
|
||||
});
|
||||
});
|
||||
});return;
|
||||
|
||||
it('write contacts', function(done){
|
||||
var all = {}, to, start, tmp;
|
||||
|
Loading…
x
Reference in New Issue
Block a user