css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div id="web_chat_holder"></div>
  overflow: auto;
  max-height: 220px;
  width: 100%;
  /*max-width: 600px;*/
  overflow: auto;
  max-height: 900px;


  max-width: 600px;
  max-height: 100px;
  width: 600px;
              var timer = new Date();
function web_send_msg()
    // Getting values from input elements.
    var text = $("#WebChatTextID").val();
    var name = $("#WebChatNameID").val();
    // Form cleaning
    // We will write the time at the time of sending the message
    timer = new Date();
    // Adding a sent message to the list of messages.
    //$("#WebChatFormForm").append("<p><b>"+HtmlEncode(name)+": </b>"+HtmlEncode(text)+"</p>");
    // Sending a message to the chat channel
    CometServer().web_pipe_send("web_chat_pipe", {"text":text, "name":name});
    // Notify the other tabs that we added a message to the chat
    comet_server_signal().send_emit("AddToChat", {"text":text, "name":name})
// The function will be executed in after the page loads.
    // Create a chat form. Layout.
    var html =  "<div style=\"border: 1px solid #ccc;padding:10px;\" >"
	          + "<div id=\"WebChatFormForm\" ></div>"
		  + "<input type=\"text\" id=\"WebChatNameID\" placeholder=\"Enter your name...\" > <div id=\"answer_div\" style=\"float:right;\" ></div>"
	          + "<textarea id = \"WebChatTextID\" placeholder = \"Send an online chat...\" ></textarea>"
                  + "<div style=\"margin-bottom: 0px;margin-top: 10px;\">"
                  +    "<input type=\"button\" style=\"width: 220px;\" onclick=\"web_send_msg();\" value=\"Send\" >"
                  +    " <div id=\"answer_error\"  style=\"float:right;\" ></div>"
                  + "</div>"
             +  "</div>";
    // Subscribe to the channel in which chat messages will be sent.
    CometServer().subscription("web_chat_pipe", function(msg){
        console.log(["msg", msg]);
        // dding a received message to the list of messages.
        $("#WebChatFormForm").append("<p><b>"+HtmlEncode(msg.data.name)+": </b>"+HtmlEncode(msg.data.text)+"</p>");
    // We subscribe to the event of adding a message to the chat by us, so that if the chat is open in several tabs
    // our message added on one tab was displayed on all the others without reloading the page
    comet_server_signal().connect("AddToChat", function(msg){
        console.log(["msg", msg]);
        // Adding a received message to the list of messages.
        $("#WebChatFormForm").append("<p><b>"+HtmlEncode(msg.name)+": </b>"+HtmlEncode(msg.text)+"</p>");
    // We subscribe to the channel in which the delivery notifications of the sent messages will be sent.
    CometServer().subscription("#web_chat_pipe", function(p)
        // We will write the time at the time of receipt of the delivery report
        var etime = new Date();
        console.log(["answer_to_web_chat_pipe", p]);
        $("#answer_div").html("Message delivered "+p.data.number_messages+" recipients for "+ (etime.getTime() - timer.getTime() )+"ms");
   // Download message history
   // CometServer().get_pipe_log("web_chat_pipe");
function HtmlEncode(s)
  var el = document.createElement("div");
  el.innerText = el.textContent = s;
  s = el.innerHTML;
  return s;

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................