Team:Cornell/javascripts/notebook

From 2013.igem.org

(Difference between revisions)
Line 114: Line 114:
];
];
-
// var names = [
 
-
// "Rafael",
 
-
// "Inigo Montoya",
 
-
// "Vizzini",
 
-
// "Count Rugen",
 
-
// "Prince Humperdink",
 
-
// "Nupur",
 
-
// "Westley",
 
-
// "Fezzik"];
 
-
//
 
-
// var fullNames = [
 
-
// "Rafael Lizarralde",
 
-
// "Inigo Montoya",
 
-
// "Vizzini",
 
-
// "Count Rugen",
 
-
// "Prince Humperdink",
 
-
// "Nupur Bhatt",
 
-
// "Westley",
 
-
// "Fezzik"];
 
-
//
 
-
// var pics = [
 
-
// "https://static.igem.org/mediawiki/2012/2/25/CornellProteinFoldingIsHard.gif",
 
-
// "https://static.igem.org/mediawiki/2013/5/50/Cornell-nb-wet-bc.png",
 
-
// "https://static.igem.org/mediawiki/2013/2/29/Cornell-nb-dry-sc.png",
 
-
// "https://static.igem.org/mediawiki/2013/5/50/Cornell-nb-wet-bc.png",
 
-
// "https://static.igem.org/mediawiki/2013/2/29/Cornell-nb-dry-sc.png",
 
-
// "https://static.igem.org/mediawiki/2013/2/29/Cornell-nb-dry-sc.png",
 
-
// "https://static.igem.org/mediawiki/2013/2/29/Cornell-nb-dry-sc.png",
 
-
// "https://static.igem.org/mediawiki/2013/2/29/Cornell-nb-dry-sc.png"];
 
-
//
 
-
// var desc = [
 
-
// "I like pickled watermelons dipped in soy sauce. Also, I'm not as cool as Nupur.",
 
-
// "Hello there. Slow going?",
 
-
// "You're trying to kidnap what I've rightfully stolen.",
 
-
// "Stop saying that!" ,
 
-
// "She is alive, or was an hour ago.",
 
-
// "The awesome",
 
-
// "Rodents Of Unusual Size? I don't think they exist.",
 
-
// "You just wiggled your finger. That's wonderful!"];
 
-
 
if(window.find)  
if(window.find)  
{
{
Line 161: Line 121:
{
{
var name = info[i][0];
var name = info[i][0];
-
var n = 0;
+
var skip = false;
while(window.find(name))
while(window.find(name))
{
{
-
if(n%2 == 0 || firefox)  
+
if(skip || firefox)  
{
{
var ah = document.createElement('div');
var ah = document.createElement('div');
Line 194: Line 154:
rng.insertNode(ah);
rng.insertNode(ah);
}
}
-
n++;
+
skip = !skip;
}
}
window.getSelection().removeAllRanges();
window.getSelection().removeAllRanges();

Revision as of 17:49, 28 June 2013

function loadHref() { if(document.location != "https://2013.igem.org/Team:Cornell/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'; } var techb = document.getElementsByClassName('nb-onetech-i'); for(var i = techb.length-1; i >= 0; i--) { techb[i].onclick = function() { showTech(this); } var teche = techb[i].parentNode.parentNode.children[1]; if(teche.innerHTML == "" || teche.innerHTML.indexOf("{{{tech}}}") != -1){ techb[i].className = 'nb-onetech-disabled'; teche.className = 'nb-tech-disabled'; } } } 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('nb-' + 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=0; i<row.children.length; 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('nb-' + 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('wet-only').parentNode.parentNode; for(var i=0; i<row.children.length; 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('wet-only').parentNode.parentNode; for(var i=0; i<row.children.length; 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 showAllTech() { var techbut = document.getElementById('nb-alltech'); var all = techbut.className == 'nb-all-i'; techbut.className = (all ? 'nb-all' : 'nb-all-i'); var row = document.getElementsByClassName('nb-tech'); for(var i=0; i<row.length; i++) { row[i].style.display = (all ? 'block' : 'none'); } var techs = document.getElementsByClassName(all ? 'nb-onetech-i' : 'nb-onetech'); for(var i= techs.length -1; i >= 0; i--) { techs[i].className = (all ? 'nb-onetech' : 'nb-onetech-i'); } } function showTech(that) { var show = that.className == 'nb-onetech'; that.className = show ? 'nb-onetech-i' : 'nb-onetech'; that.parentNode.parentNode.children[1].style.display = show ? 'none' : 'block'; }

function findNames() {

var info = [ ["Rafael", "Rafael Lizarralde", "CornellProteinFoldingIsHard.gif", "I like pickled watermelons dipped in soy sauce. Also, I'm not as cool as Nupur."], ["Inigo", "Inigo Montoya", "Cornell-nb-wet-bc.png", "You killed his father."], ["Nupur", "Nupur Bhatt", "Cornell-nb-dry-sc.png", "Source of all greater trash."] ];

if(window.find) { var firefox = /Firefox/i.test(navigator.userAgent);

for(var i = 0; i < info.length; i++) { var name = info[i][0]; var skip = false;

while(window.find(name)) { if(skip || firefox) { var ah = document.createElement('div'); ah.className="author-hover"; ah.appendChild(document.createTextNode(name));

var ahp = document.createElement('div'); ahp.className="author-hover-pic"; var ad = document.createElement('div'); ad.className="author-desc"; var img = document.createElement('img'); img.src = info[i][2]; var d = document.createElement('div'); var h = document.createElement('h5'); h.appendChild(document.createTextNode(info[i][1])); var p = document.createElement('p'); p.appendChild(document.createTextNode(info[i][3]));

d.appendChild(h); d.appendChild(p); ad.appendChild(img); ad.appendChild(d); ahp.appendChild(ad);

var rng = window.getSelection().getRangeAt(0); rng.deleteContents(); rng.insertNode(ahp); rng.insertNode(ah); } skip = !skip; } window.getSelection().removeAllRanges(); } } else if(document.body.createTextRange) { for(var i = 0; i < info.length; i++) { var rng=document.body.createTextRange(); var name = info[i][0];

while(rng.findText(name)) { alert(rng.parentElement().innerHTML);

rng.pasteHTML('
' + name + '
<img src="' + info[i][2] +'" </img>
' + info[i][1] + '
' + info[i][3] + '
');

} } } window.scroll(0,0) }