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 content="text/html; charset=windows-1252" http-equiv="content-type">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsenui.css">
  <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsen-css-components.min.css">
  <script src="https://unpkg.com/onsenui/js/onsenui.min.js"></script>
    <script>
      if (ons.platform.isIPhoneX()) { // Utility function
        // Add empty attribute to the <html> element
        document.documentElement.setAttribute('onsflag-iphonex-portrait', '');
      } 
      if (ons.platform.isIPhoneX()) { // Utility function
        // Add empty attribute to the <html> element
        document.documentElement.setAttribute('onsflag-iphonex-landscape', '');
      }
      // Setup Button Handler
      document.addEventListener('init', function(event) {
        var page = event.target;
        if (page.id === 'setup') {
          page.querySelector('#go-to-main').onclick = function() {
            // Store in localStorage
            localStorage.setItem("pub",document.getElementById('pub').value);
            localStorage.setItem("sub",document.getElementById('sub').value);
            // no secret key needed localStorage.setItem("sec",document.getElementById('sec').value);
            document.querySelector('#myNavigator').pushPage('feed.html', {data: {title: 'Auto'}});
          };
        }
        else if (page.id === 'setup-return') {
          page.querySelector('#go-to-main').onclick = function() {
            // Store in localStorage
            localStorage.setItem("pub",document.getElementById('pub').value);
            localStorage.setItem("sub",document.getElementById('sub').value);

            document.querySelector('#myNavigator').pushPage('feed.html', {data: {title: 'Auto'}});
          };
          page.querySelector('#go-cancel').onclick = function() {
            document.querySelector('#myNavigator').pushPage('feed.html', {data: {title: 'Auto'}});
          };
        }
        else if (page.id === 'feed') {
          page.querySelector('#enter-setup').onclick = function() {
            document.querySelector('#myNavigator').pushPage('setup-return.html', {data: {title: 'Auto'}});
          };
        } 
      });
      var shouldIGoToSetup = false;
      // end setup button handler
      if (localStorage.getItem("sub") === null || localStorage.getItem("pub") === null) {
        // hi
        shouldIGoToSetup = true;
        // if this doesn't work, make it set a variable, and use a script tag in feed to launch the page
      }
      else {
        // Do some init stuff
      }      
      function toastThing() {
        
        //myToast.toggle();
        ons.notification.toast('Toast',{timeout: 2000});
      } 
      function ifgoToSetup() {
        if (shouldIGoToSetup) {
          document.querySelector('#myNavigator').pushPage('setup.html', {data: {title: 'Name'}});
        }
      }

window.fn = {};

window.fn.open = function() {
  var menu = document.getElementById('menu');
  menu.open();
};

window.fn.load = function(page, data) {
  var content = document.getElementById('myNavigator');
  var menu = document.getElementById('menu');
  content.pushPage(page, data)
    .then(menu.close.bind(menu));
};

window.fn.pop = function() {
  var content = document.getElementById('myNavigator');
  content.popPage();
};

    </script>
  </head>
  <body> 
    <ons-splitter>
      
      <ons-splitter-side id="menu" side="left" width="220px" collapse swipeable>
        <ons-page>
          <ons-list>
            <ons-list-item onclick="fn.load('feed.html')" tappable>
              Main
            </ons-list-item>
            <ons-list-item onclick="fn.load('setup-return.html')" tappable>
              Setup
            </ons-list-item>
            <a href="http://google.com" target="_blank"><ons-list-item tappable>
                Google
            </ons-list-item></a>
          </ons-list>
        </ons-page>
      </ons-splitter-side>
      <ons-splitter-content id="content" page="homePage.html"></ons-splitter-content>
    </ons-splitter>
    <template id="homePage.html">
      <ons-page id="homePage">
          <ons-navigator id="myNavigator" page="feed.html"></ons-navigator>
      </ons-page>
    </template>
    <template id="feed.html">
      <ons-page id="feed">
        <ons-toolbar>
          <div class="left">
            <ons-toolbar-button onclick="fn.open()">
              <ons-icon icon="md-menu"></ons-icon>
            </ons-toolbar-button>
          </div>
          <div class="center">
            Name
          </div>
        </ons-toolbar>
        <ons-card>
          <div class="title">Toast</div>
          <div class="content">
            <p>
              <ons-button autofocus="autofocus" value="Feed" name="Feed"
              onclick="toastThing();">Toast</ons-button>
            </p>
          </div>
        </ons-card>
        <ons-card>
          <div class="title"> Go to google</div>
          <a href="http://google.com" target="_blank"><ons-button>Go to a website</ons-button></a>
        </ons-card>
        <img src="b.png" style="display: none;" onload="ifgoToSetup()">
      </ons-page>
    </template>

    <template id="setup.html">
      <ons-page id="setup">
        <ons-toolbar>
          <div class="center">Name</div>
        </ons-toolbar>
        <ons-card>
          <div class="title">Setup</div>
          <div class="content">
            <p>
              <ons-input id="pub" modifier="underbar" placeholder="Publish Key"
              float=""></ons-input>
            </p>
            <p>
              <ons-input id="sub" modifier="underbar" placeholder="Subscribe Key"
              float=""></ons-input>
            </p>
            <!--<p>
              <ons-input id="sec" modifier="underbar" placeholder="Secret Key"
              float=""></ons-input>
            </p>-->
            <p style="margin-top: 30px;">
              <ons-button id="go-to-main">Done</ons-button>
            </p>
          </div>
        </ons-card>
      </ons-page>
    </template>
    
    <template id="setup-return.html">
        <ons-page id="setup-return">
          <ons-toolbar>
            <div class="left">
              <ons-toolbar-button onclick="fn.open()">
                <ons-icon icon="md-menu"></ons-icon>
              </ons-toolbar-button>
            </div>
            <div class="center">
              Name
            </div>
          </ons-toolbar>
          <ons-card>
            <div class="title">Setup</div>
            <div class="content">
              <p>
                <ons-input id="pub" modifier="underbar" placeholder="Publish Key"
                float=""></ons-input>
              </p>
              <p>
                <ons-input id="sub" modifier="underbar" placeholder="Subscribe Key"
                float=""></ons-input>
              </p>
              <!--<p>
                <ons-input id="sec" modifier="underbar" placeholder="Secret Key"
                float=""></ons-input>
              </p>-->
              <p style="margin-top: 30px;">
                <ons-button id="go-to-main">Done</ons-button>
              </p>
              <p>
                <ons-button id="go-cancel">Cancel</ons-button>
              </p>
            </div>
          </ons-card>
        </ons-page>
      </template>
  </body>
</html>

              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console