view RollUp.js @ 32:4cea8b128fdd

Possibilité de choisir des templates différents en fonction du type de sortie. Le fichier templates.conf permet d'associer à chaque type de sortie (correspondant à une section du fichier INI) des templates pour le squelette, les posts et les commentaires. Il est possible de définir virtuellement une infinité de type de sorties différents, pour le moment seul de quoi obtenir un flux Atom a été ajouté. Pour changer le type de sortie, il faut passer en GET au script appellant un paramètre outputType. Si le paramètre reçu ne correspondant à aucun des types de sorties définis dans templates.conf, alors on prend du xhtml par défaut.
author Franck Deroche <webmaster@defr.org>
date Mon, 05 Nov 2007 09:06:46 +0100
parents 629389204276
children
line wrap: on
line source
  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 ^^;;');
  }