Pen Settings

HTML

CSS

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

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                // Initialize Firebase our database, you don't have to touch this part
var firebaseConfig = {
    apiKey: "AIzaSyBHcN0HVMwxxW-xBkXHYAm2X-kGWjxPzNk",
    authDomain: "basiccrud-ffe19.firebaseapp.com",
    databaseURL: "https://basiccrud-ffe19.firebaseio.com",
    projectId: "basiccrud-ffe19",
    storageBucket: "basiccrud-ffe19.appspot.com",
    messagingSenderId: "47974982638",
    appId: "1:47974982638:web:9a034202ca787ee47764ff"
};
firebase.initializeApp(firebaseConfig);
function getUniqueId() { //a silly function just to let you fork this codepen and have your own database
  var CODEPEN_ID = /[codepen|cdpn]\.io\/[^/]+\/(?:pen|debug|fullpage|fullembedgrid)\/([^?#]+)/;
  var id;
  if(CODEPEN_ID.test(window.location.href)) {
    id = CODEPEN_ID.exec(window.location.href)[1];
  } else if (CODEPEN_ID.test(document.location.href)){
    id = CODEPEN_ID.exec(window.location.href)[1];
  } else {
    var metas = document.getElementsByTagName('link');    
    for(i=0;i<metas.length;i++) {
      if(metas[i].getAttribute('rel') == 'canonical') {
        if(CODEPEN_ID.test(metas[i].getAttribute('href')))
        id = CODEPEN_ID.exec(metas[i].getAttribute('href'))[1];  
      }
    }
  }
  return id || `randoDB${Math.floor(Math.random()*10000000)}`;
}

//this is the "handler" for YOUR database where we can store and read values from anyone at your site!
let yourDatabase = firebase.database().ref("dbdemo").child(getUniqueId());
// EVERYTHING ABOVE THIS IS DATABASE SETUP

$('#clickme').click(function(){
  //Paste code that gets name & message under here
  
  
  let newMsgInDatabase = yourDatabase.push();
  newMsgInDatabase.set(input); //from socket.emit to database.push
  $('#message').val(''); //sets message bar back to being empty after you press send
  return false;
});

yourDatabase.on('child_added', function(msgObj){
  //Append msgObj.value to list under here

  window.scrollTo(0, document.body.scrollHeight);  
});
                    
                    
              
            
!
999px

Console