{"id":6492,"date":"2014-02-07T15:49:12","date_gmt":"2014-02-07T07:49:12","guid":{"rendered":"http:\/\/mynotes.org\/tech\/?p=6492"},"modified":"2014-04-28T10:36:15","modified_gmt":"2014-04-28T02:36:15","slug":"%e5%9c%a8phonegap%e6%9e%b6%e6%a7%8b%e4%b8%8b%e7%9a%84%e6%9b%b8%e7%b1%a4bookmark%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/mynotes.org\/tech\/2014\/02\/07\/6492.htm","title":{"rendered":"\u5728phonegap\u67b6\u69cb\u4e0b\u7684\u66f8\u7c64bookmark\u529f\u80fd"},"content":{"rendered":"<p>\u5728\u52a0\u83f2\u8c93\u6f2b\u756b\u95b1\u8b80\u7a0b\u5f0f\u7684APP\u88e1\uff0c\u9700\u8981\u4e00\u500b\u66f8\u7c64\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u8a18\u9304\u8b80\u8005\u770b\u5230\u54ea\u88e1\uff0c\u4e0b\u6b21\u7e7c\u7e8c\u5f9e\u9019\u88e1\u770b\u8d77\u3002\u5efa\u7acb\u9019\u500b\u529f\u80fd\u7684\u89c0\u5ff5\u662f\uff1a\u7576\u4f7f\u7528\u8005\u6309\u4e0b\u66f8\u7c64\u7684\u529f\u80fd\u6642\uff0c\u7db2\u9801\u6703\u628a\u76ee\u524d\u7684\u7db2\u5740\u5beb\u9032\u66f8\u7c64\u8a18\u9304\u6a94\u3002\u7136\u5f8c\u7d22\u5f15\u9801\u7684\u756b\u9762\u6703\u6aa2\u67e5\u9019\u500b\u66f8\u7c64\u8a18\u9304\u6a94\uff0c\u5982\u679c\u6a94\u6848\u88e1\u9762\u6709\u8a18\u9304\u4e0b\u7db2\u5740\uff0c\u5c31\u5728\u7d22\u5f15\u9801\u51fa\u73fe\u300c\u4e0a\u6b21\u770b\u5230\u7684\u5730\u65b9\u300d\u7684\u9023\u7d50\u3002<\/p>\n<p><a href=\"http:\/\/mynotes.org\/tech\/wp-content\/uploads\/2014\/02\/Screenshots_20140212_013032.png\"><img decoding=\"async\" src=\"http:\/\/mynotes.org\/tech\/wp-content\/uploads\/2014\/02\/Screenshots_20140212_013032-639x1024.png\" alt=\"Screenshots_20140212_013032\" width=\"370\" class=\"aligncenter size-large wp-image-6493\" srcset=\"https:\/\/mynotes.org\/tech\/wp-content\/uploads\/2014\/02\/Screenshots_20140212_013032-639x1024.png 639w, https:\/\/mynotes.org\/tech\/wp-content\/uploads\/2014\/02\/Screenshots_20140212_013032-187x300.png 187w, https:\/\/mynotes.org\/tech\/wp-content\/uploads\/2014\/02\/Screenshots_20140212_013032.png 760w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/a><\/p>\n<p><!--more--><\/p>\n<p>\u57fa\u672c\u7684\u6a94\u6848\u5efa\u7acb\u8207\u8f38\u51fa\u3001\u8b80\u53d6\u529f\u80fd\uff0c\u662f\u63a1\u7528Phonegap (2.3)\u7684\u57fa\u672c\u529f\u80fd\uff0c\u8a9e\u6cd5\u8aaa\u660e\u53ef\u4ee5\u53c3\u8003<a href=\"http:\/\/docs.phonegap.com\/en\/2.3.0\/cordova_file_file.md.html#File\" target=\"_blank\">\u5b98\u65b9\u7db2\u7ad9<\/a>\u3002<\/p>\n<p>1.\u5148\u5728\u95b1\u8b80\u6bcf\u9031\u6f2b\u756b\u7684\u7db2\u9801\uff0c\u52a0\u5165\u4e00\u500b\u300c\u5efa\u7acb\u66f8\u7c64\u300d\u7684\u529f\u80fd<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n    function keepBookmark() {\r\n        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);\r\n    function gotFS(fileSystem) {\r\n        fileSystem.root.getFile(&quot;\/your\/dir\/yourfile.txt&quot;, {create: true, exclusive: false}, gotFileEntry, fail);\r\n    }\r\n    function gotFileEntry(fileEntry) {\r\n        fileEntry.createWriter(gotFileWriter, fail);\r\n    }\r\n    function gotFileWriter(writer) {\r\n        writer.write(window.location.href);\r\n\t\talert('\u6210\u529f\u52a0\u5165\u66f8\u7c64');\r\n    }\r\n    function fail(error) {\r\n        console.log(error.code);\r\n    }\r\n\t}\r\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u6703\u5728\u6309\u4e0b\u300c\u52a0\u5165\u66f8\u7c64\u300d\u7684\u6309\u9215\u5f8c\u958b\u59cb\u904b\u4f5c\uff0c\u7b2c4\u884c\u8acb\u8f38\u5165\u4f60\u8981\u5b58\u6a94\u7684\u4f4d\u7f6e\u548c\u6a94\u540d\uff0c\u7b2c10\u884c\u6703\u5c07\u76ee\u524d\u7684\u7db2\u5740\u5beb\u5165\u6a94\u6848\u4e2d\u3002<\/p>\n<p>\u300c\u52a0\u5165\u66f8\u7c64\u300d\u6309\u9215\u7684HTML\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;div data-role=&quot;footer&quot;  data-position=&quot;fixed&quot; data-theme=&quot;e&quot; &gt;\r\n &lt;div data-role=&quot;navbar&quot;&gt;\r\n &lt;ul data-inset=&quot;true&quot;&gt;\r\n &lt;li&gt;&lt;a href=&quot;#&quot; data-icon=&quot;star&quot; onClick=&quot;keepBookmark();&quot;\/&gt;Bookmark&lt;\/a&gt;&lt;\/li&gt;\r\n &lt;\/ul&gt;\r\n &lt;\/div&gt;&lt;!-- \/navbar --&gt;\r\n &lt;\/div&gt;&lt;!-- \/footer --&gt;\r\n<\/pre>\n<p>\u9019\u662f\u6211\u642d\u914dJquery mobile\u8981\u628a\u52a0\u5165\u66f8\u7c64\u529f\u80fd\u653e\u5728\u5e95\u90e8\u6309\u9215\u7684\u5beb\u6cd5\uff08\u5982\u4e0b\u5716\uff09\uff0c<br \/>\n<a href=\"http:\/\/mynotes.org\/tech\/wp-content\/uploads\/2014\/02\/Screenshots_20140212_012947.png\"><img decoding=\"async\" src=\"http:\/\/mynotes.org\/tech\/wp-content\/uploads\/2014\/02\/Screenshots_20140212_012947-639x1024.png\" alt=\"Screenshots_20140212_012947\" width=\"380\" class=\"aligncenter size-large wp-image-6494\" srcset=\"https:\/\/mynotes.org\/tech\/wp-content\/uploads\/2014\/02\/Screenshots_20140212_012947-639x1024.png 639w, https:\/\/mynotes.org\/tech\/wp-content\/uploads\/2014\/02\/Screenshots_20140212_012947-187x300.png 187w, https:\/\/mynotes.org\/tech\/wp-content\/uploads\/2014\/02\/Screenshots_20140212_012947.png 760w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/a><\/p>\n<p>\u5982\u679c\u53ea\u662f\u7c21\u55ae\u52a0\u500b\u6309\u9215\u53ef\u4ee5\u9019\u6a23\u5beb\uff1a<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;input type=&quot;button&quot; value=&quot;\u52a0\u5165\u66f8\u7c64&quot; onClick=&quot;keepBookmark();&quot;\/&gt;\r\n<\/pre>\n<p>2.\u5728\u60f3\u8981\u986f\u793a\u66f8\u7c64\u9023\u7d50\u7684\u9801\u9762\uff08\u6211\u662f\u653e\u5728\u6f2b\u756b\u7d22\u5f15\u7684\u9801\u9762\uff09\uff0c\u63d2\u5165\u8b80\u53d6\u6a94\u6848\u7684\u8a9e\u6cd5<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n    document.addEventListener(&quot;deviceready&quot;, onDeviceReady, false);\r\n    function onDeviceReady() {\r\n        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);\r\n    }\r\n    function gotFS(fileSystem) {\r\n        fileSystem.root.getFile(&quot;\/your\/dir\/yourfile.txt&quot;, null, gotFileEntry, fail);\r\n    }\r\n    function gotFileEntry(fileEntry) {\r\n        fileEntry.file(gotFile, fail);\r\n    }\r\n    function gotFile(file){\r\n        readAsText(file);\r\n    }\r\n    function readAsText(file) {\r\n        var reader = new FileReader();\r\n        reader.onloadend = function(evt) {\r\n            console.log(&quot;Read as text&quot;);\r\n            console.log(evt.target.result);\r\n\t\t    var linkURL = '&lt;li&gt;&lt;a href=&quot;'+evt.target.result+'&quot; rel=&quot;external&quot;&gt;\u4e0a\u6b21\u770b\u5230\u7684\u5730\u65b9&lt;\/a&gt;&lt;\/li&gt;';\r\n\t\t\tdocument.getElementById('linklist').innerHTML += linkURL;\r\n\t\t\t$('#linklist').listview('refresh');\r\n        };\r\n        reader.readAsText(file);\r\n    }\r\n    function fail(evt) {\r\n        console.log(evt.target.error.code);\r\n    }\r\n<\/pre>\n<p>\u8b80\u53d6\u6a94\u6848\u5167\u5bb9\u7684\u6a94\u540d\u5728\u7b2c6\u884c\uff0c\u7b2c19\u884c\u662f\u8981\u585e\u5165\u7db2\u9801\u7684\u6587\u5b57\uff0c\u8a2d\u5b9a\u662f\u585e\u5230id\u70balinklist\u7684\u5730\u65b9\u3002<\/p>\n<p>HTML\u53ea\u8981\u642d\u914d\u5beb\u500bdiv\u5c31\u53ef\u4ee5\u3002<\/p>\n<div id=\"linklist\"><\/div>\n<p>\u5982\u679c\u662f\u548c\u6211\u4e00\u6a23\u8981\u585e\u5728jquery mobile\u7684listview\u88e1\u9762\u7684\u8a71\uff0c\u8acb\u4e0d\u8981\u5fd8\u8a18\u7b2c21\u884c\u628alistview\u66f4\u65b0\u3002<\/p>\n<p>\u9019\u6a23\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u52a0\u83f2\u8c93\u6f2b\u756b\u95b1\u8b80\u7a0b\u5f0f\u7684APP\u88e1\uff0c\u9700\u8981\u4e00\u500b\u66f8\u7c64\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u8a18\u9304\u8b80\u8005\u770b\u5230\u54ea\u88e1\uff0c\u4e0b\u6b21\u7e7c\u7e8c\u5f9e\u9019\u88e1\u770b\u8d77\u3002\u5efa\u7acb\u9019\u500b\u529f\u80fd\u7684\u89c0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[126,131],"tags":[103,88,12,36,40,91,100],"class_list":["post-6492","post","type-post","status-publish","format-standard","hentry","category-android","category-app-android","tag-android0","tag-app","tag-garfield","tag-java","tag-java-scripts","tag-jquery-mobile","tag-phonegap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mynotes.org\/tech\/wp-json\/wp\/v2\/posts\/6492","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mynotes.org\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mynotes.org\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mynotes.org\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mynotes.org\/tech\/wp-json\/wp\/v2\/comments?post=6492"}],"version-history":[{"count":3,"href":"https:\/\/mynotes.org\/tech\/wp-json\/wp\/v2\/posts\/6492\/revisions"}],"predecessor-version":[{"id":6497,"href":"https:\/\/mynotes.org\/tech\/wp-json\/wp\/v2\/posts\/6492\/revisions\/6497"}],"wp:attachment":[{"href":"https:\/\/mynotes.org\/tech\/wp-json\/wp\/v2\/media?parent=6492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mynotes.org\/tech\/wp-json\/wp\/v2\/categories?post=6492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mynotes.org\/tech\/wp-json\/wp\/v2\/tags?post=6492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}