Mercurial > defr > DualBlog
diff RollUp.js @ 0:629389204276
Import initial
author | Franck Deroche <webmaster@defr.org> |
---|---|
date | Sat, 20 Oct 2007 14:15:10 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RollUp.js Sat Oct 20 14:15:10 2007 +0200 @@ -0,0 +1,121 @@ + var styleSwitch = { + set:function(title) { + var i, a, main; + for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { + if(a.getAttribute("rel").indexOf("Style") != -1 && a.getAttribute("title")) { + a.disabled = true; + if(a.getAttribute("title") == title) a.disabled = false; + } + } + document._currentStyleSheet = title; + }, + + get:function() { + return document._currentStyleSheet; + }, + + getPref:function() { + var a = document.getElementsByTagName("link"); + for(var i=0; a[i]; i++) { + if(a[i].getAttribute("rel").indexOf("Style") != -1 && a[i].getAttribute("rel").indexOf("Alt") == -1 && a[i].getAttribute("title")) + return a[i].getAttribute("title"); + } + return null; + }, + + unload:function() { + var date = new Date(); + date.setTime(date.getTime() + 365 * 24 * 3600 * 1000); + document.cookie="style=" + document._currentStyleSheet +";expires=" + date.toGMTString() + ";path=/"; + } + } + + var arContent = new Array(); + var arTitle = new Array(); + + window.onload = function() { + var shownSection = 'About', i, x; + x=document.getElementsByTagName('dt'); + for(i=0;i<x.length;i++) { + if(x[i].parentNode.id == 'SideBar') { + x[i].onclick=ToggleDisp; + arTitle[arTitle.length] = x[i]; + } + } + x=document.getElementsByTagName('dd'); + for (i=0;i<x.length;i++) { + if(x[i].parentNode.id == 'SideBar') { + arContent[arContent.length] = x[i]; + if(arTitle[arContent.length - 1].id!=shownSection) { + x[i].style.display='none'; + } else { + arTitle[arContent.length - 1].className='Actif'; + } + } + } + var ad = document.getElementById('Adresse'); + ad.onclick = ToggleLink; + arContent[arContent.length] = document.getElementById("Link"); + arTitle[arTitle.length] = ad; + + styleSwitch.set(styleSwitch.getPref()); +/* var dS = document.styleSheets; + if(dS && dS[dS.length - 1].title) { + for(var i =0; i < dS.length; i++) + { + if(dS[i].title=='Somatic') { + if(dS[i].insertRule) + dS[i].insertRule("@import url('/blog/Somatic_JS.css');", 0); + else + dS[i].addImport('Somatic_JS.css'); + } + } + } + else if(dS && styleSwitch.get() == "Somatic") { + dS[dS.length - 1].insertRule("@import url(/blog/Somatic_JS.css);", 0); + //for(j in dS[0]) alert(j); + }*/ + } + + window.onunload = function() { + styleSwitch.unload(); + return true; + } + + + function ToggleDisp(e) { + for(var i=0; i<arTitle.length; i++) arTitle[i].className=''; + var targetAc; + if(!e) e=window.event; + if(e.target) targetAc=e.target; + else targetAc=e.srcElement; + //Parait que la ligne suivante est utile pour Safari ^^;... Sauf qu'Opera retourne en plus le ns dans le nodeName... + while(targetAc.nodeName.toLowerCase() != 'dt' && targetAc.nodeName.toLowerCase() != 'html:dt') targetAc=targetAc.parentNode; + targetAc.className = 'Actif'; + var nextSib=targetAc.nextSibling; + while(nextSib.nodeType!=1) {nextSib=nextSib.nextSibling;} + if(styleSwitch.get() != "Somatic") { + var nextSibDisp=(nextSib.style.display=='none') ? 'block' : 'none'; + nextSib.style.display=nextSibDisp; + } else { + for(i=0;i<arContent.length;i++) arContent[i].style.display = 'none'; + nextSib.style.display='block'; + } + } + + function ToggleLink() { + var obj=document.getElementById('Link'); + if(styleSwitch.get() == "Somatic") { + for(i=0; i<arTitle.length; i++) arTitle[i].className=''; + arTitle[arTitle.length - 1].className='Actif'; + for(i=0;i<arContent.length;i++) arContent[i].style.display='none'; + obj.style.display='block'; + } else { + obj.style.display=(obj.style.display=='block') ? 'none' : 'block'; + } + } + + function pop_config() { + alert('Vouip, je sais, faut qu\'j\'remette ca, mais faut l\'updater d\'abord ^^;;'); + } + \ No newline at end of file