Created
July 2, 2010 19:15
-
-
Save wagenet/461774 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<html> | |
<head> | |
<script type="text/javascript" charset="utf-8"> | |
function transactionErrorCallback(error) { | |
console.error('Oops. Transaction error was '+error.message+' (Code '+error.code+')'); | |
} | |
function transactionSuccessCallback() { | |
alert('Done'); | |
} | |
function errorHandler(transaction, error) { | |
// error.message is a human-readable string. | |
// error.code is a numeric error code | |
console.error('Oops. Error was '+error.message+' (Code '+error.code+')'); | |
// Handle errors here | |
var we_think_this_error_is_fatal = true; | |
if (we_think_this_error_is_fatal) return true; | |
return false; | |
} | |
function nullDataHandler(transaction, results) { } | |
function populateDb(num) { | |
var db = openDatabase('testdb'+num, '1.0', 'Test Database '+num, 50000000); | |
db.transaction(function (t) { | |
t.executeSql('CREATE TABLE test(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, value TEXT NOT NULL);', [], nullDataHandler, errorHandler); | |
for(var count=0; count < 20000; count++) { | |
// 1KB of data | |
t.executeSql('INSERT INTO test(value) VALUES ("01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789'+ | |
'01234567890123456789012345678901234567890123456789");', [], nullDataHandler, errorHandler); | |
} | |
console.log('count: '+count); | |
}, transactionErrorCallback, transactionSuccessCallback); | |
} | |
</script> | |
</head> | |
<body> | |
<a href="#" onclick="populateDb(1); return false;">Populate DB 1</a> | |
<a href="#" onclick="populateDb(2); return false;">Populate DB 2</a> | |
<a href="#" onclick="populateDb(3); return false;">Populate DB 3</a> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment