launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/impl/Console.java
changeset 1827 f07753959dcf
parent 1787 ea12a3bb4b33
child 1860 4ce38f21f4cd
     1.1 --- a/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/impl/Console.java	Tue Feb 24 11:12:53 2015 +0100
     1.2 +++ b/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/impl/Console.java	Sun Apr 26 10:58:52 2015 +0300
     1.3 @@ -53,8 +53,16 @@
     1.4          "elem[attr] = value;")
     1.5      private static native void setAttr(Object id, String attr, Object value);
     1.6      
     1.7 -    @JavaScriptBody(args = {}, body = "return; window.close();")
     1.8 -    private static native void closeWindow();
     1.9 +    @net.java.html.js.JavaScriptBody(args = {  }, body = 
    1.10 +        "var a = document.createElement('a');"
    1.11 +      + "a.innerHTML = 'Cancel: closing in 10s...';\n"
    1.12 +      + "a.href = '#';\n"
    1.13 +      + "var closing = window.setTimeout(function() { window.close(); }, 10000);\n"
    1.14 +      + "a.onclick = function() { clearTimeout(closing); document.body.removeChild(a); };\n"
    1.15 +      + "document.body.appendChild(a);\n" +
    1.16 +        "return;\n"
    1.17 +    )
    1.18 +    static native void closeWindow();
    1.19  
    1.20      private static Object textArea;
    1.21      private static Object statusArea;