http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/file/fileerror/fileerror.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/file/fileerror/fileerror.md b/www/docs/zh-cn/3.1.0/cordova/file/fileerror/fileerror.md new file mode 100644 index 0000000..3b9312e --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/file/fileerror/fileerror.md @@ -0,0 +1,48 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: FileError +--- + +# FileError + +A `FileError` ç©ä»¶æåºç¾é¯èª¤å¨æª API æ¹æ³ä¸çä»»ä½è¨ç½®ã + +## å±¬æ§ + +* **代碼**ï¼ ä¸é¢ååºçé å®ç¾©çé¯èª¤ä»£ç¢¼ä¹ä¸ã + +## 常é + +* `FileError.NOT_FOUND_ERR` +* `FileError.SECURITY_ERR` +* `FileError.ABORT_ERR` +* `FileError.NOT_READABLE_ERR` +* `FileError.ENCODING_ERR` +* `FileError.NO_MODIFICATION_ALLOWED_ERR` +* `FileError.INVALID_STATE_ERR` +* `FileError.SYNTAX_ERR` +* `FileError.INVALID_MODIFICATION_ERR` +* `FileError.QUOTA_EXCEEDED_ERR` +* `FileError.TYPE_MISMATCH_ERR` +* `FileError.PATH_EXISTS_ERR` + +## 說æ + +`FileError`ç©ä»¶æ¯æä¾çµ¦ä»»ä½æª API é¯èª¤åæªçå¯ä¸åæ¸ã è¥è¦ç¢ºå®é¯èª¤çé¡åï¼æ¯è¼å ¶ `code` 屬æ§è¨ç½®çºä»»ä½ä¸è¿°çç¯ç®è¡¨ã \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/file/fileobj/fileobj.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/file/fileobj/fileobj.md b/www/docs/zh-cn/3.1.0/cordova/file/fileobj/fileobj.md new file mode 100644 index 0000000..37801de --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/file/fileobj/fileobj.md @@ -0,0 +1,82 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: æª +--- + +# æª + +æ¤ç©ä»¶å å«çå®åæªç屬æ§ã + +## å±¬æ§ + +* **å稱**ï¼ æªçå稱ã*() DOMString* + +* **宿´è·¯å¾**ï¼ å æ¬æªæ¡åçæªç宿´è·¯å¾ã*() DOMString* + +* **é¡å**ï¼ æªç mime é¡åã*() DOMString* + +* **lastModifiedDate**ï¼ ä¸æ¬¡ä¿®æ¹è©²æªçæéã*ï¼æ¥æï¼* + +* **大å°**ï¼ ä»¥ä½å çµçºå®ä½çæªæ¡å¤§å°ã*(é·)* + +## æ¹æ³ + +* **åç**: å 鏿äºé¨åè¦è®åçæªã + +## 詳細è³è¨ + +`File`ç©ä»¶å å«å®åæªç屬æ§ãæ¨å¯ä»¥ç²åçå¯¦ä¾ `File` ç©ä»¶ééèª¿ç¨ `[FileEntry](../fileentry/fileentry.html)` ç©ä»¶ç `file()` æ¹æ³ã + +## æ¯æ´çå¹³èº + +* Android 系統 +* é»èææ© WebWorks ï¼OS 5.0 åæ´é«ï¼ +* iOS +* Windows Phone 7 å 8 +* Windows 8 + +## åç + +è¿åä¸åæ°ç `File` ç©ä»¶ï¼çºå ¶ `[FileReader](../filereader/filereader.html)` è¿ååªæè©²æªçæå®çé¨åã è² å¼è¨ç½®çº `start` æ `end` 測é徿ªçæ«å°¾ã ç¸å°æ¼ç¶ååçå®ä½çç´¢å¼ã ï¼è«åé±ä¸é¢ç宿´ç¤ºä¾ï¼ã + +**忏ï¼** + +* **éå§**ï¼ è¦é±è®ï¼å ·æå 容æ§ç第ä¸åä½å çµçç´¢å¼ã + +* **çµæ**: 徿å¾ä¸åè¦è®åçä½å çµçç´¢å¼ã + +**å¿«éç示ä¾** + + var slicedFile = file.slice(10, 30); + + +**宿´ç示ä¾** + + var slice1 = file.slice(100, 400); + var slice2 = slice1.slice(20, 35); + + var slice3 = file.slice(120, 135); + // slice2 and slice3 are equivalent. + + +**æ¯æ´çå¹³èº** + +* Android 系統 +* iOS \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/file/filereader/filereader.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/file/filereader/filereader.md b/www/docs/zh-cn/3.1.0/cordova/file/filereader/filereader.md new file mode 100644 index 0000000..c188ef1 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/file/filereader/filereader.md @@ -0,0 +1,259 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: FileReader +--- + +# FileReader + +`FileReader`å è¨±åºæ¬æªçå忬éã + +## å±¬æ§ + +* **readyState**ï¼ ä¸åè®è çä¸åå¯è½ççæ ï¼è¦éº¼ `EMPTY` ï¼ `LOADING` æ`DONE`. + +* **çµæ**ï¼ å·²è®åæªçå §å®¹ã*() DOMString* + +* **é¯èª¤**ï¼ å å«é¯èª¤çç©ä»¶ã*() FileError* + +* **onloadstart**: è®åååæèª¿ç¨ã*ï¼å½æ¸ï¼* + +* **onload**ï¼ è®åå·²æå宿æèª¿ç¨ã*ï¼å½æ¸ï¼* + +* **onabort**ï¼ ç¶å·²ä¸æ¢ï¼è®åæèª¿ç¨ãä¾å¦ï¼ééèª¿ç¨ `abort()` æ¹æ³ã*ï¼å½æ¸ï¼* + +* **onerror**: ç¶è®å已失ææèª¿ç¨ã*ï¼å½æ¸ï¼* + +* **onloadend**ï¼ ç¶è«æ±å·²å®æ ï¼ç¡è«æåæå¤±æï¼ æèª¿ç¨ã*ï¼å½æ¸ï¼* + +**注ï¼**以ä¸ç¢æ¬ä¸åæ¯æ´ï¼ + +* **onprogress**: è®å該æªï¼å ±åé²åº¦çè§åº¦æç¨±çº `progress.loaded` / `progress.total` ã*ï¼å½æ¸ï¼* + +## æ¹æ³ + +* **䏿¢**: 䏿¢è®åæªã + +* **readAsDataURL**: è®åæªä¸¦è¿åè³æä½çº base64 編碼çè³æç URLã + +* **readAsText**ï¼ æªä¸è®åææ¬ã + +* **readAsBinaryString**: è®åæªçºäºé²ä½æªæ¡ï¼ä¸¦è¿åä¸åäºé²ä½å串ã + +* **readAsArrayBuffer**: è®åæªä½çº`ArrayBuffer`. + +## 詳細è³è¨ + +`FileReader`ç©ä»¶æä¾çæ¹æ³ä¾å¾è©²è¨åçæªæ¡ç³»çµ±ä¸è®åæªã å¯ä»¥è®åæªï¼ä½çºææ¬æ base64 編碼çè³æçå串ã äºä»¶ææªå¨æ¥æ¶ `loadstart` ï¼ `progress` ï¼ `load` ï¼ `loadend` ï¼ `error` ï¼å `abort` çäºä»¶ã + +## æ¯æ´çå¹³èº + +* Android 系統 +* é»èææ© WebWorks ï¼OS 5.0 åæ´é«ï¼ +* iOS +* Windows Phone 7 å 8 +* Windows 8 + +## readAsDataURL + +**忏ï¼** + +* **æª**ï¼ è¦è®åçæªç©ä»¶ã + +## å¿«éçç¤ºä¾ + + function win(file) { + var reader = new FileReader(); + reader.onloadend = function (evt) { + console.log("read success"); + console.log(evt.target.result); + }; + reader.readAsDataURL(file); + }; + + var fail = function (error) { + console.log(error.code); + }; + + entry.file(win, fail); + + +## readAsText + +**忏ï¼** + +* **æª**ï¼ è¦è®åçæªç©ä»¶ã + +* **編碼**ï¼ ä½¿ç¨ç·¨ç¢¼çæªå §å®¹ç編碼ãé è¨å¼çº UTF8ã + +## å¿«éçç¤ºä¾ + + function win(file) { + var reader = new FileReader(); + reader.onloadend = function (evt) { + console.log("read success"); + console.log(evt.target.result); + }; + reader.readAsText(file); + }; + + var fail = function (error) { + console.log(error.code); + }; + + entry.file(win, fail); + + +## 䏿¢ + + function win(file) { + var reader = new FileReader(); + reader.onloadend = function(evt) { + console.log("read success"); + console.log(evt.target.result); + }; + reader.readAsText(file); + reader.abort(); + }; + + function fail(error) { + console.log(error.code); + } + + entry.file(win, fail); + + +## 宿´çç¤ºä¾ + + <!DOCTYPE html> + <html> + <head> + <title>FileReader Example</title> + + <script type="text/javascript" charset="utf-8" src="cordova.js"></script> + <script type="text/javascript" charset="utf-8"> + + // Wait for device API libraries to load + // + document.addEventListener("deviceready", onDeviceReady, false); + + // device APIs are available + // + function onDeviceReady() { + window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); + } + + function gotFS(fileSystem) { + fileSystem.root.getFile("readme.txt", null, gotFileEntry, fail); + } + + function gotFileEntry(fileEntry) { + fileEntry.file(gotFile, fail); + } + + function gotFile(file){ + readDataUrl(file); + readAsText(file); + } + + function readDataUrl(file) { + var reader = new FileReader(); + reader.onloadend = function(evt) { + console.log("Read as data URL"); + console.log(evt.target.result); + }; + reader.readAsDataURL(file); + } + + function readAsText(file) { + var reader = new FileReader(); + reader.onloadend = function(evt) { + console.log("Read as text"); + console.log(evt.target.result); + }; + reader.readAsText(file); + } + + function fail(error) { + console.log(error.code); + } + + </script> + </head> + <body> + <h1>Example</h1> + <p>Read File</p> + </body> + </html> + + +## iOS çæªç + +* **編碼**忏ä¸åæ¯æ´ï¼ä¸¦ä¸ UTF8 編碼總æ¯å¨ææã + +## readAsBinaryString + +ç®åå æ¯æ´ iOS å android 系統ã + +**忏ï¼** + +* **æª**ï¼ è¦è®åçæªç©ä»¶ã + +## å¿«éçç¤ºä¾ + + function win(file) { + var reader = new FileReader(); + reader.onloadend = function (evt) { + console.log("read success"); + console.log(evt.target.result); + }; + reader.readAsBinaryString(file); + }; + + var fail = function (error) { + console.log(error.code); + }; + + entry.file(win, fail); + + +## readAsArrayBuffer + +ç®åå æ¯æ´ iOS å android 系統ã + +**忏ï¼** + +* **æª**ï¼ è¦è®åçæªç©ä»¶ã + +## å¿«éçç¤ºä¾ + + function win(file) { + var reader = new FileReader(); + reader.onloadend = function (evt) { + console.log("read success"); + console.log(new Uint8Array(evt.target.result)); + }; + reader.readAsArrayBuffer(file); + }; + + var fail = function (error) { + console.log(error.code); + }; + + entry.file(win, fail); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/file/filesystem/filesystem.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/file/filesystem/filesystem.md b/www/docs/zh-cn/3.1.0/cordova/file/filesystem/filesystem.md new file mode 100644 index 0000000..bbcb7f9 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/file/filesystem/filesystem.md @@ -0,0 +1,91 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: æªæ¡ç³»çµ± +--- + +# æªæ¡ç³»çµ± + +æ¤ç©ä»¶è¡¨ç¤ºä¸åæªæ¡ç³»çµ±ã + +## å±¬æ§ + +* **å稱**ï¼ æªæ¡ç³»çµ±çå稱ã*() DOMString* + +* **æ ¹**ï¼ æªæ¡ç³»çµ±çæ ¹ç®éã*() DirectoryEntry* + +## 詳細è³è¨ + +`FileSystem`ç©ä»¶è¡¨ç¤ºæªæ¡ç³»çµ±çè³è¨ã æªæ¡ç³»çµ±çå稱çå ¬éçæªæ¡ç³»çµ±çæ¸ å®ä¸æ¯å¯ä¸çã æ ¹å±¬æ§å å« `DirectoryEntry` ç©ä»¶ï¼è¡¨ç¤ºæªæ¡ç³»çµ±çæ ¹ç®éã + +## æ¯æ´çå¹³èº + +* Android 系統 +* é»èææ© WebWorks ï¼OS 5.0 åæ´é«ï¼ +* iOS +* Windows Phone 7 å 8 +* Windows 8 + +## æªæ¡ç³»çµ±å¿«éç¤ºä¾ + + function onSuccess(fileSystem) { + console.log(fileSystem.name); + console.log(fileSystem.root.name); + } + + // request the persistent file system + window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, null); + + +## 宿´çç¤ºä¾ + + <!DOCTYPE html> + <html> + <head> + <title>File System Example</title> + + <script type="text/javascript" charset="utf-8" src="cordova.js"></script> + <script type="text/javascript" charset="utf-8"> + + // Wait for device API libraries to load + // + document.addEventListener("deviceready", onDeviceReady, false); + + // device APIs are available + // + function onDeviceReady() { + window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail); + } + + function onFileSystemSuccess(fileSystem) { + console.log(fileSystem.name); + console.log(fileSystem.root.name); + } + + function fail(evt) { + console.log(evt.target.error.code); + } + + </script> + </head> + <body> + <h1>Example</h1> + <p>File System</p> + </body> + </html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/file/filetransfer/filetransfer.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/file/filetransfer/filetransfer.md b/www/docs/zh-cn/3.1.0/cordova/file/filetransfer/filetransfer.md new file mode 100644 index 0000000..393e956 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/file/filetransfer/filetransfer.md @@ -0,0 +1,255 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: æªæ¡å³è¼¸ +--- + +# æªæ¡å³è¼¸ + +`FileTransfer`ç©ä»¶å è¨±ä½ ä¸å³æä¸è¼æªæ¡ï¼ä¼ºæå¨åç¨æ¶ç«¯ã + +## å±¬æ§ + +* **onprogress**ï¼ ä½¿ç¨èª¿ç¨ `ProgressEvent` æ¯ç¶ä¸å¡æ°çè³æå³è¼¸ã*ï¼å½æ¸ï¼* + +## æ¹æ³ + +* **ä¸å³**ï¼ å°æªç¼éå°ä¼ºæå¨ã + +* **ä¸è¼**ï¼ å¾ä¼ºæå¨ä¸ä¸è¼æªæ¡ã + +* **䏿¢**: 䏿¢æ£å¨é²è¡è½è®ã + +## 詳細è³è¨ + +`FileTransfer`ç©ä»¶æä¾ä¸ç¨®æ¹æ³å°æªä¸è¼å°é 端伺æå¨ä½¿ç¨å¤é¨åç HTTP POST è«æ±ã æ¯æ´ HTTP å HTTPS åå®ã å¯ä»¥ééæå®å¯é¸åæ¸ `[FileUploadOptions](../fileuploadoptions/fileuploadoptions.html)` ç©ä»¶ç `upload()` æ¹æ³ã ä¸å³æåï¼ `[FileUploadResult](../fileuploadresult/fileuploadresult.html)` ç©ä»¶å³é給æååæªã 妿ç¼çé¯èª¤ï¼ `[FileTransferError](../filetransfererror/filetransfererror.html)` ç©ä»¶å³éå°é¯èª¤åæªã å®ä¹æ¯å¯è½ç ï¼åªå¨ iOS å Androidï¼ å¾é 端伺æå¨ä¸è¼æªæ¡ä¸¦å°å ¶ä¿åå¨è¨åä¸ã + +## æ¯æ´çå¹³èº + +* Android 系統 +* é»èææ© WebWorks ï¼OS 5.0 åæ´é«ï¼ +* iOS +* Windows Phone 7 å 8 +* Windows 8 + +## ä¸å³ + +**忏ï¼** + +* **æªè·¯å¾**: è¨åä¸çæªç宿´è·¯å¾ã + +* **伺æå¨**ï¼ ä¼ºæå¨ä»¥æ¥æ¶è©²æªï¼ç±ç·¨ç¢¼ç URL`encodeURI()`. + +* **successCallback**ï¼ å³éä¸ååæª `Metadata` ç©ä»¶ã*ï¼å½æ¸ï¼* + +* **errorCallback**ï¼ åæªçå·è¡å¦æåºç¾æª¢ç´¢é¯èª¤ `Metadata` ã調ç¨è `[FileTransferError](../filetransfererror/filetransfererror.html)` ç©ä»¶ã*ï¼å½æ¸ï¼* + +* **é¸é **ï¼ æªæ¡å稱å mimetype çå¯é¸åæ¸ã + +* **trustAllHosts**: å¯é¸åæ¸ï¼é è¨å¼çº `false` ã 妿è¨ç½®çº `true` ï¼å®å¯ä»¥æ¥åçææå®å ¨èæ¸ã ç±æ¼ Android æçµèªè¡ç°½ç½²å¼å®å ¨èæ¸ï¼éé常æç¨ã ä¸å»ºè°ä¾çç¢ä½¿ç¨ã å¨ Android å iOS ä¸åæ¯æ´ã *(叿å¼)* + +**å¿«éç示ä¾** + + // !! Assumes variable fileURI contains a valid URI to a text file on the device + + var win = function (r) { + console.log("Code = " + r.responseCode); + console.log("Response = " + r.response); + console.log("Sent = " + r.bytesSent); + } + + var fail = function (error) { + alert("An error has occurred: Code = " + error.code); + console.log("upload error source " + error.source); + console.log("upload error target " + error.target); + } + + var options = new FileUploadOptions(); + options.fileKey = "file"; + options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1); + options.mimeType = "text/plain"; + + var params = {}; + params.value1 = "test"; + params.value2 = "param"; + + options.params = params; + + var ft = new FileTransfer(); + ft.upload(fileURI, encodeURI("http://some.server.com/upload.php"), win, fail, options); + + +**宿´ç示ä¾** + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> + <html> + <head> + <title>File Transfer Example</title> + + <script type="text/javascript" charset="utf-8" src="cordova.js"></script> + <script type="text/javascript" charset="utf-8"> + + // Wait for device API libraries to load + // + document.addEventListener("deviceready", onDeviceReady, false); + + // device APIs are available + // + function onDeviceReady() { + // Retrieve image file location from specified source + navigator.camera.getPicture( + uploadPhoto, + function(message) { alert('get picture failed'); }, + { + quality : 50, + destinationType : navigator.camera.DestinationType.FILE_URI, + sourceType : navigator.camera.PictureSourceType.PHOTOLIBRARY + } + ); + } + + function uploadPhoto(imageURI) { + var options = new FileUploadOptions(); + options.fileKey="file"; + options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1); + options.mimeType="image/jpeg"; + + var params = {}; + params.value1 = "test"; + params.value2 = "param"; + + options.params = params; + + var ft = new FileTransfer(); + ft.upload(imageURI, encodeURI("http://some.server.com/upload.php"), win, fail, options); + } + + function win(r) { + console.log("Code = " + r.responseCode); + console.log("Response = " + r.response); + console.log("Sent = " + r.bytesSent); + } + + function fail(error) { + alert("An error has occurred: Code = " + error.code); + console.log("upload error source " + error.source); + console.log("upload error target " + error.target); + } + + </script> + </head> + <body> + <h1>Example</h1> + <p>Upload File</p> + </body> + </html> + + +**è¨ç½®ä¸å³æ¨é ** + +å¨ Android å iOS ä¸åæ¯æ´ + + function win(r) { + console.log("Code = " + r.responseCode); + console.log("Response = " + r.response); + console.log("Sent = " + r.bytesSent); + } + + function fail(error) { + alert("An error has occurred: Code = " + error.code); + console.log("upload error source " + error.source); + console.log("upload error target " + error.target); + } + + var uri = encodeURI("http://some.server.com/upload.php"); + + var options = new FileUploadOptions(); + options.fileKey="file"; + options.fileName=fileURI.substr(fileURI.lastIndexOf('/')+1); + options.mimeType="text/plain"; + + var headers={'headerParam':'headerValue'}; + + options.headers = headers; + + var ft = new FileTransfer(); + ft.upload(fileURI, uri, win, fail, options); + + +**Android çæªç** + +è¨ç½® `chunkedMode` é¸é `false` ï¼é²æ¢å°ä¸è¼å° Nginx 伺æå¨çåé¡ã + +## ä¸è¼ + +**忏ï¼** + +* **便º**ï¼ è¦ä¸è¼çæªï¼å¦ç±ç·¨ç¢¼ç伺æå¨ç URL`encodeURI()`. + +* **ç®æ¨**ï¼ å¨è¨åä¸çæªç宿´è·¯å¾ã + +* **successCallback**ï¼ å³éä¸ååæª `[FileEntry](../fileentry/fileentry.html)` ç©ä»¶ã*ï¼å½æ¸ï¼* + +* **errorCallback**ï¼ å¦æé¯èª¤ç¼ç卿ª¢ç´¢æå°å·è¡çåæª `Metadata` ã調ç¨è `[FileTransferError](../filetransfererror/filetransfererror.html)` ç©ä»¶ã*ï¼å½æ¸ï¼* + +* **trustAllHosts**: å¯é¸åæ¸ï¼é è¨å¼çº `false` ã 妿è¨ç½®çº `true` ç¶å¾å®å°æ¥åææå®å ¨èæ¸ã é¨è Android æçµèªæç°½ç½²çå®å ¨èæ¸ï¼éé常æç¨ã ä¸å»ºè°ä¾çç¢ä½¿ç¨ã å¨ Android å iOS ä¸åæ¯æ´ã *(叿å¼)* + +* **é¸é **ï¼ å¯é¸åæ¸ï¼ç®ååªæ¯æ´æ¨é¡ ï¼å¦ææ¬ ï¼åºæ¬é©èï¼ çï¼ã + +**å¿«éç示ä¾** + + // !! å宿ªè·¯å¾æ¯è¨å var æªæ¡å³è¼¸çææè·¯å¾ = æ° FileTransfer() ï¼var uri = encodeURI ("HTTP://some.server.com/download.php"ï¼ ï¼fileTransfer.download (uriï¼æªè·¯å¾ï¼function(entry) {console.log ("ä¸è¼å®æï¼"+ entry.fullPathï¼ ï¼}ï¼function(error) {console.log ("ä¸è¼é¯èª¤æº"+ error.source) ï¼console.log ("ä¸è¼é¯èª¤ç®æ¨"+ error.target) ï¼console.log ("ä¸å³é¯èª¤ä»£ç¢¼"+ error.code) ï¼}ï¼falseï¼{æ¨é¡ï¼ {"ææ¬æ¸"ï¼"åºæ¬ dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA = ="}}) ï¼ + + +## 䏿¢ + +䏿¢æ£å¨é²è¡è½è®ãOnerror åæªå³éçé¯èª¤ä»£ç¢¼çº [FileTransferError](../filetransfererror/filetransfererror.html).ABORT_ERR ç [FileTransferError](../filetransfererror/filetransfererror.html) ç©ä»¶ã + +**æ¯æ´çå¹³èº** + +* Android 系統 +* iOS + +**å¿«éç示ä¾** + + // !! åå®è®æ¸ fileURI å 嫿æç URI å°ä¸åæåæªä¸ï¼å°è¨åç¡åè´ = function(r) {console.log ("ä¸æèª¿ç¨ã");}var 失æ = function(error) {/ / error.code = = FileTransferError.ABORT_ERR è¦å ± ("ç¼çäºä¸åé¯èª¤ï¼ 代碼 ="+ error.codeï¼ ï¼console.log ï¼"ä¸å³é¯èª¤æº"+ error.sourceï¼ ï¼console.log ("ä¸å³é¯èª¤ç®æ¨"+ error.target);}var é¸é = æ° FileUploadOptions() ï¼options.fileKey="file"ï¼options.fileName="myphoto.jpg"ï¼options.mimeType="image/jpeg"ï¼var ft = æ° FileTransfer() ï¼ft.upload ï¼fileURIã encodeURI ("HTTP://some.server.com/upload.php"ï¼ã è´ã 失æã é¸é ï¼ ï¼ft.abort() ï¼ + + +## onprogress + +æ¯ç¶æ°çè³æåå¡è½ç§»è ProgressEvent 調ç¨ã + +**æ¯æ´çå¹³èº** + +* Android 系統 +* iOS + +**示ä¾** + + fileTransfer.onprogress = function(progressEvent) { + if (progressEvent.lengthComputable) { + loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total); + } else { + loadingStatus.increment(); + } + }; + fileTransfer.download(...); // or fileTransfer.upload(...); + + +**æªç**-å¨éå ©åä¸å iOSï¼Android ä¸ lengthComputable æ¯ `false` ä½¿ç¨ gzip 已編碼çä¸è¼ã \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/file/filetransfererror/filetransfererror.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/file/filetransfererror/filetransfererror.md b/www/docs/zh-cn/3.1.0/cordova/file/filetransfererror/filetransfererror.md new file mode 100644 index 0000000..b626420 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/file/filetransfererror/filetransfererror.md @@ -0,0 +1,46 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: FileTransferError +--- + +# FileTransferError + +A `FileTransferError` ç©ä»¶å³éå°é¯èª¤åæªæåºç¾é¯èª¤ã + +## å±¬æ§ + +* **代碼**ï¼ ä¸é¢ååºçé å®ç¾©çé¯èª¤ä»£ç¢¼ä¹ä¸ãï¼äººæ¸ï¼ + +* **æº**ï¼ æº URIãï¼åä¸²ï¼ + +* **ç®æ¨**ï¼ åç®æ¨ URIãï¼åä¸²ï¼ + +* **HTTP_status**ï¼ HTTP çæ ç¢¼ãå¾ HTTP 飿¥æ¶å°ä¸ååæä»£ç¢¼æï¼æ¤å±¬æ§æå¯ç¨ãï¼äººæ¸ï¼ + +## 常é + +* `FileTransferError.FILE_NOT_FOUND_ERR` +* `FileTransferError.INVALID_URL_ERR` +* `FileTransferError.CONNECTION_ERR` +* `FileTransferError.ABORT_ERR` + +## 說æ + +`FileTransferError`ä¸å³æä¸è¼æªæ¡æåºç¾é¯èª¤æï¼å°ç©ä»¶å³éå°é¯èª¤åæªã \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/file/fileuploadoptions/fileuploadoptions.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/file/fileuploadoptions/fileuploadoptions.md b/www/docs/zh-cn/3.1.0/cordova/file/fileuploadoptions/fileuploadoptions.md new file mode 100644 index 0000000..557b189 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/file/fileuploadoptions/fileuploadoptions.md @@ -0,0 +1,47 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: FileUploadOptions +--- + +# FileUploadOptions + +A `FileUploadOptions` å¯ä»¥å°ç©ä»¶å³é給 `FileTransfer` ç©ä»¶ç `upload()` æ¹æ³ï¼ä»¥æå®ä¸è¼è ³æ¬çéå 忏ã + +## å±¬æ§ + +* **fileKey**ï¼ è¡¨å®å ç´ çå稱ãé è¨å¼çº `file` ã() DOMString + +* **æªæ¡å**ï¼ è¦ä¿åå¨ä¼ºæå¨ä¸çæªæä½¿ç¨çæªæ¡å稱ãé è¨å¼çº `image.jpg` ã() DOMString + +* **mimeType**ï¼ è¦ä¸å³çè³æç mime é¡åãé è¨å¼çº `image/jpeg` ã() DOMString + +* **params**ï¼ ä¸çµå¯é¸çéµ/å¼å°ä¸ç HTTP è¦æ±çå³éãï¼ç©ä»¶ï¼ + +* **chunkedMode**ï¼ æ¯å¦è¦å塿µå¼èçæ¨¡å¼ä¸çè³æä¸è¼ãé è¨å¼çº `true` ã(叿å¼) + +* **æ¨é¡**ï¼ ä¸å¼µå°åçæ¨é å稱/æ¨é å¼ã使ç¨é£å便å®å¤åå¼ãï¼ç©ä»¶ï¼ + +## 說æ + +A `FileUploadOptions` å¯ä»¥å°ç©ä»¶å³é給 `FileTransfer` ç©ä»¶ç `upload()` æ¹æ³ï¼ä»¥æå®ä¸è¼è ³æ¬çéå 忏ã + +## WP7 æªç + +* **chunkedModeï¼**ï¼ å¨ WP7 ä¸å¯ä»¥å¿½ç¥ã \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/file/fileuploadresult/fileuploadresult.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/file/fileuploadresult/fileuploadresult.md b/www/docs/zh-cn/3.1.0/cordova/file/fileuploadresult/fileuploadresult.md new file mode 100644 index 0000000..923c562 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/file/fileuploadresult/fileuploadresult.md @@ -0,0 +1,41 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: FileUploadResult +--- + +# FileUploadResult + +A `FileUploadResult` ç©ä»¶å³é給æååæªç `FileTransfer` ç©ä»¶ç `upload()` æ¹æ³ã + +## å±¬æ§ + +* **ä½å çµç¼é**ï¼ ä½çºä¸è¼çä¸é¨åç¼éå°ä¼ºæå¨çä½å çµæ¸ã(é·) + +* **responseCode**ï¼ ç±ä¼ºæå¨è¿åç HTTP åæä»£ç¢¼ã(é·) + +* **åæ**ï¼ ç±ä¼ºæå¨è¿åç HTTP åæã() DOMString + +## 說æ + +`FileUploadResult`ééæååæªçè¿åçç©ä»¶æ¯ `FileTransfer` ç©ä»¶ç `upload()` æ¹æ³ã + +## iOS çæªç + +* 䏿¯æ´ `responseCode` æ`bytesSent`. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/file/filewriter/filewriter.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/file/filewriter/filewriter.md b/www/docs/zh-cn/3.1.0/cordova/file/filewriter/filewriter.md new file mode 100644 index 0000000..2dc18ff --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/file/filewriter/filewriter.md @@ -0,0 +1,236 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: FileWriter +--- + +# FileWriter + +ä½çºç©ä»¶ï¼å®å 許æ¨åµå»ºååæªä¸å¯«å ¥è³æã + +## å±¬æ§ + +* **readyState**ï¼ ä¸ç¨®å¯è½çæ ä¹ä¸ï¼æè `INIT` ï¼ `WRITING` ï¼æ`DONE`. + +* **æªæ¡å**: è¦å¯«å ¥çæªçå稱ã*() DOMString* + +* **é·åº¦**ï¼ è¦å¯«å ¥çæªçé·åº¦ã*(é·)* + +* **ä½ç½®**ï¼ ç¶åæªææ¨çä½ç½®ã*(é·)* + +* **é¯èª¤**ï¼ å å«é¯èª¤çç©ä»¶ã*() FileError* + +* **onwritestart**ï¼ ç¶å¯«æä½éå§æèª¿ç¨ã*ï¼å½æ¸ï¼* + +* **onwrite**ï¼ ç¶è«æ±å·²æå宿æèª¿ç¨ã*ï¼å½æ¸ï¼* + +* **onabort**ï¼ ç¶å¯«æä½å·²ä¸æ¢æèª¿ç¨ãä¾å¦ï¼ééèª¿ç¨ abort () æ¹æ³ã*ï¼å½æ¸ï¼* + +* **onerror**ï¼ ç¶å¯«æä½å·²å¤±ææèª¿ç¨ã*ï¼å½æ¸ï¼* + +* **onwriteend**ï¼ ç¶è«æ±å·²å®æ ï¼ç¡è«æåæå¤±æï¼ æèª¿ç¨ã*ï¼å½æ¸ï¼* + +ä¸é¢ç屬æ§*ä¸*忝æ´ï¼ + +* **onprogress**ï¼ å¯«å ¥æªï¼å ±åé²åº¦çè§åº¦æç¨±çº `progress.loaded` / `progress.total` ã*ï¼å½æ¸ï¼* + +## æ¹æ³ + +* **䏿¢**: 䏿¢å¯«å ¥æªã + +* **å°æ±**ï¼ å°æªææ¨ç§»å°æå®çä½å çµã + +* **æªæ·**ï¼ ç¸®çè³æå®é·åº¦çæªã + +* **寫**ï¼ å°è³æå¯«å ¥å°è©²æªã + +## 詳細è³è¨ + +`FileWriter`ç©ä»¶æä¾ utf-8 編碼æªå¯«å ¥è¨åæªæ¡ç³»çµ±çæ¹æ³ã æç¨ç¨å¼åæ `writestart` ï¼ `progress` ï¼ `write` ï¼ `writeend` ï¼ `error` ï¼å `abort` çäºä»¶ã + +æ¯å `FileWriter` å°æäºä¸åæªä¸ï¼è³æå¯ä»¥è¢«å¯«å ¥è¨±å¤åã `FileWriter`ç¶è·çæª `position` å `length` 屬æ§ï¼å è¨±å° app `seek` å `write` æªä¸çä»»æä½ç½®ã é è¨æ æ³ä¸ï¼ `FileWriter` å°å¯«å ¥å°æªä¸ï¼è¦èç¾æè³æçéå§ã è¨ç½®å¯é¸ç `append` å°å¸æ `true` å¨ `FileWriter` ç建æ§å½å¼ä¾å¯«å ¥å°æªçæ«å°¾ã + +ä¸é¢ååºçææå¹³èºé½æ¯æ´ææ¬è³æã æ£å¨å¯«å ¥å°æªæ¡ç³»çµ±ä¹åææ¬ç·¨ç¢¼çº utf-8ã ä¸äºå¹³èºéæ¯æ´å¯ä»¥ä½çº ArrayBuffer æ Blob å³éä¸çäºé²ä½è³æã + +## æ¯æ´çå¹³èº + +ææ¬åäºé²ä½çæ¯æ´ï¼ + +* Android 系統 +* iOS + +å éææ¬çæ¯æ´ï¼ + +* é»èææ© WebWorks ï¼OS 5.0 åæ´é«ï¼ +* Windows Phone 7 å 8 +* Windows 8 + +## å°æ±å¿«éçç¤ºä¾ + + function win(writer) { + // fast forwards file pointer to end of file + writer.seek(writer.length); + }; + + var fail = function(evt) { + console.log(error.code); + }; + + entry.createWriter(win, fail); + + +## æªæ·å¿«éç¤ºä¾ + + function win(writer) { + writer.truncate(10); + }; + + var fail = function(evt) { + console.log(error.code); + }; + + entry.createWriter(win, fail); + + +## 寫快éç¤ºä¾ + + function win(writer) { + writer.onwrite = function(evt) { + console.log("write success"); + }; + writer.write("some sample text"); + }; + + var fail = function(evt) { + console.log(error.code); + }; + + entry.createWriter(win, fail); + + +## äºé²ä½æªæ¡å¯«å ¥å¿«éç¤ºä¾ + + function win(writer) { + var data = new ArrayBuffer(5), + dataView = new Int8Array(data); + for (i=0; i < 5; i++) { + dataView[i] = i; + } + writer.onwrite = function(evt) { + console.log("write success"); + }; + writer.write(data); + }; + + var fail = function(evt) { + console.log(error.code); + }; + + entry.createWriter(win, fail); + + +## 追å å¿«éç¤ºä¾ + + function win(writer) { + writer.onwrite = function(evt) { + console.log("write success"); + }; + writer.seek(writer.length); + writer.write("appended text"); + }; + + var fail = function(evt) { + console.log(error.code); + }; + + entry.createWriter(win, fail); + + +## 䏿¢å¿«éç¤ºä¾ + + function win(writer) { + writer.onwrite = function(evt) { + console.log("write success"); + }; + writer.write("some sample text"); + writer.abort(); + }; + + var fail = function(evt) { + console.log(error.code); + }; + + entry.createWriter(win, fail); + + +## 宿´çç¤ºä¾ + + <!DOCTYPE html> + <html> + <head> + <title>FileWriter Example</title> + + <script type="text/javascript" charset="utf-8" src="cordova.js"></script> + <script type="text/javascript" charset="utf-8"> + + // Wait for device API libraries to load + // + document.addEventListener("deviceready", onDeviceReady, false); + + // device APIs are available + // + function onDeviceReady() { + window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); + } + + 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"); + } + + function fail(error) { + console.log(error.code); + } + + </script> + </head> + <body> + <h1>Example</h1> + <p>Write File</p> + </body> + </html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/file/flags/flags.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/file/flags/flags.md b/www/docs/zh-cn/3.1.0/cordova/file/flags/flags.md new file mode 100644 index 0000000..694ed72 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/file/flags/flags.md @@ -0,0 +1,45 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: æ¨èª +--- + +# æ¨èª + +æä¾ç忏 `DirectoryEntry` ç©ä»¶ç `getFile()` å `getDirectory()` æ¹æ³ï¼æ¥æ¾æåµå»ºçæªåç®éï¼åå¥ã + +## å±¬æ§ + +* **åµå»º**ï¼ æç¤ºæåµå»ºçæªæç®éï¼æ¯å¦å®ä¸åå¨ã*ï¼å¸æï¼* + +* **ç¨å®¶**: å·²ç±æ¬èº«ï¼ä½èä¸èµ·ä½¿ç¨æä¸èµ·ä»»ä½ä½ç¨ `create` å°è´æªæç®éçåµå»ºï¼å¦æå·²ç¶åå¨çç®æ¨è·¯å¾å¤±æã*ï¼å¸æï¼* + +## æ¯æ´çå¹³èº + +* Android 系統 +* é»èææ© WebWorks ï¼OS 5.0 åæ´é«ï¼ +* iOS +* Windows Phone 7 å 8 +* Windows 8 + +## å¿«éçç¤ºä¾ + + / / ç²åè³æç®éï¼å¦æå®ä¸åå¨ï¼ååµå»ºå®ã + dataDir = fileSystem.root.getDirectory ï¼"è³æ"ï¼{åµå»º: true});/ / åµå»ºé宿ªï¼ç¶ä¸å ç¶å®ä¸åå¨ã + å份çé宿ª = dataDir.getFile ("lockfile.txt"ï¼{åµå»º: ç實ã ç¨å®¶ï¼ true}) ï¼ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/file/localfilesystem/localfilesystem.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/file/localfilesystem/localfilesystem.md b/www/docs/zh-cn/3.1.0/cordova/file/localfilesystem/localfilesystem.md new file mode 100644 index 0000000..a55d13a --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/file/localfilesystem/localfilesystem.md @@ -0,0 +1,132 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: å ´å +--- + +# å ´å + +æ¤ç©ä»¶æä¾ä¸åç²åæ ¹æªæ¡ç³»çµ±æ¹æ³ã + +## æ¹æ³ + +* **requestFileSystem**: è«æ±çæªæ¡ç³»çµ±ã*ï¼å½æ¸ï¼* + +* **resolveLocalFileSystemURI**: 檢索 `DirectoryEntry` æ `[FileEntry](../fileentry/fileentry.html)` 使ç¨ç¶å°ç URIã*ï¼å½æ¸ï¼* + +## 常é + +* `LocalFileSystem.PERSISTENT`ï¼ ç¨æ¼åå²ï¼ä¸æç±ä½¿ç¨è 代ç䏿ç¨ç¨å¼æä½¿ç¨è çè¨±å¯æ¬çæ æ³ä¸åªé¤ã + +* `LocalFileSystem.TEMPORARY`ï¼ ç¨æ¼ä¸è½ä¿èçæä¹ æ§åå²ã + +## 詳細è³è¨ + +`LocalFileSystem`ç©ä»¶çæ¹æ³å®ç¾©å¨ `window` ç©ä»¶ã + +## æ¯æ´çå¹³èº + +* Android 系統 +* é»èææ© WebWorks ï¼OS 5.0 åæ´é«ï¼ +* iOS +* Windows Phone 7 å 8 +* Windows 8 + +## è«æ±æªæ¡ç³»çµ±å¿«éç¤ºä¾ + + function onSuccess(fileSystem) { + console.log(fileSystem.name); + } + + // request the persistent file system + window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, onError); + + +## 解決æ¬å°æªæ¡ç³»çµ±ç URI å¿«éç¤ºä¾ + + function onSuccess(fileEntry) { + console.log(fileEntry.name); + } + + window.resolveLocalFileSystemURI("file:///example.txt", onSuccess, onError); + + +## 宿´çç¤ºä¾ + + <!DOCTYPE html> + <html> + <head> + <title>Local File System Example</title> + + <script type="text/javascript" charset="utf-8" src="cordova.js"></script> + <script type="text/javascript" charset="utf-8"> + + // Wait for device API libraries to load + // + document.addEventListener("deviceready", onDeviceReady, false); + + // device APIs are available + // + function onDeviceReady() { + window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail); + window.resolveLocalFileSystemURI("file:///example.txt", onResolveSuccess, fail); + } + + function onFileSystemSuccess(fileSystem) { + console.log(fileSystem.name); + } + + function onResolveSuccess(fileEntry) { + console.log(fileEntry.name); + } + + function fail(evt) { + console.log(evt.target.error.code); + } + + </script> + </head> + <body> + <h1>Example</h1> + <p>Local File System</p> + </body> + </html> + + +# requestFileSystem + +> è«æ±ä¸åæªæ¡ç³»çµ±ï¼ç¨ä¾å岿ç¨ç¨å¼è³æã + + window.requestFileSystem(type, size, successCallback, errorCallback) + + +* **è¦çª**ï¼ å°å ¨çè¦çªç©ä»¶çå¼ç¨ +* **é¡å**ï¼ æ¬å°æªæ¡ç³»çµ±é¡åï¼è«åè¦å ´åå¸¸æ¸ +* **大å°**ï¼ æç¤ºæç¨ç¨å¼ææéè¦å¤å°åå²ç©ºéï¼ä»¥ä½å çµçºå®ä½ï¼ +* **successCallback**ï¼ ä½¿ç¨ä¸åæªæ¡ç³»çµ±ç©ä»¶èª¿ç¨ +* **errorCallback**ï¼ å¦æç¼çé¯èª¤çæª¢ç´¢æªæ¡ç³»çµ±èª¿ç¨ + +## è«æ±æªæ¡ç³»çµ±å¿«éç¤ºä¾ + + function onSuccess(fileSystem) { + console.log(fileSystem.name); + } + + // request the persistent file system + window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, onError); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/file/metadata/metadata.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/file/metadata/metadata.md b/www/docs/zh-cn/3.1.0/cordova/file/metadata/metadata.md new file mode 100644 index 0000000..80f5e1e --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/file/metadata/metadata.md @@ -0,0 +1,50 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: ä¸ç¹¼è³æ +--- + +# ä¸ç¹¼è³æ + +ä¾æçæ è³è¨çæªæç®éçä¸åä»é¢ã + +## å±¬æ§ + +* **modificationTime**ï¼ ç¶æªæç®é被æå¾ä¿®æ¹çæéã*ï¼æ¥æï¼* + +## 詳細è³è¨ + +`Metadata`ç©ä»¶è¡¨ç¤ºæªæç®éççæ è³è¨ã èª¿ç¨ `DirectoryEntry` æ `[FileEntry](../fileentry/fileentry.html)` ç©ä»¶ç `getMetadata()` æ¹æ³å°ç¢ç `Metadata` 實ä¾ã + +## æ¯æ´çå¹³èº + +* Android 系統 +* é»èææ© WebWorks ï¼OS 5.0 åæ´é«ï¼ +* iOS +* Windows Phone 7 å 8 +* Windows 8 + +## å¿«éçç¤ºä¾ + + function win(metadata) { + console.log("Last Modified: " + metadata.modificationTime); + } + + // Request the metadata object for this entry + entry.getMetadata(win, null); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/geolocation/Coordinates/coordinates.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/geolocation/Coordinates/coordinates.md b/www/docs/zh-cn/3.1.0/cordova/geolocation/Coordinates/coordinates.md new file mode 100644 index 0000000..cde04fd --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/geolocation/Coordinates/coordinates.md @@ -0,0 +1,129 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: åº§æ¨ +--- + +# åº§æ¨ + +æè¿°ä½ç½®çå°ç座æ¨ç屬æ§éã + +## å±¬æ§ + +* **緯度**ï¼ ç·¯åº¦ä»¥åé²ä½åº¦çºå®ä½ã*ï¼äººæ¸ï¼* + +* **ç¶åº¦**: ç¶åº¦ä»¥åé²ä½åº¦çºå®ä½ã*ï¼äººæ¸ï¼* + +* **æµ·æé«åº¦**ï¼ é«åº¦å¨ç±³ä»¥ä¸æ©¢çé«ä¸çä½ç½®ã*ï¼äººæ¸ï¼* + +* **æºç¢ºæ§**ï¼ ä¸ç±³ç緯度åç¶åº¦åº§æ¨ç精度ç´å¥ã*ï¼äººæ¸ï¼* + +* **altitudeAccuracy**ï¼ å¨ç±³çæµ·æé«åº¦åº§æ¨ç精度ç´å¥ã*ï¼äººæ¸ï¼* + +* **æ¨é¡**ï¼ æ è¡ï¼æå®ä»¥åº¦çºå®ä½å æ¸ç®ç¸å°æ¼çåé æéæ¹åã*ï¼äººæ¸ï¼* + +* **é度**ï¼ ç¶åå°é¢é度çè¨åï¼æå®å¨ç±³æ¯ç§ã*ï¼äººæ¸ï¼* + +## 說æ + +`Coordinates`ç©ä»¶éå å° `Position` ç©ä»¶ï¼å¯ç¨æ¼å¨ç¶åè·ä½çè«æ±ä¸çåå¼å½æ¸ã + +## æ¯æ´çå¹³èº + +* Android 系統 +* é»èææ© WebWorks ï¼OS 5.0 åæ´é«ï¼ +* iOS +* Tizen +* Windows Phone 7 å 8 +* Windows 8 + +## å¿«éçç¤ºä¾ + + // onSuccess Callback + // + var onSuccess = function(position) { + alert('Latitude: ' + position.coords.latitude + '\n' + + 'Longitude: ' + position.coords.longitude + '\n' + + 'Altitude: ' + position.coords.altitude + '\n' + + 'Accuracy: ' + position.coords.accuracy + '\n' + + 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' + + 'Heading: ' + position.coords.heading + '\n' + + 'Speed: ' + position.coords.speed + '\n' + + 'Timestamp: ' + position.timestamp + '\n'); + }; + + // onError Callback + // + var onError = function() { + alert('onError!'); + }; + + navigator.geolocation.getCurrentPosition(onSuccess, onError); + + +## 宿´çç¤ºä¾ + + <!DOCTYPE html> + <html> + <head> + <title>Geolocation Position Example</title> + <script type="text/javascript" charset="utf-8" src="cordova.js"></script> + <script type="text/javascript" charset="utf-8"> + + // wait for device API libraries to load + // + document.addEventListener("deviceready", onDeviceReady, false); + + // device APIs are available + // + function onDeviceReady() { + navigator.geolocation.getCurrentPosition(onSuccess, onError); + } + + // Display `Position` properties from the geolocation + // + function onSuccess(position) { + var div = document.getElementById('myDiv'); + + div.innerHTML = 'Latitude: ' + position.coords.latitude + '<br/>' + + 'Longitude: ' + position.coords.longitude + '<br/>' + + 'Altitude: ' + position.coords.altitude + '<br/>' + + 'Accuracy: ' + position.coords.accuracy + '<br/>' + + 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '<br/>' + + 'Heading: ' + position.coords.heading + '<br/>' + + 'Speed: ' + position.coords.speed + '<br/>'; + } + + // Show an alert if there is a problem getting the geolocation + // + function onError() { + alert('onError!'); + } + + </script> + </head> + <body> + <div id="myDiv"></div> + </body> + </html> + + +## Android çæªç + +**altitudeAccuracy**: 䏿¯æ´ç Android è¨åï¼è¿å`null`. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/geolocation/Position/position.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/geolocation/Position/position.md b/www/docs/zh-cn/3.1.0/cordova/geolocation/Position/position.md new file mode 100644 index 0000000..4a22f51 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/geolocation/Position/position.md @@ -0,0 +1,117 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: ä½ç½® +--- + +# ä½ç½® + +å å« `Position` 座æ¨åæéæ³è¨ï¼ç±å°çä½ç½® API åµå»ºã + +## å±¬æ§ + +* **coords**ï¼ ä¸çµçå°ç座æ¨ã*ï¼åº§æ¨ï¼* + +* **æéæ³è¨**ï¼ åµå»ºæéæ³è¨çº `coords` ã*ï¼æ¥æï¼* + +## 說æ + +`Position`åµå»ºåå¡«å çç§ç¾å¤ç¦ï¼ä¸¦è¿åå°ä½¿ç¨è ééä¸ååå¼å½æ¸ç©ä»¶ã + +## æ¯æ´çå¹³èº + +* Android 系統 +* é»èææ© WebWorks ï¼OS 5.0 åæ´é«ï¼ +* iOS +* Tizen +* Windows Phone 7 å 8 +* Windows 8 + +## å¿«éçç¤ºä¾ + + // onSuccess Callback + // + var onSuccess = function(position) { + alert('Latitude: ' + position.coords.latitude + '\n' + + 'Longitude: ' + position.coords.longitude + '\n' + + 'Altitude: ' + position.coords.altitude + '\n' + + 'Accuracy: ' + position.coords.accuracy + '\n' + + 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' + + 'Heading: ' + position.coords.heading + '\n' + + 'Speed: ' + position.coords.speed + '\n' + + 'Timestamp: ' + position.timestamp + '\n'); + }; + + // onError Callback receives a PositionError object + // + function onError(error) { + alert('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); + } + + navigator.geolocation.getCurrentPosition(onSuccess, onError); + + +## 宿´çç¤ºä¾ + + <!DOCTYPE html> + <html> + <head> + <title>Device Properties Example</title> + + <script type="text/javascript" charset="utf-8" src="cordova.js"></script> + <script type="text/javascript" charset="utf-8"> + + // Wait for device API libraries to load + // + document.addEventListener("deviceready", onDeviceReady, false); + + // device APIs are available + // + function onDeviceReady() { + navigator.geolocation.getCurrentPosition(onSuccess, onError); + } + + // onSuccess Geolocation + // + function onSuccess(position) { + var element = document.getElementById('geolocation'); + element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' + + 'Longitude: ' + position.coords.longitude + '<br />' + + 'Altitude: ' + position.coords.altitude + '<br />' + + 'Accuracy: ' + position.coords.accuracy + '<br />' + + 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '<br />' + + 'Heading: ' + position.coords.heading + '<br />' + + 'Speed: ' + position.coords.speed + '<br />' + + 'Timestamp: ' + position.timestamp + '<br />'; + } + + // onError Callback receives a PositionError object + // + function onError(error) { + alert('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); + } + + </script> + </head> + <body> + <p id="geolocation">Finding geolocation...</p> + </body> + </html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/geolocation/PositionError/positionError.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/geolocation/PositionError/positionError.md b/www/docs/zh-cn/3.1.0/cordova/geolocation/PositionError/positionError.md new file mode 100644 index 0000000..aabda22 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/geolocation/PositionError/positionError.md @@ -0,0 +1,53 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: PositionError +--- + +# PositionError + +A `PositionError` ç©ä»¶å³é給 `[geolocationError](../parameters/geolocationError.html)` åæªæåºç¾é¯èª¤ã + +## å±¬æ§ + +* **代碼**ï¼ ä¸é¢ååºçé å®ç¾©çé¯èª¤ä»£ç¢¼ä¹ä¸ã + +* **æ¶æ¯**ï¼ æè¿°æéå°çé¯èª¤ç詳細è³è¨çé¯èª¤è¨æ¯ã + +## 常é + +* `PositionError.PERMISSION_DENIED` +* `PositionError.POSITION_UNAVAILABLE` +* `PositionError.TIMEOUT` + +## 說æ + +`PositionError`ç©ä»¶å³é給 `[geolocationError](../parameters/geolocationError.html)` èå°çå®ä½ç¼çé¯èª¤æçåå¼å½æ¸ã + +### `PositionError.PERMISSION_DENIED` + +è¿åç¶ä½¿ç¨è ä¸å 許æ¨çæç¨ç¨å¼æª¢ç´¢çä½ç½®è³è¨ã鿝忱ºæ¼å¹³èºã + +### `PositionError.POSITION_UNAVAILABLE` + +è¿åè¨åæï¼ä¸è½æª¢ç´¢çä½ç½®ãéå°±æå³è該è¨åæ²æç¶²è·¯é£æ¥å/æä¸è½å¾å°è¡æç修復ã + +### `PositionError.TIMEOUT` + +è¿åè¨åæï¼ç¡æ³å¨æå®çæéå §æª¢ç´¢ä½ç½® `[geolocationOptions](../parameters/geolocation.options.html)` ' `timeout` 屬æ§ã èä¸èµ·ä½¿ç¨æ `[geolocation.watchPosition](../geolocation.watchPosition.html)` ï¼æ¤é¯èª¤å¯è½å³é給 `[geolocationError](../parameters/geolocationError.html)` åæªæ¯ `timeout` 毫ç§çºå®ä½ï¼ã \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.clearWatch.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.clearWatch.md b/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.clearWatch.md new file mode 100644 index 0000000..6bf1104 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.clearWatch.md @@ -0,0 +1,114 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: geolocation.clearWatch +--- + +# geolocation.clearWatch + +åçå°æå¼ç¨çè¨åçä½ç½®æ´æ¹çº `watchID` 忏ã + + navigator.geolocation.clearWatch(watchID); + + +## 忏 + +* **watchID**ï¼ ç id `watchPosition` æ¸ é¤çæéééãï¼åä¸²ï¼ + +## 說æ + +`geolocation.clearWatch`å°åæ¢è§çå°è¨åçä½ç½®çæ´æ¹é鿏 é¤ `[geolocation.watchPosition](geolocation.watchPosition.html)` å¼ç¨ç`watchID`. + +## æ¯æ´çå¹³èº + +* Android 系統 +* é»èææ© WebWorks ï¼OS 5.0 åæ´é«ï¼ +* iOS +* Tizen +* Windows Phone 7 å 8 +* Windows 8 + +## å¿«éçç¤ºä¾ + + / / é¸é ï¼ ç£è¦çæ´æ¹çä½ç½®ï¼ä¸¦ä½¿ç¨æ / / æºç¢ºå®ä½æ¡éæ¹æ³å¯ç¨ã + // + var watchID = navigator.geolocation.watchPosition(onSuccess, onError, { enableHighAccuracy: true }); + + // ...later on... + + navigator.geolocation.clearWatch(watchID); + + +## 宿´çç¤ºä¾ + + <!DOCTYPE html> + <html> + <head> + <title>Device Properties Example</title> + + <script type="text/javascript" charset="utf-8" src="cordova.js"></script> + <script type="text/javascript" charset="utf-8"> + + // Wait for device API libraries to load + // + document.addEventListener("deviceready", onDeviceReady, false); + + var watchID = null; + + // device APIs are available + // + function onDeviceReady() { + // Get the most accurate position updates available on the + // device. + var options = { enableHighAccuracy: true }; + watchID = navigator.geolocation.watchPosition(onSuccess, onError, options); + } + + // onSuccess Geolocation + // + function onSuccess(position) { + var element = document.getElementById('geolocation'); + element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' + + 'Longitude: ' + position.coords.longitude + '<br />' + + '<hr />' + element.innerHTML; + } + + // clear the watch that was started earlier + // + function clearWatch() { + if (watchID != null) { + navigator.geolocation.clearWatch(watchID); + watchID = null; + } + } + + // onError Callback receives a PositionError object + // + function onError(error) { + alert('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); + } + + </script> + </head> + <body> + <p id="geolocation">Watching geolocation...</p> + <button onclick="clearWatch();">Clear Watch</button> + </body> + </html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.getCurrentPosition.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.getCurrentPosition.md b/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.getCurrentPosition.md new file mode 100644 index 0000000..d185e88 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.getCurrentPosition.md @@ -0,0 +1,126 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: geolocation.getCurrentPosition +--- + +# geolocation.getCurrentPosition + +è¿åè¨åçç¶åä½ç½®ä½çº `Position` ç©ä»¶ã + + navigator.geolocation.getCurrentPosition(geolocationSuccess, + [geolocationError], + [geolocationOptions]); + + +## 忏 + +* **geolocationSuccess**ï¼ å³éç¶åä½ç½®çåæªã + +* **geolocationError**ï¼ *ï¼å¯é¸ï¼*妿é¯èª¤ç¼çæå·è¡çåæªã + +* **geolocationOptions**ï¼ *ï¼å¯é¸ï¼*å°çå®ä½é¸é ã + +## 說æ + +`geolocation.getCurrentPosition`æ¯ä¸åé忥彿¸ã å®å°è¿åå°è©²è¨åçç¶åä½ç½® `[geolocationSuccess](parameters/geolocationSuccess.html)` åæªè `Position` ç©ä»¶ä½çºåæ¸ã 妿æé¯èª¤ï¼ `[geolocationError](parameters/geolocationError.html)` åæªéé `[PositionError](PositionError/positionError.html)` ç©ä»¶ã + +## æ¯æ´çå¹³èº + +* Android 系統 +* é»èææ© WebWorks ï¼OS 5.0 åæ´é«ï¼ +* iOS +* Tizen +* Windows Phone 7 å 8 +* Windows 8 + +## å¿«éçç¤ºä¾ + + // onSuccess Callback + // This method accepts a Position object, which contains the + // current GPS coordinates + // + var onSuccess = function(position) { + alert('Latitude: ' + position.coords.latitude + '\n' + + 'Longitude: ' + position.coords.longitude + '\n' + + 'Altitude: ' + position.coords.altitude + '\n' + + 'Accuracy: ' + position.coords.accuracy + '\n' + + 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' + + 'Heading: ' + position.coords.heading + '\n' + + 'Speed: ' + position.coords.speed + '\n' + + 'Timestamp: ' + position.timestamp + '\n'); + }; + + // onError Callback receives a PositionError object + // + function onError(error) { + alert('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); + } + + navigator.geolocation.getCurrentPosition(onSuccess, onError); + + +## 宿´çç¤ºä¾ + + <!DOCTYPE html> + <html> + <head> + <title>Device Properties Example</title> + + <script type="text/javascript" charset="utf-8" src="cordova.js"></script> + <script type="text/javascript" charset="utf-8"> + + // Wait for device API libraries to load + // + document.addEventListener("deviceready", onDeviceReady, false); + + // device APIs are available + // + function onDeviceReady() { + navigator.geolocation.getCurrentPosition(onSuccess, onError); + } + + // onSuccess Geolocation + // + function onSuccess(position) { + var element = document.getElementById('geolocation'); + element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' + + 'Longitude: ' + position.coords.longitude + '<br />' + + 'Altitude: ' + position.coords.altitude + '<br />' + + 'Accuracy: ' + position.coords.accuracy + '<br />' + + 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '<br />' + + 'Heading: ' + position.coords.heading + '<br />' + + 'Speed: ' + position.coords.speed + '<br />' + + 'Timestamp: ' + position.timestamp + '<br />'; + } + + // onError Callback receives a PositionError object + // + function onError(error) { + alert('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); + } + + </script> + </head> + <body> + <p id="geolocation">Finding geolocation...</p> + </body> + </html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.md b/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.md new file mode 100644 index 0000000..0251933 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.md @@ -0,0 +1,109 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: å°çå®ä½ +--- + +# å°çå®ä½ + +> `geolocation`ç©ä»¶æä¾å°åºæ¼è¨åç GPS ææå¨ææ¨æ·ç¶²è·¯ä¿¡èçä½ç½®è³æç訪åã + +`Geolocation`æä¾æé該è¨åçä½ç½®ï¼ä¾å¦ç·¯åº¦åç¶åº¦è³è¨ã 常è¦çä½ç½®è³è¨ä¾æºå æ¬å ¨çå®ä½ç³»çµ± (GPS) å網路信èï¼å¦ IP ä½åã RFIDã WiFi åèç MAC ä½åå GSM/CDMA å²åæ ¼ Id 徿¨æ·åºçä½ç½®ã æ²æä»»ä½ä¿èï¼API è¿åè¨åç實éä½ç½®ã + +æ¤ API åºæ¼[W3C å°çå®ä½ API è¦ç¯][1]ï¼ä¸¦åªå·è¡å·²ç¶ä¸æä¾å¯¦ç¾çè¨åä¸ã + + [1]: http://dev.w3.org/geo/api/spec-source.html + +**éè¦çé±ç§æ³¨ï¼**å°çå®ä½è³æçæ¶éåä½¿ç¨æåºäºéè¦çé±ç§åé¡ã æ¨çæç¨ç¨å¼çé±ç§æ¬ååæè©²è¨è«é款æç¨ç¨å¼å¦ä½ä½¿ç¨å°çå®ä½è³æï¼è³ææ¯å¦å ±ç¨å®çä»»ä½å ¶ä»ç· ç´æ¹åçè³æ ï¼ä¾å¦ï¼ç²ã ç´°ï¼ZIP 代碼ç´å¥ï¼ççï¼ ç精度水æºã å°çå®ä½è³æè¢«æ®éèªçºææçå çºå®è½æç¤ºä¸å人çä¸è½ï¼å¦æåå²ä¸ï¼ä»æå¥¹çæ è¡å²ã å æ¤ï¼é¤äºæ¨çæç¨ç¨å¼çé±ç§æ¬ååï¼æ¨æå¼·çèæ ®æä¾å¨æ¨çæç¨ç¨å¼è¨ªåå°çå®ä½è³æ ï¼å¦æè¨å使¥ç³»çµ±ä¸æé樣åå·²ç¶ï¼ ä¹åçæéåªæ¯éç¥ã 該éç¥ææä¾ç¸åçè³è¨ä¸ææåºç並ç²å該使ç¨è çè¨±å¯æ¬ ï¼ä¾å¦ï¼ééçº**確å®**並**䏿è¬**æåºç鏿ï¼ã æé詳細è³è¨ï¼è«åé±é±ç§æåã + +## æ¹æ³ + +* [geolocation.getCurrentPosition](geolocation.getCurrentPosition.html) +* [geolocation.watchPosition](geolocation.watchPosition.html) +* [geolocation.clearWatch](geolocation.clearWatch.html) + +## 忏 + +* [geolocationSuccess](parameters/geolocationSuccess.html) +* [geolocationError](parameters/geolocationError.html) +* [geolocationOptions](parameters/geolocation.options.html) + +## ç©ä»¶ ï¼å¯è®ï¼ + +* Position +* [PositionError](PositionError/positionError.html) +* Coordinates + +## 訪ååè½ + +å¾ 3.0 çï¼ç§ç¾å¤ç¦ä½çº*夿ç¨å¼*實ç¾äºè¨åç´ Apiã ä½¿ç¨ CLI ç `plugin` å½ä»¤ï¼æè¿°å¨å½ä»¤åä»é¢ï¼å¯ä»¥æ·»å æåªé¤ä¸åå°æ¡ï¼çºæ¤åè½ï¼ + + $ cordova plugin add org.apache.cordova.geolocation + $ cordova plugin ls + [ 'org.apache.cordova.geolocation' ] + $ cordova plugin rm org.apache.cordova.geolocation + + +éäºå½ä»¤é©ç¨äºæææéå°æ§çå¹³èºï¼ä½ä¿®æ¹å¦ä¸æè¿°çç¹å®äºå¹³èºçé ç½®è¨ç½®ï¼ + +* Android 系統 + + (in app/res/xml/config.xml) + <feature name="Geolocation"> + <param name="android-package" value="org.apache.cordova.GeoBroker" /> + </feature> + + (in app/AndroidManifest.xml) + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> + <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> + + +* é»èææ© WebWorks + + (in www/plugins.xml) + <feature name="Geolocation"> + <param name="blackberry-package" value="org.apache.cordova.geolocation.Geolocation" /> + </feature> + + (in www/config.xml) + <rim:permissions> + <rim:permit>read_geolocation</rim:permit> + </rim:permissions> + + +* ï¼å¨ iOS`config.xml`) + + <feature name="Geolocation"> + <param name="ios-package" value="CDVLocation" /> + </feature> + + +* ï¼å¨ Windows Phone`Properties/WPAppManifest.xml`) + + <Capabilities> + <Capability Name="ID_CAP_LOCATION" /> + </Capabilities> + + + å¼ç¨ï¼[çº Windows Phone æç¨ç¨å¼æ¸ å®][2] + + [2]: http://msdn.microsoft.com/en-us/library/ff769509%28v=vs.92%29.aspx + +ä¸äºå¹³èºå¯è½æ¯æ´æ¤åè½ï¼èç¡éä»»ä½ç¹æ®çé ç½®ãè«åè¦å¨æ¦è¿°é¨åä¸*çå¹³èºæ¯æ´*ã \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.watchPosition.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.watchPosition.md b/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.watchPosition.md new file mode 100644 index 0000000..05ec411 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/geolocation/geolocation.watchPosition.md @@ -0,0 +1,127 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: geolocation.watchPosition +--- + +# geolocation.watchPosition + +å°è©²è¨åçç¶åçä½ç½®æ´æ¹çæé¶ã + + var watchId = navigator.geolocation.watchPosition(geolocationSuccess, + [geolocationError], + [geolocationOptions]); + + +## 忏 + +* **geolocationSuccess**ï¼ å³éç¶åä½ç½®çåæªã + +* **geolocationError**ï¼ ï¼å¯é¸ï¼ 妿é¯èª¤ç¼çæå·è¡çåæªã + +* **geolocationOptions**ï¼ ï¼å¯é¸ï¼ å°çå®ä½é¸é ã + +## è¿å + +* **å串**ï¼ è¿åå¼ç¨çè§çä½ç½®ééç表 idãæèä¸èµ·ä½¿ç¨ç表 id `[geolocation.clearWatch](geolocation.clearWatch.html)` 忢äºè§çä¸ä½ç½®çæ´æ¹ã + +## 說æ + +`geolocation.watchPosition`æ¯ä¸åé忥彿¸ã ç¶æª¢æ¸¬å°ä½ç½®æ´æ¹æï¼å®è¿å該è¨åçç¶åçä½ç½®ã ç¶è¨å䏿ª¢ç´¢ä¸åæ°çä½ç½®ï¼ `[geolocationSuccess](parameters/geolocationSuccess.html)` åæªå·è¡è `Position` ç©ä»¶ä½çºåæ¸ã 妿æé¯èª¤ï¼ `[geolocationError](parameters/geolocationError.html)` åæªå·è¡è `[PositionError](PositionError/positionError.html)` ç©ä»¶ä½çºåæ¸ã + +## æ¯æ´çå¹³èº + +* Android 系統 +* é»èææ© WebWorks ï¼OS 5.0 åæ´é«ï¼ +* iOS +* Tizen +* Windows Phone 7 å 8 +* Windows 8 + +## å¿«éçç¤ºä¾ + + // onSuccess Callback + // This method accepts a `Position` object, which contains + // the current GPS coordinates + // + function onSuccess(position) { + var element = document.getElementById('geolocation'); + element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' + + 'Longitude: ' + position.coords.longitude + '<br />' + + '<hr />' + element.innerHTML; + } + + // onError Callback receives a PositionError object + // + function onError(error) { + alert('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); + } + + // Options: throw an error if no update is received every 30 seconds. + // + var watchID = navigator.geolocation.watchPosition(onSuccess, onError, { timeout: 30000 }); + + +## 宿´çç¤ºä¾ + + <!DOCTYPE html> + <html> + <head> + <title>Device Properties Example</title> + + <script type="text/javascript" charset="utf-8" src="cordova.js"></script> + <script type="text/javascript" charset="utf-8"> + + // Wait for device API libraries to load + // + document.addEventListener("deviceready", onDeviceReady, false); + + var watchID = null; + + // device APIs are available + // + function onDeviceReady() { + // Throw an error if no update is received every 30 seconds + var options = { timeout: 30000 }; + watchID = navigator.geolocation.watchPosition(onSuccess, onError, options); + } + + // onSuccess Geolocation + // + function onSuccess(position) { + var element = document.getElementById('geolocation'); + element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' + + 'Longitude: ' + position.coords.longitude + '<br />' + + '<hr />' + element.innerHTML; + } + + // onError Callback receives a PositionError object + // + function onError(error) { + alert('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); + } + + </script> + </head> + <body> + <p id="geolocation">Watching geolocation...</p> + </body> + </html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/geolocation/parameters/geolocation.options.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/geolocation/parameters/geolocation.options.md b/www/docs/zh-cn/3.1.0/cordova/geolocation/parameters/geolocation.options.md new file mode 100644 index 0000000..31cfed6 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/geolocation/parameters/geolocation.options.md @@ -0,0 +1,40 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: geolocationOptions +--- + +# geolocationOptions + +è¥è¦èªè¨çå°çå®ä½æª¢ç´¢çå¯é¸åæ¸`Position`. + + {maximumAge: 3000ï¼è¶ æï¼ 5000ï¼enableHighAccuracy: true} ï¼ + + +## é¸é + +* **enableHighAccuracy**ï¼ æä¾æç¨ç¨å¼éè¦æä½³çå¯è½çµæçæç¤ºã é è¨æ æ³ä¸ï¼è©²è¨åå°å試檢索 `Position` 使ç¨åºæ¼ç¶²è·¯çæ¹æ³ã å°æ¤å±¬æ§è¨ç½®çº `true` å訴è¦ä½¿ç¨æ´ç²¾ç¢ºçæ¹æ³ï¼å¦è¡æå®ä½çæ¡æ¶ã *(叿å¼)* + +* **è¶ æ**ï¼ æé (毫ç§) å¾èª¿ç¨å³éï¼å 許çæå¤§é·åº¦ `[geolocation.getCurrentPosition](../geolocation.getCurrentPosition.html)` æ `[geolocation.watchPosition](../geolocation.watchPosition.html)` ç´å°ç¸æç `[geolocationSuccess](geolocationSuccess.html)` åæªå·è¡ã 妿 `[geolocationSuccess](geolocationSuccess.html)` 䏿卿¤æéå §èª¿ç¨åæª `[geolocationError](geolocationError.html)` å³éåæª `[PositionError](../PositionError/positionError.html).TIMEOUT` é¯èª¤ä»£ç¢¼ã (è«æ³¨æï¼èä¸èµ·ä½¿ç¨æ `[geolocation.watchPosition](../geolocation.watchPosition.html)` ã `[geolocationError](geolocationError.html)` çæéééå¯ä»¥èª¿ç¨åæªæ¯ `timeout` 毫ç§!)*ï¼äººæ¸ï¼* + +* **maximumAge**ï¼ æ¥åå ¶å¹´é½¡å¤§æ¼æå®ä»¥æ¯«ç§çºå®ä½çæéæ²æç·©åçä½ç½®ã*ï¼äººæ¸ï¼* + +## Android çæªç + +Android 2.x 模æ¬å¨ä¸è¿åå°çå®ä½çµæé¤é `enableHighAccuracy` é¸é è¨ç½®çº`true`. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/geolocation/parameters/geolocationError.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/geolocation/parameters/geolocationError.md b/www/docs/zh-cn/3.1.0/cordova/geolocation/parameters/geolocationError.md new file mode 100644 index 0000000..d686755 --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/geolocation/parameters/geolocationError.md @@ -0,0 +1,34 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: geolocationError +--- + +# geolocationError + +ç¶æå°çå®ä½åè½é¯èª¤æå·è¡ç使ç¨è çåå¼å½æ¸ã + + function(error) { + // Handle the error + } + + +## 忏 + +* **é¯èª¤**: è¨åæè¿åçé¯èª¤ã*() PositionError* \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/a890e4de/www/docs/zh-cn/3.1.0/cordova/geolocation/parameters/geolocationSuccess.md ---------------------------------------------------------------------- diff --git a/www/docs/zh-cn/3.1.0/cordova/geolocation/parameters/geolocationSuccess.md b/www/docs/zh-cn/3.1.0/cordova/geolocation/parameters/geolocationSuccess.md new file mode 100644 index 0000000..61642cb --- /dev/null +++ b/www/docs/zh-cn/3.1.0/cordova/geolocation/parameters/geolocationSuccess.md @@ -0,0 +1,47 @@ +--- +license: > + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +title: geolocationSuccess +--- + +# geolocationSuccess + +使ç¨è çå°çä½ç½®è®å¾å¯ç¨æå·è¡çåå¼å½æ¸ ï¼ç¶å¾èª¿ç¨ `[geolocation.getCurrentPosition](../geolocation.getCurrentPosition.html)` ï¼ï¼æ ï¼ç¶å¾èª¿ç¨ä½ç½®çæ´æ¹æ`[geolocation.watchPosition](../geolocation.watchPosition.html)`). + + function(position) { + // Do something + } + + +## 忏 + +* **ä½ç½®**ï¼ è¿åè¨åçå°çä½ç½®ã*ï¼ä½ç½®ï¼* + +## ç¤ºä¾ + + function geolocationSuccess(position) { + alert('Latitude: ' + position.coords.latitude + '\n' + + 'Longitude: ' + position.coords.longitude + '\n' + + 'Altitude: ' + position.coords.altitude + '\n' + + 'Accuracy: ' + position.coords.accuracy + '\n' + + 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' + + 'Heading: ' + position.coords.heading + '\n' + + 'Speed: ' + position.coords.speed + '\n' + + 'Timestamp: ' + position.timestamp + '\n'); + } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org