public Application(IApp page) { this.page = page; // historic callsite scoping does not yet support instance references that = this; // X:\jsc.svn\examples\javascript\UIAutomationEvents\UIAutomationEvents\Application.cs page.YesIAgree.Historic( async scope => { // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201405/20140526 new UIEvent(UIEventsOfInterestAndSignificance.ClickAgree, NestedEvents: that.Events.ToArray()).With( e => { that.Events.Clear(); that.Events.Add(e); } ); var message = await that.Agree(that.page.email); var x = new IHTMLPre { new { message } }.AttachToDocument(); await scope; x.Orphanize(); } ); }
/// <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) { // allow to be called from historic function service = this; new IStyle(IHTMLElement.HTMLElementEnum.head).display = IStyle.DisplayEnum.block; new IStyle(IHTMLElement.HTMLElementEnum.title).display = IStyle.DisplayEnum.block; // UI Automation // can we show svg as background? // we already had multimouse drawing dint we? document.onmousemove += e => { // update the curent shadow element // contentText wont work on non pseudo? pseudo[index % 2].contentText = new { random, index, x = e.CursorX, y = e.CursorY, z = window.history.length } .ToString(); pseudo[index % 2].style.SetLocation( e.CursorX, e.CursorY ); pseudo[index % 2].style.position = IStyle.PositionEnum.@fixed; pseudo[index % 2].style.color = "blue"; //current.memory }; //document.documentElement.click(); // do not resume if browser has historic data. if (window.history.length != 1) // cant we use console as body? //body.innerText = "will not try to resume, as there is history. start a new clean tab insead."; document.title = "will not try to resume, as there is history. start a new clean tab insead."; else // resume only works if a new tab is spawned without any history! Resume( e => { if (!e.Any()) return; if (!window.confirm("resume state of " + e.Count())) { ForgetAll(); return; } replay = e.ToList(); foreach (var item in e) { // lets start to replay. // ? document.body.click(); break; } // fake //Console.WriteLine("click " + new { e.x, e.y }); } ); document.onclick += e => { // did jsc do background compilation and update our snapshot // and add the new version into AB testing view by jsc zombie server? // or did I have to hit F5 again? // can we flip the new shadow dom element into view? // Error 2 No overload for method 'pushState' takes 2 arguments X:\jsc.svn\examples\javascript\future\HistoricSnapshotMashup\HistoricSnapshotMashup\Application.cs 84 21 HistoricSnapshotMashup //HistoryExtensions.pushState( // h: window.history, long x = e.CursorX; long y = e.CursorY; if (replay.Any()) { x = replay[0].x; y = replay[0].y; } window.history.pushState( state: new { index, x, y }, yield: async scope => { if (replay.Any()) { service.data.Add(replay[0]); replay.RemoveAt(0); } else { // prepare new data to be saved service.data.Add( new Data.HistoricsTheEntryRow { x = scope.state.x, y = scope.state.y, index = scope.state.index, } ); } // make it stale pseudo[index % 2].style.color = "gray"; Console.WriteLine("enter scope " + new { index }); index++; // show without mouse hover! pseudo[index % 2].style.color = "blue"; //pseudo[index % 2].contentText = new { index, z = window.history.length }.ToString(); pseudo[index % 2].contentText = new { service.random, index, x = scope.state.x, y = scope.state.y, z = window.history.length } .ToString(); var pre = new IHTMLPre { new { service.random, index, x = scope.state.x, y = scope.state.y, z = window.history.length } }.AttachToDocument(); pre.style.SetLocation( (int)scope.state.x, (int)scope.state.y ); pseudo[index % 2].style.SetLocation( (int)scope.state.x, (int)scope.state.y ); pseudo[index % 2].style.backgroundColor = "yellow"; await Task.Delay(300); pseudo[index % 2].style.backgroundColor = "transparent"; // save it! bit late tho await service.InsertNewHistoric(); await scope; pre.Orphanize(); // so. what state did we remove? var forget = service.data.Last(); // pop. does jsc tier split support stack? service.data.RemoveAt(service.data.Count - 1); service.Forget(forget); Console.WriteLine("exit scope " + new { index }); // this is from the future then? click forward to reactivate? pseudo[index % 2].style.color = "red"; // undo??? // exclusive? index--; pseudo[index % 2].contentText = new { index, z = window.history.length }.ToString(); // show without mouse hover! pseudo[index % 2].style.color = "blue"; pseudo[index % 2].style.transition = ""; pseudo[index % 2].style.backgroundColor = "cyan"; await Task.Delay(300); pseudo[index % 2].style.backgroundColor = "transparent"; } ); }; }
/// <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) { // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201405/20140517 this.page = page; // historic callsite scoping does not yet support instance references that = this; page.email.ondblclick += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.ondblclick)); page.email.onclick += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onclick)); page.email.onmouseover += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onmouseover)); page.email.onmouseout += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onmouseout)); page.email.onchange += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onchange)); page.email.onfocus += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onfocus)); page.email.onblur += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onblur)); page.email.onkeyup += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "email " + new { page.email.value }, IHTMLEvents.onkeyup)); page.EULA.onmouseover += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "EULA " + new { }, IHTMLEvents.onmouseover)); page.EULA.onmouseout += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "EULA " + new { }, IHTMLEvents.onmouseout)); page.EULA.onfocus += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "EULA " + new { }, IHTMLEvents.onfocus)); page.EULA.onblur += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "EULA " + new { }, IHTMLEvents.onblur)); page.EULA.onscroll += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "EULA " + new { }, IHTMLEvents.onscroll)); window.onfocus += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "window " + new { }, IHTMLEvents.onfocus)); window.onblur += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "window " + new { }, IHTMLEvents.onblur)); window.onscroll += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "window " + new { }, IHTMLEvents.onscroll)); //redux //window.ondeviceorientation += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "window " + new { }, IHTMLEvents.ondeviceorientation)); window.onresize += e => Events.Add(new UIEvent(UIEventsOfInterestAndSignificance.DOM, "window " + new { }, IHTMLEvents.onresize)); // ScriptCoreLib could also ask for expression which it could monitor a bit better // or we could use variable monitoring speed. slow down when no updates. // or we could ask to be notified if a field changes. jsc magic needed? new IHTMLPre { () => new { Events.Count, LastOrDefault = Events.LastOrDefault() } }.AttachToDocument(); // also send in the performance data //:26ms enter Historic: // { // domain = 192.168.1.76, baseURI = http://192.168.1.76:10237/, location = http://192.168.1.76:10237/, xlocation = http://192.168.1.76:10237/, href = http://192.168.1.76:10237/agree } //0:26ms event: activate! { hash = , url = } //0:27ms event: onclick // { // href = http://192.168.1.76:10237/agree, MouseButton = 1 } css.style.transition = "background-color 300ms linear"; new IStyle(that.page.HideMe) { transition = "margin-top 300ms linear" }; new IStyle(that.page.EULA.css) { borderLeft = "1em solid yellow", transition = "border-left 600ms linear", }; new IStyle(that.page.EULA.css[that.page.EULA.async.onscrollToBottom]) { borderLeft = "1em solid green" }; //Native.window.async.onscrollToBottom //page.EULA.onscroll //page.email.async.onscr //page.EULA.onscroll += // delegate //{ // Console.WriteLine(new // { // page.EULA.scrollTop, // page.EULA.scrollHeight, // page.EULA.clientHeight // }); //}; //page.EULA.async.onscrollToBottom.With( // async onscrollToBottom => // { // await onscrollToBottom; // page.EULA.style.borderLeft = "1em solid green"; // } //); page.YesIAgree.Historic( async (HistoryScope<object> scope) => { // indicate we are sending data to server css.style.backgroundColor = "yellow"; //new IStyle(that.page.HideMe) // we want it to be undone at back button! new IStyle(that.page.HideMe.css) { marginTop = -that.page.HideMe.clientHeight + "px" }; // X:\jsc.svn\examples\javascript\async\test\TestChainedAsync\TestChainedAsync\Application.cs // we are basically grouping it // why is it destroying rewrite? new UIEvent(UIEventsOfInterestAndSignificance.ClickAgree, NestedEvents: that.Events.ToArray()).With( e => { that.Events.Clear(); that.Events.Add(e); } ); var message = await that.Agree(that.page.email); // indicate got data css.style.backgroundColor = "cyan"; var x = new IHTMLPre { new { message } }.AttachToDocument(); that.Events.Add( new UIEvent(UIEventsOfInterestAndSignificance.ClickAgreeComplete, Data: new { message }.ToString()) ); await scope; // indicate we went back in time // css will be undone bj scriptcorelib! // back button! x.Orphanize(); that.Events.Add( new UIEvent(UIEventsOfInterestAndSignificance.ClickAgreeHistoryGoBack) ); } ); }