Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <input id="enterchat">
  <ul></ul>
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/lib/time.js"></script>
</body>
</html>
 
localStorage.clear();
var gun = Gun();
let chatroom = gun.get('chatroom');
chatroom.time((data, key, time)=>{
   gun.get(data['#']).once((d,id)=>{
      console.log(d.message);
     var li = $('#' + id).get(0) || $('<li>').attr('id', id).appendTo('ul');
     if(li){
       $(li).empty().append(d.message);
     }else{
      $(li).hide();
     }
   });
  
},20);//number display when loaded and load when time is trigger here
//..
$('#enterchat').on("keyup",function(e){
   e = e || window.event;
   if(e.keyCode == 13){
      let text = $('#enterchat').val();
      chatroom.time({alias:'test',message:text});
   }
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers