Commit 4a53d149 authored by David Foucher's avatar David Foucher

Fix indent

parent 15444793
Pipeline #2091 failed with stage
in 1 minute and 3 seconds
......@@ -20,15 +20,15 @@
<br>
<!-- pre>{{ this.ruleToShow.data }}</pre -->
<!-- the demo root element -->
<ul id="demo">
<tree-item
<!-- the demo root element -->
<ul id="demo">
<tree-item
class="item"
:item="ruleTree"
@make-folder="makeFolder"
@add-item="addItem"
></tree-item>
</ul>
></tree-item>
</ul>
</div>
<div v-else>
......@@ -59,62 +59,62 @@
}
function toTree(lines) { // eslint-disable-line no-unused-vars
//var lines=rules['Guyane.rules']['data'].split('\n');
//var lines=rules['Auvergne-Rhône-Alpes.rules']['data'].split('\n');
var root= new Node('Règle');
var currentIndent=-1;
var currentNode=root;
// we scan the rules line by line
for (var i=0;i<lines.length;i++) {
var line=lines[i];
if (line.match(/^\s*$/)) continue; // Empty line, skip
var indent=line.search(/\S|$/); // number of indenting spaces
//debugger;
var newNode= new Node(line.trim());
if (indent>currentIndent) { // New child
// Set the new node parent
newNode.parent=currentNode;
// attach the new node to its parent
currentNode.children.push(newNode);
// Set the new current node
currentNode=newNode;
currentIndent=indent;
//debugger;
} else if (indent<currentIndent){
// Move up in the tree
var level=currentIndent-indent;
for (var j=0;j<level/4;j++) {
// up one level
//debugger;
currentNode=currentNode.parent;
//debugger;
currentIndent=currentIndent-4;
//debugger;
}
newNode.parent=currentNode.parent;
currentNode.parent.children.push(newNode); // Add a sibbling
currentNode=newNode;
//debugger;
} else {
// Add as sibbling
newNode.parent=currentNode.parent;
currentNode.parent.children.push(newNode);
currentNode=newNode;
//debugger;
}
}
return root;
//var lines=rules['Guyane.rules']['data'].split('\n');
//var lines=rules['Auvergne-Rhône-Alpes.rules']['data'].split('\n');
var root= new Node('Règle');
var currentIndent=-1;
var currentNode=root;
// we scan the rules line by line
for (var i=0;i<lines.length;i++) {
var line=lines[i];
if (line.match(/^\s*$/)) continue; // Empty line, skip
var indent=line.search(/\S|$/); // number of indenting spaces
//debugger;
var newNode= new Node(line.trim());
if (indent>currentIndent) { // New child
// Set the new node parent
newNode.parent=currentNode;
// attach the new node to its parent
currentNode.children.push(newNode);
// Set the new current node
currentNode=newNode;
currentIndent=indent;
//debugger;
} else if (indent<currentIndent){
// Move up in the tree
var level=currentIndent-indent;
for (var j=0;j<level/4;j++) {
// up one level
//debugger;
currentNode=currentNode.parent;
//debugger;
currentIndent=currentIndent-4;
//debugger;
}
newNode.parent=currentNode.parent;
currentNode.parent.children.push(newNode); // Add a sibbling
currentNode=newNode;
//debugger;
} else {
// Add as sibbling
newNode.parent=currentNode.parent;
currentNode.parent.children.push(newNode);
currentNode=newNode;
//debugger;
}
}
return root;
}
export default {
......
......@@ -66,12 +66,12 @@ export default {
cursor: pointer;
}
.bold {
font-weight: bold;
font-weight: bold;
}
ul {
padding-left: 1em;
line-height: 1.5em;
list-style-type: dot;
padding-left: 1em;
line-height: 1.5em;
list-style-type: dot;
}
</style>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment