game9g.utils.js 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. if( typeof(game9g)=="undefined"){
  2. game9g={};
  3. }
  4. if(!game9g.utils){
  5. game9g.utils={};
  6. }
  7. console.dir(game9g.utils);
  8. var gstyle = document.createElement("style");
  9. str =".game9gdialog {display:none;color: white;background-color: rgb(0,0,0);text-align: center;-moz-border-radius: 8px;-webkit-border-radius: 8px;border-radius: 8px;font-family: Arial,Helvetica,sans-serif;font-weight: normal;font-size: 14px;width: 280px; z-index: 9991; top: 50%; left: 50%; position: fixed; margin-left: -140px; margin-top: -82.5px;}.game9gdialog header {font-weight: bold;margin-top: 10px;text-align: center;height: auto;width:auto;}.game9gdialog section {padding: 0px 20px 20px 20px;text-align: center;font-family: Arial,Helvetica,sans-serif;font-weight: normal;height:auto;width: auto;box-shadow: rgb(178, 178, 178) 0px -1px 1px -1px inset;}.game9gdialog footer {height: 60px;padding: 0px 0px;width: auto;}.game9gdialog footer a {display: inline-block;color: #007afe;text-align: center;line-height: 36px;font-weight: bold;text-decoration: none;Arial,Helvetica,sans-serif;font-size: 16px;width:43%;margin: 8px;border: solid 1px white;}.game9gmake{display:none;z-index: 9990; background-color: rgb(0, 0, 0); position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; opacity: 0.5}";
  10. gstyle.type="text/css";
  11. if(gstyle.styleSheet){ //ie下
  12. gstyle.styleSheet.cssText = str;
  13. } else {
  14. gstyle.innerHTML = str;
  15. }
  16. document.getElementsByTagName("head")[0].appendChild(gstyle);
  17. var game9gmake=document.createElement("div");
  18. game9gmake.id="game9gmake";
  19. game9gmake.className="game9gmake";
  20. document.getElementsByTagName("body")[0].appendChild(game9gmake);
  21. var game9gdialog=document.createElement("div");
  22. console.dir(game9gdialog);
  23. game9gdialog.id="game9gdialog";
  24. game9gdialog.className="game9gdialog";
  25. game9gdialog.innerHTML='<header><h2 id="game9gtitle">空中传媒</h2></header><section id="game9gcontent"></section><footer><a href="javascript:void(0)" id="game9gleftbtn">取消</a><a href="javascript:void(0)" id="game9grightbtn">确定</a></footer>';
  26. document.getElementsByTagName("body")[0].appendChild(game9gdialog);
  27. game9g.utils.dialog=function(){
  28. document.getElementById('game9gtitle').innerHTML=game9g.utils.shareConfirmparam.stitle;
  29. document.getElementById('game9gcontent').innerHTML=game9g.utils.shareConfirmparam.scontent;
  30. var game9gleftbtn=document.getElementById('game9gleftbtn');
  31. var game9grightbtn=document.getElementById('game9grightbtn');
  32. game9gleftbtn.removeEventListener('click');
  33. game9grightbtn.removeEventListener('click');
  34. game9gleftbtn.addEventListener('click',function(){
  35. game9g.utils.hideDialog();
  36. })
  37. game9grightbtn.addEventListener('click',function(){
  38. try{
  39. if(game9g.utils.shareConfirmparam.callback&&typeof(game9g.utils.shareConfirmparam.callback)=='function'){
  40. game9g.utils.shareConfirmparam.callback();
  41. }
  42. }catch(e){
  43. console.err("回调方法错误!");
  44. }
  45. game9g.utils.hideDialog();
  46. })
  47. game9g.utils.showDialog();
  48. };
  49. game9g.utils.shareConfirmparam={};
  50. game9g.utils.shareConfirm=function(scontent,callback,stitle){
  51. if(!stitle){
  52. stitle="空中传媒";
  53. }
  54. game9g.utils.shareConfirmparam={
  55. stitle:stitle,
  56. scontent:scontent,
  57. callback:callback
  58. }
  59. setTimeout(delayShareConfirm,1000);
  60. }
  61. function delayShareConfirm(){
  62. game9g.utils.dialog();
  63. }
  64. game9g.utils.hideDialog=function(){
  65. game9g.utils.hide('game9gmake');
  66. game9g.utils.hide('game9gdialog');
  67. }
  68. game9g.utils.showDialog=function(){
  69. game9g.utils.show('game9gmake');
  70. game9g.utils.show('game9gdialog');
  71. }
  72. game9g.utils.show=function(id){
  73. document.getElementById(id).style.display="block";
  74. }
  75. game9g.utils.hide=function(id){
  76. document.getElementById(id).style.display="none";
  77. }