remember state of folds
This commit is contained in:
104
index.html
104
index.html
@@ -7,10 +7,10 @@
|
||||
TABLE { width: 100%; }
|
||||
HR { height:5px; border: 0px;}
|
||||
TD { vertical-align: top; width: 10%; }
|
||||
LI {
|
||||
text-indent:-1.3em;
|
||||
LI {
|
||||
text-indent:-1.3em;
|
||||
padding-left:1.4em;
|
||||
list-style-type:none;
|
||||
list-style-type:none;
|
||||
overflow: hidden;
|
||||
margin-bottom: 0.2em;
|
||||
}
|
||||
@@ -31,7 +31,7 @@
|
||||
A:focus { text-decoration: underline; }
|
||||
#filter { width: 100%; }
|
||||
#search { width: 100%; display: table; }
|
||||
.search_span { display: table-cell; text-align: center; vertical-align: middle;
|
||||
.search_span { display: table-cell; text-align: center; vertical-align: middle;
|
||||
padding-left: 0.1em; padding-right: 0.1em; }
|
||||
.head { font-size: 16px; text-align:left; padding-top: 0.2em; margin-bottom: -0.5em; }
|
||||
#menu { font-size: 12px; width: 3em; }
|
||||
@@ -49,7 +49,7 @@
|
||||
</STYLE>
|
||||
<script language="javascript">
|
||||
function init() {
|
||||
var head = document.head;
|
||||
var head = document.head;
|
||||
if (config.style!=null) {
|
||||
var link = document.createElement('link');
|
||||
link.type = 'text/css';
|
||||
@@ -70,8 +70,8 @@ function init() {
|
||||
if (!config.search) {
|
||||
document.getElementById('search').style.display='none';
|
||||
}
|
||||
if (config.columns==1 || narrow_window()) {
|
||||
make_menu();
|
||||
if (config.columns==1 || narrow_window()) {
|
||||
make_menu();
|
||||
}
|
||||
document.getElementById("open_blank_arrow").innerHTML=config.arrows[0];
|
||||
document.getElementById("filter").focus();
|
||||
@@ -90,7 +90,7 @@ String.prototype.capitalizeFirstLetter = function() {
|
||||
|
||||
function make_link(md) {
|
||||
var match=linkReg.exec(md);
|
||||
if (match != null) {
|
||||
if (match != null) {
|
||||
return "<li>"+match[1]+"<a href=\""+match[3]+"\">"+match[2]+"</a>"+match[4];
|
||||
}
|
||||
match=linkPlain.exec(md);
|
||||
@@ -104,7 +104,7 @@ function make_head(c,index="") {
|
||||
var name=c.substring(1).trim();
|
||||
var head=c.replace(/ /g," ");
|
||||
var id=name.replace(/ /g,"")+"_"+index;
|
||||
return '<a name="'+name+'" id="anchor_'+id+'" onclick="fold_content(\''+id+'\')">'+
|
||||
return '<a name="'+name+'" id="anchor_'+id+'" onclick="fold_toggle(\''+id+'\')">'+
|
||||
'<div class=head align=center id="head_'+id+'">'+head+'</div></a>'+
|
||||
'<hr WIDTH="100%" SIZE=3 NOSHADE>';
|
||||
}
|
||||
@@ -148,7 +148,7 @@ function filter(ev) {
|
||||
if (c>1) {
|
||||
document.getElementById('filter').focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function no_filter(){}
|
||||
|
||||
@@ -172,13 +172,13 @@ function search_hits(needle) {
|
||||
}
|
||||
}
|
||||
var match=linkReg.exec(linkList[l].toLowerCase());
|
||||
if (match != null ) {
|
||||
if (match != null ) {
|
||||
/* matches to markdown link */
|
||||
if ( match[2].indexOf(needle)>-1 ) { hitList.push(l); }
|
||||
if ( match[2].indexOf(needle)>-1 ) { hitList.push(l); }
|
||||
continue
|
||||
}
|
||||
match=linkPlain.exec(linkList[l].toLowerCase());
|
||||
if (match != null ) {
|
||||
if (match != null ) {
|
||||
/* matches to plain link */
|
||||
if ( match[2].indexOf(needle)>-1 ) { hitList.push(l); }
|
||||
continue
|
||||
@@ -248,7 +248,7 @@ function reload_source() {
|
||||
location.href=config.source
|
||||
}
|
||||
function get_URL(s) {
|
||||
if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }
|
||||
if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }
|
||||
else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
|
||||
xmlhttp.onreadystatechange=function()
|
||||
{ if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
||||
@@ -258,8 +258,8 @@ function get_URL(s) {
|
||||
xmlhttp.send();
|
||||
}
|
||||
|
||||
function read_links() {
|
||||
get_URL(config.source);
|
||||
function read_links() {
|
||||
get_URL(config.source);
|
||||
}
|
||||
|
||||
function parse_links(s) {
|
||||
@@ -271,15 +271,15 @@ function parse_links(s) {
|
||||
}
|
||||
}
|
||||
linkList=links.slice(0);
|
||||
init();
|
||||
init();
|
||||
}
|
||||
function keyboard_entry(ev) {
|
||||
var kC=ev.keyCode;
|
||||
var k=String.fromCharCode(ev.keyCode);
|
||||
var kC=ev.keyCode;
|
||||
var k=String.fromCharCode(ev.keyCode);
|
||||
if ( document.activeElement === document.getElementById("filter")) {
|
||||
return
|
||||
}
|
||||
if (/S/.test(k)) {
|
||||
if (/S/.test(k)) {
|
||||
document.getElementById("filter").focus();
|
||||
}
|
||||
if (/N/.test(k)) {
|
||||
@@ -287,8 +287,8 @@ function keyboard_entry(ev) {
|
||||
}
|
||||
}
|
||||
function keyboard_control(ev) {
|
||||
var kC=ev.keyCode;
|
||||
var k=String.fromCharCode(ev.keyCode);
|
||||
var kC=ev.keyCode;
|
||||
var k=String.fromCharCode(ev.keyCode);
|
||||
if (ev.ctrlKey) {
|
||||
if (k=='C') {
|
||||
document.getElementById("filter").value='';
|
||||
@@ -305,7 +305,7 @@ function toggle_blank() {
|
||||
span.attributes['data']="false";
|
||||
} else {
|
||||
span.attributes['data']="true";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
span.attributes['data']="true"
|
||||
}
|
||||
@@ -354,33 +354,83 @@ function filter_cookies(cookies,name) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
function fold_content(name) {
|
||||
function fold_toggle(name,save_state = true) {
|
||||
if (!narrow_window()) { return }
|
||||
if (!config.foldCategories) { return }
|
||||
var title = document.getElementById("head_"+name);
|
||||
var el = document.getElementById("content_"+name);
|
||||
el.hidden = ! el.hidden;
|
||||
title.classList.toggle("fold_plus");
|
||||
if (save_state) {
|
||||
set_cookie("fold",fold_get_state());
|
||||
}
|
||||
}
|
||||
function fold_set(name,value) {
|
||||
if (!narrow_window()) { return }
|
||||
if (!config.foldCategories) { return }
|
||||
var title = document.getElementById("head_"+name);
|
||||
var el = document.getElementById("content_"+name);
|
||||
el.hidden = value;
|
||||
if (value) {
|
||||
title.classList.add("fold_plus");
|
||||
} else {
|
||||
title.classList.remove("fold_plus");
|
||||
}
|
||||
}
|
||||
function fold_initial() {
|
||||
if (!narrow_window()) { return }
|
||||
if (!config.foldCategories) { return }
|
||||
var state = get_cookie("fold");
|
||||
if (state !== null) {
|
||||
fold_set_state(state);
|
||||
return;
|
||||
}
|
||||
var slides = document.getElementsByClassName("head");
|
||||
for(var i = 0; i < slides.length; i++) {
|
||||
var el = slides.item(i);
|
||||
var rect = el.getBoundingClientRect();
|
||||
if (window.innerHeight*1.5 < rect.top) {
|
||||
var name = el.id.replace("head_","");
|
||||
fold_content(name);
|
||||
fold_toggle(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
function fold_get_state() {
|
||||
var slides = document.getElementsByClassName("head");
|
||||
var state = "";
|
||||
for(var i = 0; i < slides.length; i++) {
|
||||
var title = slides.item(i);
|
||||
var name = title.id.replace("head_","");
|
||||
var el = document.getElementById("content_"+name);
|
||||
if (el.hidden) {
|
||||
state += '-';
|
||||
} else {
|
||||
state += '+';
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
function fold_set_state(state) {
|
||||
var slides = document.getElementsByClassName("head");
|
||||
for(var i = 0; i < slides.length; i++) {
|
||||
var title = slides.item(i);
|
||||
var name = title.id.replace("head_","");
|
||||
if (state[i] == '-') {
|
||||
fold_set(name, true);
|
||||
}
|
||||
if (state[i] == '+') {
|
||||
fold_set(name, false);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function set_cookie(name,value) {
|
||||
// Save cookies for 2 hours
|
||||
document.cookie = name + "=" + value.toString() + "&" + window.location.pathname +
|
||||
";path=" + window.location.pathname + ";max-age="+ (60*60*2).toString() + ";";
|
||||
";path=" + window.location.pathname + ";max-age="+ (60*60*2).toString() + ";";
|
||||
}
|
||||
document.onkeyup=keyboard_entry;
|
||||
document.onkeydown=keyboard_control;
|
||||
|
||||
Reference in New Issue
Block a user