Mercurial > defr > DualBlog
comparison RollUp.js @ 0:629389204276
Import initial
author | Franck Deroche <webmaster@defr.org> |
---|---|
date | Sat, 20 Oct 2007 14:15:10 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:629389204276 |
---|---|
1 var styleSwitch = { | |
2 set:function(title) { | |
3 var i, a, main; | |
4 for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { | |
5 if(a.getAttribute("rel").indexOf("Style") != -1 && a.getAttribute("title")) { | |
6 a.disabled = true; | |
7 if(a.getAttribute("title") == title) a.disabled = false; | |
8 } | |
9 } | |
10 document._currentStyleSheet = title; | |
11 }, | |
12 | |
13 get:function() { | |
14 return document._currentStyleSheet; | |
15 }, | |
16 | |
17 getPref:function() { | |
18 var a = document.getElementsByTagName("link"); | |
19 for(var i=0; a[i]; i++) { | |
20 if(a[i].getAttribute("rel").indexOf("Style") != -1 && a[i].getAttribute("rel").indexOf("Alt") == -1 && a[i].getAttribute("title")) | |
21 return a[i].getAttribute("title"); | |
22 } | |
23 return null; | |
24 }, | |
25 | |
26 unload:function() { | |
27 var date = new Date(); | |
28 date.setTime(date.getTime() + 365 * 24 * 3600 * 1000); | |
29 document.cookie="style=" + document._currentStyleSheet +";expires=" + date.toGMTString() + ";path=/"; | |
30 } | |
31 } | |
32 | |
33 var arContent = new Array(); | |
34 var arTitle = new Array(); | |
35 | |
36 window.onload = function() { | |
37 var shownSection = 'About', i, x; | |
38 x=document.getElementsByTagName('dt'); | |
39 for(i=0;i<x.length;i++) { | |
40 if(x[i].parentNode.id == 'SideBar') { | |
41 x[i].onclick=ToggleDisp; | |
42 arTitle[arTitle.length] = x[i]; | |
43 } | |
44 } | |
45 x=document.getElementsByTagName('dd'); | |
46 for (i=0;i<x.length;i++) { | |
47 if(x[i].parentNode.id == 'SideBar') { | |
48 arContent[arContent.length] = x[i]; | |
49 if(arTitle[arContent.length - 1].id!=shownSection) { | |
50 x[i].style.display='none'; | |
51 } else { | |
52 arTitle[arContent.length - 1].className='Actif'; | |
53 } | |
54 } | |
55 } | |
56 var ad = document.getElementById('Adresse'); | |
57 ad.onclick = ToggleLink; | |
58 arContent[arContent.length] = document.getElementById("Link"); | |
59 arTitle[arTitle.length] = ad; | |
60 | |
61 styleSwitch.set(styleSwitch.getPref()); | |
62 /* var dS = document.styleSheets; | |
63 if(dS && dS[dS.length - 1].title) { | |
64 for(var i =0; i < dS.length; i++) | |
65 { | |
66 if(dS[i].title=='Somatic') { | |
67 if(dS[i].insertRule) | |
68 dS[i].insertRule("@import url('/blog/Somatic_JS.css');", 0); | |
69 else | |
70 dS[i].addImport('Somatic_JS.css'); | |
71 } | |
72 } | |
73 } | |
74 else if(dS && styleSwitch.get() == "Somatic") { | |
75 dS[dS.length - 1].insertRule("@import url(/blog/Somatic_JS.css);", 0); | |
76 //for(j in dS[0]) alert(j); | |
77 }*/ | |
78 } | |
79 | |
80 window.onunload = function() { | |
81 styleSwitch.unload(); | |
82 return true; | |
83 } | |
84 | |
85 | |
86 function ToggleDisp(e) { | |
87 for(var i=0; i<arTitle.length; i++) arTitle[i].className=''; | |
88 var targetAc; | |
89 if(!e) e=window.event; | |
90 if(e.target) targetAc=e.target; | |
91 else targetAc=e.srcElement; | |
92 //Parait que la ligne suivante est utile pour Safari ^^;... Sauf qu'Opera retourne en plus le ns dans le nodeName... | |
93 while(targetAc.nodeName.toLowerCase() != 'dt' && targetAc.nodeName.toLowerCase() != 'html:dt') targetAc=targetAc.parentNode; | |
94 targetAc.className = 'Actif'; | |
95 var nextSib=targetAc.nextSibling; | |
96 while(nextSib.nodeType!=1) {nextSib=nextSib.nextSibling;} | |
97 if(styleSwitch.get() != "Somatic") { | |
98 var nextSibDisp=(nextSib.style.display=='none') ? 'block' : 'none'; | |
99 nextSib.style.display=nextSibDisp; | |
100 } else { | |
101 for(i=0;i<arContent.length;i++) arContent[i].style.display = 'none'; | |
102 nextSib.style.display='block'; | |
103 } | |
104 } | |
105 | |
106 function ToggleLink() { | |
107 var obj=document.getElementById('Link'); | |
108 if(styleSwitch.get() == "Somatic") { | |
109 for(i=0; i<arTitle.length; i++) arTitle[i].className=''; | |
110 arTitle[arTitle.length - 1].className='Actif'; | |
111 for(i=0;i<arContent.length;i++) arContent[i].style.display='none'; | |
112 obj.style.display='block'; | |
113 } else { | |
114 obj.style.display=(obj.style.display=='block') ? 'none' : 'block'; | |
115 } | |
116 } | |
117 | |
118 function pop_config() { | |
119 alert('Vouip, je sais, faut qu\'j\'remette ca, mais faut l\'updater d\'abord ^^;;'); | |
120 } | |
121 |