Author: gotcha
Date: Mon Dec 24 12:28:26 2007
New Revision: 50058

Modified:
   kukit/kukit.js/branch/finish-closures/kukit/TODO.txt
   kukit/kukit.js/branch/finish-closures/kukit/kukit.js
Log:
unindent and initialize

Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt
==============================================================================
--- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt        (original)
+++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt        Mon Dec 24 
12:28:26 2007
@@ -4,11 +4,9 @@
 
 files where indentation has to be undone and initialize needs to be done
 
-dom.js
 eventreg.js
 forms.js
 kssparser.js
-kukit.js
 oper.js
 providerreg.js
 selectorreg.js

Modified: kukit/kukit.js/branch/finish-closures/kukit/kukit.js
==============================================================================
--- kukit/kukit.js/branch/finish-closures/kukit/kukit.js        (original)
+++ kukit/kukit.js/branch/finish-closures/kukit/kukit.js        Mon Dec 24 
12:28:26 2007
@@ -54,6 +54,8 @@
 * class Engine
 */
 ku.Engine = function() {
+
+this.initialize = function() {
     this.documentRules = new kukit.rd.MethodTable();
     // table from res_type to rule processor
     this._ruleProcessorClasses = {};
@@ -72,225 +74,227 @@
     // setup events queuing, collect them at the end of commands
     this.setupEventsQueue = [];
     this.setupEventsInProgress = false;
+    this.baseUrl = this.calculateBase();
+};
 
-    this.calculateBase = function() {
-        var base = '';
-        try {
-            var _dummy = document;
-            _dummy = window;
-        } catch (e) {
-            // testing or what
-            return base;
-        }
-        var nodes = document.getElementsByTagName("link");
-        if (nodes.length > 0) {
-            for (var i=0; i<nodes.length; i++) {
-                var link = nodes[i];
-                if (link.rel == 'kss-base-url') {
-                    return link.href;
-                }
+this.calculateBase = function() {
+    var base = '';
+    try {
+        var _dummy = document;
+        _dummy = window;
+    } catch (e) {
+        // testing or what
+        return base;
+    }
+    var nodes = document.getElementsByTagName("link");
+    if (nodes.length > 0) {
+        for (var i=0; i<nodes.length; i++) {
+            var link = nodes[i];
+            if (link.rel == 'kss-base-url') {
+                return link.href;
             }
         }
-        nodes = document.getElementsByTagName("base");
-        if (nodes.length === 0) {
-            base = window.location.href;
-            var pieces = base.split('/');
-            pieces.pop();
-            base = pieces.join('/');
-        } else {
-            base = nodes[0].href;
-            // take off trailing slash
-            var baselen = base.length;
-            if (baselen > 0 && base.substring(baselen - 1) == '/') {
-                base = base.substring(0, baselen - 1);
-            }
+    }
+    nodes = document.getElementsByTagName("base");
+    if (nodes.length === 0) {
+        base = window.location.href;
+        var pieces = base.split('/');
+        pieces.pop();
+        base = pieces.join('/');
+    } else {
+        base = nodes[0].href;
+        // take off trailing slash
+        var baselen = base.length;
+        if (baselen > 0 && base.substring(baselen - 1) == '/') {
+            base = base.substring(0, baselen - 1);
         }
-        return base;
-    };
-    this.baseUrl = this.calculateBase();
+    }
+    return base;
+};
 
-    this.getRuleSheetLinks = function() {
-        var nodes = document.getElementsByTagName("link");
-        var results = [];
-        for (var i=0; i<nodes.length; i++) {
-            if (_isKineticStylesheet(nodes[i])) {
-                var res_type = null;
-                // Resource syntax is decided on type attribute.
-                if((nodes[i].type == 'text/css') || (nodes[i].type == 
'text/kss')) {
-                    res_type = 'kss';
-;;;             } else {
-;;;                 // Just show this, and go on with the processing.
-;;;                 kukit.logError("rel type is not text/css or text/kss");
-                }
-                var newRuleLink = new _RuleSheetLink(nodes[i].href, res_type);
-                results[results.length] = newRuleLink;
+this.getRuleSheetLinks = function() {
+    var nodes = document.getElementsByTagName("link");
+    var results = [];
+    for (var i=0; i<nodes.length; i++) {
+        if (_isKineticStylesheet(nodes[i])) {
+            var res_type = null;
+            // Resource syntax is decided on type attribute.
+            if((nodes[i].type == 'text/css') || (nodes[i].type == 'text/kss')) 
{
+                res_type = 'kss';
+;;;         } else {
+;;;             // Just show this, and go on with the processing.
+;;;             kukit.logError("rel type is not text/css or text/kss");
             }
+            var newRuleLink = new _RuleSheetLink(nodes[i].href, res_type);
+            results[results.length] = newRuleLink;
         }
-        return results;
-    };
+    }
+    return results;
+};
 
-    this.createRuleProcessor = function(rulelink) {
-        var _RuleProcessorClass = 
this._ruleProcessorClasses[rulelink.res_type];
-;;;     var msg = '';
-        if (_RuleProcessorClass) {
-;;;         msg = "Start loading and processing " + rulelink.href;
-;;;         msg = msg + " of type " + rulelink.res_type;
-;;;         kukit.log(msg);
-            var ruleprocessor = new _RuleProcessorClass(rulelink.href);
-            this._ruleProcessors[this._ruleProcessors.length] = ruleprocessor;
-            return ruleprocessor;
-;;;     } else {
-;;;         msg = "Ignore rulesheet " + rulelink.href;
-;;;         msg = msg + " of type " + rulelink.res_type;
-;;;         kukit.log(msg);
-        }
-        return null;
-    };
+this.createRuleProcessor = function(rulelink) {
+    var _RuleProcessorClass = this._ruleProcessorClasses[rulelink.res_type];
+;;; var msg = '';
+    if (_RuleProcessorClass) {
+;;;     msg = "Start loading and processing " + rulelink.href;
+;;;     msg = msg + " of type " + rulelink.res_type;
+;;;     kukit.log(msg);
+        var ruleprocessor = new _RuleProcessorClass(rulelink.href);
+        this._ruleProcessors[this._ruleProcessors.length] = ruleprocessor;
+        return ruleprocessor;
+;;; } else {
+;;;     msg = "Ignore rulesheet " + rulelink.href;
+;;;     msg = msg + " of type " + rulelink.res_type;
+;;;     kukit.log(msg);
+    }
+    return null;
+};
 
 
-    this.getRules = function() {
-        var rules = [];
-        var ruleProcessors = this._ruleProcessors;
-        for (var j=0; j<ruleProcessors.length; j++) {
-            var ruleProcessor = ruleProcessors[j];
-            for (var i=0; i<ruleProcessor.rules.length; i++) {
-                rules.push(ruleProcessor.rules[i]);
-            }
+this.getRules = function() {
+    var rules = [];
+    var ruleProcessors = this._ruleProcessors;
+    for (var j=0; j<ruleProcessors.length; j++) {
+        var ruleProcessor = ruleProcessors[j];
+        for (var i=0; i<ruleProcessor.rules.length; i++) {
+            rules.push(ruleProcessor.rules[i]);
         }
-        return rules;
-    };
+    }
+    return rules;
+};
 
-    this.getRuleProcessors = function() {
-        return this._ruleProcessors;
-    };
+this.getRuleProcessors = function() {
+    return this._ruleProcessors;
+};
 
-    this.setupEvents = function(inNodes) {
-        if (this.setupEventsInProgress) {
-            // remember them
-            this.setupEventsQueue = this.setupEventsQueue.concat(inNodes);
-        } else {
-            // do it
-            this.doSetupEvents(inNodes);
-        }
-    };
+this.setupEvents = function(inNodes) {
+    if (this.setupEventsInProgress) {
+        // remember them
+        this.setupEventsQueue = this.setupEventsQueue.concat(inNodes);
+    } else {
+        // do it
+        this.doSetupEvents(inNodes);
+    }
+};
 
-    this.beginSetupEventsCollection = function() {
-        this.setupEventsInProgress = true;
-    };
+this.beginSetupEventsCollection = function() {
+    this.setupEventsInProgress = true;
+};
 
-    this.finishSetupEventsCollection = function() {
-        this.setupEventsInProgress = false;
-        var setupEventsQueue = this.setupEventsQueue;
-        this.setupEventsQueue = [];
-        this.doSetupEvents(setupEventsQueue);
-    };
+this.finishSetupEventsCollection = function() {
+    this.setupEventsInProgress = false;
+    var setupEventsQueue = this.setupEventsQueue;
+    this.setupEventsQueue = [];
+    this.doSetupEvents(setupEventsQueue);
+};
 
-    this.doSetupEvents = function(inNodes) {
-        var self = this;
-        var deferredEventsSetup = function() {
-            self._setupEvents(inNodes);
-        };
-;;;     var targetMsg;
-        var found = false;
-        if ( ! inNodes) {
-;;;         targetMsg = 'document';
-            found = true;
-        } else {
-;;;         targetMsg = 'nodes subtrees ';
-            for (var i=0; i<inNodes.length; i++) {
-                var node = inNodes[i];
-                if (node.nodeType == 1) {
-                    if (! found) {
-                        found = true;
-;;;                 } else {
-;;;                     targetMsg += ', '; 
-                    }
-;;;                 targetMsg += '[' + node.tagName.toLowerCase() + ']';
+this.doSetupEvents = function(inNodes) {
+    var self = this;
+    var deferredEventsSetup = function() {
+        self._setupEvents(inNodes);
+    };
+;;; var targetMsg;
+    var found = false;
+    if ( ! inNodes) {
+;;;     targetMsg = 'document';
+        found = true;
+    } else {
+;;;     targetMsg = 'nodes subtrees ';
+        for (var i=0; i<inNodes.length; i++) {
+            var node = inNodes[i];
+            if (node.nodeType == 1) {
+                if (! found) {
+                    found = true;
+;;;             } else {
+;;;                 targetMsg += ', '; 
                 }
+;;;             targetMsg += '[' + node.tagName.toLowerCase() + ']';
             }
         }
-        if (found) {
-            var remark = '';
-;;;         remark += 'Setup of events for ' + targetMsg;
-            this.bindScheduler.addPre(deferredEventsSetup, remark);
-        }
-    };
+    }
+    if (found) {
+        var remark = '';
+;;;     remark += 'Setup of events for ' + targetMsg;
+        this.bindScheduler.addPre(deferredEventsSetup, remark);
+    }
+};
 
-    this._setupEvents = function(inNodes) {
-        // Decide phase. 1=initial, 2=insertion.
-        var phase;
-        if (typeof(inNodes) == 'undefined') {
-            phase = 1;
-        } else {
-            phase = 2;
-        }
-        this.binderInfoRegistry.startBindingPhase();
-;;;     kukit.log('Selection of HTML nodes starts.');
-        var rules = this.getRules();
-        var ruletable = new kukit.rd.RuleTable(this.loadScheduler);
-        for (var y=0; y < rules.length; y++) {
-            rules[y].mergeForSelectedNodes(ruletable, phase, inNodes);
-        }
-;;;     kukit.log('Binding of document starts.');
-        if (phase == 1) {
-            this.documentRules.bindall(phase);
-        }
-        // finally bind the merged events
-;;;     kukit.log('Binding of HTML nodes starts.');
-        ruletable.bindall(phase);
+this._setupEvents = function(inNodes) {
+    // Decide phase. 1=initial, 2=insertion.
+    var phase;
+    if (typeof(inNodes) == 'undefined') {
+        phase = 1;
+    } else {
+        phase = 2;
+    }
+    this.binderInfoRegistry.startBindingPhase();
+;;; kukit.log('Selection of HTML nodes starts.');
+    var rules = this.getRules();
+    var ruletable = new kukit.rd.RuleTable(this.loadScheduler);
+    for (var y=0; y < rules.length; y++) {
+        rules[y].mergeForSelectedNodes(ruletable, phase, inNodes);
+    }
+;;; kukit.log('Binding of document starts.');
+    if (phase == 1) {
+        this.documentRules.bindall(phase);
+    }
+    // finally bind the merged events
+;;; kukit.log('Binding of HTML nodes starts.');
+    ruletable.bindall(phase);
 
-        // ... and do the actual binding. 
-        this.binderInfoRegistry.processBindingEvents();
-    };
+    // ... and do the actual binding. 
+    this.binderInfoRegistry.processBindingEvents();
+};
 
-    this.initializeRules = function() {
-;;;     var msg = '';
-        if (window.kukitRulesInitializing || window.kukitRulesInitialized) {
-            // Refuse to initialize a second time.
-;;;         kukit.log('[initializeRules] is called twice.');
-            return;
-        }
-;;;     kukit.log('Initializing kinetic stylesheets.');
-        // Succesful initialization. At the moment the engine is kept
-        // as a global variable, but this needs refinement in the future.
-        kukit.engine = this;
-        window.kukitRulesInitializing = true;
-        // load the rulesheets
-        var rulelinks = this.getRuleSheetLinks();
-;;;     kukit.log("Count of kinetic stylesheet links: " + rulelinks.length);
-        for (var i=0; i<rulelinks.length; i++) {
-            var rulelink = rulelinks[i];
-            var ruleprocessor = this.createRuleProcessor(rulelink);
-            if (ruleprocessor) {
-;;;             var ts_start = (new Date()).valueOf();
-                ruleprocessor.load();
-;;;             var ts_loaded = (new Date()).valueOf();
-                ruleprocessor.parse();
-;;;             var ts_end = (new Date()).valueOf();
-;;;             msg = "Finished loading and processing " + rulelink.href;
-;;;             msg += " resource type " + rulelink.res_type;
-;;;             msg += ' in ' + (ts_loaded - ts_start) + ' + ';
-;;;             msg += (ts_end - ts_loaded) + ' ms.';
-;;;             kukit.log(msg);
-            }
+this.initializeRules = function() {
+;;; var msg = '';
+    if (window.kukitRulesInitializing || window.kukitRulesInitialized) {
+        // Refuse to initialize a second time.
+;;;     kukit.log('[initializeRules] is called twice.');
+        return;
+    }
+;;; kukit.log('Initializing kinetic stylesheets.');
+    // Succesful initialization. At the moment the engine is kept
+    // as a global variable, but this needs refinement in the future.
+    kukit.engine = this;
+    window.kukitRulesInitializing = true;
+    // load the rulesheets
+    var rulelinks = this.getRuleSheetLinks();
+;;; kukit.log("Count of kinetic stylesheet links: " + rulelinks.length);
+    for (var i=0; i<rulelinks.length; i++) {
+        var rulelink = rulelinks[i];
+        var ruleprocessor = this.createRuleProcessor(rulelink);
+        if (ruleprocessor) {
+;;;         var ts_start = (new Date()).valueOf();
+            ruleprocessor.load();
+;;;         var ts_loaded = (new Date()).valueOf();
+            ruleprocessor.parse();
+;;;         var ts_end = (new Date()).valueOf();
+;;;         msg = "Finished loading and processing " + rulelink.href;
+;;;         msg += " resource type " + rulelink.res_type;
+;;;         msg += ' in ' + (ts_loaded - ts_start) + ' + ';
+;;;         msg += (ts_end - ts_loaded) + ' ms.';
+;;;         kukit.log(msg);
         }
-;;;     try {
-            this.setupEvents();
-;;;     } catch(e) {
-;;;         // Event setup errors are logged.
-;;;         if (e.name == 'RuleMergeError' || e.name == 'EventBindError') {
-;;;            msg = 'Events setup - ' + e.toString();
-;;;             // Log the message
-;;;             kukit.logFatal(msg);
-;;;             // and throw it...
-;;;             throw new Error(msg);
-;;;         } else {
-;;;             throw e;
-;;;         }
+    }
+;;; try {
+        this.setupEvents();
+;;; } catch(e) {
+;;;     // Event setup errors are logged.
+;;;     if (e.name == 'RuleMergeError' || e.name == 'EventBindError') {
+;;;        msg = 'Events setup - ' + e.toString();
+;;;         // Log the message
+;;;         kukit.logFatal(msg);
+;;;         // and throw it...
+;;;         throw new Error(msg);
+;;;     } else {
+;;;         throw e;
 ;;;     }
-        window.kukitRulesInitializing = false;
-        window.kukitRulesInitialized = true;
-    };
+;;; }
+    window.kukitRulesInitializing = false;
+    window.kukitRulesInitialized = true;
+};
+this.initialize.apply(this, arguments);
 };
 
 
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to