Difference between revisions of "Template:NTNU Trondheim/Notebook/javascript/notebook"
Line 1: | Line 1: | ||
function loadHref() { | function loadHref() { | ||
− | if(document.location != "https://2015.igem.org/Team:NTNU_Trondheim/ | + | if(document.location != "https://2015.igem.org/Team:NTNU_Trondheim/Notebook") { |
var href = document.location.href; | var href = document.location.href; | ||
− | var i = href.substring(href.indexOf("#")+ | + | var i = href.substring(href.indexOf("#")+1); |
document.getElementById('week' + i + 'entry').style.display = 'block'; | document.getElementById('week' + i + 'entry').style.display = 'block'; | ||
− | if(i != 'A') { | + | /*if(i != 'A') { |
document.getElementById('weekAentry').style.display = 'none'; | document.getElementById('weekAentry').style.display = 'none'; | ||
document.getElementById('weekA').className = ''; | document.getElementById('weekA').className = ''; | ||
− | } | + | }*/ |
document.getElementById('week' + i ).className = 'active'; | document.getElementById('week' + i ).className = 'active'; | ||
} | } | ||
Line 17: | Line 17: | ||
that.parentNode.children[1].className = (show ? 'nb-only' : 'nb-only-i'); | that.parentNode.children[1].className = (show ? 'nb-only' : 'nb-only-i'); | ||
all(); | all(); | ||
− | var list = document.getElementsByClassName(' | + | var list = document.getElementsByClassName('pc-' + ele.id); |
for (var i = 0; i < list.length; i++) { | for (var i = 0; i < list.length; i++) { | ||
list[i].style.display = (show ? 'block' : 'none'); | list[i].style.display = (show ? 'block' : 'none'); | ||
Line 34: | Line 34: | ||
row.children[i].children[1].className = (hide ? 'nb-only-i' : 'nb-only'); | row.children[i].children[1].className = (hide ? 'nb-only-i' : 'nb-only'); | ||
− | var list = document.getElementsByClassName(' | + | var list = document.getElementsByClassName('pc-' + row.children[i].children[0].children[0].id); |
for (var j = 0; j < list.length; j++) { | for (var j = 0; j < list.length; j++) { | ||
list[j].style.display = (hide ? 'none' : 'block'); | list[j].style.display = (hide ? 'none' : 'block'); | ||
Line 44: | Line 44: | ||
var all = true; | var all = true; | ||
var allbut = document.getElementById('nb-all'); | var allbut = document.getElementById('nb-all'); | ||
− | var row = document.getElementById(' | + | var row = document.getElementById('media-only').parentNode.parentNode; |
for(var i=1; i<row.children.length-1; i++) | for(var i=1; i<row.children.length-1; i++) | ||
{ if(row.children[i].children[1].className == 'nb-only-i') all = false; } | { if(row.children[i].children[1].className == 'nb-only-i') all = false; } | ||
Line 52: | Line 52: | ||
var all = true; | var all = true; | ||
var allbut = document.getElementById('nb-all'); | var allbut = document.getElementById('nb-all'); | ||
− | var row = document.getElementById(' | + | var row = document.getElementById('media-only').parentNode.parentNode; |
for(var i=1; i<row.children.length-1; i++) | for(var i=1; i<row.children.length-1; i++) | ||
{ | { | ||
Line 79: | Line 79: | ||
document.getElementById(filt).style.display = 'block'; | document.getElementById(filt).style.display = 'block'; | ||
} | } | ||
− | |||
function isDelimiter(ch) | function isDelimiter(ch) | ||
{ | { | ||
return ch == ' ' || ch == '.'; | return ch == ' ' || ch == '.'; | ||
} | } |
Latest revision as of 22:47, 18 September 2015
function loadHref() { if(document.location != "https://2015.igem.org/Team:NTNU_Trondheim/Notebook") { var href = document.location.href; var i = href.substring(href.indexOf("#")+1); document.getElementById('week' + i + 'entry').style.display = 'block'; /*if(i != 'A') { document.getElementById('weekAentry').style.display = 'none'; document.getElementById('weekA').className = ; }*/ document.getElementById('week' + i ).className = 'active'; } } function filter(that) { var ele = that.children[0]; var show = ele.style.display == 'none'; ele.style.display= (show ? 'block' : 'none'); that.parentNode.children[1].className = (show ? 'nb-only' : 'nb-only-i'); all(); var list = document.getElementsByClassName('pc-' + ele.id); for (var i = 0; i < list.length; i++) { list[i].style.display = (show ? 'block' : 'none'); } } function onlyFilter(that) { var filt = that.parentNode; var row = filt.parentNode;
for(var i=1; i<row.children.length-1; i++) { var hide = true; if(row.children[i] == filt) hide = false;
row.children[i].children[0].children[0].style.display = (hide ? 'none' : 'block'); row.children[i].children[1].className = (hide ? 'nb-only-i' : 'nb-only');
var list = document.getElementsByClassName('pc-' + row.children[i].children[0].children[0].id); for (var j = 0; j < list.length; j++) { list[j].style.display = (hide ? 'none' : 'block'); } } all(); } function all() { var all = true; var allbut = document.getElementById('nb-all'); var row = document.getElementById('media-only').parentNode.parentNode; for(var i=1; i<row.children.length-1; i++) { if(row.children[i].children[1].className == 'nb-only-i') all = false; } allbut.className = (all ? 'nb-all' : 'nb-all-i'); } function showAll() { var all = true; var allbut = document.getElementById('nb-all'); var row = document.getElementById('media-only').parentNode.parentNode; for(var i=1; i<row.children.length-1; i++) { row.children[i].children[0].children[0].style.display = 'block'; row.children[i].children[1].className = 'nb-only'; } allbut.className = (all ? 'nb-all' : 'nb-all-i'); var list = document.getElementsByClassName("entry"); for (var i = 0; i < list.length; i++) { list[i].style.display = 'block'; } } function weekFilter(that) { for(var i = -4; i<25; i++) { var c = (i > 0 ? "" + i : String.fromCharCode(69 + i)); var ele = document.getElementById('week' + c); if(ele != null) ele.className = (that.id.substr(4) == c ? 'active' : ); }
var filt = that.id + "entry"; var all = document.getElementsByClassName('nb-week'); for(var i = 0; i<all.length; i++) { if(all[i].tagName == 'DIV') all[i].style.display = 'none'; }
document.getElementById(filt).style.display = 'block'; } function isDelimiter(ch) { return ch == ' ' || ch == '.'; }