summaryrefslogtreecommitdiffstats
path: root/examples/example5-collapsing.html
diff options
context:
space:
mode:
Diffstat (limited to 'examples/example5-collapsing.html')
-rw-r--r--examples/example5-collapsing.html17
1 files changed, 8 insertions, 9 deletions
diff --git a/examples/example5-collapsing.html b/examples/example5-collapsing.html
index 7c655ed..babbcd7 100644
--- a/examples/example5-collapsing.html
+++ b/examples/example5-collapsing.html
@@ -152,20 +152,19 @@ $(function () {
// prepare the data
for (var i = 0; i < 1000; i++) {
var d = (data[i] = {});
- var parent = null;
+ var parent;
- if (Math.random() > 0.8) {
+ if (Math.random() > 0.8 && i > 0) {
indent++;
- parent = i - 1;
- parents.push(parent);
+ parents.push(i - 1);
} else if (Math.random() < 0.3 && indent > 0) {
indent--;
- parent = parents.pop();
- } else if (parents.length > 0) {
+ parents.pop();
+ }
+
+ if (parents.length > 0) {
parent = parents[parents.length - 1];
- }
-
- if (indent == 0) {
+ } else {
parent = null;
}