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 16function gsize(ptype) 17{ 18 var h = document.compatMode === "CSS1Compat" && 19 !window.opera ? 20 document.documentElement.clientHeight : 21 document.body.clientHeight; 22 var w = document.compatMode === "CSS1Compat" && 23 !window.opera ? 24 document.documentElement.clientWidth : 25 document.body.clientWidth; 26 var pageWidth, pageHeight, t; 27 28 if (document.body && 29 (document.body.scrollWidth || document.body.scrollHeight)) { 30 t = document.body.scrollWidth; 31 pageWidth = (w > t) ? ("" + w + "px") : ("" + (t) + "px"); 32 t = document.body.scrollHeight; 33 pageHeight = (h > t) ? ("" + h + "px") : ("" + (t) + "px"); 34 } else if (document.body.offsetWidth) { 35 t = document.body.offsetWidth; 36 pageWidth = (w > t) ? ("" + w + "px") : ("" + (t) + "px"); 37 t = document.body.offsetHeight; 38 pageHeight =(h > t) ? ("" + h + "px") : ("" + (t) + "px"); 39 } else { 40 pageWidth = "100%"; 41 pageHeight = "100%"; 42 } 43 return (ptype === 1) ? pageWidth : pageHeight; 44} 45 46function addEvent( obj, type, fn ) { 47 if ( obj.attachEvent ) { 48 obj["e" + type + fn] = fn; 49 obj[type+fn] = function() { obj["e" + type + fn]( window.event );}; 50 obj.attachEvent("on" + type, obj[type + fn]); 51 } else 52 obj.addEventListener(type, fn, false); 53} 54 55function removeEvent( obj, type, fn ) { 56 if ( obj.detachEvent ) { 57 obj.detachEvent("on" + type, obj[type + fn]); 58 obj[type + fn] = null; 59 } else 60 obj.removeEventListener(type, fn, false); 61} 62 63function lws_gray_out(vis, _options) { 64 65 var options = _options || {}; 66 var zindex = options.zindex || 50; 67 var opacity = options.opacity || 70; 68 var opaque = (opacity / 100); 69 var bgcolor = options.bgcolor || "#000000"; 70 var dark = document.getElementById("darkenScreenObject"); 71 72 if (!dark) { 73 var tbody = document.getElementsByTagName("body")[0]; 74 var tnode = document.createElement("div"); 75 tnode.style.position = "absolute"; 76 tnode.style.top = "0px"; 77 tnode.style.left = "0px"; 78 tnode.style.overflow = "hidden"; 79 tnode.style.display ="none"; 80 tnode.id = "darkenScreenObject"; 81 tbody.appendChild(tnode); 82 dark = document.getElementById("darkenScreenObject"); 83 } 84 if (vis) { 85 dark.style.opacity = opaque; 86 dark.style.MozOpacity = opaque; 87 // dark.style.filter ='alpha(opacity='+opacity+')'; 88 dark.style.zIndex = zindex; 89 dark.style.backgroundColor = bgcolor; 90 dark.style.width = gsize(1); 91 dark.style.height = gsize(0); 92 dark.style.display = "block"; 93 addEvent(window, "resize", 94 function() { 95 dark.style.height = gsize(0); 96 dark.style.width = gsize(1); 97 } 98 ); 99 } else { 100 dark.style.display = "none"; 101 removeEvent(window, "resize", 102 function() { 103 dark.style.height = gsize(0); 104 dark.style.width = gsize(1); 105 } 106 ); 107 } 108} 109 110/* 111 * end of grayOut related stuff 112 */ 113 114function new_ws(urlpath, protocol) 115{ 116 return new WebSocket(urlpath, protocol); 117} 118 119function lws_san(s) 120{ 121 if (s.search("<") !== -1) 122 return "invalid string"; 123 124 return s; 125} 126