incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [25/51] [abbrv] added functionality to Example project
Date Thu, 12 Jan 2012 19:30:14 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/3248e663/example/www/location.html
----------------------------------------------------------------------
diff --git a/example/www/location.html b/example/www/location.html
new file mode 100644
index 0000000..8e50b6d
--- /dev/null
+++ b/example/www/location.html
@@ -0,0 +1,162 @@
+<!doctype html>
+<html>
+  <head>
+    <!-- meta name="viewport" content="width=device-width, height=device-height, user-scalable=yes,
initial-scale=2.0, maximum-scale=4.0, minimum-scale=1.0" / -->
+    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no;"
/>
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8"> 
+    <title>PhoneGap</title>
+    <link rel="stylesheet" href="master.css" type="text/css" media="screen">
+    
+    <script type="text/javascript">
+      // provide our own console if it does not exist, huge dev aid!
+      if(typeof window.console == "undefined")
+      {
+      window.console = {log:function(str){window.external.Notify(str);}};
+      }
+
+      // output any errors to console log, created above.
+      window.onerror=function(e)
+      {
+      console.log("window.onerror ::" + JSON.stringify(e));
+      };
+
+      console.log("Installed console ! ");
+    </script>
+    
+    <script type="text/javascript" charset="utf-8" src="phonegap-1.2.0.js"></script>
      
+    
+ 
+
+      
+<script type="text/javascript" charset="utf-8">
+
+    var deviceReady = false;
+
+    //-------------------------------------------------------------------------
+    // Location
+    //-------------------------------------------------------------------------
+    var watchLocationId = null;
+
+    /**
+     * Start watching location
+     */
+    var watchLocation = function() {
+        console.log("watchLocation()");
+
+        // Success callback
+        var success = function(p){
+            document.getElementById('latitude').innerHTML = p.coords.latitude;
+            document.getElementById('longitude').innerHTML = p.coords.longitude;
+			
+			document.getElementById('tdAlt').innerHTML = p.coords.altitude;
+			document.getElementById('tdAcc').innerHTML = p.coords.accuracy;
+			document.getElementById('tdAltAcc').innerHTML = p.coords.altitudeAccuracy;
+			document.getElementById('tdHeading').innerHTML = p.coords.heading;
+			document.getElementById('tdSpeed').innerHTML = p.coords.speed;
+        };
+
+        // Fail callback
+        var fail = function(e){
+            console.log("watchLocation fail callback with error code "+e);
+            stopLocation();
+        };
+
+        // Get location
+        watchLocationId = navigator.geolocation.watchPosition(success, fail, {enableHighAccuracy:
true});
+        setLocationStatus("Running");
+    };
+
+    /**
+     * Stop watching the location
+     */
+    var stopLocation = function() {
+        setLocationStatus("Stopped");
+        if (watchLocationId) {
+            navigator.geolocation.clearWatch(watchLocationId);
+            watchLocationId = null;
+        }
+    };
+
+    /**
+     * Get current location
+     */
+    var getLocation = function() {
+        console.log("getLocation()");
+
+        // Stop location if running
+        stopLocation();
+
+        // Success callback
+        var success = function(p)
+		{
+            document.getElementById('latitude').innerHTML = p.coords.latitude;
+            document.getElementById('longitude').innerHTML = p.coords.longitude;
+			
+			document.getElementById('tdAlt').innerHTML = p.coords.altitude;
+			document.getElementById('tdAcc').innerHTML = p.coords.accuracy;
+			document.getElementById('tdAltAcc').innerHTML = p.coords.altitudeAccuracy;
+			document.getElementById('tdHeading').innerHTML = p.coords.heading;
+			document.getElementById('tdSpeed').innerHTML = p.coords.speed;
+
+            setLocationStatus("Done");
+        };
+
+        // Fail callback
+        var fail = function(e){
+            console.log("getLocation fail callback with error code "+e.code);
+            setLocationStatus("Error: "+e.code);
+        };
+
+        // Get location
+        navigator.geolocation.getCurrentPosition(success, fail, {enableHighAccuracy: true});
//, {timeout: 10000});
+        setLocationStatus("Retrieving location...");
+
+    };
+
+    /**
+     * Set location status
+     */
+    var setLocationStatus = function(status) {
+        document.getElementById('location_status').innerHTML = status;
+    };
+    
+    /**
+     * Function called when page has finished loading.
+     */
+    function init() {
+        document.addEventListener("deviceready", function() {
+                deviceReady = true;
+                console.log("Device="+device.platform+" "+device.version);
+            }, false);
+        window.setTimeout(function() {
+        	if (!deviceReady) {
+        		alert("Error: PhoneGap did not initialize.  Demo will not run correctly.");
+        	}
+        },1000);
+    }
+
+</script>
+
+  </head>
+  <body onLoad="init();" id="stage" class="theme">
+  
+    <h1>Location</h1>
+    <div id="info">
+        <b>Status:</b> <span id="location_status">Stopped</span>
+        <table width="100%">
+            <tr><td><b>Latitude:</b></td><td id="latitude">&nbsp;</td></tr>
+            <tr><td><b>Longitude:</b></td><td id="longitude">&nbsp;</td></tr>
+            <tr><td><b>Altitude:</b></td><td id="tdAlt">&nbsp;</td></tr>
+            <tr><td><b>Accuracy:</b></td><td id="tdAcc">&nbsp;</td></tr>
+            <tr><td><b>Altitude Accuracy:</b></td><td id="tdAltAcc">&nbsp;</td></tr>
+            <tr><td><b>Heading:</b></td><td id="tdHeading">&nbsp;</td></tr>
+            <tr><td><b>Speed:</b></td><td id="tdSpeed">&nbsp;</td></tr>
+        </table>
+    </div>
+    <h2>Action</h2>
+    <a href="#" class="btn large" onClick="getLocation();">Get Location</a>
+    <a href="#" class="btn large" onClick="watchLocation();">Start Watching Location</a>
+    <a href="#" class="btn large" onClick="stopLocation();">Stop Watching Location</a>
+    <h2>&nbsp;</h2><a href="index.html" class="backBtn">Back</a>
  
+  </body>
+</html>      
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/3248e663/example/www/master.css
----------------------------------------------------------------------
diff --git a/example/www/master.css b/example/www/master.css
index a015c7e..f3f3717 100644
--- a/example/www/master.css
+++ b/example/www/master.css
@@ -1,25 +1,112 @@
-´╗┐body {
-    background-color:Green;
-    font-family:"Segoe WP";
-    color:#FFF;
-}
-
-h1 {
-    font-size: 40px;
-}
-
-li {
-    background-image:url('images/ArrowImg.png');
-    background-repeat:no-repeat;
-    min-height: 50px;
-    padding-left:55px;
-    font-size:26px;
-    margin-left:-30px;
-    margin-bottom:4px;
-    list-style-type:none;
-}
-
-li a {
-    color:#FFF;
-    text-decoration:none;
-}
+  
+  body {
+	background:#222 none repeat scroll 0 0;
+	color:#FFC312;
+	font-family:Helvetica, Verdana, Geneva, sans-serif;
+	font-size:72%;
+	line-height:1.5em;
+	margin:0;
+	border-top:1px solid #393939;
+  }
+
+  #info{
+    background:#ffa;
+    border: 1px solid #ffd324;
+    -webkit-border-radius: 5px;
+    border-radius: 5px;
+    clear:both;
+    margin:15px 6px 0;
+    width:295px;
+    padding:4px 0px 2px 10px;
+	color:#666;
+  }
+  
+  #info > h4{
+    font-size:.95em;
+    margin:5px 0;
+  }
+ 	
+  #stage.theme{
+    padding-top:3px;
+  }
+
+  /* Definition List */
+  #stage.theme > dl{
+  	padding-top:10px;
+  	clear:both;
+  	margin:0;
+  	list-style-type:none;
+  	padding-left:10px;
+  	overflow:auto;
+  }
+
+  #stage.theme > dl > dt{
+  	font-weight:bold;
+  	float:left;
+  	margin-left:5px;
+  }
+
+  #stage.theme > dl > dd{
+  	width:45px;
+  	float:left;
+  	color:#a87;
+  	font-weight:bold;
+  }
+
+  /* Content Styling */
+  #stage.theme > h1, #stage.theme > h2, #stage.theme > p{
+    margin:1em 0 .5em 13px;
+  }
+
+  #stage.theme > h1{
+    color:#eee;
+    font-size:1.6em;
+    text-align:center;
+    margin:0;
+    margin-top:15px;
+    padding:0;
+  }
+
+  #stage.theme > h2{
+  	clear:both;
+    margin:0;
+    padding:3px;
+    font-size:1em;
+    text-align:center;
+  }
+
+  /* Stage Buttons */
+  #stage.theme .btn{
+  	border: 1px solid #555;
+  	-webkit-border-radius: 5px;
+  	border-radius: 5px;
+  	text-align:center;
+  	display:block;
+  	float:left;
+  	background:#444;
+  	width:150px;
+  	color:#9ab;
+  	font-size:1.1em;
+  	text-decoration:none;
+  	padding:1.2em 0;
+  	margin:3px 0px 3px 5px;
+  }
+  #stage.theme .btn.large{
+  	width:308px;
+  	padding:1.2em 0;
+  }
+  #stage.theme .backBtn{
+   border: 1px solid #555;
+   -webkit-border-radius: 5px;
+   border-radius: 5px;
+   text-align:center;
+   display:block;
+   float:right;
+   background:#666;
+   width:75px;
+   color:#9ab;
+   font-size:1.1em;
+   text-decoration:none;
+   padding:1.2em 0;
+   margin:3px 5px 3px 5px;
+  }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/3248e663/example/www/network.html
----------------------------------------------------------------------
diff --git a/example/www/network.html b/example/www/network.html
new file mode 100644
index 0000000..c1ef707
--- /dev/null
+++ b/example/www/network.html
@@ -0,0 +1,93 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <!-- meta name="viewport" content="width=device-width, height=device-height, user-scalable=yes,
initial-scale=2.0, maximum-scale=4.0, minimum-scale=1.0" / -->
+    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no;"
/>
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/> <!-- ISO-8859-1
-->
+    <title>PhoneGap</title>
+    <link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no
title" charset="utf-8"/>
+    <script type="text/javascript">
+      // provide our own console if it does not exist, huge dev aid!
+      if(typeof window.console == "undefined")
+      {
+      window.console = {log:function(str){window.external.Notify(str);}};
+      }
+
+      // output any errors to console log, created above.
+      window.onerror=function(e)
+      {
+      console.log("window.onerror ::" + JSON.stringify(e));
+      };
+
+      console.log("Installed console ! ");
+    </script>
+    
+    <script type="text/javascript" charset="utf-8" src="phonegap-1.2.0.js"></script>

+
+
+    <script type="text/javascript" charset="utf-8">
+
+    var deviceReady = false;
+
+    //-------------------------------------------------------------------------
+    // Notifications
+    //-------------------------------------------------------------------------
+
+    function getConnectionState()
+	{
+        var networkState = navigator.network.connection.type;
+
+        var states = {};
+        states[Connection.UNKNOWN]  = 'Unknown connection';
+        states[Connection.ETHERNET] = 'Ethernet connection';
+        states[Connection.WIFI]     = 'WiFi connection';
+        states[Connection.CELL_2G]  = 'Cell 2G connection';
+        states[Connection.CELL_3G]  = 'Cell 3G connection';
+        states[Connection.CELL_4G]  = 'Cell 4G connection';
+        states[Connection.NONE]     = 'No network connection';
+
+		
+        document.getElementById("info").innerHTML = 'Connection type: ' + networkState;
+    };
+
+
+
+
+
+    
+    /**
+     * Function called when page has finished loading.
+     */
+    function init() {
+		
+		
+		
+        document.addEventListener("deviceready", function() {
+                deviceReady = true;
+                console.log("Device="+device.platform+" "+device.version);
+				
+				PhoneGap.onPhoneGapConnectionReady.subscribeOnce(getConnectionState);
+				
+            }, false);
+        window.setTimeout(function() {
+        	if (!deviceReady) {
+        		console.log("Error: PhoneGap did not initialize.  Demo will not run correctly.");
+        	}
+        },1000);
+    }
+
+</script>
+
+  </head>
+  <body onLoad="init();" id="stage" class="theme">
+  
+    <h1>Network Connection</h1>
+    <div id="info">
+    </div>
+    
+    <h2>Action</h2>
+    <a href="#" class="btn large" onClick="getConnectionState();">Get Connection State</a>
+
+    <a href="index.html" class="backBtn">Back</a>
+  </body>
+</html>      
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/3248e663/example/www/notification.html
----------------------------------------------------------------------
diff --git a/example/www/notification.html b/example/www/notification.html
new file mode 100644
index 0000000..0f8d8d1
--- /dev/null
+++ b/example/www/notification.html
@@ -0,0 +1,120 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <!-- meta name="viewport" content="width=device-width, height=device-height, user-scalable=yes,
initial-scale=2.0, maximum-scale=4.0, minimum-scale=1.0" / -->
+    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no;"
/>
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/> <!-- ISO-8859-1
-->
+    <title>PhoneGap</title>
+    <link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no
title" charset="utf-8"/>
+    <script type="text/javascript">
+      // provide our own console if it does not exist, huge dev aid!
+      if(typeof window.console == "undefined")
+      {
+      window.console = {log:function(str){window.external.Notify(str);}};
+      }
+
+      // output any errors to console log, created above.
+      window.onerror=function(e)
+      {
+      console.log("window.onerror ::" + JSON.stringify(e));
+      };
+
+      console.log("Installed console ! ");
+    </script>
+    
+    <script type="text/javascript" charset="utf-8" src="phonegap-1.2.0.js"></script>

+
+
+    <script type="text/javascript" charset="utf-8">
+
+      var deviceReady = false;
+
+      //-------------------------------------------------------------------------
+      // Notifications
+      //-------------------------------------------------------------------------
+
+      function doBeep(x)
+      {
+
+      navigator.notification.beep(x);
+      };
+
+      function doVibrate()
+      {
+      navigator.notification.vibrate(0);
+      };
+
+      function doAlert()
+      {
+      var message = "This is an Alert dialog";
+      var title = "Attention!";
+
+      navigator.notification.alert(message,
+      function()
+      {
+      console.log("Alert dismissed.");
+      },
+      title);
+
+      console.log("After alert");
+      };
+
+      function doConfirm()
+      {
+      var message = "This is a confirm dialog";
+      var title = "Please Confirm";
+      var buttons = "OK,Cancel";
+      navigator.notification.confirm(message,
+      function(r) {
+      console.log("You selected " + r);
+
+      },
+      title,
+      buttons);
+      }
+
+      function startActivity()
+      {
+      navigator.notification.activityStart();
+      }
+
+      function stopActivity()
+      {
+      navigator.notification.activityStop();
+      }
+
+      /**
+      * Function called when page has finished loading.
+      */
+      function init() {
+      document.addEventListener("deviceready", function() {
+      deviceReady = true;
+      console.log("Device="+device.platform+" "+device.version);
+      }, false);
+      window.setTimeout(function() {
+      if (!deviceReady) {
+      console.log("Error: PhoneGap did not initialize.  Demo will not run correctly.");
+      }
+      },1000);
+      }
+
+    </script>
+
+  </head>
+  <body onLoad="init();" id="stage" class="theme">
+  
+    <h1>Notifications and Dialogs</h1>
+    <div id="info">
+    </div>
+    
+    <h2>Action</h2>
+    <a href="#" class="btn large" onClick="doBeep();">Beep Once</a>
+    <a href="#" class="btn large" onClick="doBeep(3);">Beep 3X</a>
+    <a href="#" class="btn large" onClick="doVibrate();">Vibrate</a>
+    <a href="#" class="btn large" onClick="doAlert();">Show Alert Dialog</a>
+    <a href="#" class="btn large" onClick="doConfirm();">Show Confirm Dialog</a>
+    <a href="#" class="btn large" onClick="startActivity();">startActivity</a>
+    <a href="#" class="btn large" onClick="stopActivity();">stopActivity</a>
+    <h2>&nbsp;</h2><a href="index.html" class="backBtn">Back</a>
+  </body>
+</html>      
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/3248e663/example/www/pg_logo.png
----------------------------------------------------------------------
diff --git a/example/www/pg_logo.png b/example/www/pg_logo.png
deleted file mode 100644
index e864cdf..0000000
Binary files a/example/www/pg_logo.png and /dev/null differ


Mime
View raw message