Skip to content

Instantly share code, notes, and snippets.

View purplecabbage's full-sized avatar
:shipit:
shippin'

Jesse MacFadyen purplecabbage

:shipit:
shippin'
View GitHub Profile
@purplecabbage
purplecabbage / pgDebug.js
Created July 15, 2010 01:10
Workout your iPhone PhoneGap UI in Desktop Safari
var safariDebug = ( navigator.platform.indexOf("iPhone") < 0 && navigator.platform.indexOf("iPod") < 0 && navigator.platform.indexOf("iPad") < 0 );
if(safariDebug)
{
PhoneGap.run_command = function()
{
if (!PhoneGap.available || !PhoneGap.queue.ready)
return;
@purplecabbage
purplecabbage / EventBroadcaster.js
Created July 19, 2010 21:32
EventBroadcaster.js
/*
The MIT License
Copyright (c) 2010 Jesse MacFadyen
jesse.macfadyen@nitobi.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
/*
The MIT License
Copyright (c) 2010 Jesse MacFadyen, Nitobi Software
jesse.macfadyen@nitobi.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
/*
The MIT License
Copyright (c) 2010 Jesse MacFadyen, Nitobi Software
jesse.macfadyen@nitobi.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
@purplecabbage
purplecabbage / Mixin Decorator
Created March 4, 2011 10:35
Non-Inheritance addition of methods from a source class, either to an instance or a prototype
/*
@destObj :Object to decorate
@propName :String name of
@className :Class to use as the decorator source
*/
function decorate(destObj,propName,className)
{
// are we working with an instance?
if(typeof destObj == "object")
{
@purplecabbage
purplecabbage / ClassHelpers.js
Created March 6, 2011 21:23
adding namespaces to the prototype chain in js.
var Class = {};
Class.namespace = function(ns,value)
{
var nsArr = ns.split(".");
var obj = window;
var prop;
for(var n=0; n < nsArr.length-1; n++)
{
prop = nsArr[n];
if(!obj[prop])
@interface MYPROJECT_AppDelegate : PhoneGapDelegate {
NSString* invokeString;
}
@property (copy) NSString* invokeString;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// perform any custom startup stuff you need to ...
// process your launch options
NSArray *keyArray = [launchOptions allKeys];
if ([launchOptions objectForKey:[keyArray objectAtIndex:0]]!=nil)
{
// we store the string, so we can use it later, after the webView loads
NSURL *url = [launchOptions objectForKey:[keyArray objectAtIndex:0]];
self.invokeString = [url absoluteString];
@purplecabbage
purplecabbage / initialization.html
Created May 4, 2011 21:23
GoogleAnalyticsPhoneGapPlugin
<script type="text/javascript" charset="utf-8" src="GoogleAnalyticsPlugin.js"></script>
<script type="text/javascript" charset="utf-8">
var googleAnalytics;
function onBodyLoad()
{
document.addEventListener("deviceready",onDeviceReady,false);
}
@purplecabbage
purplecabbage / stopgap.js
Created October 6, 2011 19:42 — forked from brianleroux/stopgap.js
alunny's stopgap in gist form
(function () {
function deviceready() {
var e = document.createEvent('Events')
e.initEvent('deviceready')
document.dispatchEvent(e)
}
if (PhoneGap) {
PhoneGap.exec = function(success, fail, service, action, args){
var callbackId = service + PhoneGap.callbackId++;
if (typeof success == "function" || typeof fail == "function") {