ModifierSuppression des espaces superflus
{BR}
function trim(string){BR}
{{BR}
return string.replace(/(^\s*)|(\s*$)/g,'');{BR}
} {BR}
ModifierRemplacement des accents
{BR}
String.prototype.sans_accents = function() {{BR}
var ch = this.replace(/é|è|ê|ë/g, "e");{BR}
ch = ch.replace(/à|â|ä/g, "a");{BR}
ch = ch.replace(/ç/g, "c");{BR}
ch = ch.replace(/î|ï/g, "i");{BR}
ch = ch.replace(/ô|ö/g, "o");{BR}
ch = ch.replace(/ù|û|ü/g, "u");{BR}
ch = ch.replace(/À|Â|Ä|Å/g, "A");{BR}
ch = ch.replace(/Ç/g, "C");{BR}
ch = ch.replace(/É|È|Ê|Ë/g, "E");{BR}
ch = ch.replace(/Ô|Ö/g, "O");{BR}
ch = ch.replace(/Ù|Û|Ü/g, "U");{BR}
ch = ch.replace(/\s/g, "+");{BR}
return ch;{BR}
}{BR}
APPEL
StrChaine += trim(StrChaineAvecAccent.sans_accents());
ModifierAppel simi ajax:aha
{BR}
Send AHAH Request{BR}
function ahah(url,target) {{BR}
document.getElementById(target).innerHTML = 'loading data...';{BR}
if (window.XMLHttpRequest) {{BR}
req = new XMLHttpRequest();{BR}
req.onreadystatechange = function() {ahahDone(target);};{BR}
req.open("GET", url, true);{BR}
req.send(null);{BR}
} else if (window.ActiveXObject) {{BR}
req = new ActiveXObject("Microsoft.XMLHTTP");{BR}
if (req) {{BR}
req.onreadystatechange = function() {ahahDone(target);};{BR}
req.open("GET", url, true);{BR}
req.send();{BR}
}{BR}
}{BR}
}{BR}
{BR}
{BR}
{BR}
Receive AHAH Request{BR}
function ahahDone(target) {{BR}
// only if req is "loaded"{BR}
if (req.readyState == 4) {{BR}
// only if "OK"{BR}
if (req.status == 200 || req.status == 304) {{BR}
results = req.responseText;{BR}
document.getElementById(target).innerHTML = results;{BR}
} else {{BR}
document.getElementById(target).innerHTML="ahah error:\n" +{BR}
req.statusText;{BR}
}{BR}
}{BR}
}{BR}
ModifierDifférence entre deux dates
Note : Il s'agit de fonctionner en date utc (un int) et d'ajouter ou retirer des millisecondes.
Attention : il faut prendre en compte le décalage horaire : getTimezoneOffset
{BR}
var Portal_Maintenant = new Date();{BR}
var Portal_DateUTC =Date.UTC(Portal_Maintenant.getYear(),Portal_Maintenant.getMonth(),Portal_Maintenant.getDate(),Portal_Maintenant.getHours(),Portal_Maintenant.getMinutes(),Portal_Maintenant.getSeconds()) + Portal_Maintenant.getTimezoneOffset()* 60000;{BR}
var Portal_Avant = new Date(Portal_DateUTC-5*60*1000);{BR}
TempsActuDiffere = Portal_Avant.getHours()+"h"+Portal_Avant.getMinutes();{BR}
alert("TEmp actu"+TempsActuDiffere);{BR}