Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

*JSCall delimiter changed; hopefully an extended ASCII char will do

svn path=/trunk/aspeditor/; revision=49932
  • Loading branch information...
commit ed5da8c07955c99fd116cffaac11edeb4786f3b1 1 parent ed28d93
Blagovest Dachev authored
View
23 src/chrome/README
@@ -1,24 +1,14 @@
INSTALLATION
============
-All the files in src/chrome/content should go in $MOZ_HOME/chrome/aspdesigner/content/aspdesigner
-All the files in src/chrome/locale should go in $MOZ_HOME/chrome/aspdesigner/locale/en-US/aspdesigner
-All the files in src/chrome/skin should go in $MOZ_HOME/chrome/aspdesigner/skin/aspdesigner
+All the files in src/chrome/content should go in $MOZ_HOME/chrome/aspdesigner/content
+All the files in src/chrome/locale should go in $MOZ_HOME/chrome/aspdesigner/locale/en-US
The following lines should be added to the end of $MOZ_HOME/chrome/installed-chrome.txt:
-content,install,url,resource:/chrome/aspdesigner/content/aspdesigner/
-skin,install,url,resource:/chrome/aspdesigner/skin/aspdesigner/
-locale,install,url,resource:/chrome/aspdesigner/locale/en-US/aspdesigner/
+content,install,url,resource:/chrome/aspdesigner/content/
+locale,install,url,resource:/chrome/aspdesigner/locale/en-US/
The extention will be available through the following URL:
-chrome://aspdesigner/content/aspdesigner.xul
-
-Alternatively a jar file instalation will yield the following:
-$MOZ_HOME/chrome/aspNetEditor.jar
-
-The following lines should be added to the end of $MOZ_HOME/chrome/installed-chrome.txt:
-content,install,url,jar:resource:/chrome/aspNetEditor.jar!/content/
-locale,install,url,jar:resource:/chrome/aspNetEditor.jar!/locale/en-US/
-skin,install,url,jar:resource:/chrome/aspNetEditor.jar!/skin/
+chrome://aspdesigner/content/editor.xul
EDITOR COMMANDS
===============
@@ -27,3 +17,6 @@ http://lxr.mozilla.org/seamonkey/source/editor/docs/Editor_Embedding_Guide.html
Currently commands with parameters are NOT supported. This is going to change soon.
+INTERFACE
+===============
+
View
320 src/jscall/AspNetEdit.JSCall/CommandManager.cs
@@ -26,163 +26,163 @@
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-using System;
-using System.Collections;
-using Gecko;
-using System.Text;
-using System.Runtime.InteropServices;
-
-namespace AspNetEdit.JSCall
-{
- public class CommandManager
- {
- [DllImport ("jscallglue.dll")]
- static extern int PlaceFunctionCall (IntPtr embed,
- [MarshalAs(UnmanagedType.LPWStr)] string call,
- [MarshalAs(UnmanagedType.LPWStr)] string returnto,
- [MarshalAs(UnmanagedType.LPWStr)] string args);
-
- private Hashtable functions;
- private WebControl webControl;
-
- public CommandManager (WebControl w)
- {
- functions = new Hashtable();
-
- webControl = w;
- webControl.TitleChange += new EventHandler (webControl_ECMAStatus);
- }
-
- private void webControl_ECMAStatus (object sender, EventArgs e)
- {
- if (!webControl.Title.StartsWith ("JSCall"))
- return;
-
- string[] call = webControl.Title.Split ('|');
- if (call.Length < 2)
- throw new Exception ("Too few parameters in call from JavaScript");
-
- string function = call[1];
- string returnTo = call[2];
-
- string[] args = (string[]) System.Array.CreateInstance (typeof(String), (call.Length - 3));
- System.Array.Copy (call, 3, args, 0, (call.Length - 3));
-
- if (!functions.Contains (function))
- throw new Exception ("Unknown function name called from JavaScript");
-
- ClrCall clrCall = (ClrCall) functions[function];
-
-
- if (returnTo.Length == 0)
- {
- string result = clrCall (args);
- }
- else
- {
- string[] result = { clrCall (args) };
- JSCall(returnTo, null, result);
- }
- }
-
-
-
- public void JSCall (string function, string returnTo, params string[] args)
- {
- string argsOut = String.Empty;
-
- if (args != null)
- {
- argsOut += args[0];
- for (int i = 1; i <= args.Length - 1; i++)
- {
- argsOut += "|" + args[i];
- }
- }
-
- if (returnTo == null) returnTo = string.Empty;
- int result = PlaceFunctionCall (webControl.Handle, function, returnTo, argsOut);
-
- string err;
-
- switch (result)
- {
- case 0:
- return;
-
- case 1:
- err = "Could not obtain IDOMDocument from GtkMozEmbed. Have you shown the window yet?";
- break;
-
- case 2:
- err = "Error finding 'jscall' nodes.";
- break;
-
- case 3:
- err = "Error getting number of 'jscall' nodes.";
- break;
-
- case 4:
- err = "More or fewer than one 'jscall' node.";
- break;
-
- case 5:
- err = "Error getting 'jscall' node.";
- break;
-
- case 6:
- err = "Error adding 'infunction' node.";
- break;
-
- case 7:
- err = "Error setting attributes on 'infunction' node.";
- break;
-
- case 8:
- err = "Error getting nsIDOMNode interface on 'infunction' node.";
- break;
-
- case 9:
- err = "Error appending 'infunction' node to 'jscall' node.";
- break;
-
- default:
- err = "The glue wrapper returned an unknown error.";
- break;
- }
-
- throw new Exception ("Glue function PlaceFunctionCall: "+err);
- }
-
- public void RegisterJSHandler (string name, ClrCall handler)
- {
- if (!functions.Contains (name))
- {
- functions.Add (name, handler);
- }
- else
- {
- throw new Exception ("A handler with this name already exists");
- }
-
- }
-
- public void UnregisterJSHandler (string name)
- {
- if (functions.Contains (name))
- {
- functions.Remove (name);
- }
- else
- {
- throw new IndexOutOfRangeException ("A function with this name has not been registered");
- }
- }
-
- }
-
-
- public delegate string ClrCall (string[] args);
-}
+ */
+
+using System;
+using System.Collections;
+using Gecko;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace AspNetEdit.JSCall
+{
+ public class CommandManager
+ {
+ [DllImport ("jscallglue.dll")]
+ static extern int PlaceFunctionCall (IntPtr embed,
+ [MarshalAs(UnmanagedType.LPWStr)] string call,
+ [MarshalAs(UnmanagedType.LPWStr)] string returnto,
+ [MarshalAs(UnmanagedType.LPWStr)] string args);
+
+ private Hashtable functions;
+ private WebControl webControl;
+
+ public CommandManager (WebControl w)
+ {
+ functions = new Hashtable();
+
+ webControl = w;
+ webControl.TitleChange += new EventHandler (webControl_ECMAStatus);
+ }
+
+ private void webControl_ECMAStatus (object sender, EventArgs e)
+ {
+ if (!webControl.Title.StartsWith ("JSCall"))
+ return;
+
+ string[] call = webControl.Title.Split ((char)234);
+ if (call.Length < 2)
+ throw new Exception ("Too few parameters in call from JavaScript");
+
+ string function = call[1];
+ string returnTo = call[2];
+
+ string[] args = (string[]) System.Array.CreateInstance (typeof(String), (call.Length - 3));
+ System.Array.Copy (call, 3, args, 0, (call.Length - 3));
+
+ if (!functions.Contains (function))
+ throw new Exception ("Unknown function name called from JavaScript");
+
+ ClrCall clrCall = (ClrCall) functions[function];
+
+
+ if (returnTo.Length == 0)
+ {
+ string result = clrCall (args);
+ }
+ else
+ {
+ string[] result = { clrCall (args) };
+ JSCall(returnTo, null, result);
+ }
+ }
+
+
+
+ public void JSCall (string function, string returnTo, params string[] args)
+ {
+ string argsOut = String.Empty;
+
+ if (args != null)
+ {
+ argsOut += args[0];
+ for (int i = 1; i <= args.Length - 1; i++)
+ {
+ argsOut += "|" + args[i];
+ }
+ }
+
+ if (returnTo == null) returnTo = string.Empty;
+ int result = PlaceFunctionCall (webControl.Handle, function, returnTo, argsOut);
+
+ string err;
+
+ switch (result)
+ {
+ case 0:
+ return;
+
+ case 1:
+ err = "Could not obtain IDOMDocument from GtkMozEmbed. Have you shown the window yet?";
+ break;
+
+ case 2:
+ err = "Error finding 'jscall' nodes.";
+ break;
+
+ case 3:
+ err = "Error getting number of 'jscall' nodes.";
+ break;
+
+ case 4:
+ err = "More or fewer than one 'jscall' node.";
+ break;
+
+ case 5:
+ err = "Error getting 'jscall' node.";
+ break;
+
+ case 6:
+ err = "Error adding 'infunction' node.";
+ break;
+
+ case 7:
+ err = "Error setting attributes on 'infunction' node.";
+ break;
+
+ case 8:
+ err = "Error getting nsIDOMNode interface on 'infunction' node.";
+ break;
+
+ case 9:
+ err = "Error appending 'infunction' node to 'jscall' node.";
+ break;
+
+ default:
+ err = "The glue wrapper returned an unknown error.";
+ break;
+ }
+
+ throw new Exception ("Glue function PlaceFunctionCall: "+err);
+ }
+
+ public void RegisterJSHandler (string name, ClrCall handler)
+ {
+ if (!functions.Contains (name))
+ {
+ functions.Add (name, handler);
+ }
+ else
+ {
+ throw new Exception ("A handler with this name already exists");
+ }
+
+ }
+
+ public void UnregisterJSHandler (string name)
+ {
+ if (functions.Contains (name))
+ {
+ functions.Remove (name);
+ }
+ else
+ {
+ throw new IndexOutOfRangeException ("A function with this name has not been registered");
+ }
+ }
+
+ }
+
+
+ public delegate string ClrCall (string[] args);
+}
View
186 src/jscall/Resources/JSCall.js
@@ -26,97 +26,97 @@
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-var JSCallFunctions;
-
-function JSCallInit()
-{
- JSCallFunctions = Array();
-
- if (document.getElementsByTagName("jscall").length == 0) {
- el = document.createElement("jscall");
- document.documentElement.appendChild(el);
- }
-
- if (document.getElementsByTagName("jscall").length != 1) {
- throw "Error: the document already contains a <jscall> element";
- }
-
- el = document.getElementsByTagName("jscall")[0];
- el.addEventListener( "DOMNodeInserted", JSCallHandler, false );
-
- //JSCallRegisterClrHandler("Redo", Redo);
-}
-
-
-//function Redo()
-//{
-// alert("Yay!");
-//}
-
-
-function JSCallHandler(e)
-{
- if ( e.target.nodeName == "infunction" && e.target.nodeType == 1 ){
- fn = e.target.attributes[0].value;
- returnTo = e.target.attributes[1].value;
- args = e.target.attributes[2].value.split('|');
-
- try {
- if(JSCallFunctions[fn]) {
- f = JSCallFunctions[fn];
- result = f(args);
- }
- else {
- throw "JSCall: The '"+fn+"' function has not been registered";
- }
-
-
- if (returnTo.length != 0) {
- JSCallPlaceClrCall(returnTo, "", new Array(result));
- }
-
- }
- catch(e) {
- alert(e)
- }
- e.target.parentNode.removeChild(e.target);
- }
-}
-
-
-function JSCallPlaceClrCall(fn, returnTo, args) {
- str = "JSCall|" + fn + "|" + returnTo + "|";
-
+ */
+
+var JSCallFunctions;
+
+function JSCallInit()
+{
+ JSCallFunctions = Array();
+
+ if (document.getElementsByTagName("jscall").length == 0) {
+ el = document.createElement("jscall");
+ document.documentElement.appendChild(el);
+ }
+
+ if (document.getElementsByTagName("jscall").length != 1) {
+ throw "Error: the document already contains a <jscall> element";
+ }
+
+ el = document.getElementsByTagName("jscall")[0];
+ el.addEventListener( "DOMNodeInserted", JSCallHandler, false );
+
+ //JSCallRegisterClrHandler("Redo", Redo);
+}
+
+
+//function Redo()
+//{
+// alert("Yay!");
+//}
+
+
+function JSCallHandler(e)
+{
+ if ( e.target.nodeName == "infunction" && e.target.nodeType == 1 ){
+ fn = e.target.attributes[0].value;
+ returnTo = e.target.attributes[1].value;
+ args = e.target.attributes[2].value.split('|');
+
+ try {
+ if(JSCallFunctions[fn]) {
+ f = JSCallFunctions[fn];
+ result = f(args);
+ }
+ else {
+ throw "JSCall: The '"+fn+"' function has not been registered";
+ }
+
+
+ if (returnTo.length != 0) {
+ JSCallPlaceClrCall(returnTo, "", new Array(result));
+ }
+
+ }
+ catch(e) {
+ alert(e)
+ }
+ e.target.parentNode.removeChild(e.target);
+ }
+}
+
+
+function JSCallPlaceClrCall(fn, returnTo, args) {
+ var delimiter = unescape ("%ea");
+ str = "JSCall" + delimiter + fn + delimiter + returnTo + delimiter;
+
if (args && args.length > 0)
- {
- str += args.join("|");
- }
-
- document.title= str;
-
-}
-
-
-function JSCallUnregisterClrHandler() {
- if(JSCallFunctions[n]) {
- delete JSCallFunctions[n];
- }
- else {
- throw "Function with that name not registered";
- }
-}
-
-
-function JSCallRegisterClrHandler(n, fn) {
- if((typeof fn) != "function") {
- throw "The fn argument must be a function";
- }
- if(JSCallFunctions[n]) {
- throw "Function with that name already registered";
- }
- else {
- JSCallFunctions[n] = fn;
- }
-}
+ {
+ str += args.join(delimiter);
+ }
+ document.title= str;
+
+}
+
+
+function JSCallUnregisterClrHandler() {
+ if(JSCallFunctions[n]) {
+ delete JSCallFunctions[n];
+ }
+ else {
+ throw "Function with that name not registered";
+ }
+}
+
+
+function JSCallRegisterClrHandler(n, fn) {
+ if((typeof fn) != "function") {
+ throw "The fn argument must be a function";
+ }
+ if(JSCallFunctions[n]) {
+ throw "Function with that name already registered";
+ }
+ else {
+ JSCallFunctions[n] = fn;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.