<leo_file xmlns:leo="
http://leoeditor.com/namespaces/leo-python-editor/1.1" >
<leo_header file_format="2" tnodes="0" max_tnode_index="0" clone_windows="0"/>
<globals body_outline_ratio="0.50" body_secondary_ratio="0.50">
<global_window_position top="50" left="50" height="832" width="1308"/>
<global_log_window_position top="0" left="0" height="0" width="0"/>
</globals>
<preferences/>
<find_panel_settings/>
<vnodes>
<v t="ekr.20150217160307.26"><vh>test.leo</vh>
<v t="ekr.20150217160307.27"><vh>node 1</vh></v>
<v t="ekr.20150217160307.28"><vh>node 2</vh>
<v t="ekr.20150303091549.1"><vh>node 2-1</vh></v>
</v>
<v t="ekr.20150303091549.2"><vh>node 3</vh></v>
</v>
</vnodes>
<tnodes>
<t tx="ekr.20150217160307.26">This is a test</t>
<t tx="ekr.20150217160307.27">Node 1 text.</t>
<t tx="ekr.20150217160307.28">Node 2 text.</t>
<t tx="ekr.20150303091549.1">node 2-1 text.</t>
<t tx="ekr.20150303091549.2">Node 3 text.</t>
</tnodes>
</leo_file>
the transform creates something like the following web page::
@tabwidth -2
<html>
<head>
<style>
pre { background:#FFE7C6; }
div.outlinepane {
height: 3.0in;
}
div.bodypane,div.body-text {
height: 2.0in;
}
div.tnode {
visibility: hidden;
height: 0;
}
div.node {
position: relative;
left: 20px;
background:Khaki;
}
</style>
<script src="
http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("h1").click(function(){
$(this).parent().children("div.node").toggle();
// The parent div's id is v.x.
// Find the tnode div whose id is t.x.
console.clear();
parent_id=$(this).parent().attr("id");
if (parent_id) {
target=$(this).parent().attr("id").substring(2);
console.log("clicked:"+$(this).text())
// console.log("parent:"+$(this).parent())
// console.log("target:"+target)
$(".tnode").each(function(){
console.log($(this).attr("id"))
target2=$(this).attr("id").substring(2);
if (target === target2) {
console.log("found:"+target2)
$("pre.body-text").text($(this).text());
};
}); // end .each.
};
});
});
</script>
</head>
<body>
<div class="tnodes">
<div class="tnode" id="ekr.20150217160307.26">This is a test</div>
<div class="tnode" id="ekr.20150217160307.27">Node 1 text.</div>
<div class="tnode" id="ekr.20150217160307.28">Node 2 text.</div>
<div class="tnode" id="ekr.20150303091549.1">node 2-1 text.</div>
<div class="tnode" id="ekr.20150303091549.2">Node 3 text.</div>
</div>
<div class="outlinepane">
<div class="node" id="ekr.20150217160307.26">
<h1>test.leo</h1>
<div class="node" id="ekr.20150217160307.27">
<h1>node 1</h1>
</div>
<div class="node" id="ekr.20150217160307.28">
<h1>node 2</h1>
<div class="node" id="ekr.20150303091549.1">
<h1>node 2-1</h1>
</div>
</div>
<div class="node" id="ekr.20150303091549.2">
<h1>node 3</h1>
</div>
</div>
</div>
<div class="bodypane"><h1>Body Pane
</h1><pre class="body-text">body</pre>
</div>
</body>
</html>
The tnodes div is essentially a lookup table. It could be converted to a proper javascript dict on entry for greater speed.
The jQuery script above is functional when the transformed page sent back to the browser. This script expands and contracts nodes, and also puts the proper body text in the body pane.
Edward