Created
May 12, 2010 07:58
-
-
Save philippbosch/398316 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<input type="text" id="username"> | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var username = localStorage.getItem('username'); | |
if (username) $('#twitter_username').val(username); | |
}); | |
$('#twitter_username').change(function() { | |
localStorage.setItem('username', $(this).val()); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<script src="jqtouch/jquery.js"></script> | |
<script src="jqtouch/jqtouch.js"></script> | |
<script src="json2.js"></script> | |
<script src="jquery.couch.js"></script> | |
<script src="app.js"></script> | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var db = $.couch.db('databasename'); | |
var document = { | |
'name': 'Philipp', | |
'size': 185, | |
'city': 'Berlin' | |
}; | |
db.saveDoc(document, { | |
'success': function() { | |
alert('Document was successfully saved.'); | |
} | |
}); | |
db.allDocs({ | |
'success': function(result) { | |
for (var i in result.rows) { | |
db.openDoc(result.rows[i].id, { | |
'success': function(row) { | |
console.log(row.name + ', ' + row.city); | |
} | |
}) | |
} | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dbShortName = 'People'; | |
var dbVersion = '1.0'; | |
var dbDisplayName = 'People'; | |
var dbMaxSize = 65536; | |
var db = openDatabase(dbShortName, dbVersion, dbDisplayName, dbMaxSize); | |
db.transaction(function(transaction) { | |
transaction.executeSql( | |
'CREATE TABLE IF NOT EXISTS people (' + | |
' id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,' + | |
' name VARCHAR(100) NOT NULL,' + | |
' age INTEGER' + | |
');' | |
); | |
}); | |
db.transaction(function(transaction) { | |
transaction.executeSql( | |
'INSERT INTO people ' + | |
' (name, age) ' + | |
'VALUES ' + | |
' (?,?)' | |
, ["Lena Meyer-Landrut", 18], | |
function(transaction, result) { | |
alert('Data successfully inserted.'); | |
}, | |
function(transaction, error) { | |
alert('Oops. Error was "' + error.message + '" (Code: ' + error.code + ')'); | |
return true; | |
}); | |
}); | |
db.transaction(function(transaction) { | |
transaction.executeSql( | |
'SELECT * FROM people ' + | |
'WHERE age >= 18', | |
null, | |
function(transaction, result) { | |
for (var i=0; i<result.rows.length; i++) { | |
var row = result.rows.item(i); | |
console.log(row); | |
} | |
}, | |
function(transaction, error) { | |
alert('Oops. Error was "' + error.message + '" (Code: ' + error.code + ')'); | |
return true; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment