Skip to content

Instantly share code, notes, and snippets.

View shazron's full-sized avatar
😆

Shazron Abdullah shazron

😆
View GitHub Profile
@shazron
shazron / app.js
Created May 23, 2013 22:03
RequireJS with Cordova example (app.js)
requirejs(['cordova.js'],
function () {
// start of require
// cordova is now available globally
var exec = cordova.require('cordova/exec');
var app = {
// Application Constructor
@shazron
shazron / index.html
Created May 23, 2013 22:01
RequireJS with Cordova example (index.html)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
<body>
@shazron
shazron / Upgrading_a_Cordova_Project.txt
Created March 25, 2013 23:35
Upgrading a Cordova Project
1. Create a new project
2. Copy in your www assets (keep the cordova.js that is in the new)
3. Update your .html pages that reference the cordova.js to the new one
4. Copy in your Plugin source files into the Plugins group in Xcode
5. Update config.xml with your plugin mappings, access tags (whitelist), and application preferences
6. Copy in any [App]-Info.plist settings that you had before (99.99999% of the cases you can just copy it over if you created the new project with the same settings)
7. localization files - copy those folder over and register them in XCode - as we have the app in 4 languages
8. icons - overwrite the cordova ones and re-register them in XCode
9. splashscreens - ditto
@shazron
shazron / get_file_entry.js
Created February 11, 2013 23:47
Get a FileEntry
function getFileEntry(localFileSystem, filePath, onGetFileWin, onGetFileFail)
{
var onFSWin = function(fileSystem) {
fileSystem.root.getFile(filePath, {create: true, exclusive: false}, onGetFileWin, onGetFileFail);
}
var onFSFail = function(evt) {
console.log(evt.target.error.code);
}
@shazron
shazron / anchor_tag_replace_inappbrowser.js
Last active September 17, 2020 17:58
Anchor tag link replace for InAppBrowser (Apache Cordova)
// warning, jQuery code below
$(document).ready(function() {
var $a = $("a");
$a.click(function(x) {
x.preventDefault();
var url = $(this).attr('href');
launchUrl(url); // where launchUrl is your function that calls window.open, etc
});
@shazron
shazron / gist:4477622
Created January 7, 2013 19:20
OnDeviceReady
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready to be used!
//
function onDeviceReady() {
// do stuff here
var exec = cordova.require('cordova/exec');
exec.setJsToNativeBridgeMode(exec.jsToNativeModes.IFRAME_NAV);
}
@shazron
shazron / testinappbrowser.html
Created November 20, 2012 22:04
Testing InAppBrowser for Cordova 2.3.0
<script type="text/javascript">
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (str){
return this.slice(0, str.length) == str;
};
}
function launchUrl() {
try {
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width;" />
<title>Hello World</title>
<script type="text/javascript" src="cordova-2.1.0rc1.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready", onDeviceReady, true);
@shazron
shazron / check_apache_jira.sh
Created August 12, 2012 14:07
Check Apache Jira at a 5 minute interval
while :; do curl https://issues.apache.org/jira 2>/dev/null | (grep "Maintenance in progress" || say "The Apache Jeera Site is back online.") | grep -v "<h1>Maintenance in progress</h1>"; sleep 300; done
@shazron
shazron / UIWebView WebKit Bugs
Last active October 8, 2015 06:20
Unresolved UIWebView WebKit bugs
Fundamentally, this is a WebKit bug that cannot be worked around currently (it does not release memory of images that a not used anymore). I did extensive measurements by loading huge images in a previous project, and it consistently crashes because of this bug.
I believe it has been reported to the WebKit project, with no resolution:
https://bugs.webkit.org/show_bug.cgi?id=31253
https://bugs.webkit.org/show_bug.cgi?id=39628
Usually, setting the image src to null I think would flag the gc to recycle the memory, but I don't think it will work because of this bug.
Others have the same problem, from the Apple Dev Forums (login needed):
https://devforums.apple.com/search.jspa?resultTypes=MESSAGE&q=UIWebView+memory&peopleEnabled=true&start=1&dateRange=all