diff --git a/CefSharp.Example/Properties/Resources.Designer.cs b/CefSharp.Example/Properties/Resources.Designer.cs index 822e4ac0c..737e8994e 100644 --- a/CefSharp.Example/Properties/Resources.Designer.cs +++ b/CefSharp.Example/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34209 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -220,6 +220,33 @@ namespace CefSharp.Example.Properties { } } + /// + /// Looks up a localized string similar to /** + /// * SyntaxHighlighter + /// * http://alexgorbatchev.com/SyntaxHighlighter + /// * + /// * SyntaxHighlighter is donationware. If you are using it, please donate. + /// * http://alexgorbatchev.com/SyntaxHighlighter/donate.html + /// * + /// * @version + /// * 3.0.83 (July 02 2010) + /// * + /// * @copyright + /// * Copyright (C) 2004-2010 Alex Gorbatchev. + /// * + /// * @license + /// * Dual licensed under the MIT and GPL licenses. + /// */ + ///; (function () { + /// // CommonJS + /// typeof (require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxH [rest of string was truncated]";. + /// + internal static string assets_js_shBrushJScript_js { + get { + return ResourceManager.GetString("assets_js_shBrushJScript_js", resourceCulture); + } + } + /// /// Looks up a localized string similar to /** /// * SyntaxHighlighter @@ -357,12 +384,12 @@ namespace CefSharp.Example.Properties { /// /// Looks up a localized string similar to <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> ///<html> - /// <head> - /// <title>Framed WebGL Test</title> - /// </head> - /// <body> + /// <head> + /// <title>Framed WebGL Test</title> + /// </head> + /// <body> /// <iframe width="600" height="400" src="http://webglsamples.org/aquarium/aquarium.html"></iframe> - /// </body> + /// </body> ///</html> ///. /// @@ -396,17 +423,16 @@ namespace CefSharp.Example.Properties { /// /// Looks up a localized string similar to <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> ///<html> - /// <head> - /// <title>Multi Binding Test</title> - /// </head> - /// <body> - /// <table style="width:100%; height:100%"> - /// <tr height="50%"> - /// <td width="50%"> - /// <iframe src="custom://cefsharp/BindingTest.html" style="width:100%; height:100%"></iframe> - /// </td> - /// <td width="50%"> - /// <iframe src="custom://cefsharp/BindingTest.html" style="width:100%; heig [rest of string was truncated]";. + /// <head> + /// <title>Multi Binding Test</title> + /// <script type="text/javascript"> + /// var DYNAMIC_CONTAINER_COUNT = 6; + /// var PRIMES = [1453, 4273, 6277, 9923, 26099, 41231]; + /// function replaceContainer(id, src) + /// { + /// console.log("Replacing Container " + id); + /// var container = document.getElementById("dynamicContainer" + id); + /// var newFram [rest of string was truncated]";. /// internal static string MultiBindingTest { get { @@ -426,9 +452,8 @@ namespace CefSharp.Example.Properties { /// <a href="#" onclick="window.open('https://github.com/CefSharp/CefSharp')">window.open()</a> /// <br /> /// <a href="#" onclick="window.open('custom://cefsharp/BindingTest.html')">BindingTest.html</a> - /// </body> - ///</html> - ///. + /// <br /> + /// <a href="#" onclick [rest of string was truncated]";. /// internal static string PopupTest { get { @@ -462,23 +487,45 @@ namespace CefSharp.Example.Properties { } } + /// + /// Looks up a localized string similar to <!DOCTYPE html> + ///<html lang="en"> + ///<head> + /// <meta charset="utf-8"> + /// <meta name="viewport" content="width=device-width, initial-scale=1.0"> + /// <meta name="description" content=""> + /// <meta name="author" content=""> + /// <title>ScriptedMethodsTest</title> + /// <link href="bootstrap/bootstrap.min.css" rel="stylesheet"> + /// <link href="assets/css/shCore.css" rel="stylesheet"> + /// <link href="assets/css/shCoreDefault.css" rel="stylesheet"> + ///</head> + ///<body> + /// <div class="container"> + /// <div [rest of string was truncated]";. + /// + internal static string ScriptedMethodsTest { + get { + return ResourceManager.GetString("ScriptedMethodsTest", resourceCulture); + } + } + /// /// Looks up a localized string similar to <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> ///<html> - /// <head> - /// <title>Scheme Handler Test</title> - /// </head> - /// <body> + /// <head> + /// <title>Tooltip Test</title> + /// </head> + /// <body style="width:500px;"> /// <form> /// <input type="text" size=25 title="This is the first tooltip"> /// <br /> /// <input type="text" size=25 title="This is the second tooltip"> /// <br /> - /// <select> - /// <option selected>test</option> - /// <option>one</option> - /// <option>two</option> - /// </select> [rest of string was truncated]";. + /// <div> + /// <select style="float: left;"> + /// <option selected>test</option> + /// [rest of string was truncated]";. /// internal static string TooltipTest { get { diff --git a/CefSharp.Example/Properties/Resources.resx b/CefSharp.Example/Properties/Resources.resx index 61dd1f66b..1fe73e3f1 100644 --- a/CefSharp.Example/Properties/Resources.resx +++ b/CefSharp.Example/Properties/Resources.resx @@ -175,4 +175,10 @@ ..\Resources\MultiBindingTest.html;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + ..\Resources\assets\js\shBrushJScript.js;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + + ..\Resources\ScriptedMethodsTest.html;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + \ No newline at end of file diff --git a/CefSharp.Example/Resources/ScriptedMethodsTest.html b/CefSharp.Example/Resources/ScriptedMethodsTest.html new file mode 100644 index 000000000..f53def8c8 --- /dev/null +++ b/CefSharp.Example/Resources/ScriptedMethodsTest.html @@ -0,0 +1,60 @@ + + + + + + + + ScriptedMethodsTest + + + + + +
+ +

Asynchronous events from the Javascript environment.

+

Sending events from the Javascript environment to a .Net class involves the following:

+ +

Most of the time the web page's Javascript will be written specifically to interact with the embedded browser and any class methods that are exposed through RegisterJsObject. However to monitor some web pages it may be necessary to inject Javascript code that can detect changes and events in the web page and then invoke a method on a bound object.

+ +

Demonstration

+

This page demonstrates the injection of Javascript code that asynchronously invokes a bound method when a button is clicked. Clicking the Script -> Listen for button click menu will cause Javascript1 to be executed that adds an event listener to the click event of the button below. When the button is clicked the bound class's exposed method will be invoked with information from the event including the element's id attribute and tag name.

+ +

1Javascript code that adds a click event listener and passes event data to .Net when the event occurs.

+
+            (function () {
+                var counter = 0;
+	            var elem = document.getElementById('test-button');
+                elem.removeAttribute('disabled');
+	            elem.addEventListener('click', function(e){
+		            if (!window.boundEvent){
+			            console.log('window.boundEvent does not exist.');
+			            return;
+		            }
+                    counter++;
+            		window.boundEvent.raiseEvent('click', {count: counter, id: e.target.id, tagName: e.target.tagName});
+	            });
+	            console.log(`Added click listener to ${elem.id}.`);
+            })();
+        
+
+ + + + + + + + + + diff --git a/CefSharp.Example/Resources/assets/js/application.js b/CefSharp.Example/Resources/assets/js/application.js index 1c722fad2..f9acc72f7 100644 --- a/CefSharp.Example/Resources/assets/js/application.js +++ b/CefSharp.Example/Resources/assets/js/application.js @@ -60,6 +60,7 @@ // TODO: Create a PR towards the JS SyntaxHighlighter so we don't have to do this kludge. $('[data-shBrush=csharp]').attr('class', 'brush: csharp'); + $('[data-shBrush=js]').attr('class', 'brush: js'); SyntaxHighlighter.all(); }); diff --git a/CefSharp.Example/Resources/assets/js/shBrushJScript.js b/CefSharp.Example/Resources/assets/js/shBrushJScript.js new file mode 100644 index 000000000..39d3b0185 --- /dev/null +++ b/CefSharp.Example/Resources/assets/js/shBrushJScript.js @@ -0,0 +1,50 @@ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/SyntaxHighlighter + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/SyntaxHighlighter/donate.html + * + * @version + * 3.0.83 (July 02 2010) + * + * @copyright + * Copyright (C) 2004-2010 Alex Gorbatchev. + * + * @license + * Dual licensed under the MIT and GPL licenses. + */ +; (function () { + // CommonJS + typeof (require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null; + + function Brush() { + var keywords = 'break case catch continue ' + + 'default delete do else false ' + + 'for function if in instanceof ' + + 'new null return super switch ' + + 'this throw true try typeof var while with' + ; + + var r = SyntaxHighlighter.regexLib; + + this.regexList = [ + { regex: r.multiLineDoubleQuotedString, css: 'string' }, // double quoted strings + { regex: r.multiLineSingleQuotedString, css: 'string' }, // single quoted strings + { regex: r.singleLineCComments, css: 'comments' }, // one line comments + { regex: r.multiLineCComments, css: 'comments' }, // multiline comments + { regex: /\s*#.*/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // keywords + ]; + + this.forHtmlScript(r.scriptScriptTags); + }; + + Brush.prototype = new SyntaxHighlighter.Highlighter(); + Brush.aliases = ['js', 'jscript', 'javascript']; + + SyntaxHighlighter.brushes.JScript = Brush; + + // CommonJS + typeof (exports) != 'undefined' ? exports.Brush = Brush : null; +})();