incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [17/29] git commit: FileWriter example app needs to be rewritten as async
Date Thu, 12 Jan 2012 20:14:00 GMT
FileWriter example app needs to be rewritten as async


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/commit/c93f2d2b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/tree/c93f2d2b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/diff/c93f2d2b

Branch: refs/heads/master
Commit: c93f2d2ba7110914ce91939af33f5091b4db4973
Parents: 64b5588
Author: macdonst <simon.macdonald@gmail.com>
Authored: Thu Jan 5 04:33:03 2012 +0800
Committer: Fil Maj <filip.maj@nitobi.com>
Committed: Thu Jan 12 12:13:44 2012 -0800

----------------------------------------------------------------------
 .../1.3.0/phonegap/file/filewriter/filewriter.md   |   58 ++++++++-------
 .../en/edge/phonegap/file/filewriter/filewriter.md |   58 ++++++++-------
 2 files changed, 60 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/c93f2d2b/docs/en/1.3.0/phonegap/file/filewriter/filewriter.md
----------------------------------------------------------------------
diff --git a/docs/en/1.3.0/phonegap/file/filewriter/filewriter.md b/docs/en/1.3.0/phonegap/file/filewriter/filewriter.md
index 55ca32b..c8d220d 100644
--- a/docs/en/1.3.0/phonegap/file/filewriter/filewriter.md
+++ b/docs/en/1.3.0/phonegap/file/filewriter/filewriter.md
@@ -124,50 +124,52 @@ Full Example
     <html>
       <head>
         <title>FileWriter Example</title>
-
-        <script type="text/javascript" charset="utf-8" src="phonegap.0.9.4.js"></script>
+    
+        <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
         <script type="text/javascript" charset="utf-8">
-
+    
         // Wait for PhoneGap to load
         //
         document.addEventListener("deviceready", onDeviceReady, false);
-
+    
         // PhoneGap is ready
         //
         function onDeviceReady() {
-			window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
+            window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
         }
-		
-		function gotFS(fileSystem) {
-			fileSystem.root.getFile("readme.txt", null, gotFileEntry, fail);
-		}
-		
-		function gotFileEntry(fileEntry) {
-			fileEntry.createWriter(gotFileWriter, fail);
-		}
-		
-		function gotFileWriter(writer) {
-	        writer.onwrite = function(evt) {
-                console.log("write success");
+    
+        function gotFS(fileSystem) {
+            fileSystem.root.getFile("readme.txt", {create: true, exclusive: false}, gotFileEntry,
fail);
+        }
+    
+        function gotFileEntry(fileEntry) {
+            fileEntry.createWriter(gotFileWriter, fail);
+        }
+    
+        function gotFileWriter(writer) {
+            writer.onwriteend = function(evt) {
+                console.log("contents of file now 'some sample text'");
+                writer.truncate(11);  
+                writer.onwriteend = function(evt) {
+                    console.log("contents of file now 'some sample'");
+                    writer.seek(4);
+                    writer.write(" different text");
+                    writer.onwriteend = function(evt){
+                        console.log("contents of file now 'some different text'");
+                    }
+                };
             };
             writer.write("some sample text");
-			// contents of file now 'some sample text'
-			writer.truncate(11);
-			// contents of file now 'some sample'
-			writer.seek(4);
-			// contents of file still 'some sample' but file pointer is after the 'e' in 'some'
-			writer.write(" different text");
-			// contents of file now 'some different text'
-		}
-        
+        }
+    
         function fail(error) {
             console.log(error.code);
         }
-        
+    
         </script>
       </head>
       <body>
         <h1>Example</h1>
         <p>Write File</p>
       </body>
-    </html>
+    </html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/c93f2d2b/docs/en/edge/phonegap/file/filewriter/filewriter.md
----------------------------------------------------------------------
diff --git a/docs/en/edge/phonegap/file/filewriter/filewriter.md b/docs/en/edge/phonegap/file/filewriter/filewriter.md
index 55ca32b..c8d220d 100644
--- a/docs/en/edge/phonegap/file/filewriter/filewriter.md
+++ b/docs/en/edge/phonegap/file/filewriter/filewriter.md
@@ -124,50 +124,52 @@ Full Example
     <html>
       <head>
         <title>FileWriter Example</title>
-
-        <script type="text/javascript" charset="utf-8" src="phonegap.0.9.4.js"></script>
+    
+        <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
         <script type="text/javascript" charset="utf-8">
-
+    
         // Wait for PhoneGap to load
         //
         document.addEventListener("deviceready", onDeviceReady, false);
-
+    
         // PhoneGap is ready
         //
         function onDeviceReady() {
-			window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
+            window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
         }
-		
-		function gotFS(fileSystem) {
-			fileSystem.root.getFile("readme.txt", null, gotFileEntry, fail);
-		}
-		
-		function gotFileEntry(fileEntry) {
-			fileEntry.createWriter(gotFileWriter, fail);
-		}
-		
-		function gotFileWriter(writer) {
-	        writer.onwrite = function(evt) {
-                console.log("write success");
+    
+        function gotFS(fileSystem) {
+            fileSystem.root.getFile("readme.txt", {create: true, exclusive: false}, gotFileEntry,
fail);
+        }
+    
+        function gotFileEntry(fileEntry) {
+            fileEntry.createWriter(gotFileWriter, fail);
+        }
+    
+        function gotFileWriter(writer) {
+            writer.onwriteend = function(evt) {
+                console.log("contents of file now 'some sample text'");
+                writer.truncate(11);  
+                writer.onwriteend = function(evt) {
+                    console.log("contents of file now 'some sample'");
+                    writer.seek(4);
+                    writer.write(" different text");
+                    writer.onwriteend = function(evt){
+                        console.log("contents of file now 'some different text'");
+                    }
+                };
             };
             writer.write("some sample text");
-			// contents of file now 'some sample text'
-			writer.truncate(11);
-			// contents of file now 'some sample'
-			writer.seek(4);
-			// contents of file still 'some sample' but file pointer is after the 'e' in 'some'
-			writer.write(" different text");
-			// contents of file now 'some different text'
-		}
-        
+        }
+    
         function fail(error) {
             console.log(error.code);
         }
-        
+    
         </script>
       </head>
       <body>
         <h1>Example</h1>
         <p>Write File</p>
       </body>
-    </html>
+    </html>
\ No newline at end of file


Mime
View raw message