events.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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>Hello H5+</title>
  9. <script type="text/javascript" src="../js/common.js"></script>
  10. <script type="text/javascript">
  11. if(window.plus){
  12. if(document.body){
  13. outLine( currentTimeString()+" HTML5 Plus已准备" );
  14. }else{
  15. document.addEventListener("DOMContentLoaded",function(){
  16. outLine( currentTimeString()+" HTML5 Plus已准备" );
  17. },false);
  18. }
  19. }else{
  20. document.addEventListener("plusready",function(){
  21. outLine( currentTimeString()+" HTML5 Plus已准备" );
  22. }, false );
  23. }
  24. document.addEventListener("pause",function(){
  25. outLine( currentTimeString()+" 应用从前台切换到后台" );
  26. }, false );
  27. document.addEventListener("resume",function(){
  28. outLine( currentTimeString()+" 应用从后台切换到前台" );
  29. }, false );
  30. document.addEventListener("netchange",function(){
  31. var types = {};
  32. types[plus.networkinfo.CONNECTION_UNKNOW] = "未知";
  33. types[plus.networkinfo.CONNECTION_NONE] = "未连接网络";
  34. types[plus.networkinfo.CONNECTION_ETHERNET] = "有线网络";
  35. types[plus.networkinfo.CONNECTION_WIFI] = "WiFi网络";
  36. types[plus.networkinfo.CONNECTION_CELL2G] = "2G蜂窝网络";
  37. types[plus.networkinfo.CONNECTION_CELL3G] = "3G蜂窝网络";
  38. types[plus.networkinfo.CONNECTION_CELL4G] = "4G蜂窝网络";
  39. outLine( currentTimeString()+" 切换网络:"+types[plus.networkinfo.getCurrentType()] );
  40. }, false );
  41. document.addEventListener("newintent",function(){
  42. outLine( currentTimeString()+" 从第三方应用启动:"+plus.runtime.arguments );
  43. }, false );
  44. function currentTimeString(){
  45. var d = new Date();
  46. return d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()+"."+d.getMilliseconds()+" - ";
  47. }
  48. </script>
  49. <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
  50. </head>
  51. <body>
  52. <br/>
  53. <p class="des">按“HOME”键切换应用触发“pause”和“resume”事件,在设置中改变网络配置触发“netchange”事件。</p>
  54. <br/>
  55. <div id="outpos"/>
  56. <div id="output">
  57. Events模块管理客户端事件,包括系统事件,如扩展API加载完毕、程序前后台切换等。<br/>
  58. </div>
  59. </body>
  60. </html>