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

              
                <html>
  <head>
    <meta charset="utf8" />
    <title>LocalForage Example Pen</title>
  </head>
  <body>
    <h1>LocalForage Example Pen</h1>
    <ul id="htmlConsole" class="logList"></ul>
    <script src="https://cdn.rawgit.com/mozilla/localForage/master/dist/localforage.js"></script>
  </body>
</html>

              
            
!

CSS

              
                .logList {
	margin-top: 20px;
	width: 250px;
	min-height: 200px;
	padding: 5px 15px;
	border: 5px solid #000;
	border-radius: 15px;
  margin: 10px 0 30px;
  list-style: none outside none;
}

.logList:before {
	content: 'log';
	padding: 0 5px;
	position: relative;
	top: -1.1em;
	background-color: #FFF;
}
              
            
!

JS

              
                // Feel free to change the drivers order :)
localforage.setDriver([
  localforage.INDEXEDDB,
  localforage.WEBSQL,
  localforage.LOCALSTORAGE
  ]).then(function() {
  var key = 'STORE_KEY';
  // var value = 'What we save offline';
  var value = 'asdf';
  value[0] = 65
  // var value = undefined;
  var UNKNOWN_KEY = 'unknown_key';

  localforage.setItem(key, value, function() {
    console.log('Using:' + localforage.driver());
    console.log('Saved: ' + value);

    localforage.getItem(key).then(function(readValue) {
      console.log('Read: ', readValue);
    });

    // Since this key hasn't been set yet, we'll get a null value
    localforage.getItem(UNKNOWN_KEY, function(err, readValue) {
      console.log('Result of reading ' + UNKNOWN_KEY, readValue);
    });
  });
});

// this is just for demonstration purposes
var originalConsoleLog = console.log;
function consoleLogProxy() {
  originalConsoleLog.apply(console, arguments);
  var htmlConsole = document.getElementById('htmlConsole');
  if (htmlConsole) {
    var message = Array.prototype.slice.apply(arguments, []).join(' ');
    htmlConsole.innerHTML += '<li>' + message + '</li>';
  }
}
console.log = consoleLogProxy;
              
            
!
999px

Console