lws-common.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * This section around grayOut came from here:
  3. * http://www.codingforums.com/archive/index.php/t-151720.html
  4. * Assumed public domain
  5. *
  6. * Init like this in your main html script, this also reapplies the gray
  7. *
  8. * lws_gray_out(true,{'zindex':'499'});
  9. *
  10. * To remove the gray
  11. *
  12. * lws_gray_out(false);
  13. *
  14. */
  15. function lws_gray_out(vis, options) {
  16. var options = options || {};
  17. var zindex = options.zindex || 50;
  18. var opacity = options.opacity || 70;
  19. var opaque = (opacity / 100);
  20. var bgcolor = options.bgcolor || '#000000';
  21. var dark = document.getElementById('darkenScreenObject');
  22. if (!dark) {
  23. var tbody = document.getElementsByTagName("body")[0];
  24. var tnode = document.createElement('div');
  25. tnode.style.position = 'absolute';
  26. tnode.style.top = '0px';
  27. tnode.style.left = '0px';
  28. tnode.style.overflow = 'hidden';
  29. tnode.style.display ='none';
  30. tnode.id = 'darkenScreenObject';
  31. tbody.appendChild(tnode);
  32. dark = document.getElementById('darkenScreenObject');
  33. }
  34. if (vis) {
  35. dark.style.opacity = opaque;
  36. dark.style.MozOpacity = opaque;
  37. dark.style.filter ='alpha(opacity='+opacity+')';
  38. dark.style.zIndex = zindex;
  39. dark.style.backgroundColor = bgcolor;
  40. dark.style.width = gsize(1);
  41. dark.style.height = gsize(0);
  42. dark.style.display ='block';
  43. addEvent(window, "resize",
  44. function() {
  45. dark.style.height = gsize(0);
  46. dark.style.width = gsize(1);
  47. }
  48. );
  49. } else {
  50. dark.style.display = 'none';
  51. removeEvent(window, "resize",
  52. function() {
  53. dark.style.height = gsize(0);
  54. dark.style.width = gsize(1);
  55. }
  56. );
  57. }
  58. }
  59. function gsize(ptype)
  60. {
  61. var h = document.compatMode == 'CSS1Compat' &&
  62. !window.opera ?
  63. document.documentElement.clientHeight :
  64. document.body.clientHeight;
  65. var w = document.compatMode == 'CSS1Compat' &&
  66. !window.opera ?
  67. document.documentElement.clientWidth :
  68. document.body.clientWidth;
  69. if (document.body &&
  70. (document.body.scrollWidth || document.body.scrollHeight)) {
  71. var pageWidth = (w > (t = document.body.scrollWidth)) ?
  72. ("" + w + "px") : ("" + (t) + "px");
  73. var pageHeight = (h > (t = document.body.scrollHeight)) ?
  74. ("" + h + "px") : ("" + (t) + "px");
  75. } else if (document.body.offsetWidth) {
  76. var pageWidth = (w > (t = document.body.offsetWidth)) ?
  77. ("" + w + "px") : ("" + (t) + "px");
  78. var pageHeight =(h > (t = document.body.offsetHeight)) ?
  79. ("" + h + "px") : ("" + (t) + "px");
  80. } else {
  81. var pageWidth = '100%';
  82. var pageHeight = '100%';
  83. }
  84. return (ptype == 1) ? pageWidth : pageHeight;
  85. }
  86. function addEvent( obj, type, fn ) {
  87. if ( obj.attachEvent ) {
  88. obj['e' + type + fn] = fn;
  89. obj[type+fn] = function() { obj['e' + type+fn]( window.event );}
  90. obj.attachEvent('on' + type, obj[type + fn]);
  91. } else
  92. obj.addEventListener(type, fn, false);
  93. }
  94. function removeEvent( obj, type, fn ) {
  95. if ( obj.detachEvent ) {
  96. obj.detachEvent('on' + type, obj[type + fn]);
  97. obj[type + fn] = null;
  98. } else
  99. obj.removeEventListener(type, fn, false);
  100. }
  101. /*
  102. * end of grayOut related stuff
  103. */
  104. function lws_san(s)
  105. {
  106. if (s.search("<") != -1)
  107. return "invalid string";
  108. return s;
  109. }