shortcut.js 908 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. (function(w){
  2. document.addEventListener('plusready',function(){
  3. checkArguments();
  4. },false);
  5. // 判断启动方式
  6. function checkArguments(){
  7. console.log("Shortcut-plus.runtime.launcher: "+plus.runtime.launcher);
  8. if(plus.runtime.launcher=='shortcut'){
  9. try{
  10. var cmd = JSON.parse(plus.runtime.arguments);
  11. console.log("Shortcut-plus.runtime.arguments: "+plus.runtime.arguments)
  12. var type=cmd&&cmd.type;
  13. switch(type){
  14. case 'share':
  15. openWebview('plus/share.html');
  16. break;
  17. case 'about':
  18. openWebview('about.html','zoom-fade-out',true);
  19. break;
  20. default:
  21. break;
  22. }
  23. }catch(e){
  24. console.log("Shortcut-exception: "+e);
  25. }
  26. }
  27. }
  28. // 打开页面
  29. function openWebview(id,a,s){
  30. if(!_openw||_openw.id!=id){
  31. clicked(id,a,s);
  32. }
  33. }
  34. // 处理从后台恢复
  35. document.addEventListener('newintent',function(){
  36. console.log("Shortcut-newintent");
  37. checkArguments();
  38. },false);
  39. })(window);