TOC html

From Redazione
Jump to navigation Jump to search
Line 60: Line 60:
  
 
function walk_through_TOC(children,parent,depth) {
 
function walk_through_TOC(children,parent,depth) {
depth++
 
  
 
if(!children || !Object.keys(children).length) {
 
if(!children || !Object.keys(children).length) {
 
return
 
return
 
}
 
}
 +
 +
 +
depth++
 +
  
 
for(var value of children) {
 
for(var value of children) {
Line 70: Line 73:
 
// '&&' does not work !
 
// '&&' does not work !
 
if(value.path) {
 
if(value.path) {
 +
 
if(value.state.selected) {
 
if(value.state.selected) {
var repeat = depth
+
wiki_list.push('#'.repeat(depth) + '[[' + value.path + '|' + value.text + ']]')
 +
}
  
// '&&' does not work !
+
} else {
if(parent) {
+
 
if(!parent.path) {
+
if(value.state.selected) {
var regExp = new RegExp('\\b' + parent.text + '$')
+
wiki_list.push('#'.repeat(depth) + value.text)
if(regExp.test(value.path)) {
 
repeat--;
 
}
 
}
 
}
 
wiki_list.push('#'.repeat(repeat) + '[[' + value.path + '|' + value.text + ']]')
 
 
}
 
}
 +
 
}
 
}
  
Line 92: Line 92:
 
 
 
}
 
}
 +
 +
 
}
 
}
 
  
 
var contents = $ci('#TOC_contents').val();
 
var contents = $ci('#TOC_contents').val();

Revision as of 08:57, 1 October 2020