Shazron Abdullah 12 anni fa
parent
commit
57afa6e3f4
3 ha cambiato i file con 117 aggiunte e 226 eliminazioni
  1. 50 129
      example/index.html
  2. 67 0
      example/index.js
  3. 0 97
      example/master.css

+ 50 - 129
example/index.html

@@ -1,131 +1,52 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+         "http://www.w3.org/TR/html4/strict.dtd">
 <html>
-  <head>
-	<!-- Change this if you want to allow scaling -->
-    <meta name="viewport" content="width=default-width; user-scalable=no" />
-
-    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
-
-    <title></title>
-	
-	<!-- iPad/iPhone specific css below, add after your main css >
-	<link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="ipad.css" type="text/css" />		
-	<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone.css" type="text/css" />		
-	-->
-	<script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"></script>
-	<script type="text/javascript" charset="utf-8" src="keychain.js"></script>
-    <script type="text/javascript" charset="utf-8">
-
-
-	// If you want to prevent dragging, uncomment this section
-	/*
-	function preventBehavior(e) 
-	{ 
-      e.preventDefault(); 
-    };
-	document.addEventListener("touchmove", preventBehavior, false);
-	*/
-	
-	function onBodyLoad()
-	{
-		document.addEventListener("deviceready", onDeviceReady,false);
-	}
-	
-	/* When this function is called, PhoneGap has been initialized and is ready to roll */
-	function onDeviceReady()
-	{
-		try {
-		
-			// do your thing!
-		
-		} catch (e) {
-			debug.error(e);
-		}
-	}
-	
-	function onGet()
-	{
-       var kc = cordova.require("cordova/plugin/keychain");
-        
-	   var key = document.getElementById("keytoget").value;
-	   var servicename = document.getElementById("servicename").value
-	   
-	   var win = function(value) {
-			alert("GET SUCCESS - Key: " + key + " Value: " + value);
-	   };
-	   var fail = function(error) {
-			alert("GET FAIL - Key: " + key + " Error: " + error);
-	   };
-	   
-	   kc.getForKey(win, fail, key, servicename);
-	}
-
-	function onSet()
-	{
-       var kc = cordova.require("cordova/plugin/keychain");
-
-	   var key = document.getElementById("keytoset").value;
-	   var value = document.getElementById("valuetoset").value;
-	   var servicename = document.getElementById("servicename").value;
-	   
-	   var win = function() {
-			alert("SET SUCCESS - Key: " + key);
-	   };
-	   var fail = function(error) {
-			alert("SET FAIL - Key: " + key + " Error: " + error);
-	   };
-	   
-	   kc.setForKey(win, fail, key, servicename, value);
-	}
-
-	function onRemove()
-	{
-       var kc = cordova.require("cordova/plugin/keychain");
-        
-	   var key = document.getElementById("keytoremove").value;
-	   var servicename = document.getElementById("servicename").value
-	   
-	   var win = function() {
-			alert("REMOVE SUCCESS - Key: " + key);
-	   };
-	   var fail = function(error) {
-			alert("REMOVE FAIL - Key: " + key + " Error: " + error);
-	   };
-	   
-	   kc.removeForKey(win, fail, key, servicename);
-	}
-    
-    </script>
-  </head>
-  <body onload="onBodyLoad()">
-  
-  <div style="color:red">(using servicename <input type="text" value="GOLDILOCKS" id="servicename" />)</div>
-
-  <hr>
-  <br />
-
-  <div> GET FROM KEYCHAIN </div>
-  <br />
-  <label for="keytoget">Key to Get&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="keytoget" value="ILLUMINATI" /></label>
-  <button onclick="onGet();">GET</button>
-
-  <br />
-  <hr />
-  <br />
-
-  <div> SET TO KEYCHAIN </div>  <br />
-
-  <label for="keytoset">Key to Set&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="keytoset" value="ILLUMINATI"/></label>  <br />
-  <label for="valuetoset">Value to Set <input type="text" id="valuetoset" value="SEKRIT" /></label>
-  <button onclick="onSet();">SET</button>
-
-  <br />
-  <hr />
-  <br />
-  <div> REMOVE FROM KEYCHAIN </div>  <br />
-
-  <label for="keytoremove">Key to Remove<input type="text" id="keytoremove" value="ILLUMINATI"/></label> 
-  <button onclick="onRemove();">DEL</button>
-	
-  </body>
+        <head>
+                <!-- Change this if you want to allow scaling -->
+                <meta name="viewport" content="width=default-width; user-scalable=no">
+                <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+                <title></title>
+
+                <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
+                <script type="text/javascript" charset="utf-8" src="index.js"></script>
+        </head>
+        <body onload="onBodyLoad()">
+                <div style="color:red">
+                        (using servicename <input type="text" value="GOLDILOCKS" id="servicename">)
+                </div>
+                <hr>
+                <p>
+                        <br>
+                </p>
+                <div>
+                        GET FROM KEYCHAIN
+                </div>
+                <p>
+                        <br>
+                        <label for="keytoget">Key to Get&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="keytoget" value="ILLUMINATI"></label> <button onclick="onGet();">GET</button><br>
+                </p>
+                <hr>
+                <p>
+                        <br>
+                </p>
+                <div>
+                        SET TO KEYCHAIN
+                </div>
+                <p>
+                        <br>
+                        <label for="keytoset">Key to Set&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="keytoset" value="ILLUMINATI"></label><br>
+                        <label for="valuetoset">Value to Set <input type="text" id="valuetoset" value="SEKRIT"></label> <button onclick="onSet();">SET</button><br>
+                </p>
+                <hr>
+                <p>
+                        <br>
+                </p>
+                <div>
+                        REMOVE FROM KEYCHAIN
+                </div>
+                <p>
+                        <br>
+                        <label for="keytoremove">Key to Remove<input type="text" id="keytoremove" value="ILLUMINATI"></label> <button onclick="onRemove();">DEL</button>
+                </p>
+        </body>
 </html>

+ 67 - 0
example/index.js

@@ -0,0 +1,67 @@
+/*
+PRE-REQUISITE: Install the Keychain plugin using the Cordova cli or plugman
+*/
+
+function onBodyLoad() {
+    document.addEventListener("deviceready", onDeviceReady, false);
+}
+
+/* When this function is called, PhoneGap has been initialized and is ready to roll */
+
+function onDeviceReady() {
+    try {
+
+        // do your thing!
+    } catch (e) {
+        debug.error(e);
+    }
+}
+
+function onGet() {
+    var kc = new Keychain();
+
+    var key = document.getElementById("keytoget").value;
+    var servicename = document.getElementById("servicename").value
+
+    var win = function(value) {
+            alert("GET SUCCESS - Key: " + key + " Value: " + value);
+        };
+    var fail = function(error) {
+            alert("GET FAIL - Key: " + key + " Error: " + error);
+        };
+
+    kc.getForKey(win, fail, key, servicename);
+}
+
+function onSet() {
+    var kc = new Keychain();
+
+    var key = document.getElementById("keytoset").value;
+    var value = document.getElementById("valuetoset").value;
+    var servicename = document.getElementById("servicename").value;
+
+    var win = function() {
+            alert("SET SUCCESS - Key: " + key);
+        };
+    var fail = function(error) {
+            alert("SET FAIL - Key: " + key + " Error: " + error);
+        };
+
+    kc.setForKey(win, fail, key, servicename, value);
+}
+
+function onRemove() {
+    var kc = new Keychain();
+
+    var key = document.getElementById("keytoremove").value;
+    var servicename = document.getElementById("servicename").value
+
+    var win = function() {
+            alert("REMOVE SUCCESS - Key: " + key);
+        };
+    var fail = function(error) {
+            alert("REMOVE FAIL - Key: " + key + " Error: " + error);
+        };
+
+    kc.removeForKey(win, fail, key, servicename);
+}

+ 0 - 97
example/master.css

@@ -1,97 +0,0 @@
-
-body {
-  background:#222 none repeat scroll 0 0;
-  color:#666;
-  font-family:Helvetica;
-  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;
-}
-
-#info h4{
-  font-size:.95em;
-  margin:0;
-  padding:0;
-}
-
-#stage.theme{
-  padding-top:3px;
-}
-
-/* Definition List */
-#Page1 > dl{
-	padding-top:10px;
-	clear:both;
-	margin:0;
-	list-style-type:none;
-	padding-left:10px;
-	overflow:auto;
-}
-
-#Page1 > dl > dt{
-	font-weight:bold;
-	float:left;
-	margin-left:5px;
-}
-
-#Page1 > dl > dd{
-	width:45px;
-	float:left;
-	color:#a87;
-	font-weight:bold;
-}
-
-/* Content Styling */
-h1, h2, p{
-  margin:1em 0 .5em 13px;
-}
-
-h1{
-  color:#eee;
-  font-size:1.6em;
-  text-align:center;
-  margin:0;
-  margin-top:15px;
-  padding:0;
-}
-
-h2{
-	clear:both;
-  margin:0;
-  padding:3px;
-  font-size:1em;
-  text-align:center;
-}
-
-/* Stage Buttons */
-#stage.theme a.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 a.btn.large{
-	width:308px;
-	padding:1.2em 0;
-}