Skip to content

Instantly share code, notes, and snippets.

@chrsch
Forked from purplecabbage/pgDebug.js
Created August 8, 2011 19:48
Show Gist options
  • Select an option

  • Save chrsch/1132549 to your computer and use it in GitHub Desktop.

Select an option

Save chrsch/1132549 to your computer and use it in GitHub Desktop.

Revisions

  1. purplecabbage created this gist Jul 15, 2010.
    47 changes: 47 additions & 0 deletions pgDebug.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    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;

    PhoneGap.queue.ready = false;

    var args = PhoneGap.queue.commands.shift();
    if (PhoneGap.queue.commands.length == 0) {
    clearInterval(PhoneGap.queue.timer);
    PhoneGap.queue.timer = null;
    }

    var uri = [];
    var dict = null;
    for (var i = 1; i < args.length; i++) {
    var arg = args[i];
    if (arg == undefined || arg == null)
    arg = '';
    if (typeof(arg) == 'object')
    dict = arg;
    else
    uri.push(encodeURIComponent(arg));
    }
    var url = "gap://" + args[0] + "/" + uri.join("/");
    if (dict != null) {
    var query_args = [];
    for (var name in dict) {
    if (typeof(name) != 'string')
    continue;
    query_args.push(encodeURIComponent(name) + "=" + encodeURIComponent(dict[name]));
    }
    if (query_args.length > 0)
    url += "?" + query_args.join("&");
    }
    console.log(url);
    setTimeout(function(){PhoneGap.queue.ready = true;},10); // so the next one can go

    };

    setTimeout(function(){DeviceInfo.uuid = "testing";},2000);