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.

            
              <html>
<head>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" media="screen" title="no title" charset="utf-8">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet" media="screen" title="no title" charset="utf-8">
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js"></script> 
<script src="//cdn.firebase.com/js/client/2.0.6/firebase.js"></script>  
</head>

<body style="background: rgb(78, 163, 153);" >
   <div id="name" class="container" style="background: #fbd860;">
   <h3 class="text-center">Firebase Live Board </h3>
   <div id="innerbase" class="jumbotron">
      <label>To-Do Item</label>
      <input type="text" id="firetextbox" class="form-control" /> <br/>
      <button id="sync" class="btn btn-success">Sync to Firebase</button>
      <button id="clearbutton" class="btn btn-warning">Clear List</button>
      <button id="purgeDatabase" class="btn btn-danger">Purge Database</button>
   </div>
   <div id="listItem" class="text-center jumbotron background: rgb(8, 13, 15);">
   </div> 
</body>
<script src="./firebase.js" > </script> 
</html>
            
          
!
            
              //Imported firebase.js through cdn 
//Javascript code will go here
//=====================================
// Created by - Harshit Pandey
// Read more - http://www.oyecode.com
//=====================================
//************************************
//Create firebase instance to database
//************************************

var firebutton = document.getElementById('sync');
var firetext = document.getElementById('firetextbox');
var itemList = document.getElementById('listItem');
var purgeButton = document.getElementById('purgeDatabase');
var clear = document.getElementById('clearbutton');
//Create dataReference to Firebase and henceforth Data Dictionary
var dataRef = new Firebase('https://oyefire.firebaseio.com');
var itemRef = dataRef.child('Items');
drawTable();

purgeButton.addEventListener('click', function() {
    if(itemRef)
    itemRef.remove();
    else { alert('Database is already purged, insert a new item');}
    drawTable();
});


clear.addEventListener('click', function(){
                        $('#listItem').empty();
                       }); 
//Lets create some events handlers
firebutton.addEventListener('click', function() {
    //caputure the text from the textbox
    //user firebase Reference to sync to Firebase
    itemRef.push({
        item: firetext.value
    });
    //set textbox to blank 
    firetext.value = '';
    drawTable();
});



function drawTable()
{
var elem = document.getElementById('firebaseTable');

if ($('#elemId').length!==0)
{
  elem.parentNode.removeChild(elem);
}

var theTable = "<table id=\"firebaseTable\" class=\"";
theTable += "table table-striped table-hover \" ><tbody>";
var tableContent = theTable;
itemRef.on("value", function(snapshot) {
    var newPost = snapshot.val();
    $.each(newPost, function(index) {
        tableContent += "<tr class=\"success\">";
        tableContent +=
            "<td class=active>" + newPost[index].item + "</td>";
        tableContent += "</tr>";
    });
    tableContent += '</tbody></table>';
    $('#listItem').html(tableContent);
});

}


            
          
!
999px
🕑 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.

Console