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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <!DOCTYPE html>
<html>
	<head> 
		<!--<link rel="stylesheet" href="./lib/onsen/css/onsenui.css">-->
		<!--<link rel="stylesheet" href="./lib/onsen/css/onsen-css-components.css">-->
		<!--<link rel="stylesheet" href="./lib/onsen/css/my-onsen-css-components.css">-->
		<!--<script src="./lib/onsen/js/onsenui.js"></script>-->
		<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>
		</script>
	</head>
	<body>
		<ons-splitter>
			<ons-splitter-side id="menu" side="left" width="220px" collapse swipeable>
				<ons-page>
					<ons-list-item onclick="fn.load('home.html')" tappable>
						Home
					</ons-list-item>
					<ons-list-item onclick="fn.load('additem.html')" tappable>
						Add Item
					</ons-list-item>
				</ons-page>
			</ons-splitter-side>
			<ons-splitter-content id="content">
				<ons-navigator id="myNavigator" page="home.html"></ons-navigator>
			</ons-splitter-content>
		</ons-splitter>
		
		<template id="home.html">
			<ons-page id="home">
				<ons-toolbar>
					<div class="left">
						<ons-toolbar-button onclick="fn.openMenu()">
							<ons-icon icon="md-menu"></ons-icon>
						</ons-toolbar-button>
					</div>

					<div class="center">
						Shopping List
					</div>
				</ons-toolbar>
				
				<ons-list id="shoppinglist">
					<ons-list-item>Filler-1</ons-list-item>
					<ons-list-item>Filler-2</ons-list-item>
					<ons-list-item>Filler-3</ons-list-item>
				</ons-list>
				
				<ons-fab position="bottom right">
					<ons-icon icon="md-plus" onclick="myNavigator.pushPage('additem.html');"></ons-icon>
				</ons-fab>
			</ons-page>
		</template>
		
		<template id="additem.html">
			<ons-page>
				<ons-toolbar>
					<div class="center">Add Item</div>
					<div class="left">
						<ons-back-button>Back</ons-back-button>
					</div>
				</ons-toolbar>
				
				<div style="text-align: center; margin-top: 30px;">
					<p>
						<ons-input id="item" placeholder="Item Description" modifier="underbar" float style="width:90%;"></ons-input>
					</p>
					<p style="margin-top: 30px;">
						<ons-button onclick="addItem()">Add Item</ons-button>
					</p>
				</div>
			</ons-page>
		</template>
		
		<script type="text/javascript" src="cordova.js"></script>
		<script type="text/javascript" src="new.app.js"></script>
	</body>
</html>												
              
            
!

CSS

              
                
              
            
!

JS

              
                			ons.platform.select('android');
			
			//---------------------------------------------------------//
			
			window.fn = {};
			
			window.fn.openMenu = function () {
				var menu = document.getElementById('menu');
				menu.open();
			};
			
			window.fn.load = function (page) {
				var menu = document.getElementById('menu');
				var myNavigator = document.getElementById('myNavigator');
				
				menu.close();
				myNavigator.pushPage(page);
			};
			
			//---------------------------------------------------------//
			
			var db = null;

			document.addEventListener("init", function(event){
				if(event.target.id == "home"){
					openDb();
					getItems();
				}
			});

			function onError(tx, e){
				alert("something went wrong: " + e.message);
			}
			
			function onSuccess(tx, r){
				getItems();
			}
			
			function openDb(){
				db = openDatabase("ShoppingList", "1", "Shopping List", 1024*1024);
				
				db.transaction(function(tx){
					tx.executeSql("CREATE TABLE IF NOT EXISTS items (ID INTEGER PRIMARY KEY ASC, item TEXT)", [], onSuccess, onError);
				});
			}
			
			function getItems(){
				db.transaction(function(tx){
					//               the statement       inital values    success      fail
					tx.executeSql("SELECT * FROM items", [],             renderItems, onError);
				});
			}
			
			function renderItems(tx, rs){
				var output = "";
				var list = document.getElementById("shoppinglist");
				
				if(rs.rows.length==0){
					output = "<ons-list-item tappable>No items yet</ons-list-item>";
				} else {
					for(i = 0; i < rs.rows.length; i++){
						var row = rs.rows.item(i);
						output += "<ons-list-item>" + row.item +
						"<div class='right'><ons-button onclick='deleteItem(" + row.ID + ");'><ons-icon icon='trash'></ons-icon></ons-button></div>" +
						"</ons-list-item>";
					}
				}
				
				list.innerHTML = output;
			}
			
			function addItem(){
				var textbox = document.getElementById("item");
				var value = textbox.value;
				
				db.transaction(function(tx){
					tx.executeSql("INSERT INTO items (item) VALUES (?)", [value], onSuccess, onError);
				});
				
				textbox.value = "";
				
				//fn.load2('home.html');
				myNavigator.popPage();
			}
			
			function deleteItem(id){
				db.transaction(function(tx){
					tx.executeSql("DELETE FROM items WHERE ID=?", [id], onSuccess, onError);  
				});
			}

              
            
!
999px

Console