uploader_ret.html 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  6. <meta name="HandheldFriendly" content="true"/>
  7. <meta name="MobileOptimized" content="320"/>
  8. <title>Uploaded Data & File</title>
  9. <script type="text/javascript">
  10. // H5 plus事件处理
  11. var ret=null;
  12. function plusReady(){
  13. ret=plus.storage.getItem('uploader');
  14. update();
  15. // 添加删除按钮
  16. plus.webview.currentWebview().setStyle({titleNView: {
  17. buttons:[{
  18. fontSrc: '_www/helloh5.ttf',
  19. text: '\ue444',
  20. fontSize: '22px',
  21. onclick: 'javascript:deleteFiles()'
  22. }]
  23. }});
  24. }
  25. if(window.plus){
  26. plusReady();
  27. }else{
  28. document.addEventListener('plusready', plusReady, false);
  29. }
  30. // DOM事件
  31. var ce=null;
  32. document.addEventListener('DOMContentLoaded', function(){
  33. ce=document.getElementById('dcontent');
  34. update();
  35. }, false);
  36. // 更新内容
  37. var fs=null;
  38. function update(){
  39. if(!ret||!ce)return;
  40. var j=JSON.parse(ret);
  41. var ih='<br/>Datas:<br/><div style="text-align:left;padding:10px 2%;">';
  42. var ds=j.strings;
  43. for(d in ds){
  44. ih += d+' : '+ds[d]+'<br/>';
  45. }
  46. ih+='</div><hr/>Files:<br/><div id="fl">';
  47. fs=j.files;
  48. for(f in fs){
  49. ih += '<a class="fitem" onclick="plus.runtime.openURL(\'http://demo.dcloud.net.cn/helloh5/uploader/'+fs[f].url+'\')">'+fs[f].name+'</a>';
  50. }
  51. ih+='</div>';
  52. ce.innerHTML=ih;
  53. }
  54. // 清除上传返回的数据
  55. function resetUploader(){
  56. plus.storage.setItem('uploader', '');
  57. }
  58. // 删除上传的文件
  59. function deleteFiles(){
  60. var url='http://demo.dcloud.net.cn/helloh5/uploader/delete.php?';
  61. for(f in fs){
  62. url += f+'='+fs[f].name+'&';
  63. }
  64. var r=new plus.net.XMLHttpRequest();
  65. r.open('GET', url);
  66. r.send();
  67. document.getElementById('fl').innerHTML='';
  68. }
  69. </script>
  70. <script type="text/javascript" src="../js/common.js"></script>
  71. <style type="text/css">
  72. .fitem {
  73. width: 96%;
  74. overflow: hidden;
  75. padding: 10px 2%;
  76. border-bottom: 1px solid #c6c6c6;
  77. color: #6c6c6c;
  78. text-align: left;
  79. text-decoration: none;
  80. display: block;
  81. }
  82. .fitem:active {
  83. background: #f4f4f4;
  84. }
  85. .fname {
  86. font-weight: bolder;
  87. height: 22px;
  88. font-size: 16px;
  89. }
  90. </style>
  91. <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
  92. </head>
  93. <body>
  94. <div id="dcontent">
  95. </div>
  96. </body>
  97. </html>