Inheritance: SampleAppModule
示例#1
0
        private void cmdTestSampleAppModule_Click(object sender, EventArgs e)
        {
            //1. create our custom app module
            myAppModule = new MyTestHtmlAppModule();
            //1. init html
            easeViewport.LoadHtmlString(myAppModule.RootDir, myAppModule.GetInitPage());
            //----------------------------------------------------------------
            //after load html page
            //2.  assign dom
            myAppModule.HtmlDoc = easeViewport.GetHtmlDom() as LayoutFarm.WebDom.IHtmlDocument;
            //3. assign  js console
            myAppModule.Console = myWbConsole;
            //4. init js engine
            myAppModule.InitJsEngine();
            //----------------------------------------------------------------
            //5. test access/ modify/ interact dom with js
            string simplejs   = @"
                    (function(){
                        console.log('hello world!');
                        var domNodeA = document.getElementById('a');
                        var domNodeB = document.getElementById('b');
                        var domNodeC = document.getElementById('c');

                        var newText1 = document.createTextNode('... says hello world!');
                        domNodeA.appendChild(newText1);

                        for(var i=0;i<10;++i){
                            var newText2= document.createTextNode(i.toString());
                            domNodeA.appendChild(newText2);       
                        } 

                        var newDivNode= document.createElement('div');
                        newDivNode.appendChild(document.createTextNode('new div'));
                        newDivNode.attachEventListener('mousedown',function(){console.log('new div');});
                        domNodeB.appendChild(newDivNode);    
                        
                        domNodeC.innerHTML='<div> from inner html <span> from span</span> </div>';
                        console.log(domNodeC.innerHTML);
                    })();
                ";
            object testResult = myAppModule.ExecuteJs(simplejs);
        }
示例#2
0
        private void cmdTestSampleAppModule_Click(object sender, EventArgs e)
        {
            //1. create our custom app module
            myAppModule = new MyTestHtmlAppModule();
            //1. init html 
            easeViewport.LoadHtmlString(myAppModule.RootDir, myAppModule.GetInitPage());
            //----------------------------------------------------------------
            //after load html page 
            //2.  assign dom 
            myAppModule.HtmlDoc = easeViewport.GetHtmlDom() as LayoutFarm.WebDom.IHtmlDocument;
            //3. assign  js console 
            myAppModule.Console = myWbConsole;
            //4. init js engine
            myAppModule.InitJsEngine();
            //---------------------------------------------------------------- 
            //5. test access/ modify/ interact dom with js
            string simplejs = @"
                    (function(){
                        console.log('hello world!');
                        var domNodeA = document.getElementById('a');
                        var domNodeB = document.getElementById('b');
                        var domNodeC = document.getElementById('c');

                        var newText1 = document.createTextNode('... says hello world!');
                        domNodeA.appendChild(newText1);

                        for(var i=0;i<10;++i){
                            var newText2= document.createTextNode(i.toString());
                            domNodeA.appendChild(newText2);       
                        } 

                        var newDivNode= document.createElement('div');
                        newDivNode.appendChild(document.createTextNode('new div'));
                        newDivNode.attachEventListener('mousedown',function(){console.log('new div');});
                        domNodeB.appendChild(newDivNode);    
                        
                        domNodeC.innerHTML='<div> from inner html <span> from span</span> </div>';
                        console.log(domNodeC.innerHTML);
                    })();
                ";
            object testResult = myAppModule.ExecuteJs(simplejs);

        }