Skip to content

Instantly share code, notes, and snippets.

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@macdonst
macdonst / gist:937315
Created April 22, 2011 18:30
SECURITY_ERR from openDatabase
E/Web Console( 1791): SECURITY_ERR: DOM Exception 18: An attempt was made to break through the security policy of the user agent. at file:///android_asset/www/db.html:64
@macdonst
macdonst / gist:937307
Created April 22, 2011 18:28
Opendatabase issue on Android 3.0
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Contact Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.0.9.4.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
@macdonst
macdonst / read.js
Created May 10, 2011 15:49
Read a file with new File API
function readArabic() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, getFS, fail);
}
function getFS(fileSystem) {
fileSystem.root.getFile("articals.txt", {"create":false, "exclusive":false}, gotArticals, fail);
}
function gotArticals(fileEntry) {
fileEntry.file(getFile, fail);
@macdonst
macdonst / audio.html
Created May 18, 2011 19:48
PhoneGap Media Class Example
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>PhoneGap Back Button Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.0.9.5.js"></script>
<script type="text/javascript" charset="utf-8">
var myMedia = null;
@macdonst
macdonst / cb.html
Created September 9, 2011 15:47
ChildBrowser Example
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Child Browser Example</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
<script type="text/javascript" charset="utf-8" src="childbrowser.js"></script>
<script type="text/javascript" charset="utf-8">
@macdonst
macdonst / contact_example.html
Created September 21, 2011 01:48
Contact Save Example
<!DOCTYPE html>
<html>
<head>
<title>Contact Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
@macdonst
macdonst / index.html
Created December 2, 2011 20:53
BarcodeScanner Android Example
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>PhoneGap</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script type="text/javascript" charset="utf-8" src="phonegap-1.2.0.js"></script>
<script type="text/javascript" charset="utf-8" src="barcodescanner.js"></script>
<script type="text/javascript" charset="utf-8">
@macdonst
macdonst / master.css
Created December 2, 2011 20:54
Sample Android CSS
body {
background:#222 none repeat scroll 0 0;
color:#666;
font-family:Helvetica;
font-size:72%;
line-height:1.5em;
margin:0;
border-top:1px solid #393939;
}
@macdonst
macdonst / tweets.js
Created December 21, 2011 19:50
Load Tweets
function loadTweets() {
var request = new XMLHttpRequest();
request.open("GET", "http://search.twitter.com/search.json?q=phonegap", true);
request.onreadystatechange = function() {//Call a function when the state changes.
if (request.readyState == 4) {
if (request.status == 200 || request.status == 0) {
var tweets = JSON.parse(request.responseText);
var data = "<table cellspacing='0'>";
var tableClass;
for (i = 0; i < tweets.results.length; i++) {