Skip to content

Instantly share code, notes, and snippets.

@purplecabbage
Forked from brianleroux/stopgap.js
Created October 6, 2011 19:42

Revisions

  1. Jesse MacFadyen revised this gist Oct 6, 2011. 1 changed file with 11 additions and 8 deletions.
    19 changes: 11 additions & 8 deletions stopgap.js
    Original file line number Diff line number Diff line change
    @@ -4,12 +4,15 @@
    e.initEvent('deviceready')
    document.dispatchEvent(e)
    }
    if (typeof PhoneGap != 'undefined') {
    navigator.camera = {}
    navigator.camera.getPicture = function() {
    alert('sorry, camera not supported in the browser: yet!')
    }
    window.PhoneGap = {}
    deviceready()
    if (PhoneGap) {
    PhoneGap.exec = function(success, fail, service, action, args){
    var callbackId = service + PhoneGap.callbackId++;
    if (typeof success == "function" || typeof fail == "function") {
    PhoneGap.callbacks[callbackId] = {success:success, fail:fail};
    }
    var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args);
    console.log(command);
    };
    deviceready();
    }
    })()
    })();
  2. @brianleroux brianleroux revised this gist Oct 6, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion stopgap.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    e.initEvent('deviceready')
    document.dispatchEvent(e)
    }
    if (!PhoneGap) {
    if (typeof PhoneGap != 'undefined') {
    navigator.camera = {}
    navigator.camera.getPicture = function() {
    alert('sorry, camera not supported in the browser: yet!')
  3. @brianleroux brianleroux revised this gist Oct 6, 2011. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions stopgap.js
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,10 @@
    document.dispatchEvent(e)
    }
    if (!PhoneGap) {
    navigator.camera = {}
    navigator.camera.getPicture = function() {
    alert('sorry, camera not supported in the browser: yet!')
    }
    window.PhoneGap = {}
    deviceready()
    }
  4. @brianleroux brianleroux created this gist Oct 6, 2011.
    11 changes: 11 additions & 0 deletions stopgap.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    (function () {
    function deviceready() {
    var e = document.createEvent('Events')
    e.initEvent('deviceready')
    document.dispatchEvent(e)
    }
    if (!PhoneGap) {
    window.PhoneGap = {}
    deviceready()
    }
    })()