Author: gotcha
Date: Tue Sep 18 10:42:59 2007
New Revision: 46711
Modified:
kukit/kukit.js/trunk/kukit/actionreg.js
kukit/kukit.js/trunk/kukit/commandprocessor.js
kukit/kukit.js/trunk/kukit/commandreg.js
Log:
fix indentation
Modified: kukit/kukit.js/trunk/kukit/actionreg.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/actionreg.js (original)
+++ kukit/kukit.js/trunk/kukit/actionreg.js Tue Sep 18 10:42:59 2007
@@ -18,57 +18,58 @@
*/
kukit.ar = new function() { /// MODULE START
+
+var ar = this;
/*
* class ActionRegistry
*
* The local event actions need to be registered here.
*/
- var ActionRegistry = function () {
- this.content = {};
- };
-
- ActionRegistry.prototype.register = function(name, func) {
-;;; if (typeof(func) == 'undefined') {
-;;; kukit.E = '[func] argument is mandatory when registering an
action';
-;;; kukit.E += ' [ActionRegistry.register].';
-;;; throw new Error(kukit.E);
-;;; }
- if (this.content[name]) {
- // Do not allow redefinition
-;;; kukit.logError('Error : action [' + name + '] already
registered.');
- return;
- }
- this.content[name] = func;
- };
-
- ActionRegistry.prototype.exists = function(name) {
- var entry = this.content[name];
- return (typeof(entry) != 'undefined');
- };
-
- ActionRegistry.prototype.get = function(name) {
- var func = this.content[name];
- if (! func) {
- // not found
-;;; kukit.E = 'Error : undefined local action [' + name + '].';
- throw Error(kukit.E);
- }
- return func;
- };
-
- kukit.actionsGlobalRegistry = new ActionRegistry();
+var ActionRegistry = function () {
+ this.content = {};
+};
+
+ActionRegistry.prototype.register = function(name, func) {
+;;;if (typeof(func) == 'undefined') {
+;;; kukit.E = '[func] argument is mandatory when registering an action';
+;;; kukit.E += ' [ActionRegistry.register].';
+;;; throw new Error(kukit.E);
+;;;}
+ if (this.content[name]) {
+ // Do not allow redefinition
+;;; kukit.logError('Error : action [' + name + '] already registered.');
+ return;
+ }
+ this.content[name] = func;
+};
+
+ActionRegistry.prototype.exists = function(name) {
+ var entry = this.content[name];
+ return (typeof(entry) != 'undefined');
+};
+
+ActionRegistry.prototype.get = function(name) {
+ var func = this.content[name];
+ if (! func) {
+ // not found
+;;; kukit.E = 'Error : undefined local action [' + name + '].';
+ throw Error(kukit.E);
+ }
+ return func;
+};
+kukit.actionsGlobalRegistry = new ActionRegistry();
/* XXX deprecated methods, to be removed asap */
- this.actionRegistry = {};
- this.actionRegistry.register = function(name, func) {
-;;; var msg='Deprecated kukit.ar.actionRegistry.register, use ';
-;;; msg += 'kukit.actionsGlobalRegistry.register instead !';
-;;; kukit.logWarning(msg);
- kukit.actionsGlobalRegistry.register(name, func);
- };
+ar.actionRegistry = {};
+ar.actionRegistry.register = function(name, func) {
+;;;var msg='Deprecated kukit.ar.actionRegistry.register, use ';
+;;;msg += 'kukit.actionsGlobalRegistry.register instead !';
+;;;kukit.logWarning(msg);
+ kukit.actionsGlobalRegistry.register(name, func);
+};
}(); /// MODULE END
Modified: kukit/kukit.js/trunk/kukit/commandprocessor.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/commandprocessor.js (original)
+++ kukit/kukit.js/trunk/kukit/commandprocessor.js Tue Sep 18 10:42:59 2007
@@ -19,119 +19,121 @@
kukit.cp = new function() { /// MODULE START
+var cp = this;
+
/*
* class CommandProcessor
*/
- this.CommandProcessor = function() {
- this.commands = new Array();
- };
-
- this.CommandProcessor.prototype.parseCommands =
- function(commands, transport) {
-;;; kukit.log('Parsing commands.');
-;;; kukit.logDebug('Number of commands : ' + commands.length + '.');
- for (var y=0;y < commands.length;y++) {
- var command = commands[y];
- this.parseCommand(command, transport);
- // If we receive an error command, we handle that separately.
- // We abort immediately and let the processError handler do its
job.
- // This means that although no other commands should be in
commands,
- // we make sure we execute none of them.
- var lastcommand = this.commands[this.commands.length-1];
- if (lastcommand.name == 'error') {
-;;; throw kukit.err.explicitError(lastcommand);
- throw new Error(kukit.E);
- }
+cp.CommandProcessor = function() {
+ this.commands = new Array();
+};
+
+cp.CommandProcessor.prototype.parseCommands =
+ function(commands, transport) {
+;;;kukit.log('Parsing commands.');
+;;;kukit.logDebug('Number of commands : ' + commands.length + '.');
+ for (var y=0;y < commands.length;y++) {
+ var command = commands[y];
+ this.parseCommand(command, transport);
+ // If we receive an error command, we handle that separately.
+ // We abort immediately and let the processError handler do its job.
+ // This means that although no other commands should be in commands,
+ // we make sure we execute none of them.
+ var lastcommand = this.commands[this.commands.length-1];
+ if (lastcommand.name == 'error') {
+;;; throw kukit.err.explicitError(lastcommand);
+ throw new Error(kukit.E);
}
- };
+ }
+};
- this.CommandProcessor.prototype.parseCommand =
- function(command, transport) {
- var selector = "";
- var params = {};
- var name = "";
-
- selector = command.getAttribute("selector");
- name = command.getAttribute("name");
- type = command.getAttribute("selectorType");
- if (name == null)
- name = "";
- var childNodes = command.childNodes;
- for (var n=0;n < childNodes.length;n++) {
- var childNode = childNodes[n];
- if (childNode.nodeType != 1)
- continue;
- if (childNode.localName) {
- // (here tolerate both cases)
- if (childNode.localName.toLowerCase() != "param"
- && childNode.nodeName.toLowerCase() != "kukit:param") {
- throw new Error('Bad payload, expected param');
- }
- } else {
- //IE does not know DOM2
- if (childNode.nodeName.toLowerCase() != "kukit:param") {
- throw new Error('Bad payload, expected kukit:param');
- }
- }
- data = childNode.getAttribute('name');
- if (data != null) {
- // Decide if we have a string or a dom parameter
- var childCount = childNode.childNodes.length;
- var result;
- if (childCount == 0) {
- result = '';
- } else {
- // (we do not interpret html inline content any more)
- // we have a single text node
- // OR
- // we have a single CDATA node (HTML parameter CDATA-style)
-;;; var isTextNode = childNode.firstChild.nodeType == 3;
-;;; var isCData = childNode.firstChild.nodeType == 4;
-;;; if (! (childCount == 1 && (isTextNode || isCData))) {
-;;; kukit.E = 'Bad payload, expected a text or a CDATA
node';
-;;; throw new Error(kukit.E);
-;;; }
- // we consider this as html payload
- // The result is always a string from here.
- result = childNode.firstChild.nodeValue;
- }
- params[data] = result;
+cp.CommandProcessor.prototype.parseCommand =
+ function(command, transport) {
+ var selector = "";
+ var params = {};
+ var name = "";
+
+ selector = command.getAttribute("selector");
+ name = command.getAttribute("name");
+ type = command.getAttribute("selectorType");
+ if (name == null)
+ name = "";
+ var childNodes = command.childNodes;
+ for (var n=0;n < childNodes.length;n++) {
+ var childNode = childNodes[n];
+ if (childNode.nodeType != 1)
+ continue;
+ if (childNode.localName) {
+ // (here tolerate both cases)
+ if (childNode.localName.toLowerCase() != "param"
+ && childNode.nodeName.toLowerCase() != "kukit:param") {
+ throw new Error('Bad payload, expected param');
+ }
+ } else {
+ //IE does not know DOM2
+ if (childNode.nodeName.toLowerCase() != "kukit:param") {
+ throw new Error('Bad payload, expected kukit:param');
+ }
+ }
+ data = childNode.getAttribute('name');
+ if (data != null) {
+ // Decide if we have a string or a dom parameter
+ var childCount = childNode.childNodes.length;
+ var result;
+ if (childCount == 0) {
+ result = '';
} else {
- throw new Error('Bad payload, expected attribute "name"');
+ // (we do not interpret html inline content any more)
+ // we have a single text node
+ // OR
+ // we have a single CDATA node (HTML parameter CDATA-style)
+;;; var isTextNode = childNode.firstChild.nodeType == 3;
+;;; var isCData = childNode.firstChild.nodeType == 4;
+;;; if (! (childCount == 1 && (isTextNode || isCData))) {
+;;; kukit.E = 'Bad payload, expected a text or a CDATA
node';
+;;; throw new Error(kukit.E);
+;;; }
+ // we consider this as html payload
+ // The result is always a string from here.
+ result = childNode.firstChild.nodeValue;
}
+ params[data] = result;
+ } else {
+ throw new Error('Bad payload, expected attribute "name"');
}
- var command = new kukit.cr.makeCommand(selector, name, type, params,
- transport);
- this.addCommand(command);
- };
-
- this.CommandProcessor.prototype.addCommand = function(command) {
- this.commands[this.commands.length] = command;
- };
-
- this.CommandProcessor.prototype.executeCommands = function(oper) {
- kukit.engine.beginSetupEventsCollection();
- // node, eventRule, binderInstance are given on oper, in case
- // the command was called up from an event
- if (typeof(oper) == 'undefined' || oper == null) {
- oper = new kukit.op.Oper();
- }
- var commands = this.commands;
- for (var y=0;y < commands.length;y++) {
- var command = commands[y];
-;;; try {
- command.execute(oper);
-;;; } catch (e) {
-;;; if (e.name == 'RuleMergeError' || e.name == 'EventBindError') {
-;;; throw(e);
-;;; } else {
-;;; // augment the error message
-;;; throw kukit.err.commandExecutionError(e, command);
-;;; }
-;;; }
- }
- kukit.engine.finishSetupEventsCollection();
- };
+ }
+ var command = new kukit.cr.makeCommand(selector, name, type, params,
+ transport);
+ this.addCommand(command);
+};
+
+cp.CommandProcessor.prototype.addCommand = function(command) {
+ this.commands[this.commands.length] = command;
+};
+
+cp.CommandProcessor.prototype.executeCommands = function(oper) {
+ kukit.engine.beginSetupEventsCollection();
+ // node, eventRule, binderInstance are given on oper, in case
+ // the command was called up from an event
+ if (typeof(oper) == 'undefined' || oper == null) {
+ oper = new kukit.op.Oper();
+ }
+ var commands = this.commands;
+ for (var y=0;y < commands.length;y++) {
+ var command = commands[y];
+;;; try {
+ command.execute(oper);
+;;; } catch (e) {
+;;; if (e.name == 'RuleMergeError' || e.name == 'EventBindError') {
+;;; throw(e);
+;;; } else {
+;;; // augment the error message
+;;; throw kukit.err.commandExecutionError(e, command);
+;;; }
+;;; }
+ }
+ kukit.engine.finishSetupEventsCollection();
+};
}(); /// MODULE END
Modified: kukit/kukit.js/trunk/kukit/commandreg.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/commandreg.js (original)
+++ kukit/kukit.js/trunk/kukit/commandreg.js Tue Sep 18 10:42:59 2007
@@ -21,12 +21,14 @@
kukit.cr = new function() { /// MODULE START
+var cr = this;
+
/*
* class _CommandRegistry
*/
- var _CommandRegistry = function () {
- this.commands = {};
- };
+var _CommandRegistry = function () {
+ this.commands = {};
+};
/*
* This is the proposed way of registration, as we like all commands to be
@@ -42,121 +44,121 @@
* kukit.commandsGlobalRegistry.registerFromAction('replaceInnerHTML',
* kukit.cr.makeSelectorCommand);
*/
- _CommandRegistry.prototype.registerFromAction =
- function(srcname, factory, name) {
- if (typeof(name) == 'undefined') {
- // allows to set a different name as the action name,
- // usable for backward
- // compatibility setups
- name = srcname;
+_CommandRegistry.prototype.registerFromAction =
+ function(srcname, factory, name) {
+ if (typeof(name) == 'undefined') {
+ // allows to set a different name as the action name,
+ // usable for backward
+ // compatibility setups
+ name = srcname;
+ }
+ // register a given action as a command, using the given vactor
+ var f = kukit.actionsGlobalRegistry.get(srcname);
+ factory(name, f);
+};
+
+_CommandRegistry.prototype.register = function(name, klass) {
+ if (this.commands[name]) {
+ // Do not allow redefinition
+;;; var msg = 'ValueError : command [' + name + '] is already registered.';
+;;; kukit.logError(msg);
+ return;
}
- // register a given action as a command, using the given vactor
- var f = kukit.actionsGlobalRegistry.get(srcname);
- factory(name, f);
- };
-
- _CommandRegistry.prototype.register = function(name, klass) {
- if (this.commands[name]) {
- // Do not allow redefinition
-;;; var msg = 'ValueError : command [' + name + '] is already
registered.';
-;;; kukit.logError(msg);
- return;
- }
- this.commands[name] = klass;
- };
+ this.commands[name] = klass;
+};
- _CommandRegistry.prototype.get = function(name) {
- var klass = this.commands[name];
-;;; if (! klass) {
-;;; // not found
-;;; var msg = 'ValueError : no command registered under [' + name +
'].';
-;;; kukit.logError(msg);
-;;; }
- return klass;
- };
+_CommandRegistry.prototype.get = function(name) {
+ var klass = this.commands[name];
+;;;if (! klass) {
+;;; // not found
+;;; var msg = 'ValueError : no command registered under [' + name + '].';
+;;; kukit.logError(msg);
+;;; }
+ return klass;
+};
- kukit.commandsGlobalRegistry = new _CommandRegistry();
+kukit.commandsGlobalRegistry = new _CommandRegistry();
/* XXX deprecated methods, to be removed asap */
- this.commandRegistry = {};
- this.commandRegistry.registerFromAction = function(srcname, factory, name)
{
-;;; var msg = 'Deprecated kukit.cr.commandRegistry.registerFromAction,';
-;;; msg += ' use kukit.commandsGlobalRegistry.registerFromAction instead!
(';
-;;; msg += srcname + ')';
-;;; kukit.logWarning(msg);
- kukit.commandsGlobalRegistry.registerFromAction(srcname, factory,
name);
- };
+cr.commandRegistry = {};
+cr.commandRegistry.registerFromAction = function(srcname, factory, name) {
+;;;var msg = 'Deprecated kukit.cr.commandRegistry.registerFromAction,';
+;;;msg += ' use kukit.commandsGlobalRegistry.registerFromAction instead! (';
+;;;msg += srcname + ')';
+;;;kukit.logWarning(msg);
+ kukit.commandsGlobalRegistry.registerFromAction(srcname, factory, name);
+};
/* Command factories */
- this.makeCommand = function(selector, name, type, parms, transport) {
- var commandClass = kukit.commandsGlobalRegistry.get(name);
- var command = new commandClass();
- command.selector = selector;
- command.name = name;
- command.selectorType = type;
- command.parms = parms;
- command.transport = transport;
- return command;
- };
-
- var _executeCommand = function(oper) {
- var newoper = oper.clone({
- 'parms': this.parms,
- 'orignode': oper.node,
- 'node': null
- });
- this.executeOnScope(newoper);
- };
-
- var _executeCommandOnSelector = function(oper) {
- var selfunc = kukit.selectorTypesGlobalRegistry.get(this.selectorType);
- // When applying the selection, the original event target will be used
- // as a starting point for the selection.
- var nodes = selfunc(this.selector, oper.orignode, {});
-;;; var printType;
-;;; if (this.selectorType) {
-;;; printType = this.selectorType;
-;;; } else {
-;;; printType = 'default (';
-;;; printType += kukit.selectorTypesGlobalRegistry.defaultSelectorType;
-;;; printType += ')';
-;;; }
-;;; var msg = 'Selector type [' + printType + '], selector [';
-;;; msg += this.selector + '], selected nodes [' + nodes.length + '].';
-;;; kukit.logDebug(msg);
-;;; if (!nodes || nodes.length == 0) {
-;;; kukit.logWarning('Selector found no nodes.');
-;;; }
- for (var i=0;i < nodes.length;i++) {
- oper.node = nodes[i];
- //XXX error handling for wrong command name
-;;; kukit.logDebug('[' + this.name + '] execution.');
- this.executeOnSingleNode(oper);
- }
- };
-
- this.makeSelectorCommand = function(name, executeOnSingleNode) {
- var commandClass = function() {};
- commandClass.prototype = {
- execute: _executeCommand,
- executeOnScope: _executeCommandOnSelector,
- executeOnSingleNode: executeOnSingleNode
- };
- kukit.commandsGlobalRegistry.register(name, commandClass);
- };
-
- this.makeGlobalCommand = function(name, executeOnce) {
- var commandClass = function() {};
- commandClass.prototype = {
- execute: _executeCommand,
- executeOnScope: executeOnce,
- executeOnSingleNode: executeOnce
- };
- kukit.commandsGlobalRegistry.register(name, commandClass);
+cr.makeCommand = function(selector, name, type, parms, transport) {
+ var commandClass = kukit.commandsGlobalRegistry.get(name);
+ var command = new commandClass();
+ command.selector = selector;
+ command.name = name;
+ command.selectorType = type;
+ command.parms = parms;
+ command.transport = transport;
+ return command;
+};
+
+var _executeCommand = function(oper) {
+ var newoper = oper.clone({
+ 'parms': this.parms,
+ 'orignode': oper.node,
+ 'node': null
+ });
+ this.executeOnScope(newoper);
+};
+
+var _executeCommandOnSelector = function(oper) {
+ var selfunc = kukit.selectorTypesGlobalRegistry.get(this.selectorType);
+ // When applying the selection, the original event target will be used
+ // as a starting point for the selection.
+ var nodes = selfunc(this.selector, oper.orignode, {});
+;;;var printType;
+;;;if (this.selectorType) {
+;;; printType = this.selectorType;
+;;;} else {
+;;; printType = 'default (';
+;;; printType += kukit.selectorTypesGlobalRegistry.defaultSelectorType;
+;;; printType += ')';
+;;;}
+;;;var msg = 'Selector type [' + printType + '], selector [';
+;;;msg += this.selector + '], selected nodes [' + nodes.length + '].';
+;;;kukit.logDebug(msg);
+;;;if (!nodes || nodes.length == 0) {
+;;; kukit.logWarning('Selector found no nodes.');
+;;;}
+ for (var i=0;i < nodes.length;i++) {
+ oper.node = nodes[i];
+ //XXX error handling for wrong command name
+;;; kukit.logDebug('[' + this.name + '] execution.');
+ this.executeOnSingleNode(oper);
+ }
+};
+
+cr.makeSelectorCommand = function(name, executeOnSingleNode) {
+ var commandClass = function() {};
+ commandClass.prototype = {
+ execute: _executeCommand,
+ executeOnScope: _executeCommandOnSelector,
+ executeOnSingleNode: executeOnSingleNode
+ };
+ kukit.commandsGlobalRegistry.register(name, commandClass);
+};
+
+cr.makeGlobalCommand = function(name, executeOnce) {
+ var commandClass = function() {};
+ commandClass.prototype = {
+ execute: _executeCommand,
+ executeOnScope: executeOnce,
+ executeOnSingleNode: executeOnce
};
+ kukit.commandsGlobalRegistry.register(name, commandClass);
+};
}(); /// MODULE END
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins