/// <summary> /// This is a javascript application. /// </summary> /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param> public Application(IApp page) { //new IHTMLPre { () => "loaded at " + new { DateTime.Now } }.AttachToDocument(); new IHTMLPre { "loaded at " + new { DateTime.Now } }.AttachToDocument(); Native.css[IHTMLElement.HTMLElementEnum.a].style.display = IStyle.DisplayEnum.block; new { }.With( async delegate { var foo = new IHTMLAnchor { href = "#foo", innerText = "#foo" }.AttachToDocument(); var a = new AsyncHash { hash = "#foo" }; new IHTMLButton { "go foo" }.AttachToDocument().onclick += delegate { Native.document.location.hash = a.hash; }; while (await a.onenter) { new IHTMLPre { "onenter" }.AttachToDocument(); foo.style.backgroundColor = "yellow"; await a.onexit; new IHTMLPre { "onexit" }.AttachToDocument(); foo.style.backgroundColor = ""; } } ); new { }.With( async delegate { var bar = new IHTMLAnchor { href = "#bar", innerText = "#bar" }.AttachToDocument(); var a = new AsyncHash { hash = "#bar" }; new IHTMLButton { "go bar" }.AttachToDocument().onclick += delegate { //Native.document.location.hash = a.hash; a.Go(); }; while (await a.onenter) { //new IHTMLPre { "onenter" }.AttachToDocument(); bar.style.backgroundColor = "cyan"; // using var goback = new IHTMLButton { "go back" }.AttachToDocument(); goback.onclick += delegate { //Native.document.location.hash = a.hash; //a.Go(); Native.window.history.back(); }; await a.onexit; goback.Dispose(); //new IHTMLPre { "onexit" }.AttachToDocument(); bar.style.backgroundColor = ""; } } ); new IHTMLAnchor { href = "", innerText = "go home with reload" }.AttachToDocument(); //new IHTMLAnchor { href = "/", innerText = "go home" }.AttachToDocument(); new IHTMLAnchor { href = "#", innerText = "go home" }.AttachToDocument(); Native.window.onhashchange += delegate { new IHTMLPre { new { Native.document.location.hash } }.AttachToDocument(); }; // await hash of // await cancel }