/// <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 { }.With( async delegate { var frame = new IHTMLIFrame(); frame.AttachToDocument(); frame.src = "about:blank"; await frame.async.onload; frame.contentWindow.document.DesignMode = true; // Additional information: The 'link' start tag on line 3 position 6 does not match the end tag of 'body'. Line 12, position 38. this.content = frame.contentWindow.document.body; while (await page.Yield.async.onclick) { Console.WriteLine( new { this.content } ); await this.yield(); } } ); }
/// <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 = null) { // ! start big, then resize to small var ScreenWidth = Native.Screen.width; var ScreenHeight = Native.Screen.height; Console.WriteLine( new { ScreenWidth, ScreenHeight, Native.window.Width, Native.window.Height } ); #region workaround for ThreeJS/chrome webgl upscale bug // workaround for not knowing how to tell three js to upscale correctly.. // X:\jsc.svn\examples\javascript\Test\TestNestedIFrameForMoreWidth\TestNestedIFrameForMoreWidth\Application.cs // instead of reloading full app // could we run part of it instead? // like let jsc know that this sub application should be reloadable? // this will be like threading // the outer code wil just stop doing anything // and the inner app will take over. var ApplyWorkaround = false; var location = ""; try { location = Native.Document.location.href; //var pl = Native.Window.parent.document.location; if (Native.window.Width < Native.screen.width) ApplyWorkaround = true; } catch { } if (ApplyWorkaround) { #region make sure the url looks different to make iframe actually load Native.window.parent.With( parent => { // http://stackoverflow.com/questions/5934538/is-there-a-limitation-on-an-iframe-containing-another-iframe-with-the-same-url var parentlocation = ""; try { parentlocation = parent.document.location.href; } catch { // parent from another origin } Console.WriteLine(new { parentlocation }); if (parentlocation.TakeUntilIfAny("#") == location.TakeUntilIfAny("#")) { var withouthash = location.TakeUntilIfAny("#"); var onlyhash = location.SkipUntilOrEmpty("#"); withouthash += "?"; if (onlyhash != "") { withouthash += "#" + onlyhash; } location = withouthash; } } ); #endregion #region ApplyWorkaround // this check only looks for default screen width // what about height and secondary screens? Console.WriteLine("will prepare... " + location); var iframe = new IHTMLIFrame { frameBorder = "0", allowFullScreen = true }; iframe.style.minWidth = Native.Screen.width + "px"; iframe.style.minHeight = Native.Screen.height + "px"; iframe.style.position = IStyle.PositionEnum.absolute; iframe.style.left = "0px"; iframe.style.top = "0px"; iframe.style.width = "100%"; iframe.style.height = "100%"; Native.Document.body.Clear(); Native.Document.body.style.overflow = IStyle.OverflowEnum.hidden; Native.window.onmessage += e => { Console.WriteLine("Native.Window.onmessage " + new { e.data }); // pure trickery :P if ((string)e.data == "WoodsXmasByRobert.loaded") { iframe.style.minWidth = ""; iframe.style.minHeight = ""; } }; iframe.onload += delegate { if (iframe.src != location) return; Native.window.requestAnimationFrame += delegate { Console.WriteLine("reload done! " + new { location, iframe.src }); iframe.contentWindow.postMessage("ready yet?"); }; }; Native.window.requestAnimationFrame += delegate { Console.WriteLine("will reload... " + location); iframe.AttachToDocument(); iframe.src = location; }; #endregion return; } #endregion new AppReferences().With( References => { var source = new[] { References.Three, //incompatible // new THREELibrary.opensource.gihtub.three.js.build.three().Content, References.Tween, References.CopyShader, References.FilmShader, References.VignetteShader, References.EffectComposer, References.MaskPass, References.RenderPass, References.ShaderPass, References.FilmPass, }; var yield = source.ForEach( (SourceScriptElement, i, MoveNext) => { //Console.WriteLine("will load: " + SourceScriptElement.src); SourceScriptElement.AttachToDocument().onload += delegate { //Console.WriteLine("loaded: " + SourceScriptElement.src); MoveNext(); }; } ); yield( delegate { //Console.WriteLine("will load WoodsXmasByRobert"); InitializeContent(); } ); } ); }
/// <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) { // http://davidwalsh.name/add-rules-stylesheets // http://stackoverflow.com/questions/5359943/javascript-set-print-stylesheet var pstyle = new IHTMLStyle { type = "text/css", media = "print" }; //pstyle.AttachTo( // Native.document.head //); // .StyleSheet is available only if attached to DOM? pstyle["h1"].border = "13px solid green"; //pstyle["h1"].backgroundColor = "yellow"; //pstyle["h1"].color = "green"; //IStyleSheet.Default["@media print { h1 }"].style.color = "yellow"; // http://www.w3schools.com/css/css_mediatypes.asp #region test var mp = IStyleSheet.Default["@media print"]; // { type = 4 } Console.WriteLine( new { mp.type, CSSRuleTypes.MEDIA_RULE } ); if (mp.type == CSSRuleTypes.MEDIA_RULE) { var mpr = (CSSMediaRule)(object)mp; foreach (var media in mpr.media) { // { media = print } Console.WriteLine(new { media }); } } #endregion // __awIABmCv4jKFf2Sg5roQag(__bQIABjls6jSgl0UFIggGlQ()[1], 'h1').style.color = 'purple'; //page.Header.cl //page.Header.EnsureID(); // http://www.w3schools.com/css/css_attribute_selectors.asp //page.Header.setAttribute("style-id", "45"); IStyleSheet.Default[CSSMediaTypes.print][page.Header].style.color = "blue"; IStyleSheet.Default[CSSMediaTypes.print][page.Header].style.boxShadow = "inset 0 0 0 10000px yellow"; //Console.WriteLine( // new // { // page.Header.style.parentRule, // page.Header.style.cssText, // //IStyleSheet.Default[CSSMediaTypes.print]["h1"].style.cssText // } // ); // @media print // { // h1 { // border: 3px solid blue; // } //} //new IHTMLDiv { }.AttachToHead().innerHTML = // @"<style type='text/css' media='print'>h1{ border: 13px solid yellow;}</style>"; //f.FormBorderStyle = FormBorderStyle.None; new Form1{FormBorderStyle = FormBorderStyle.None}.AttachFormTo(page.output); //f.GetHTMLTarget().AttachTo(page.output); //f.Show(); //f.WindowState = FormWindowState.Maximized; IStyleSheet.Default [CSSMediaTypes.print] [page.output].style.border = "0px solid black"; //IStyle.OverflowEnum.hidden; page.Print.onclick += delegate { Native.window.print(); }; IStyleSheet.Default [CSSMediaTypes.print] [page.Print].style.display = IStyle.DisplayEnum.none; var s = new SpecialLayout(); var i = new IHTMLIFrame(); // hide it from plain sight i.style.display = IStyle.DisplayEnum.none; //new IHTMLInput { type = ScriptCoreLib.Shared.HTMLInputTypeEnum.checkbox }.AttachToDocument().With( // x => // { // x.onclick += delegate // { // i.ToggleVisible(); // }; // } //); // it will never load with out this call! i.AttachToDocument(); // Uncaught TypeError: Cannot read property 'document' of undefined page.PrintFromIframe.disabled = true; i.onload += delegate { var idoc = i.contentWindow.document; // http://stackoverflow.com/questions/16649943/css-to-set-a4-paper-size idoc.body.style.minWidth = "21cm"; var x = new IHTMLStyle().AttachTo(idoc.body); s.AttachTo(idoc.body); x.StyleSheet[CSSMediaTypes.print][s.Header].style.color = "yellow"; x.StyleSheet[CSSMediaTypes.print][s.Header].style.boxShadow = "inset 0 0 0 10000px red"; s.Header.innerText = "test"; x.StyleSheet[CSSMediaTypes.print][s.SpecialText].before.style.content = "'print hello world'"; x.StyleSheet[CSSMediaTypes.print][s.SpecialText].before.style.color = "red"; x.StyleSheet[CSSMediaTypes.print][s.SpecialText].before.style.borderBottom = "1px solid red"; // http://www.w3schools.com/cssref/pr_gen_content.asp //x.StyleSheet // //[CSSMediaTypes.print] // ["#" + s.SpecialText.id + ":before"] // .style.setProperty("content", "'hello world'", ""); new Form1 { Text = "for print" }.AttachFormTo(s.output); page.PrintFromIframe.disabled = false; page.PrintFromIframe.onclick += delegate { i.contentWindow.print(); }; }; i.src = "about:blank"; }
/// <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) { var w = Native.Window.Width; var h = Native.Window.Height; new IHTMLPre { }.AttachToDocument().With( i => { Action u = delegate { i.innerText = new { w, Native.Window.Width, h, Native.Window.Height }.ToString(); }; u(); Native.Window.onresize += delegate { u(); }; } ); var location = "" + Native.Document.location; var parent = ""; new IHTMLPre { innerText = new { location, Native.Document.location.protocol, Native.Document.location.host, Native.Document.location.pathname, Native.Document.location.search, Native.Document.location.hash, }.ToString() }.AttachToDocument(); Native.Window.parent.With( xparent => { // http://stackoverflow.com/questions/5934538/is-there-a-limitation-on-an-iframe-containing-another-iframe-with-the-same-url parent = "" + xparent.document.location; new IHTMLPre { innerText = new { parent }.ToString() }.AttachToDocument(); } ); if (w < 400) { Native.Document.body.style.backgroundColor = JSColor.Yellow; new IHTMLButton("reopen as a bigger document").AttachToDocument().onclick += delegate { var src = location; if (location == parent) { var withouthash = src.TakeUntilIfAny("#"); var onlyhash = src.SkipUntilOrEmpty("#"); withouthash += "?"; if (onlyhash != "") { withouthash += "#" + onlyhash; } src = withouthash; } var iframe = new IHTMLIFrame { src = src, frameBorder = "0" }; iframe.style.minWidth = "800px"; iframe.style.minHeight = "600px"; iframe.style.position = IStyle.PositionEnum.absolute; iframe.style.left = "0px"; iframe.style.top = "0px"; iframe.style.width = "100%"; iframe.style.height = "100%"; Native.Document.body.Clear(); Native.Document.body.style.overflow = IStyle.OverflowEnum.hidden; iframe.onload += delegate { Console.WriteLine( new { location, iframe.src } ); iframe.style.minWidth = ""; iframe.style.minHeight = ""; }; Console.WriteLine( "will reload as: " + new { src } ); iframe.AttachToDocument(); }; return; } Native.Document.body.style.backgroundColor = JSColor.White; new IHTMLButton("this is dynamic content").AttachToDocument(); new IHTMLButton("reload").AttachToDocument().onclick += delegate { Native.Document.location = Native.Document.location; }; new IHTMLButton("add frame").AttachToDocument().onclick += delegate { var src = location; if (location == parent) { var withouthash = src.TakeUntilIfAny("#"); var onlyhash = src.SkipUntilOrEmpty("#"); withouthash += "?"; if (onlyhash != "") { withouthash += "#" + onlyhash; } src = withouthash; } var iframe = new IHTMLIFrame { src = "about:blank" }; iframe.style.position = IStyle.PositionEnum.absolute; iframe.style.left = "10%"; iframe.style.top = "10%"; iframe.style.width = "80%"; iframe.style.height = "80%"; iframe.AttachToDocument(); Console.WriteLine( "will frame as: " + new { src } ); Native.Window.requestAnimationFrame += delegate { iframe.src = src; Console.WriteLine( "did it work? " + new { iframe.src } ); }; }; new IHTMLButton("add frame via source").AttachToDocument().onclick += delegate { var iframe = new IHTMLIFrame { }; iframe.style.position = IStyle.PositionEnum.absolute; iframe.style.left = "10%"; iframe.style.top = "10%"; iframe.style.width = "80%"; iframe.style.height = "80%"; iframe.AttachToDocument(); var x = iframe.contentWindow.open("about:blank", "_self"); x.document.write("<script src='/view-source'></script>"); x.document.close(); }; @"Hello world".ToDocumentTitle(); // Send data from JavaScript to the server tier service.WebMethod2( @"A string from JavaScript.", value => value.ToDocumentTitle() ); }
/// <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) { // http://stackoverflow.com/questions/6275953/how-to-display-div-over-a-java-applet-in-chrome new ConsoleForm().With( f => { f.InitializeConsoleFormWriter(); f.Show(); //var archive = applet.ToHTMLElement().AsXElement().Attribute("archive"); //archive.Value = ("" + Native.Document.location).TakeUntilLastOrEmpty("/") + "/" + archive.Value; Console.WriteLine("calling applet.InitializeConsoleFormWriter"); applet.InitializeConsoleFormWriter( Console.Write, Console.WriteLine ); Console.WriteLine("you are looking at FormsVirtualConsoleExperiment!!"); applet.AttachAppletToDocument(); var shadow = new IHTMLIFrame { src = "about:blank", frameBorder = "0", scrolling = "no" }; shadow.AttachToDocument(); shadow.style.SetLocation(120, 48); shadow.style.zIndex = 0; Action Update = delegate { shadow.style.SetLocation(f.Left, f.Top, f.Width, f.Height); }; f.LocationChanged += delegate { Update(); }; f.SizeChanged += delegate { Update(); }; Update(); Native.Window.onresize += delegate { applet.ToHTMLElement().style.SetSize( Native.Window.Width, Native.Window.Height ); }; } ); @"Hello world".ToDocumentTitle(); // Send data from JavaScript to the server tier service.WebMethod2( @"A string from JavaScript.", value => value.ToDocumentTitle() ); }
/// <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) { // what is roslyn doing that is breaking async for us? // 02000002 LBAPrequelPromotion.Application // script: error JSC1000: unsupported flow detected, try to simplify. //Assembly V:\LBAPrequelPromotion.Application.exe //DeclaringType LBAPrequelPromotion.Application, LBAPrequelPromotion.Application, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null // OwnerMethod.ctor // Offset 0065 // .Try ommiting the return, break or continue instruction. // not ready for roslyn! #region AtFormCreated FormStyler.AtFormCreated = s => { s.Context.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; var x = new ChromeTCPServerWithFrameNone.HTML.Pages.AppWindowDrag().AttachTo(s.Context.GetHTMLTarget()); }; #endregion #region ChromeTCPServer dynamic self = Native.self; dynamic self_chrome = self.chrome; object self_chrome_socket = self_chrome.socket; if (self_chrome_socket != null) { chrome.Notification.DefaultTitle = "LBA Redux"; chrome.Notification.DefaultIconUrl = new HTML.Images.FromAssets.Preview().src; ChromeTCPServer.TheServerWithStyledForm.Invoke( AppSource.Text, AtFormCreated: FormStyler.AtFormCreated ); return; } #endregion // https://docs.google.com/a/jsc-solutions.net/spreadsheet/ccc?key=0AjBm0oHdZ3DwdFhMb2UxVnBYUnNnUE16LUNiUzJJSVE#gid=0 //<iframe src="https://docs.google.com/a/jsc-solutions.net/spreadsheet/embeddedform?formkey=dFhMb2UxVnBYUnNnUE16LUNiUzJJSVE6MQ" width="760" height="692" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe> var onpause = new SAMPLES036 { volume = 0.3, autobuffer = true }; var onunpause = new SAMPLES219 { autobuffer = true }; onunpause.load(); page.p96.InvokeOnComplete( delegate { page.p512.InvokeOnComplete( delegate { var diagnostics = new IHTMLIFrame { src = "https://docs.google.com/a/jsc-solutions.net/spreadsheet/embeddedform?formkey=dFhMb2UxVnBYUnNnUE16LUNiUzJJSVE6MQ", frameBorder = "0" }; diagnostics.style.backgroundColor = "rgba(255, 255, 255, 0)"; diagnostics.style.position = IStyle.PositionEnum.absolute; diagnostics.style.left = "0px"; diagnostics.style.top = "-100%"; diagnostics.style.width = "100%"; diagnostics.style.height = "100%"; diagnostics.style.zIndex = 9000; diagnostics.AttachToDocument(); // http://www.w3schools.com/css3/css3_transitions.asp diagnostics.style.transition = "all 0.2s ease-in-out"; diagnostics.style.transition = "all 0.3s ease-in-out"; Action Hide = delegate { diagnostics.style.top = "-100%"; diagnostics.style.backgroundColor = "rgba(255, 255, 255, 0)"; onpause.play(); onpause = new SAMPLES036 { volume = 0.3, autobuffer = true }; }; Action Show = delegate { diagnostics.style.top = "0%"; diagnostics.style.backgroundColor = "rgba(255, 255, 255, 0.9)"; onpause.play(); onpause = new SAMPLES036 { volume = 0.3, autobuffer = true }; }; Action Toggle = delegate { if (diagnostics.style.top == "0%") { Hide(); } else { Show(); } }; Action<int> AtKeyCode = KeyCode => { //new { KeyCode }.ToString().ToDocumentTitle(); if (KeyCode == 27) { Hide(); } // EE if (KeyCode == 222) { Toggle(); } // US if (KeyCode == 192) { Toggle(); } }; Native.Document.onkeyup += e => { AtKeyCode(e.KeyCode); }; //Native.window.onorientationchange += // delegate // { // Toggle(); // }; page.fund.href = diagnostics.src; page.fund.onclick += e => { e.preventDefault(); e.stopPropagation(); Toggle(); }; #region fundraiser Action fundraiser = null; fundraiser = delegate { var snd = new SAMPLES037 { volume = 0.01 + 0.1.Random() }; new Timer( delegate { page.fundspan.style.Opacity = 0.3; new Timer( delegate { page.fundspan.style.Opacity = 1; snd.play(); new Timer( delegate { page.fundspan.style.Opacity = 0.7; new Timer( delegate { page.fundspan.style.Opacity = 1; new Timer( delegate { page.fundspan.style.Opacity = 0.7; new Timer( delegate { page.fundspan.style.Opacity = 1; new Timer( delegate { page.fundspan.style.Opacity = 0.7; new Timer( delegate { page.fundspan.style.Opacity = 1; new Timer( delegate { fundraiser(); } ).StartTimeout(3000); } ).StartTimeout(300); } ).StartTimeout(300); } ).StartTimeout(300); } ).StartTimeout(300); } ).StartTimeout(300); } ).StartTimeout(300); } ).StartTimeout(10000 + 60000.Random()); } ).StartTimeout(300); }; fundraiser(); #endregion Native.Document.title = "LBA Redux"; #region newicon Action newicon = delegate { Native.Document.getElementsByTagName("link").AsEnumerable().ToList().WithEach( e => { var link = (IHTMLLink)e; if (link.rel == "icon") { if (link.type == "image/png") { link.href = new fullbox().src; } else { link.Orphanize(); } } } ); }; newicon(); #endregion #region music var musicnext = new _01_Track_1 { volume = 0.1, autobuffer = true }; var music = default(_01_Track_1); Action loop = null; loop = delegate { music = musicnext.AttachToDocument(); musicnext = new _01_Track_1 { volume = 0.1, autobuffer = true }; music.onended += delegate { Console.WriteLine(" music.onended "); music.Orphanize(); loop(); }; music.play(); }; loop(); #endregion Native.window.onscroll += e => { if (e.Element != Native.Document) return; e.preventDefault(); e.stopPropagation(); Native.window.scrollTo(0, 0); }; //new gong().AttachToDocument().play(); new ThreeDStuff.js.Tycoon4( t => { page.Preview.onclick += delegate { t.toolbar_btn_pause.RaiseClicked(); }; t.toolbar_btn_pause.Clicked += delegate { if (t.toolbar_btn_pause.IsActivated) { onpause.play(); onpause = new SAMPLES036 { volume = 0.3, autobuffer = true }; t.PauseFogTween.Value = 0.7; music.volume = 0.01; page.Preview.Show(); } else { //PauseFogTween.Value = 0; t.PauseFogTween.Value = 0; //gong.play(); onunpause.play(); onunpause = new SAMPLES219 { autobuffer = true }; page.Preview.FadeOut(); music.volume = 0.1; } }; t.toolbar_btn_pause.RaiseClicked(); new Timer( delegate { t.toolbar_btn_pause.RaiseClicked(); } ).StartTimeout(4000); } ); } ); } ); }
/// <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(IDefault page = null) { var location = "" + Native.document.location; #if false #region workaround for ThreeJS/chrome webgl upscale bug // workaround for not knowing how to tell three js to upscale correctly.. // X:\jsc.svn\examples\javascript\Test\TestNestedIFrameForMoreWidth\TestNestedIFrameForMoreWidth\Application.cs // instead of reloading full app // could we run part of it instead? // like let jsc know that this sub application should be reloadable? // this will be like threading // the outer code wil just stop doing anything // and the inner app will take over. if (Native.window.Width < Native.screen.width) { #region make sure the url looks different to make iframe actually load Native.window.parent.With( parent => { // http://stackoverflow.com/questions/5934538/is-there-a-limitation-on-an-iframe-containing-another-iframe-with-the-same-url var parentlocation = ""; try { parentlocation = parent.document.location.href; Console.WriteLine(new { parentlocation }); } catch { // we are sandboxed! } if (parentlocation.TakeUntilIfAny("#") == location.TakeUntilIfAny("#")) { var withouthash = location.TakeUntilIfAny("#"); var onlyhash = location.SkipUntilOrEmpty("#"); withouthash += "?"; if (onlyhash != "") { withouthash += "#" + onlyhash; } location = withouthash; } } ); #endregion // this check only looks for default screen width // what about height and secondary screens? Console.WriteLine("will prepare... " + location); var iframe = new IHTMLIFrame { frameBorder = "0", allowFullScreen = true }; iframe.style.minWidth = Native.screen.width + "px"; iframe.style.minHeight = Native.screen.height + "px"; iframe.style.position = IStyle.PositionEnum.absolute; iframe.style.left = "0px"; iframe.style.top = "0px"; iframe.style.width = "100%"; iframe.style.height = "100%"; Native.document.body.Clear(); Native.document.body.style.overflow = IStyle.OverflowEnum.hidden; Native.window.onmessage += e => { Console.WriteLine("Native.Window.onmessage " + new { e.data }); // pure trickery :P if ((string)e.data == "WebGLDynamicTerrainTemplate.loaded") { iframe.style.minWidth = ""; iframe.style.minHeight = ""; } }; iframe.onload += delegate { if (iframe.src != location) return; Native.window.requestAnimationFrame += delegate { Console.WriteLine("reload done! " + new { location, iframe.src }); iframe.contentWindow.postMessage("ready yet?"); }; }; Native.window.requestAnimationFrame += delegate { Console.WriteLine("will reload... " + location); iframe.AttachToDocument(); iframe.src = location; }; return; } #endregion #endif #region await Three.js then do InitializeContent new[] { new global::WebGLDynamicTerrainTemplate.Design.ThreeTerrain().Content, new global::WebGLDynamicTerrainTemplate.Design.ShaderTerrain().Content, new global::WebGLDynamicTerrainTemplate.Design.ShaderExtrasTerrain().Content, new global::WebGLDynamicTerrainTemplate.Design.PostprocessingTerrain().Content, }.ForEach( (SourceScriptElement, i, MoveNext) => { SourceScriptElement.AttachToDocument().onload += delegate { MoveNext(); }; } )( delegate { InitializeContent(page); } ); #endregion style.Content.AttachToHead(); }
/// <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) { #region con //var con = new Abstractatech.ConsoleFormPackage.Library.ConsoleForm(); var con = new ConsoleForm(); con.InitializeConsoleFormWriter(); con.Show(); con.Left = Native.Window.Width - con.Width; con.Top = 0; Native.Window.onresize += delegate { con.Left = Native.Window.Width - con.Width; con.Top = 0; }; con.Opacity = 0.6; con.HandleFormClosing = false; con.PopupInsteadOfClosing(); #endregion Console.WriteLine("click on InitializeOurFacebookLoginService!"); Native.Window.onmessage += e => { // http://developer.klout.com/blog/read/fb_identity_lookup Console.WriteLine("onmessage: " + e.data); }; // wont work as chrome app! page.InitializeOurFacebookLoginService.WhenClicked( delegate { Console.WriteLine("loading... "); // http://caniuse.com/iframe-sandbox // http://security.stackexchange.com/questions/15146/using-iframes-to-sandbox-untrusted-code var i = new IHTMLIFrame { }; // http://www.w3schools.com/tags/att_iframe_sandbox.asp // The value of the sandbox attribute can either be an empty string (all the restrictions is applied), or a space-separated list of pre-defined values that will REMOVE particular restrictions. // http://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/ // this will break our popups and cookies for facebook! //i.setAttribute("sandbox", "allow-scripts allow-forms allow-popups"); i.src = "http://young-beach-4377.herokuapp.com/"; i.AttachToDocument(); i.onload += delegate { Console.WriteLine("loading... done " + new { i.src }); // can we now talk to it? // }; } ); page.InitializeOurFacebookLoginServiceViaWindow.WhenClicked( delegate { Console.WriteLine("loading... "); //var i = new IWindow { }; //i.document.location.href = "http://young-beach-4377.herokuapp.com/"; var i = Native.Window.open("http://young-beach-4377.herokuapp.com/", "_blank", 400, 225); // doesnt tell us when loaded? i.onload += delegate { Console.WriteLine("loading... done..."); //Console.WriteLine("loading... done " + new { i.document.title }); //Console.WriteLine("loading... done " + new { i.document.location.href }); // can we now talk to it? // }; // popup will be blocked //new IHTMLButton { innerText = "send DoLogin" }.AttachToDocument().WhenClicked( // delegate // { // Console.WriteLine("send DoLogin"); // i.postMessage( // new XElement("DoLogin", new XAttribute("tag", "foo")).ToString() // ); // } //); } ); page.InitializeOurFacebookLoginServiceViaWindowAndClose.WhenClicked( delegate { Console.WriteLine("loading... "); //var i = new IWindow { }; //i.document.location.href = "http://young-beach-4377.herokuapp.com/"; var i = Native.Window.open("http://young-beach-4377.herokuapp.com/#c", "_blank", 400, 225); // doesnt tell us when loaded? i.onload += delegate { Console.WriteLine("InitializeOurFacebookLoginServiceViaWindowAndClose loading... done..."); //Console.WriteLine("loading... done " + new { i.document.title }); //Console.WriteLine("loading... done " + new { i.document.location.href }); // can we now talk to it? // }; i.onbeforeunload += delegate { Console.WriteLine("InitializeOurFacebookLoginServiceViaWindowAndClose onbeforeunload"); }; // popup will be blocked //new IHTMLButton { innerText = "send DoLogin" }.AttachToDocument().WhenClicked( // delegate // { // Console.WriteLine("send DoLogin"); // i.postMessage( // new XElement("DoLogin", new XAttribute("tag", "foo")).ToString() // ); // } //); } ); page.HerokuFacebookLoginAppLoginExperience.WhenClicked( delegate { HerokuFacebookLoginAppLoginExperience.Login( (string id, string name, string third_party_id) => { Console.WriteLine(new { id, name, third_party_id }); } ); } ); @"Hello world".ToDocumentTitle(); // Send data from JavaScript to the server tier //service.WebMethod2( // @"A string from JavaScript.", // value => value.ToDocumentTitle() //); }
public static Action BindKeyboardToDiagnosticsConsole() { var diagnostics = new IHTMLIFrame { src = "/jsc", frameBorder = "0" }; diagnostics.style.backgroundColor = "rgba(255, 255, 255, 0)"; diagnostics.style.position = IStyle.PositionEnum.absolute; diagnostics.style.left = "0px"; diagnostics.style.top = "-100%"; diagnostics.style.width = "100%"; diagnostics.style.height = "100%"; // stay on top! diagnostics.style.zIndex = 10000; Console.WriteLine("You can now press tilde key to see the /jsc page."); diagnostics.AttachToDocument(); // http://www.w3schools.com/css3/css3_transitions.asp diagnostics.style.With( (dynamic s) => s.webkitTransition = "all 0.2s ease-in-out" ); diagnostics.style.With( (dynamic s) => s.transition = "all 0.3s ease-in-out" ); Action Hide = delegate { diagnostics.style.top = "-100%"; diagnostics.style.backgroundColor = "rgba(255, 255, 255, 0)"; }; Action Show = delegate { diagnostics.style.top = "0%"; diagnostics.style.backgroundColor = "rgba(255, 255, 255, 0.9)"; }; Action Toggle = delegate { if (diagnostics.style.top == "0%") { Hide(); } else { Show(); } }; Action<int> AtKeyCode = KeyCode => { new { KeyCode }.ToString().ToDocumentTitle(); if (KeyCode == 27) { Hide(); } // US if (KeyCode == 222) { Toggle(); } // EE if (KeyCode == 192) { Toggle(); } }; diagnostics.onload += delegate { diagnostics.contentWindow.document.onkeyup += e => { AtKeyCode(e.KeyCode); }; diagnostics.contentWindow.document.oncontextmenu += e => { e.preventDefault(); Hide(); }; }; Native.document.onkeyup += e => { AtKeyCode(e.KeyCode); }; //Native.window.onorientationchange += // delegate // { // if (Native.window.orientation == 90) // Show(); // else if (Native.window.orientation == -90) // Show(); // else // Hide(); // }; return Toggle; }