From reebalazs at codespeak.net Fri Mar 10 07:57:39 2006 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 10 Mar 2006 06:57:39 -0000 Subject: [Kukit-checkins] r24201 - kukit/branch/plugin Message-ID: <20060310065739.24113100B6@code0.codespeak.net> Author: reebalazs Date: Fri Mar 10 07:57:37 2006 New Revision: 24201 Added: kukit/branch/plugin/ - copied from r24200, kukit/branch/snowsprint/ Log: Branching for plugin development From gotcha at codespeak.net Fri Mar 10 11:49:38 2006 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Fri, 10 Mar 2006 10:49:38 -0000 Subject: [Kukit-checkins] r24207 - kukit/branch/snowsprint/doc Message-ID: <20060310104938.57C1C100B0@code0.codespeak.net> Author: gotcha Date: Fri Mar 10 11:49:37 2006 New Revision: 24207 Modified: kukit/branch/snowsprint/doc/CREDITS.txt Log: correct name for Tarek Modified: kukit/branch/snowsprint/doc/CREDITS.txt ============================================================================== --- kukit/branch/snowsprint/doc/CREDITS.txt (original) +++ kukit/branch/snowsprint/doc/CREDITS.txt Fri Mar 10 11:49:37 2006 @@ -1,3 +1,3 @@ Florian Schulze (florian.schulze at gmx.net) Godefroid Chapelle (gotcha at bubbblenet.be) -Tarek Zyade (tziade at nuxeo.com) +Tarek Ziad? (tziade at nuxeo.com) From gotcha at codespeak.net Fri Mar 10 11:57:10 2006 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Fri, 10 Mar 2006 10:57:10 -0000 Subject: [Kukit-checkins] r24210 - kukit/trunk/doc Message-ID: <20060310105710.A3FAE100CC@code0.codespeak.net> Author: gotcha Date: Fri Mar 10 11:57:09 2006 New Revision: 24210 Modified: kukit/trunk/doc/CREDITS.txt Log: correct name for Tarek Modified: kukit/trunk/doc/CREDITS.txt ============================================================================== --- kukit/trunk/doc/CREDITS.txt (original) +++ kukit/trunk/doc/CREDITS.txt Fri Mar 10 11:57:09 2006 @@ -1,3 +1,3 @@ Florian Schulze (florian.schulze at gmx.net) Godefroid Chapelle (gotcha at bubbblenet.be) -Tarek Zyade (tziade at nuxeo.com) +Tarek Ziad? (tziade at nuxeo.com) From fschulze at codespeak.net Fri Mar 10 17:44:12 2006 From: fschulze at codespeak.net (fschulze at codespeak.net) Date: Fri, 10 Mar 2006 16:44:12 -0000 Subject: [Kukit-checkins] r24232 - kukit/branch/fschulze-enhancements/kukit Message-ID: <20060310164412.9F19E100D9@code0.codespeak.net> Author: fschulze Date: Fri Mar 10 17:44:05 2006 New Revision: 24232 Modified: kukit/branch/fschulze-enhancements/kukit/kukit.js Log: Added API to register commands. Modified: kukit/branch/fschulze-enhancements/kukit/kukit.js ============================================================================== --- kukit/branch/fschulze-enhancements/kukit/kukit.js (original) +++ kukit/branch/fschulze-enhancements/kukit/kukit.js Fri Mar 10 17:44:05 2006 @@ -661,7 +661,7 @@ var node = nodes[i]; //XXX error handling for wrong command name kukit.logDebug('Command Name: '+command.name); - var results = kukit.commandFunctions[command.name](node, command.params); + var results = kukit.commands.get(command.name)(node, command.params); kukit.storeResults(results); // XXX see above } } @@ -718,123 +718,147 @@ return result; } -kukit.commandFunctions = new Array(); -kukit.commandFunctions['setHtmlAsChild']=function(node, command_data) -{ - Sarissa.clearChildNodes(node); - var childNodes = command_data['html'].childNodes; - kukit.dom.appendChildren(childNodes, node); - kukit.setupEvents(node); -} - -kukit.commandFunctions['replaceNode']=function(node, command_data) -{ - var childNodes = command_data['html'].childNodes; - var sourceSelector = command_data['selector'].firstChild.nodeValue || null; - var parentNode = node.parentNode; - var newNode = parentNode.cloneNode(false); - try { - kukit.dom.appendChildren(childNodes, newNode); - } catch(exc) { - newNode.innerHTML = Sarissa.serialize(command_data['html']); - } - if (sourceSelector) { - var element = cssQuery(sourceSelector, newNode)[0]; - if (element) - parentNode.replaceChild(element, node); - else - kukit.logDebug("Found no elements in response with selector '"+sourceSelector+"'."); - } else { - parentNode.replaceChild(newNode.firstChild, node); - } - kukit.setupEvents(parentNode); -} +/* command registry */ -kukit.commandFunctions['setAttribute']=function(node, command_data) -{ - var name = command_data['name'].firstChild.nodeValue; - var value = command_data['value'].firstChild.nodeValue; - node.setAttribute(name, value); -} +kukit.commands = {}; -kukit.commandFunctions['addAfter']=function(node, command_data) -{ - var content = document.importNode(command_data['html'], true); - var parentNode = node.parentNode; - var toNode = kukit.dom.getNextSiblingTag(node); - if (toNode == null) { - var inserted = kukit.dom.appendChildren(content.childNodes, parentNode); - } else { - var inserted = kukit.dom.insertBefore(content, parentNode, toNode); - } - // update the events for the new nodes - kukit.logDebug("Inserted nodes length: "+inserted.length); - kukit.setupEvents(node); - return inserted; -} +kukit.commands._mapping = {}; -kukit.commandFunctions['removeNextSibling']=function(node, command_data) -{ - kukit.logDebug('removeNextSibling'); - var parentNode = node.parentNode; - var toNode = kukit.dom.getNextSiblingTag(node); - if (toNode != null) { - parentNode.removeChild(toNode); - } +kukit.commands.register = function(name, func) { + kukit.commands._mapping[name] = func; } -kukit.commandFunctions['removePreviousSibling']=function(node, command_data) -{ - kukit.logDebug('removePreviousSibling'); - var parentNode = node.parentNode; - var toNode = kukit.dom.getPreviousSiblingTag(node); - parentNode.removeChild(toNode); +kukit.commands.get = function(name) { + return kukit.commands._mapping[name]; } -kukit.commandFunctions['removeNode']=function(node, command_data) -{ - var parentNode = node.parentNode; - parentNode.removeChild(node); -} +kukit.commands.register('setHtmlAsChild', function(node, command_data) + { + Sarissa.clearChildNodes(node); + var childNodes = command_data['html'].childNodes; + kukit.dom.appendChildren(childNodes, node); + kukit.setupEvents(node); + } +) +kukit.commands.register('replaceNode', function(node, command_data) + { + var childNodes = command_data['html'].childNodes; + var sourceSelector = command_data['selector'].firstChild.nodeValue || null; + var parentNode = node.parentNode; + var newNode = parentNode.cloneNode(false); + try { + kukit.dom.appendChildren(childNodes, newNode); + } catch(exc) { + newNode.innerHTML = Sarissa.serialize(command_data['html']); + } + if (sourceSelector) { + var element = cssQuery(sourceSelector, newNode)[0]; + if (element) + parentNode.replaceChild(element, node); + else + kukit.logDebug("Found no elements in response with selector '"+sourceSelector+"'."); + } else { + parentNode.replaceChild(newNode.firstChild, node); + } + kukit.setupEvents(parentNode); + } +) -kukit.commandFunctions['clearChildren']=function(node, command_data) -{ - Sarissa.clearChildNodes(node); -} +kukit.commands.register('setAttribute', function(node, command_data) + { + var name = command_data['name'].firstChild.nodeValue; + var value = command_data['value'].firstChild.nodeValue; + node.setAttribute(name, value); + } +) -kukit.commandFunctions['moveNodeAfter']=function(node, command_data) -{ - var parentNode = node.parentNode; - parentNode.removeChild(node); - - var id = command_data['html_id'].firstChild.nodeValue; - var toNode = document.getElementById(id); - - var nextNode = kukit.dom.getNextSiblingTag(toNode); - if (nextNode == null) { - toNode.parentNode.appendChild(node); - } else { - parentNode.insertBefore(node, nextNode); - } -} +kukit.commands.register('addAfter', function(node, command_data) + { + var content = document.importNode(command_data['html'], true); + var parentNode = node.parentNode; + var toNode = kukit.dom.getNextSiblingTag(node); + if (toNode == null) { + var inserted = kukit.dom.appendChildren(content.childNodes, parentNode); + } else { + var inserted = kukit.dom.insertBefore(content, parentNode, toNode); + } + // update the events for the new nodes + kukit.logDebug("Inserted nodes length: "+inserted.length); + kukit.setupEvents(node); + return inserted; + } +) -kukit.commandFunctions['copyChildrenFrom']=function(node, command_data) -{ - var id = command_data['html_id'].firstChild.nodeValue; - var fromNode = document.getElementById(id); - Sarissa.copyChildNodes(fromNode, node); -} +kukit.commands.register('removeNextSibling', function(node, command_data) + { + kukit.logDebug('removeNextSibling'); + var parentNode = node.parentNode; + var toNode = kukit.dom.getNextSiblingTag(node); + if (toNode != null) { + parentNode.removeChild(toNode); + } + } +) -kukit.commandFunctions['copyChildrenTo']=function(node, command_data) -{ - var id = command_data['html_id'].firstChild.nodeValue; - toNode = document.getElementById(id); - Sarissa.copyChildNodes(node, toNode); -} +kukit.commands.register('removePreviousSibling', function(node, command_data) + { + kukit.logDebug('removePreviousSibling'); + var parentNode = node.parentNode; + var toNode = kukit.dom.getPreviousSiblingTag(node); + parentNode.removeChild(toNode); + } +) -kukit.commandFunctions['executeCode']=function(node, command_data) -{ - var code = command_data['code'].firstChild.nodeValue; - node.eval(code); -} +kukit.commands.register('removeNode', function(node, command_data) + { + var parentNode = node.parentNode; + parentNode.removeChild(node); + } +) + +kukit.commands.register('clearChildren', function(node, command_data) + { + Sarissa.clearChildNodes(node); + } +) + +kukit.commands.register('moveNodeAfter', function(node, command_data) + { + var parentNode = node.parentNode; + parentNode.removeChild(node); + + var id = command_data['html_id'].firstChild.nodeValue; + var toNode = document.getElementById(id); + + var nextNode = kukit.dom.getNextSiblingTag(toNode); + if (nextNode == null) { + toNode.parentNode.appendChild(node); + } else { + parentNode.insertBefore(node, nextNode); + } + } +) + +kukit.commands.register('copyChildrenFrom', function(node, command_data) + { + var id = command_data['html_id'].firstChild.nodeValue; + var fromNode = document.getElementById(id); + Sarissa.copyChildNodes(fromNode, node); + } +) + +kukit.commands.register('copyChildrenTo', function(node, command_data) + { + var id = command_data['html_id'].firstChild.nodeValue; + toNode = document.getElementById(id); + Sarissa.copyChildNodes(node, toNode); + } +) + +kukit.commands.register('executeCode', function(node, command_data) + { + var code = command_data['code'].firstChild.nodeValue; + node.eval(code); + } +) From fschulze at codespeak.net Fri Mar 10 18:04:37 2006 From: fschulze at codespeak.net (fschulze at codespeak.net) Date: Fri, 10 Mar 2006 17:04:37 -0000 Subject: [Kukit-checkins] r24233 - kukit/branch/fschulze-enhancements/kukit Message-ID: <20060310170437.5CA4F100DB@code0.codespeak.net> Author: fschulze Date: Fri Mar 10 18:04:35 2006 New Revision: 24233 Modified: kukit/branch/fschulze-enhancements/kukit/kukit.js Log: Added registry for selectors. Modified: kukit/branch/fschulze-enhancements/kukit/kukit.js ============================================================================== --- kukit/branch/fschulze-enhancements/kukit/kukit.js (original) +++ kukit/branch/fschulze-enhancements/kukit/kukit.js Fri Mar 10 18:04:35 2006 @@ -636,23 +636,11 @@ } } -kukit.XPATH_SELECTOR = 'xpath'; -kukit.CSS_SELECTOR = 'css'; -kukit.HTMLID_SELECTOR = 'htmlid'; - kukit.CommandProcessor.prototype.executeCommand = function(command) { kukit.logDebug('Selector type: '+command.selectorType); kukit.logDebug('Selector : '+command.selector); - if (command.selectorType == kukit.XPATH_SELECTOR) { - var xpath_res = xpathDomEval(command.selector, document); - kukit.logDebug('XPath nodes:'+xpath_res.stringValue()); - var nodes = xpath_res.nodeSetValue(); - kukit.logDebug('XPath nodes number: '+nodes.length); - } else { - var nodes = cssQuery(command.selector); - kukit.logDebug('CSS nodes number: '+nodes.length); - } + var nodes = kukit.selectors.get(command.selectorType)(command.selector); if (nodes.length == 0) { kukit.logError('Command found no nodes'); } @@ -718,6 +706,53 @@ return result; } +/* selector registry */ + +kukit.selectors = {}; + +kukit.selectors._mapping = {}; + +kukit.selectors.register = function(name, func) { + kukit.selectors._mapping[name] = func; +} + +kukit.selectors.get = function(name) { + var result = kukit.selectors._mapping[name]; + if (!result && name != 'default') + return kukit.selectors.get('default'); + return result; +} + +kukit.selectors.register('htmlid', function(expr, node) { + if (!node) + node = document; + var nodes = []; + var node = node.getElementById(expr); + if (node) + nodes[nodes.length] = node; + kukit.logDebug('HTMLID nodes number: '+nodes.length); + return nodes; +}) + +kukit.selectors.register('css', function(expr, node) { + var nodes = cssQuery(expr, node); + kukit.logDebug('CSS nodes number: '+nodes.length); + return nodes; +}) + +kukit.selectors.register('xpath', function(expr, node) { + if (!node) + node = document; + var xpath_res = xpathDomEval(expr, node); + kukit.logDebug('XPath nodes:'+xpath_res.stringValue()); + var nodes = xpath_res.nodeSetValue(); + kukit.logDebug('XPath nodes number: '+nodes.length); + return nodes; +}) + +kukit.selectors.register('default', kukit.selectors.get('css')) + + /* command registry */ kukit.commands = {}; From reebalazs at codespeak.net Sun Mar 12 12:52:39 2006 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 12 Mar 2006 11:52:39 -0000 Subject: [Kukit-checkins] r24258 - kukit/branch/plugin/kukit Message-ID: <20060312115239.82C2B100A6@code0.codespeak.net> Author: reebalazs Date: Sun Mar 12 12:52:38 2006 New Revision: 24258 Modified: kukit/branch/plugin/kukit/kukit.js Log: Progress with command plugins Modified: kukit/branch/plugin/kukit/kukit.js ============================================================================== --- kukit/branch/plugin/kukit/kukit.js (original) +++ kukit/branch/plugin/kukit/kukit.js Sun Mar 12 12:52:38 2006 @@ -649,7 +649,7 @@ var node = nodes[i]; //XXX error handling for wrong command name kukit.logDebug('Command Name: '+command.name); - var results = kukit.commandFunctions[command.name](node, command.params); + var results = kukit.commandRegistry.getFunc(command.name)(node, command.params); kukit.storeResults(results); // XXX see above } } @@ -706,24 +706,53 @@ return result; } -kukit.commandFunctions = new Array(); -kukit.commandFunctions['setHtmlAsChild']=function(node, command_data) +/* Command registry */ + +kukit.CommandRegistry = function () { + this.content = {}; + this.nr = 0; +} + +kukit.CommandRegistry.prototype.register = function(name, func) { + if (this.content[name]) { + // Do not allow redefinition + kukit.logError('Error : redefinition attempt of command ' + name); + return; + } + this.content[name] = func; + this.nr = this.nr + 1; +} + +kukit.CommandRegistry.prototype.getFunc = function(name) { + var func = this.content[name]; + if (! func) { + // not found + kukit.logError('Error : undefined command ' + name); + } + return func; +} + +kukit.commandRegistry = new kukit.CommandRegistry(); + +/* Core commands */ + +kukit.commandRegistry.register('setHtmlAsChild', function(node, command_data) { Sarissa.clearChildNodes(node); var childNodes = command_data['html'].childNodes; kukit.dom.appendChildren(childNodes, node); kukit.setupEvents(node); -} +}) -kukit.commandFunctions['setAttribute']=function(node, command_data) +kukit.commandRegistry.register('setAttribute', function(node, command_data) { var name = command_data['name'].firstChild.nodeValue; var value = command_data['value'].firstChild.nodeValue; node.setAttribute(name, value); -} +}) -kukit.commandFunctions['addAfter']=function(node, command_data) +kukit.commandRegistry.register('addAfter', function(node, command_data) { var content = document.importNode(command_data['html'], true); var parentNode = node.parentNode; @@ -737,9 +766,9 @@ kukit.logDebug("Inserted nodes length: "+inserted.length); kukit.setupEvents(node); return inserted; -} +}) -kukit.commandFunctions['removeNextSibling']=function(node, command_data) +kukit.commandRegistry.register('removeNextSibling', function(node, command_data) { kukit.logDebug('removeNextSibling'); var parentNode = node.parentNode; @@ -747,29 +776,28 @@ if (toNode != null) { parentNode.removeChild(toNode); } -} +}) -kukit.commandFunctions['removePreviousSibling']=function(node, command_data) +kukit.commandRegistry.register('removePreviousSibling', function(node, command_data) { kukit.logDebug('removePreviousSibling'); var parentNode = node.parentNode; var toNode = kukit.dom.getPreviousSiblingTag(node); parentNode.removeChild(toNode); -} +}) -kukit.commandFunctions['removeNode']=function(node, command_data) +kukit.commandRegistry.register('removeNode', function(node, command_data) { var parentNode = node.parentNode; parentNode.removeChild(node); -} - +}) -kukit.commandFunctions['clearChildren']=function(node, command_data) +kukit.commandRegistry.register('clearChildren', function(node, command_data) { Sarissa.clearChildNodes(node); -} +}) -kukit.commandFunctions['moveNodeAfter']=function(node, command_data) +kukit.commandRegistry.register('moveNodeAfter', function(node, command_data) { var parentNode = node.parentNode; parentNode.removeChild(node); @@ -783,24 +811,24 @@ } else { parentNode.insertBefore(node, nextNode); } -} +}) -kukit.commandFunctions['copyChildrenFrom']=function(node, command_data) +kukit.commandRegistry.register('copyChildrenFrom', function(node, command_data) { var id = command_data['html_id'].firstChild.nodeValue; var fromNode = document.getElementById(id); Sarissa.copyChildNodes(fromNode, node); -} +}) -kukit.commandFunctions['copyChildrenTo']=function(node, command_data) +kukit.commandRegistry.register('copyChildrenTo', function(node, command_data) { var id = command_data['html_id'].firstChild.nodeValue; toNode = document.getElementById(id); Sarissa.copyChildNodes(node, toNode); -} +}) -kukit.commandFunctions['executeCode']=function(node, command_data) +kukit.commandRegistry.register('executeCode', function(node, command_data) { var code = command_data['code'].firstChild.nodeValue; node.eval(code); -} +})