Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

debugging post

  • Loading branch information...
commit 0d910ec12151f9a365f41ba0f58b1f0f21dcb8e7 1 parent 8920b24
hutley authored
12,493 HelloPhoneGap.xcodeproj/project.xcworkspace/xcuserdata/hiedi.xcuserdatad/UserInterfaceState.xcuserstate
10,529 additions, 1,964 deletions not shown
61 www/PhoneGapShim1.js
... ... @@ -0,0 +1,61 @@
  1 +//from Jesse McFayden, Nitobi Inc
  2 +//https://gist.github.com/raw/476358/dae649dc8d7b20041780bc6a2bcfcb9f31dbcdfe/pgDebug.js
  3 +var safariDebug = (navigator.platform.indexOf("iPhone") < 0 && navigator.platform.indexOf("iPod") < 0 && navigator.platform.indexOf("iPad") < 0);
  4 +
  5 +if (safariDebug)
  6 +{
  7 +
  8 + PhoneGap.run_command = function()
  9 + {
  10 + if (!PhoneGap.available || !PhoneGap.queue.ready)
  11 + {
  12 + return;
  13 + }
  14 +
  15 + PhoneGap.queue.ready = false;
  16 +
  17 + var args = PhoneGap.queue.commands.shift();
  18 + if (PhoneGap.queue.commands.length == 0) {
  19 + clearInterval(PhoneGap.queue.timer);
  20 + PhoneGap.queue.timer = null;
  21 + }
  22 +
  23 + var uri = [];
  24 + var dict = null;
  25 + for (var i = 1; i < args.length; i++) {
  26 + var arg = args[i];
  27 + if (arg == undefined || arg == null)
  28 + arg = '';
  29 + if (typeof(arg) == 'object')
  30 + dict = arg;
  31 + else
  32 + uri.push(encodeURIComponent(arg));
  33 + }
  34 + var url = "gap://" + args[0] + "/" + uri.join("/");
  35 + if (dict != null) {
  36 + var query_args = [];
  37 + for (var name in dict) {
  38 + if (typeof(name) != 'string')
  39 + continue;
  40 + query_args.push(encodeURIComponent(name) + "=" + encodeURIComponent(dict[name]));
  41 + }
  42 + if (query_args.length > 0)
  43 + url += "?" + query_args.join("&");
  44 + }
  45 + alert(url);
  46 + //console.log(url);
  47 + setTimeout(function() {
  48 + PhoneGap.queue.ready = true;
  49 + },
  50 + 10);
  51 + // so the next one can go
  52 + };
  53 +
  54 + setTimeout(function() {
  55 + DeviceInfo.uuid = "testing";
  56 + },
  57 + 2000);
  58 +
  59 + alert("here2");
  60 +}
  61 +
11 www/PhoneGapShim2.js
... ... @@ -0,0 +1,11 @@
  1 +function StopGap() {
  2 + function deviceready() {
  3 + // fire off deviceready
  4 + var e = document.createEvent('Events');
  5 + e.initEvent('deviceready');
  6 + document.dispatchEvent(e);
  7 + }
  8 +
  9 + window.PhoneGap = {};
  10 + deviceready();
  11 +}
21 www/camera.html
@@ -9,6 +9,7 @@
9 9 <title>HelloPhoneGap</title>
10 10
11 11 <script type="text/javascript" charset="utf-8" src="phonegap.0.9.4.min.js"></script>
  12 +
12 13 <script type="text/javascript" charset="utf-8">
13 14
14 15 var pictureSource; // picture source
@@ -47,6 +48,7 @@
47 48 // The inline CSS rules are used to resize the image
48 49 //
49 50 myImage.src = "data:image/jpeg;base64," + imageData;
  51 +
50 52 }
51 53
52 54 // Called when a photo is successfully retrieved
@@ -87,17 +89,28 @@
87 89 // A button will call this function
88 90 //
89 91 function capturePhotoEdit() {
  92 + try {
90 93 // Take picture using device camera, allow edit, and retrieve image as base64-encoded string
91 94 navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 20, allowEdit: true });
92   - }
  95 + }catch (err)
  96 + {
  97 + alert(err);
  98 + }
  99 + }
93 100
94 101 // A button will call this function
95 102 //
96 103 function getPhoto(source) {
  104 +
  105 + try {
97 106 // Retrieve image file location from specified source
98 107 navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
99 108 destinationType: destinationType.FILE_URI,
100 109 sourceType: source });
  110 + }catch (err)
  111 + {
  112 + alert(err);
  113 + }
101 114 }
102 115
103 116 function onFail(mesage) {
@@ -138,12 +151,12 @@
138 151 </TR>
139 152 <TR>
140 153 <TD>
141   - <button onclick="getPhoto(pictureSource.PHOTOLIBRARY);">From Photo Library</button><br>
  154 + <button onclick="try{getPhoto(pictureSource.PHOTOLIBRARY);}catch(err){alert(err);};">From Photo Library</button><br>
142 155 </TD>
143 156 </TR>
144 157 <TR>
145 158 <TD>
146   - <button onclick="getPhoto(pictureSource.SAVEDPHOTOALBUM);">From Photo Album</button><br>
  159 + <button onclick="try{getPhoto(pictureSource.SAVEDPHOTOALBUM);}catch(err){alert(err);};">From Photo Album</button><br>
147 160 </TD>
148 161 </TR>
149 162
@@ -161,4 +174,6 @@
161 174 <DIV id="phoneGapReady" class="phoneGapReady">waiting for PhoneGap to initialize....</DIV>
162 175
163 176 </body>
  177 +
  178 +
164 179 </html>
124 www/debug.html
... ... @@ -0,0 +1,124 @@
  1 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2 +<html>
  3 + <head>
  4 + <!-- Change this if you want to allow scaling -->
  5 + <meta name="viewport" content="width=default-width; user-scalable=no" />
  6 +
  7 + <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  8 + <link rel="stylesheet" href="HelloPhoneGap.css" type="text/css"/>
  9 + <title>HelloPhoneGap</title>
  10 +
  11 + <script type="text/javascript" charset="utf-8" src="phonegap.0.9.4.min.js"></script>
  12 + <script type="text/javascript" charset="utf-8" src="PhoneGapShim1.js"></script>
  13 +
  14 + <script type="text/javascript" charset="utf-8">
  15 +
  16 + var pictureSource; // picture source
  17 + var destinationType; // sets the format of returned value
  18 +
  19 +
  20 + function onBodyLoad()
  21 + {
  22 + document.addEventListener("deviceready",onDeviceReady,false);
  23 + }
  24 +
  25 + /* When this function is called, PhoneGap has been initialized and is ready to roll */
  26 + function onDeviceReady()
  27 + {
  28 + phoneGapReady.innerHTML = "PhoneGap is Ready";
  29 +
  30 + }
  31 +
  32 + function getDeviceProperties() {
  33 + var element = document.getElementById('deviceProperties');
  34 +
  35 + element.innerHTML = 'Device Name: ' + device.name + '<br />' +
  36 + 'Device PhoneGap: ' + device.phonegap + '<br />' +
  37 + 'Device Platform: ' + device.platform + '<br />' +
  38 + 'Device UUID: ' + device.uuid + '<br />' +
  39 + 'Device Version: ' + device.version + '<br />';
  40 + }
  41 +
  42 +
  43 + </script>
  44 + </head>
  45 + <body onload="onBodyLoad()">
  46 +
  47 + <DIV class="phoneGapAPITitle">
  48 +
  49 + <TABLE width="100%">
  50 + <TR>
  51 + <TD>
  52 + Device API
  53 + </TD>
  54 + <TD align="right"><a href="index.html">back</a>
  55 + </TD>
  56 + </TR>
  57 +
  58 + </TABLE>
  59 + </DIV>
  60 + <DIV class="phoneGapAPI">
  61 +
  62 + <TABLE>
  63 + <TR>
  64 + <TD>
  65 + <button onclick="getDeviceProperties();">getDeviceProperties()</button> <br>
  66 + </TD>
  67 + </TR>
  68 +
  69 +
  70 + <TR>
  71 + <TD id="deviceProperties" >
  72 +
  73 + </TD>
  74 + </TR>
  75 +
  76 + </TABLE>
  77 + </DIV>
  78 + <DIV class="phoneGapAPITitle">
  79 +
  80 + <TABLE width="100%">
  81 + <TR>
  82 + <TD>
  83 + Accelerometer API
  84 + </TD>
  85 + <TD align="right"><a href="index.html">back</a>
  86 + </TD>
  87 + </TR>
  88 +
  89 + </TABLE>
  90 + </DIV>
  91 + <DIV class="phoneGapAPI">
  92 +
  93 + <TABLE>
  94 + <TR>
  95 + <TD>
  96 + <button class="phoneGapAPIButton" onclick="getCurrentAcceleration();">getCurrentAcceleration()</button>
  97 + </TD>
  98 + </TR>
  99 + <TR>
  100 + <TD id="currentAccelerationResult">
  101 +
  102 + </TD>
  103 + </TR>
  104 +
  105 + <TR>
  106 + <TD>
  107 + <button class="phoneGapAPIButton" onclick="startWatch();">startWatch(1000ms)</button>
  108 + <button class="phoneGapAPIButton" onclick="stopWatch();">stopWatch()</button>
  109 +
  110 + </TD>
  111 + </TR>
  112 + <TR>
  113 + <TD id="watchResult">
  114 +
  115 + </TD>
  116 + </TR>
  117 +
  118 + </TABLE>
  119 + </DIV>
  120 +
  121 + <DIV id="phoneGapReady" class="phoneGapReady">waiting for PhoneGap to initialize....</DIV>
  122 +
  123 + </body>
  124 +</html>
9 www/geolocation.html
@@ -9,6 +9,7 @@
9 9 <title>HelloPhoneGap</title>
10 10
11 11 <script type="text/javascript" charset="utf-8" src="phonegap.0.9.4.min.js"></script>
  12 +
12 13 <script type="text/javascript" charset="utf-8">
13 14
14 15 var pictureSource; // picture source
@@ -28,7 +29,13 @@
28 29 }
29 30
30 31 function getLocation() {
31   - navigator.geolocation.getCurrentPosition(onSuccess, onError);
  32 + try {
  33 + navigator.geolocation.getCurrentPosition(onSuccess, onError);
  34 + }
  35 + catch (err)
  36 + {
  37 + alert(err);
  38 + }
32 39 }
33 40
34 41 // onSuccess Geolocation

0 comments on commit 0d910ec

Please sign in to comment.
Something went wrong with that request. Please try again.