4 new revisions:

Revision: 6c83b726a875
Branch:   default
Author:   Pekka Klärck
Date:     Fri Feb 15 01:25:40 2013
Log:      log/report: somewhat random js and model cleanup....
http://code.google.com/p/robotframework/source/detail?r=6c83b726a875

Revision: f607b8458246
Branch:   default
Author:   Pekka Klärck
Date:     Fri Feb 15 04:40:25 2013
Log:      log: Cleaned up rendering errors....
http://code.google.com/p/robotframework/source/detail?r=f607b8458246

Revision: f151e20efcbc
Branch:   default
Author:   Pekka Klärck
Date:     Fri Feb 15 05:27:42 2013
Log:      log/report: moved last function to util
http://code.google.com/p/robotframework/source/detail?r=f151e20efcbc

Revision: 865d6f5c7150
Branch:   default
Author:   Pekka Klärck
Date:     Fri Feb 15 05:30:05 2013
Log:      log/report: even more js cleanup
http://code.google.com/p/robotframework/source/detail?r=865d6f5c7150

==============================================================================
Revision: 6c83b726a875
Branch:   default
Author:   Pekka Klärck
Date:     Fri Feb 15 01:25:40 2013
Log:      log/report: somewhat random js and model cleanup.

changes include:
- cleanning up undefined/null usage (prefer the latter)
- removed unused cruft from model
- use ' instead of " as quote
- whitespace

hope this doesn't break anything....
http://code.google.com/p/robotframework/source/detail?r=6c83b726a875

Modified:
 /src/robot/htmldata/rebot/log.html
 /src/robot/htmldata/rebot/log.js
 /src/robot/htmldata/rebot/model.js
 /src/robot/htmldata/rebot/report.html
 /src/robot/htmldata/rebot/testdata.js
 /utest/webcontent/spec/ParsingSpec.js

=======================================
--- /src/robot/htmldata/rebot/log.html  Thu Feb 14 16:14:02 2013
+++ /src/robot/htmldata/rebot/log.html  Fri Feb 15 01:25:40 2013
@@ -66,7 +66,7 @@
         var selector = $.tmpl('logLevelSelectorTemplate', controller);
         selector.find('select').val(controller.defaultLogLevel());
         selector.appendTo($('#top-right-header'));
-        $('#report-or-log-link a').css({'border-bottom-left-radius': '0'});
+ $('#report-or-log-link').find('a').css({'border-bottom-left-radius': '0'});
         setMessageVisibility(controller.defaultLogLevel());
     }
 }
=======================================
--- /src/robot/htmldata/rebot/log.js    Thu Feb 14 16:14:02 2013
+++ /src/robot/htmldata/rebot/log.js    Fri Feb 15 01:25:40 2013
@@ -49,7 +49,7 @@
     if (!window.elementsToExpand.length)
         return;
     var element = window.elementsToExpand.pop();
-    if (element == undefined || elementHiddenByUser(element.id)) {
+    if (!element || elementHiddenByUser(element.id)) {
         window.elementsToExpand = [];
         return;
     }
@@ -84,14 +84,14 @@

 function expandAllChildren(elementId) {
     window.elementsToExpand = [window.testdata.find(elementId)];
-    window.expandDecider = function() { return true; };
+    window.expandDecider = function () { return true; };
     expandRecursively();
 }

 function expandCriticalFailed(element) {
     if (element.status == "FAIL") {
         window.elementsToExpand = [element];
-        window.expandDecider = function(e) {
+        window.expandDecider = function (e) {
return e.status == "FAIL" && (e.isCritical === undefined || e.isCritical);
         };
         expandRecursively();
=======================================
--- /src/robot/htmldata/rebot/model.js  Thu Feb 14 16:37:41 2013
+++ /src/robot/htmldata/rebot/model.js  Fri Feb 15 01:25:40 2013
@@ -1,15 +1,15 @@
 window.model = (function () {

     function Suite(data) {
-        var suite = createModelObject(data, "s");
+        var suite = createModelObject(data);
         suite.source = data.source;
         suite.relativeSource = data.relativeSource;
- suite.fullName = data.parent ? data.parent.fullName + "." + data.name : data.name; + suite.fullName = data.parent ? data.parent.fullName + '.' + data.name : data.name;
         setStats(suite, data.statistics);
         suite.metadata = data.metadata;
-        suite.populateKeywords = createIterablePopulator("Keyword");
-        suite.populateTests = createIterablePopulator("Test");
-        suite.populateSuites = createIterablePopulator("Suite");
+        suite.populateKeywords = createIterablePopulator('Keyword');
+        suite.populateTests = createIterablePopulator('Test');
+        suite.populateSuites = createIterablePopulator('Suite');
         suite.childrenNames = ['keyword', 'suite', 'test'];
         suite.callWhenChildrenReady = function (callable) { callable(); };
         suite.message = data.message;
@@ -18,9 +18,9 @@
         };
         suite.searchTests = function (predicate) {
             var tests = [];
-            var subSuites = this.suites();
-            for (var i in subSuites)
-                tests = tests.concat(subSuites[i].searchTests(predicate));
+            var suites = this.suites();
+            for (var i in suites)
+                tests = tests.concat(suites[i].searchTests(predicate));
             return tests.concat(util.filter(this.tests(), predicate));
         };
         suite.searchTestsByTag = function (tag) {
@@ -89,22 +89,22 @@
         }
     }

-    function createModelObject(data, symbol) {
+    function createModelObject(data) {
         return {
             name: data.name,
             doc: data.doc,
             status: data.status,
             times: data.times,
- id: data.parent ? data.parent.id + "-" + symbol + (data.index + 1) : symbol + "1"
+            id: data.parent ? data.parent.id + '-' + data.id : data.id
         };
     }

     function Test(data) {
-        var test = createModelObject(data, "t");
-        test.fullName = data.parent.fullName + "." + test.name;
+        var test = createModelObject(data);
+        test.fullName = data.parent.fullName + '.' + test.name;
test.formatParentName = function () { return util.formatParentName(test); };
         test.timeout = data.timeout;
-        test.populateKeywords = createIterablePopulator("Keyword");
+        test.populateKeywords = createIterablePopulator('Keyword');
         test.childrenNames = ['keyword'];
         test.isChildrenLoaded = data.isChildrenLoaded;
test.callWhenChildrenReady = window.fileLoading.getCallbackHandlerForKeywords(test);
@@ -119,15 +119,12 @@
     }

     function Keyword(data) {
-        var kw = createModelObject(data, "k");
+        var kw = createModelObject(data);
         kw.type = data.type;
-        var parent = data.parent;
- var parentPath = (parent.path === undefined) ? parent.fullName : parent.path;
-        kw.path = parentPath + "." + data.index;
         kw.arguments = data.args;
         kw.timeout = data.timeout;
-        kw.populateMessages = createIterablePopulator("Message");
-        kw.populateKeywords = createIterablePopulator("Keyword");
+        kw.populateMessages = createIterablePopulator('Message');
+        kw.populateKeywords = createIterablePopulator('Keyword');
         kw.childrenNames = ['keyword', 'message'];
         kw.isChildrenLoaded = data.isChildrenLoaded;
kw.callWhenChildrenReady = window.fileLoading.getCallbackHandlerForKeywords(kw);
@@ -167,14 +164,14 @@
     }

     function populateIterable(obj, name, populator) {
-        var nameInLowerCase = name.toLowerCase();
- obj[nameInLowerCase + "s"] = createGetAllFunction(populator.numberOfItems, populator.creator);
+        name = name.toLowerCase() + 's';
+ obj[name] = createGetAllFunction(populator.numberOfItems, populator.creator);
     }

     function createGetAllFunction(numberOfElements, creator) {
-        var cached = undefined;
+        var cached = null;
         return function () {
-            if (cached === undefined) {
+            if (cached === null) {
                 cached = [];
                 for (var i = 0; i < numberOfElements(); i++) {
                     cached.push(creator(i));
@@ -191,7 +188,7 @@
         Message: Message,
         Times: Times,
         containsTag: containsTag,  // Exposed for tests
-        containsTagPattern: containsTagPattern,  // Exposed for tests
+        containsTagPattern: containsTagPattern  // Exposed for tests
     };
 }());

@@ -248,8 +245,8 @@
     function calculatePercents(total, passed, failed) {
         if (total == 0)
             return [0.0, 0.0];
-        pass = 100.0 * passed / total;
-        fail = 100.0 * failed / total;
+        var pass = 100.0 * passed / total;
+        var fail = 100.0 * failed / total;
         if (pass > 0 && pass < 0.1)
             return [0.1, 99.9];
         if (fail > 0 && fail < 0.1)
=======================================
--- /src/robot/htmldata/rebot/report.html       Thu Feb 14 14:04:57 2013
+++ /src/robot/htmldata/rebot/report.html       Fri Feb 15 01:25:40 2013
@@ -146,7 +146,7 @@
 }

 function renderTotalSelector(name) {
- var args = {linkTarget: (name !== undefined) ? 'total_'+name : 'totals',
+    var args = {linkTarget: (name) ? 'total_'+name : 'totals',
                 totalTabStatus: 'detail-tab-selected'};
     renderSelector(args, 'totalDetailsSelectorTemplate', {selected: name});
 }
@@ -178,7 +178,7 @@
 }

 function renderTagSelector(name) {
-    var args = {linkTarget: (name !== undefined) ? 'tag_'+name : 'tags',
+    var args = {linkTarget: (name) ? 'tag_'+name : 'tags',
                 tagTabStatus: 'detail-tab-selected'};
     var stats = {tags: window.testdata.statistics().tag, selected: name};
     renderSelector(args, 'tagDetailsSelectorTemplate', stats);
@@ -200,7 +200,7 @@
 }

 function renderSuiteSelector(id) {
-    var args = {linkTarget: (id !== undefined) ? 'suite_'+id : 'suites',
+    var args = {linkTarget: (id) ? 'suite_'+id : 'suites',
                 suiteTabStatus: 'detail-tab-selected'};
     var stats = {suites: window.testdata.statistics().suite,
                  selected: id};
=======================================
--- /src/robot/htmldata/rebot/testdata.js       Thu Feb 14 01:20:27 2013
+++ /src/robot/htmldata/rebot/testdata.js       Fri Feb 15 01:25:40 2013
@@ -8,7 +8,7 @@
     var KEYWORDS = ['KEYWORD', 'SETUP', 'TEARDOWN', 'FOR', 'VAR'];

     function addElement(elem) {
-        if (elem.id == undefined)
+        if (!elem.id)
             elem.id = uniqueId();
         elementsById[elem.id] = elem;
         return elem;
@@ -22,7 +22,7 @@
     function times(stats) {
         var startMillis = stats[1];
         var elapsed = stats[2];
-        if (startMillis == null)
+        if (startMillis === null)
             return [null, null, elapsed];
         return [util.timestamp(startMillis),
                 util.timestamp(startMillis + elapsed),
@@ -52,7 +52,9 @@

     function createKeyword(parent, element, strings, index) {
         var kw = model.Keyword({
+            parent: parent,
             type: KEYWORDS[element[0]],
+            id: 'k' + (index + 1),
             name: strings.get(element[1]),
             timeout: strings.get(element[2]),
             args: strings.get(element[4]),
@@ -63,8 +65,6 @@
             },
             status: parseStatus(element[5], strings),
             times: model.Times(times(element[5])),
-            parent: parent,
-            index: index,
             isChildrenLoaded: typeof(element[6]) !== 'number'
         });
         lazyPopulateKeywordsFromFile(kw, element[6], strings);
@@ -87,12 +87,12 @@
         return util.map(taglist, strings.get);
     }

-    function createTest(suite, element, strings, index) {
+    function createTest(parent, element, strings, index) {
         var statusElement = element[5];
         var test = model.Test({
-            parent: suite,
+            parent: parent,
+            id: 't' + (index + 1),
             name: strings.get(element[0]),
-            index: index,
             doc: function () {
                 var doc = strings.get(element[3]);
                 this.doc = function () { return doc; };
@@ -101,7 +101,7 @@
             timeout: strings.get(element[1]),
             isCritical: element[2],
             status: parseStatus(statusElement),
-            message:  function () {
+            message: function () {
                 var msg = createMessage(statusElement, strings);
                 this.message = function () { return msg; };
                 return msg;
@@ -122,8 +122,8 @@
         var statusElement = element[5];
         var suite = model.Suite({
             parent: parent,
+            id: 's' + ((index || 0) + 1),
             name: strings.get(element[0]),
-            index: index,
             source: strings.get(element[1]),
             relativeSource: strings.get(element[2]),
             doc: function () {
@@ -184,7 +184,7 @@
             },
             creator: function (index) {
                 return creator(window['keywords'+structureIndex][index],
- getStringStore(window['strings'+structureIndex]), + StringStore(window['strings'+structureIndex]),
                                index);
             }
         };
@@ -194,18 +194,18 @@
         var elem = window.output.suite;
         if (elementsById[elem.id])
             return elem;
- var main = addElement(createSuite(undefined, elem, getStringStore(window.output.strings)));
-        window.output.suite = main;
-        return main;
+ var root = addElement(createSuite(null, elem, StringStore(window.output.strings)));
+        window.output.suite = root;
+        return root;
     }

     function findById(id) {
         return elementsById[id];
     }

-    function findPathTo(pathId, callback) {
-        var ids = pathId.split("-");
-        if (ids[0] != "s1") {
+    function findPathTo(id, callback) {
+        var ids = id.split('-');
+        if (ids[0] != 's1') {
             return;
         }
         var root = suite();
@@ -213,16 +213,19 @@
         findPathWithId(ids, root, [root.id], callback);
     }

-    function findPathWithId(pathId, current, result, callback) {
-        if (pathId.length == 0) {
+    function findPathWithId(ids, current, result, callback) {
+        if (ids.length == 0) {
             callback(result);
         } else {
             current.callWhenChildrenReady(function () {
- doWithSelected(current, pathId[0][0], parseInt(pathId[0].substring(1))-1, function (item) {
-                result.push(item.id);
-                pathId.shift();
-                findPathWithId(pathId, item, result, callback);
-            })});
+                var type = ids[0][0];
+                var index = parseInt(ids[0].substring(1)) - 1;
+                doWithSelected(current, type, index, function (item) {
+                    result.push(item.id);
+                    ids.shift();
+                    findPathWithId(ids, item, result, callback);
+                });
+            });
         }
     }

@@ -233,12 +236,12 @@
         }
     }

-    function selectFrom(element, selector, index) {
-        if (selector == "k") {
+    function selectFrom(element, type, index) {
+        if (type == 'k') {
             return element.keywords()[index];
-        } else if(selector == "t") {
+        } else if (type == 't') {
             return element.tests()[index];
-        } else if(selector == "s") {
+        } else {
             return element.suites()[index];
         }
     }
@@ -248,7 +251,7 @@
         iterator.counter = 0;
         iterator.next = function () {
             return message(window.output.errors[iterator.counter++],
-                           getStringStore(window.output.strings));
+                           StringStore(window.output.strings));
         };
         iterator.hasNext = function () {
             return iterator.counter < window.output.errors.length;
@@ -264,7 +267,7 @@
         return _statistics;
     }

-    function getStringStore(strings) {
+    function StringStore(strings) {

         function getText(id) {
             var text = strings[id];
@@ -273,7 +276,7 @@
             if (text[0] == '*')
                 return text.substring(1);
             var extracted = extract(text);
-            strings[id] = "*"+extracted;
+            strings[id] = '*' + extracted;
             return extracted;
         }

@@ -284,8 +287,7 @@
         }

         function get(id) {
-            if (id == undefined) return undefined;
-            if (id == null) return null;
+            if (id === null) return null;
             return getText(id);
         }

@@ -298,7 +300,7 @@
         find: findById,
         findPathTo: findPathTo,
         statistics: statistics,
-        getStringStore: getStringStore,
+        StringStore: StringStore,  // exposed for tests
         LEVELS: LEVELS
     };

=======================================
--- /utest/webcontent/spec/ParsingSpec.js       Sun Oct 21 04:38:53 2012
+++ /utest/webcontent/spec/ParsingSpec.js       Fri Feb 15 01:25:40 2013
@@ -9,13 +9,13 @@
     }

     it("should have empty string with id 0", function () {
-        var strings = window.testdata.getStringStore(["*"]);
+        var strings = window.testdata.StringStore(["*"]);
         var empty = strings.get(0);
         expect(empty).toEqual("");
     });

     it("should uncompress", function () {
- var strings = window.testdata.getStringStore(["*", "eNorzk3MySmmLQEASKop9Q=="]); + var strings = window.testdata.StringStore(["*", "eNorzk3MySmmLQEASKop9Q=="]);
         var decompressed = strings.get(1);
         var expected = multiplyString("small", 20);
         expect(decompressed).toEqual(expected);
@@ -23,7 +23,7 @@

     it("should uncompress and replace compressed in memory", function () {
         var stringArray = ["*", "eNorzk3MySmmLQEASKop9Q=="];
-        var strings = window.testdata.getStringStore(stringArray);
+        var strings = window.testdata.StringStore(stringArray);
         expect(stringArray[1]).toEqual("eNorzk3MySmmLQEASKop9Q==");
         strings.get(1);
         var expected = multiplyString("small", 20);
@@ -31,7 +31,7 @@
     });

     it("should handle plain text", function () {
-        var strings = window.testdata.getStringStore(["*", "*plain text"]);
+        var strings = window.testdata.StringStore(["*", "*plain text"]);
         var actual = strings.get(1);
         expect(actual).toEqual("plain text");
     });
@@ -78,6 +78,7 @@
     it("should parse suite", function () {
         var suite = window.testdata.suite();
         expect(suite.name).toEqual("Suite");
+        expect(suite.id).toEqual("s1");
         expect(suite.status).toEqual("PASS");
         expect(endsWith(suite.source, "Suite.txt")).toEqual(true);
         expect(suite.doc()).toEqual("suite doc");
@@ -92,6 +93,7 @@
     it("should parse test", function () {
         var test = firstTest(window.testdata.suite());
         expect(test.name).toEqual("Test");
+        expect(test.id).toEqual("s1-t1");
         expect(test.status).toEqual("PASS");
         expect(test.fullName).toEqual("Suite.Test");
         expect(test.doc()).toEqual("test doc");
@@ -106,11 +108,11 @@
     it("should parse keyword", function () {
         var kw = nthKeyword(firstTest(window.testdata.suite()), 0);
         expect(kw.name).toEqual("BuiltIn.Sleep");
+        expect(kw.id).toEqual("s1-t1-k1");
         expect(kw.status).toEqual("PASS");
         expect(kw.times).toBeDefined();
         expect(kw.times.elapsedMillis).toBeGreaterThan(99);
         expect(kw.times.elapsedMillis).toBeLessThan(200);
-        expect(kw.path).toEqual("Suite.Test.0");
         expect(kw.type).toEqual("KEYWORD");
         expect(kw.childrenNames).toEqual(['keyword', 'message'])
     });
@@ -555,14 +557,14 @@
         window.output = window.splittingOutput;
         var i = 1;
         while (window['splittingOutputKeywords'+i]) {
-            window['keywords'+i] = window['splittingOutputKeywords'+i]
-            window['strings'+i] = window['splittingOutputStrings'+i]
+            window['keywords'+i] = window['splittingOutputKeywords'+i];
+            window['strings'+i] = window['splittingOutputStrings'+i];
             i = i+1;
         }
- var originalGetter = window.fileLoading.getCallbackHandlerForKeywords + var originalGetter = window.fileLoading.getCallbackHandlerForKeywords; window.fileLoading.getCallbackHandlerForKeywords = function(parent) {
             var normalResult = originalGetter(parent);
-            var wrapper = function (callable) {
+            function wrapper(callable) {
                 parent.isChildrenLoaded = true;
                 normalResult(callable);
             }
@@ -575,7 +577,7 @@
         var test = firstTest(subSuite(1, suite));
         expect(test.isChildrenLoaded).not.toBeTruthy();
         expect(test.children()).toBeUndefined();
-        test.callWhenChildrenReady(function() {return;});
+        test.callWhenChildrenReady(function() {});
         expect(test.isChildrenLoaded).toBeTruthy();
         expect(test.children()).not.toBeUndefined();
     });

==============================================================================
Revision: f607b8458246
Branch:   default
Author:   Pekka Klärck
Date:     Fri Feb 15 04:40:25 2013
Log:      log: Cleaned up rendering errors.

- do not store errors to render to window
- consume processed errors from window.output.errors
http://code.google.com/p/robotframework/source/detail?r=f607b8458246

Modified:
 /src/robot/htmldata/rebot/log.html
 /src/robot/htmldata/rebot/testdata.js
 /utest/webcontent/spec/ParsingSpec.js

=======================================
--- /src/robot/htmldata/rebot/log.html  Fri Feb 15 01:25:40 2013
+++ /src/robot/htmldata/rebot/log.html  Fri Feb 15 04:40:25 2013
@@ -72,21 +72,18 @@
 }

 function addErrors() {
-    var errors = window.testdata.errors();
+    var errors = window.testdata.errorIterator();
     if (errors.hasNext()) {
         $.tmpl('errorHeaderTemplate').appendTo($('body'));
-        window.errorsToRender = errors;
-        drawErrorsRecursively();
+        drawErrorsRecursively(errors, $('#errors'));
     }
 }

-function drawErrorsRecursively() {
-    if (!window.errorsToRender.hasNext())
-        return;
-    var elements = popFromIterator(window.errorsToRender, 10);
-    $.tmpl('errorTemplate', elements).appendTo($('#errors'));
-    if (window.errorsToRender.hasNext())
-        setTimeout(drawErrorsRecursively, 0);
+function drawErrorsRecursively(errors, target) {
+    var elements = popFromIterator(errors, 10);
+    $.tmpl('errorTemplate', elements).appendTo(target);
+    if (errors.hasNext())
+ setTimeout(function () { drawErrorsRecursively(errors, target); }, 0);
     else
         scrollToHash();
 }
=======================================
--- /src/robot/htmldata/rebot/testdata.js       Fri Feb 15 01:25:40 2013
+++ /src/robot/htmldata/rebot/testdata.js       Fri Feb 15 04:40:25 2013
@@ -246,17 +246,16 @@
         }
     }

-    function errors() {
-        var iterator = new Object();
-        iterator.counter = 0;
-        iterator.next = function () {
-            return message(window.output.errors[iterator.counter++],
-                           StringStore(window.output.strings));
-        };
-        iterator.hasNext = function () {
-            return iterator.counter < window.output.errors.length;
+    function errorIterator() {
+        return {
+            next: function () {
+                return message(window.output.errors.shift(),
+                               StringStore(window.output.strings));
+            },
+            hasNext: function () {
+                return window.output.errors.length > 0;
+            }
         };
-        return iterator;
     }

     function statistics() {
@@ -296,7 +295,7 @@

     return {
         suite: suite,
-        errors: errors,
+        errorIterator: errorIterator,
         find: findById,
         findPathTo: findPathTo,
         statistics: statistics,
=======================================
--- /utest/webcontent/spec/ParsingSpec.js       Fri Feb 15 01:25:40 2013
+++ /utest/webcontent/spec/ParsingSpec.js       Fri Feb 15 04:40:25 2013
@@ -258,7 +258,7 @@
     });

     it("should show warning in errors", function () {
-        var firstError = window.testdata.errors().next()
+        var firstError = window.testdata.errorIterator().next();
         expectMessage(firstError, "warning", "WARN");
         var callbackExecuted = false;
window.testdata.findPathTo(firstError.link, function (pathToKeyword) {

==============================================================================
Revision: f151e20efcbc
Branch:   default
Author:   Pekka Klärck
Date:     Fri Feb 15 05:27:42 2013
Log:      log/report: moved last function to util
http://code.google.com/p/robotframework/source/detail?r=f151e20efcbc

Modified:
 /src/robot/htmldata/rebot/testdata.js
 /src/robot/htmldata/rebot/util.js

=======================================
--- /src/robot/htmldata/rebot/testdata.js       Fri Feb 15 04:40:25 2013
+++ /src/robot/htmldata/rebot/testdata.js       Fri Feb 15 05:27:42 2013
@@ -39,10 +39,6 @@
     function parseStatus(stats) {
         return STATUSES[stats[0]];
     }
-
-    function last(items) {
-        return items[items.length-1];
-    }

     function childCreator(parent, childType) {
         return function (elem, strings, index) {
@@ -138,7 +134,7 @@
                 return msg;
             },
             times: model.Times(times(statusElement)),
-            statistics: suiteStats(last(element)),
+            statistics: suiteStats(util.last(element)),
             metadata: parseMetadata(element[4], strings)
         });
suite.populateKeywords(Populator(element[8], strings, childCreator(suite, createKeyword)));
=======================================
--- /src/robot/htmldata/rebot/util.js   Thu Feb 14 05:05:09 2013
+++ /src/robot/htmldata/rebot/util.js   Fri Feb 15 05:27:42 2013
@@ -40,6 +40,10 @@
         }
         return false;
     }
+
+    function last(items) {
+        return items[items.length-1];
+    }

     function unescape(string) {
return string.replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&');
@@ -164,6 +168,7 @@
         all: all,
         any: any,
         contains: contains,
+        last: last,
         unescape: unescape,
         normalize: normalize,
         Matcher: Matcher,

==============================================================================
Revision: 865d6f5c7150
Branch:   default
Author:   Pekka Klärck
Date:     Fri Feb 15 05:30:05 2013
Log:      log/report: even more js cleanup
http://code.google.com/p/robotframework/source/detail?r=865d6f5c7150

Modified:
 /src/robot/htmldata/rebot/log.html
 /src/robot/htmldata/rebot/log.js
 /src/robot/htmldata/rebot/report.html

=======================================
--- /src/robot/htmldata/rebot/log.html  Fri Feb 15 04:40:25 2013
+++ /src/robot/htmldata/rebot/log.html  Fri Feb 15 05:30:05 2013
@@ -101,24 +101,21 @@
     return result;
 }

-function makeElementVisible(element) {
+function makeElementVisible(id) {
// findPathTo ensures that all the data for the element has been downloaded
     // from server before executing the callback function
-    window.testdata.findPathTo(unescape(element), function (uniqueIds) {
-        for (var i in uniqueIds) {
-            expandElementWithId(uniqueIds[i]);
-        }
-        if (uniqueIds && uniqueIds.length > 0) {
- expandCriticalFailed(window.testdata.find(uniqueIds[uniqueIds.length - 1]));
-            window.location.hash = element;
+    window.testdata.findPathTo(id, function (ids) {
+        util.map(ids, expandElementWithId);
+        if (ids.length) {
+            expandCriticalFailed(window.testdata.find(util.last(ids)));
+            window.location.hash = id;
         }
     });
 }

 function addTestExecutionLog(main) {
-    var body = $('body');
-    $('<h2>Test Execution Log</h2>').appendTo(body);
-    $.tmpl('suiteTemplate', main).appendTo(body);
+    $('body').append($('<h2>Test Execution Log</h2>'),
+                     $.tmpl('suiteTemplate', main));
 }
 </script>

=======================================
--- /src/robot/htmldata/rebot/log.js    Fri Feb 15 01:25:40 2013
+++ /src/robot/htmldata/rebot/log.js    Fri Feb 15 05:30:05 2013
@@ -11,12 +11,6 @@
 function toggleKeyword(kwId) {
     toggleElement(kwId, ['keyword', 'message']);
 }
-
-function addElements(elems, templateName, target){
-    for (var i in elems) {
-        $.tmpl(templateName, elems[i]).appendTo(target);
-    }
-}

 function toggleElement(elementId, childrenNames) {
     var children = $('#' + elementId + '-children');
@@ -37,10 +31,12 @@

 function drawCallback(element, childElement, childrenNames) {
     return function () {
-        $.map(childrenNames, function (childName) {
-            addElements(element[childName + 's'](),
-                        childName + 'Template',
-                        childElement);
+        util.map(childrenNames, function (childName) {
+            var children = element[childName + 's']();
+            var template = childName + 'Template';
+            util.map(children, function (child) {
+                $.tmpl(template, child).appendTo(childElement);
+            });
         });
     }
 }
=======================================
--- /src/robot/htmldata/rebot/report.html       Fri Feb 15 01:25:40 2013
+++ /src/robot/htmldata/rebot/report.html       Fri Feb 15 05:30:05 2013
@@ -208,7 +208,7 @@
 }

 function renderSuiteDetails(id) {
-    testdata.findPathTo(id, function () {
+    testdata.findPathTo(id, function (ids) {
         var suite = testdata.find(id);
         var opts = {logURL: window.settings.logURL};
$.tmpl('suiteDetailsTemplate', suite, opts).appendTo('#details-header');

--

--- You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to