jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 1 | <html> |
| 2 | <head> |
| 3 | <title>OOPHM test page</title> |
| 4 | <script> |
| 5 | var $wnd = window,$doc = document; |
| 6 | var $moduleBase = 'file:///home/jat/s/gwt-oophm/plugins/firefox/'; |
| 7 | |
| 8 | // fake property provider |
| 9 | function __gwt_getProperty(prop) { |
| 10 | return "gecko1_8"; |
| 11 | } |
| 12 | |
| 13 | // wrapper to call JS methods, which we need both to be able to supply a |
| 14 | // different this for method lookup and to get the exception back |
| 15 | function __gwt_jsWrapper(method, methodlookup, thisref) { |
| 16 | try { |
| 17 | var args = Array.prototype.slice.call(arguments, 3); |
| 18 | // console.log("calling " + method + " on " + methodlookup + " (this=" + thisref + "), args are ", |
| 19 | // args); |
| 20 | var ret = methodlookup[method].apply(thisref, args); |
| 21 | // console.log("successful; returned ", ret); |
| 22 | return [0, ret]; |
| 23 | } catch (e) { |
| 24 | try { |
| 25 | // console.log("methodlookup[method]=", methodlookup[method] ? |
| 26 | // methodlookup[method].toString() : methodlookup[method]); |
| 27 | // console.log("failed; exception ", e); |
| 28 | } catch (e2) { |
| 29 | // console.log("exception " + e2 + " logging original exception"); |
| 30 | } |
| 31 | return [1, e]; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | function __gwt_initHandlers(resize, beforeunload, unload) { |
| 36 | console.log("initHandlers called", resize, beforeunload, unload); |
| 37 | var $wnd = window |
| 38 | , oldOnResize = $wnd.onresize |
| 39 | , oldOnBeforeUnload = $wnd.onbeforeunload |
| 40 | , oldOnUnload = $wnd.onunload |
| 41 | ; |
| 42 | |
| 43 | $wnd.onresize = function(evt) { |
| 44 | try { |
| 45 | resize(); |
| 46 | } finally { |
| 47 | oldOnResize && oldOnResize(evt); |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | $wnd.onbeforeunload = function(evt) { |
| 52 | var ret, oldRet; |
| 53 | try { |
| 54 | ret = beforeunload(); |
| 55 | } finally { |
| 56 | oldRet = oldOnBeforeUnload && oldOnBeforeUnload(evt); |
| 57 | } |
| 58 | // Avoid returning null as IE6 will coerce it into a string. |
| 59 | // Ensure that "" gets returned properly. |
| 60 | if (ret != null) { |
| 61 | return ret; |
| 62 | } |
| 63 | if (oldRet != null) { |
| 64 | return oldRet; |
| 65 | } |
| 66 | // returns undefined. |
| 67 | }; |
| 68 | |
| 69 | $wnd.onunload = function(evt) { |
| 70 | try { |
| 71 | unload(); |
| 72 | } finally { |
| 73 | oldOnUnload && oldOnUnload(evt); |
| 74 | } |
| 75 | }; |
| 76 | }; |
| 77 | |
| 78 | // fire up plugin |
| 79 | window.onload = function() { |
| 80 | var plugin = document.getElementById('plugin'); |
| 81 | var connectTo = "localhost:9997"; |
| 82 | var module = "com.google.gwt.sample.kitchensink.KitchenSink"; |
| 83 | var idx = location.search.indexOf("gwt.hosted="); |
| 84 | if (idx >= 0) { |
| 85 | var amp = location.search.indexOf("&", idx); |
| 86 | if (amp >= 0) { |
| 87 | connectTo = location.search.substring(idx + 11, amp); |
| 88 | } else { |
| 89 | connectTo = location.search.substring(idx + 11); |
| 90 | } |
| 91 | } |
| 92 | var idx = location.search.indexOf("gwt.module="); |
| 93 | if (idx >= 0) { |
| 94 | var amp = location.search.indexOf("&", idx); |
| 95 | if (amp >= 0) { |
| 96 | module = location.search.substring(idx + 11, amp); |
| 97 | } else { |
| 98 | module = location.search.substring(idx + 11); |
| 99 | } |
| 100 | } |
| 101 | plugin.connect(connectTo, module) |
| 102 | || alert("failed to connect"); |
| 103 | }; |
| 104 | </script> |
| 105 | </head> |
| 106 | <body> |
| 107 | <embed id="plugin" type="application/x-gwt-hosted-mode" width="10" |
| 108 | height="10"/> |
| 109 | </body> |
| 110 | </html> |