Mercurial > hg > ywww
comparison books/hosted.html @ 6:077b0a0a3e6d
remaining originals according to dependency walk
| author | Robert Boland <robert@markup.co.uk> |
|---|---|
| date | Thu, 16 Feb 2017 22:29:02 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 5:55445b456ad0 | 6:077b0a0a3e6d |
|---|---|
| 1 <html> | |
| 2 <head><script> | |
| 3 var $wnd = parent; | |
| 4 var $doc = $wnd.document; | |
| 5 var $moduleName, $moduleBase, $entry | |
| 6 ,$stats = $wnd.__gwtStatsEvent ? function(a) {return $wnd.__gwtStatsEvent(a);} : null | |
| 7 ,$sessionId = $wnd.__gwtStatsSessionId ? $wnd.__gwtStatsSessionId : null; | |
| 8 // Lightweight metrics | |
| 9 if ($stats) { | |
| 10 var moduleFuncName = location.search.substr(1); | |
| 11 var moduleFunc = $wnd[moduleFuncName]; | |
| 12 var moduleName = moduleFunc ? moduleFunc.moduleName : "unknown"; | |
| 13 $stats({moduleName:moduleName,sessionId:$sessionId,subSystem:'startup',evtGroup:'moduleStartup',millis:(new Date()).getTime(),type:'moduleEvalStart'}); | |
| 14 } | |
| 15 var $hostedHtmlVersion="2.1"; | |
| 16 | |
| 17 var gwtOnLoad; | |
| 18 var $hosted = "localhost:9997"; | |
| 19 | |
| 20 function loadIframe(url) { | |
| 21 var topDoc = window.top.document; | |
| 22 | |
| 23 // create an iframe | |
| 24 var iframeDiv = topDoc.createElement("div"); | |
| 25 iframeDiv.innerHTML = "<iframe scrolling=no frameborder=0 src='" + url + "'>"; | |
| 26 var iframe = iframeDiv.firstChild; | |
| 27 | |
| 28 // mess with the iframe style a little | |
| 29 var iframeStyle = iframe.style; | |
| 30 iframeStyle.position = "absolute"; | |
| 31 iframeStyle.borderWidth = "0"; | |
| 32 iframeStyle.left = "0"; | |
| 33 iframeStyle.top = "0"; | |
| 34 iframeStyle.width = "100%"; | |
| 35 iframeStyle.backgroundColor = "#ffffff"; | |
| 36 iframeStyle.zIndex = "1"; | |
| 37 iframeStyle.height = "100%"; | |
| 38 | |
| 39 // update the top window's document's body's style | |
| 40 var hostBodyStyle = window.top.document.body.style; | |
| 41 hostBodyStyle.margin = "0"; | |
| 42 hostBodyStyle.height = iframeStyle.height; | |
| 43 hostBodyStyle.overflow = "hidden"; | |
| 44 | |
| 45 // insert the iframe | |
| 46 topDoc.body.insertBefore(iframe, topDoc.body.firstChild); | |
| 47 } | |
| 48 | |
| 49 var ua = navigator.userAgent.toLowerCase(); | |
| 50 if (ua.indexOf("gecko") != -1) { | |
| 51 // install eval wrapper on FF to avoid EvalError problem | |
| 52 var __eval = window.eval; | |
| 53 window.eval = function(s) { | |
| 54 return __eval(s); | |
| 55 } | |
| 56 } | |
| 57 if (ua.indexOf("chrome") != -1) { | |
| 58 // work around __gwt_ObjectId appearing in JS objects | |
| 59 var hop = Object.prototype.hasOwnProperty; | |
| 60 Object.prototype.hasOwnProperty = function(prop) { | |
| 61 return prop != "__gwt_ObjectId" && hop.call(this, prop); | |
| 62 }; | |
| 63 // do the same in our parent as well -- see issue 4486 | |
| 64 // NOTE: this will have to be changed when we support non-iframe-based DevMode | |
| 65 var hop2 = parent.Object.prototype.hasOwnProperty; | |
| 66 parent.Object.prototype.hasOwnProperty = function(prop) { | |
| 67 return prop != "__gwt_ObjectId" && hop2.call(this, prop); | |
| 68 }; | |
| 69 } | |
| 70 | |
| 71 // wrapper to call JS methods, which we need both to be able to supply a | |
| 72 // different this for method lookup and to get the exception back | |
| 73 function __gwt_jsInvoke(thisObj, methodName) { | |
| 74 try { | |
| 75 var args = Array.prototype.slice.call(arguments, 2); | |
| 76 return [0, window[methodName].apply(thisObj, args)]; | |
| 77 } catch (e) { | |
| 78 return [1, e]; | |
| 79 } | |
| 80 } | |
| 81 | |
| 82 var __gwt_javaInvokes = []; | |
| 83 function __gwt_makeJavaInvoke(argCount) { | |
| 84 return __gwt_javaInvokes[argCount] || __gwt_doMakeJavaInvoke(argCount); | |
| 85 } | |
| 86 | |
| 87 function __gwt_doMakeJavaInvoke(argCount) { | |
| 88 // IE6 won't eval() anonymous functions except as r-values | |
| 89 var argList = ""; | |
| 90 for (var i = 0; i < argCount; i++) { | |
| 91 argList += ",p" + i; | |
| 92 } | |
| 93 var argListNoComma = argList.substring(1); | |
| 94 | |
| 95 return eval( | |
| 96 "__gwt_javaInvokes[" + argCount + "] =\n" + | |
| 97 " function(thisObj, dispId" + argList + ") {\n" + | |
| 98 " var result = __static(dispId, thisObj" + argList + ");\n" + | |
| 99 " if (result[0]) {\n" + | |
| 100 " throw result[1];\n" + | |
| 101 " } else {\n" + | |
| 102 " return result[1];\n" + | |
| 103 " }\n" + | |
| 104 " }\n" | |
| 105 ); | |
| 106 } | |
| 107 | |
| 108 /* | |
| 109 * This is used to create tear-offs of Java methods. Each function corresponds | |
| 110 * to exactly one dispId, and also embeds the argument count. We get the "this" | |
| 111 * value from the context in which the function is being executed. | |
| 112 * Function-object identity is preserved by caching in a sparse array. | |
| 113 */ | |
| 114 var __gwt_tearOffs = []; | |
| 115 var __gwt_tearOffGenerators = []; | |
| 116 function __gwt_makeTearOff(proxy, dispId, argCount) { | |
| 117 return __gwt_tearOffs[dispId] || __gwt_doMakeTearOff(dispId, argCount); | |
| 118 } | |
| 119 | |
| 120 function __gwt_doMakeTearOff(dispId, argCount) { | |
| 121 return __gwt_tearOffs[dispId] = | |
| 122 (__gwt_tearOffGenerators[argCount] || __gwt_doMakeTearOffGenerator(argCount))(dispId); | |
| 123 } | |
| 124 | |
| 125 function __gwt_doMakeTearOffGenerator(argCount) { | |
| 126 // IE6 won't eval() anonymous functions except as r-values | |
| 127 var argList = ""; | |
| 128 for (var i = 0; i < argCount; i++) { | |
| 129 argList += ",p" + i; | |
| 130 } | |
| 131 var argListNoComma = argList.substring(1); | |
| 132 | |
| 133 return eval( | |
| 134 "__gwt_tearOffGenerators[" + argCount + "] =\n" + | |
| 135 " function(dispId) {\n" + | |
| 136 " return function(" + argListNoComma + ") {\n" + | |
| 137 " var result = __static(dispId, this" + argList + ");\n" + | |
| 138 " if (result[0]) {\n" + | |
| 139 " throw result[1];\n" + | |
| 140 " } else {\n" + | |
| 141 " return result[1];\n" + | |
| 142 " }\n" + | |
| 143 " }\n" + | |
| 144 " }\n" | |
| 145 ); | |
| 146 } | |
| 147 | |
| 148 function __gwt_makeResult(isException, result) { | |
| 149 return [isException, result]; | |
| 150 } | |
| 151 | |
| 152 function __gwt_disconnected() { | |
| 153 // Prevent double-invocation. | |
| 154 window.__gwt_disconnected = new Function(); | |
| 155 // Do it in a timeout so we can be sure we have a clean stack. | |
| 156 window.setTimeout(__gwt_disconnected_impl, 1); | |
| 157 } | |
| 158 | |
| 159 function __gwt_disconnected_impl() { | |
| 160 __gwt_displayGlassMessage('GWT Code Server Disconnected', | |
| 161 'Most likely, you closed GWT Development Mode. Or, you might have lost ' | |
| 162 + 'network connectivity. To fix this, try restarting GWT Development Mode and ' | |
| 163 + '<a style="color: #FFFFFF; font-weight: bold;" href="javascript:location.reload()">' | |
| 164 + 'REFRESH</a> this page.'); | |
| 165 } | |
| 166 | |
| 167 // Keep track of z-index to allow layering of multiple glass messages | |
| 168 var __gwt_glassMessageZIndex = 2147483647; | |
| 169 | |
| 170 // Note this method is also used by ModuleSpace.java | |
| 171 function __gwt_displayGlassMessage(summary, details) { | |
| 172 var topWin = window.top; | |
| 173 var topDoc = topWin.document; | |
| 174 var outer = topDoc.createElement("div"); | |
| 175 // Do not insert whitespace or outer.firstChild will get a text node. | |
| 176 outer.innerHTML = | |
| 177 '<div style="position:absolute;z-index:' + __gwt_glassMessageZIndex-- + | |
| 178 ';left:50px;top:50px;width:600px;color:#FFF;font-family:verdana;text-align:left;">' + | |
| 179 '<div style="font-size:30px;font-weight:bold;">' + summary + '</div>' + | |
| 180 '<div style="font-size:15px;">' + details + '</div>' + | |
| 181 '</div>' + | |
| 182 '<div style="position:absolute;z-index:' + __gwt_glassMessageZIndex-- + | |
| 183 ';left:0px;top:0px;right:0px;bottom:0px;filter:alpha(opacity=60);opacity:0.6;background-color:#000;"></div>' | |
| 184 ; | |
| 185 topDoc.body.appendChild(outer); | |
| 186 var glass = outer.firstChild; | |
| 187 var glassStyle = glass.style; | |
| 188 | |
| 189 // Scroll to the top and remove scrollbars. | |
| 190 topWin.scrollTo(0, 0); | |
| 191 if (topDoc.compatMode == "BackCompat") { | |
| 192 topDoc.body.style["overflow"] = "hidden"; | |
| 193 } else { | |
| 194 topDoc.documentElement.style["overflow"] = "hidden"; | |
| 195 } | |
| 196 | |
| 197 // Steal focus. | |
| 198 glass.focus(); | |
| 199 | |
| 200 if ((navigator.userAgent.indexOf("MSIE") >= 0) && (topDoc.compatMode == "BackCompat")) { | |
| 201 // IE quirks mode doesn't support right/bottom, but does support this. | |
| 202 glassStyle.width = "125%"; | |
| 203 glassStyle.height = "100%"; | |
| 204 } else if (navigator.userAgent.indexOf("MSIE 6") >= 0) { | |
| 205 // IE6 doesn't have a real standards mode, so we have to use hacks. | |
| 206 glassStyle.width = "125%"; // Get past scroll bar area. | |
| 207 // Nasty CSS; onresize would be better but the outer window won't let us add a listener IE. | |
| 208 glassStyle.setExpression("height", "document.documentElement.clientHeight"); | |
| 209 } | |
| 210 | |
| 211 $doc.title = summary + " [" + $doc.title + "]"; | |
| 212 } | |
| 213 | |
| 214 function findPluginObject() { | |
| 215 try { | |
| 216 return document.getElementById('pluginObject'); | |
| 217 } catch (e) { | |
| 218 return null; | |
| 219 } | |
| 220 } | |
| 221 | |
| 222 function findPluginEmbed() { | |
| 223 try { | |
| 224 return document.getElementById('pluginEmbed') | |
| 225 } catch (e) { | |
| 226 return null; | |
| 227 } | |
| 228 } | |
| 229 | |
| 230 function findPluginXPCOM() { | |
| 231 try { | |
| 232 return __gwt_HostedModePlugin; | |
| 233 } catch (e) { | |
| 234 return null; | |
| 235 } | |
| 236 } | |
| 237 | |
| 238 gwtOnLoad = function(errFn, modName, modBase){ | |
| 239 $moduleName = modName; | |
| 240 $moduleBase = modBase; | |
| 241 | |
| 242 // Note that the order is important | |
| 243 var pluginFinders = [ | |
| 244 findPluginXPCOM, | |
| 245 findPluginObject, | |
| 246 findPluginEmbed, | |
| 247 ]; | |
| 248 var topWin = window.top; | |
| 249 var url = topWin.location.href; | |
| 250 if (!topWin.__gwt_SessionID) { | |
| 251 var ASCII_EXCLAMATION = 33; | |
| 252 var ASCII_TILDE = 126; | |
| 253 var chars = []; | |
| 254 for (var i = 0; i < 16; ++i) { | |
| 255 chars.push(Math.floor(ASCII_EXCLAMATION | |
| 256 + Math.random() * (ASCII_TILDE - ASCII_EXCLAMATION + 1))); | |
| 257 } | |
| 258 topWin.__gwt_SessionID = String.fromCharCode.apply(null, chars); | |
| 259 } | |
| 260 var plugin = null; | |
| 261 for (var i = 0; i < pluginFinders.length; ++i) { | |
| 262 try { | |
| 263 var maybePlugin = pluginFinders[i](); | |
| 264 if (maybePlugin != null && maybePlugin.init(window)) { | |
| 265 plugin = maybePlugin; | |
| 266 break; | |
| 267 } | |
| 268 } catch (e) { | |
| 269 } | |
| 270 } | |
| 271 if (!plugin) { | |
| 272 // try searching for a v1 plugin for backwards compatibility | |
| 273 var found = false; | |
| 274 for (var i = 0; i < pluginFinders.length; ++i) { | |
| 275 try { | |
| 276 plugin = pluginFinders[i](); | |
| 277 if (plugin != null && plugin.connect($hosted, $moduleName, window)) { | |
| 278 return; | |
| 279 } | |
| 280 } catch (e) { | |
| 281 } | |
| 282 } | |
| 283 loadIframe("http://gwt.google.com/missing-plugin"); | |
| 284 } else { | |
| 285 if (plugin.connect(url, topWin.__gwt_SessionID, $hosted, $moduleName, | |
| 286 $hostedHtmlVersion)) { | |
| 287 window.onUnload = function() { | |
| 288 try { | |
| 289 // wrap in try/catch since plugins are not required to supply this | |
| 290 plugin.disconnect(); | |
| 291 } catch (e) { | |
| 292 } | |
| 293 }; | |
| 294 } else { | |
| 295 if (errFn) { | |
| 296 errFn(modName); | |
| 297 } else { | |
| 298 __gwt_displayGlassMessage("Plugin failed to connect to Development Mode server at " + | |
| 299 simpleEscape($hosted), | |
| 300 "Follow the underlying troubleshooting instructions"); | |
| 301 loadIframe("http://code.google.com/p/google-web-toolkit/wiki/TroubleshootingOOPHM"); | |
| 302 } | |
| 303 } | |
| 304 } | |
| 305 } | |
| 306 | |
| 307 function simpleEscape(originalString) { | |
| 308 return originalString.replace("&","&") | |
| 309 .replace("<","<") | |
| 310 .replace(">",">") | |
| 311 .replace("\"","""); | |
| 312 } | |
| 313 | |
| 314 window.onunload = function() { | |
| 315 }; | |
| 316 | |
| 317 // Lightweight metrics | |
| 318 window.fireOnModuleLoadStart = function(className) { | |
| 319 $stats && $stats({moduleName:$moduleName, sessionId:$sessionId, subSystem:'startup', evtGroup:'moduleStartup', millis:(new Date()).getTime(), type:'onModuleLoadStart', className:className}); | |
| 320 }; | |
| 321 | |
| 322 window.__gwt_module_id = 0; | |
| 323 </script></head> | |
| 324 <body> | |
| 325 <font face='arial' size='-1'>This html file is for Development Mode support.</font> | |
| 326 <script><!-- | |
| 327 // Lightweight metrics | |
| 328 $stats && $stats({moduleName:$moduleName, sessionId:$sessionId, subSystem:'startup', evtGroup:'moduleStartup', millis:(new Date()).getTime(), type:'moduleEvalEnd'}); | |
| 329 | |
| 330 // OOPHM currently only supports IFrameLinker | |
| 331 var query = parent.location.search; | |
| 332 if (!findPluginXPCOM()) { | |
| 333 document.write('<embed id="pluginEmbed" type="application/x-gwt-hosted-mode" width="10" height="10">'); | |
| 334 document.write('</embed>'); | |
| 335 document.write('<object id="pluginObject" CLASSID="CLSID:1D6156B6-002B-49E7-B5CA-C138FB843B4E">'); | |
| 336 document.write('</object>'); | |
| 337 } | |
| 338 | |
| 339 // look for the old query parameter if we don't find the new one | |
| 340 var idx = query.indexOf("gwt.codesvr="); | |
| 341 if (idx >= 0) { | |
| 342 idx += 12; // "gwt.codesvr=".length() == 12 | |
| 343 } else { | |
| 344 idx = query.indexOf("gwt.hosted="); | |
| 345 if (idx >= 0) { | |
| 346 idx += 11; // "gwt.hosted=".length() == 11 | |
| 347 } | |
| 348 } | |
| 349 if (idx >= 0) { | |
| 350 var amp = query.indexOf("&", idx); | |
| 351 if (amp >= 0) { | |
| 352 $hosted = query.substring(idx, amp); | |
| 353 } else { | |
| 354 $hosted = query.substring(idx); | |
| 355 } | |
| 356 | |
| 357 // According to RFC 3986, some of this component's characters (e.g., ':') | |
| 358 // are reserved and *may* be escaped. | |
| 359 $hosted = decodeURIComponent($hosted); | |
| 360 } | |
| 361 | |
| 362 query = window.location.search.substring(1); | |
| 363 if (query && $wnd[query]) setTimeout($wnd[query].onScriptLoad, 1); | |
| 364 --></script></body></html> |
