125 lines
2.6 KiB
JavaScript
125 lines
2.6 KiB
JavaScript
|
//<SCRIPT Language="JavaScript">
|
|||
|
/*
|
|||
|
Ensemble des fonctions de traitement des cha<EFBFBD>nes de caract<EFBFBD>res
|
|||
|
*/
|
|||
|
function replaceChar(sStr, sFindStr, sReplaceStr)
|
|||
|
/*
|
|||
|
******************************************************
|
|||
|
Remplace une cha<EFBFBD>ne de caract<EFBFBD>re par une autre dans
|
|||
|
dans une texte, quelquesoit le nb d'occurences
|
|||
|
*/
|
|||
|
{
|
|||
|
return((sStr.split(sFindStr)).join(sReplaceStr));
|
|||
|
}
|
|||
|
|
|||
|
function ToLibelle(sValue)
|
|||
|
{
|
|||
|
var sTemp = '';
|
|||
|
sTemp = Replace(sValue, '<', '‹');
|
|||
|
sTemp = Replace(sTemp, '>', '›');
|
|||
|
return(sTemp);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
function RecupCRLF(sTxt)
|
|||
|
/*
|
|||
|
**********************************************************
|
|||
|
Cette fonction permet de remplacer la chaine <BR> par
|
|||
|
CRLF (Chr(13)+Chr(10))
|
|||
|
**********************************************************
|
|||
|
*/
|
|||
|
{
|
|||
|
sTxt = Replace(sTxt, "<BR>", String.fromCharCode(13,10));
|
|||
|
return(Replace(sTxt, "<br>", String.fromCharCode(13,10)));
|
|||
|
}
|
|||
|
|
|||
|
function GetWord(sTxt, nNum, sSep)
|
|||
|
//************************************************************
|
|||
|
//Fonction d'extraction d'une Ni<4E>me cha<68>ne de caract<63>re
|
|||
|
//<2F> l'int<6E>rieure d'une cha<68>ne source, avec un s<>parateur
|
|||
|
//d<>termin<69>
|
|||
|
//
|
|||
|
//Param<61>tres :
|
|||
|
// sTxt = cha<68>ne source
|
|||
|
// nNum = n<> cha<68>ne recherch<63>e
|
|||
|
// sSep = cha<68>ne s<>parateur (si "", alors = " ")
|
|||
|
//************************************************************
|
|||
|
{
|
|||
|
var nPos;
|
|||
|
var nOldPos;
|
|||
|
var sTmp;
|
|||
|
var nI;
|
|||
|
var sSepar;
|
|||
|
|
|||
|
sSepar = sSep;
|
|||
|
nI = nNum;
|
|||
|
|
|||
|
if (sSepar == "") sSepar = " ";
|
|||
|
|
|||
|
if (nNum >= 1)
|
|||
|
{
|
|||
|
sTmp = sTxt + sSepar;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
sTmp = sSepar;
|
|||
|
}
|
|||
|
|
|||
|
nOldPos = 0;
|
|||
|
|
|||
|
//*** Recherche le mot dans la liste
|
|||
|
nPos = sTmp.indexOf(sSepar);
|
|||
|
|
|||
|
while (nPos > -1 && nI >= 1)
|
|||
|
{
|
|||
|
nI--;
|
|||
|
if (nI>0)
|
|||
|
{
|
|||
|
nOldPos = nPos + sSepar.length;
|
|||
|
nPos = sTmp.indexOf(sSepar, nOldPos);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (nI == 0)
|
|||
|
{
|
|||
|
if (nPos == -1) nPos = sTmp.length + 1;
|
|||
|
sTmp = sTmp.substr(nOldPos, nPos - nOldPos);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
sTmp = "";
|
|||
|
}
|
|||
|
|
|||
|
return(sTmp);
|
|||
|
}
|
|||
|
|
|||
|
function RTrim(sTxt)
|
|||
|
//************************************************************
|
|||
|
//Function de suppression des blanc <20> droite d'une chaine
|
|||
|
//
|
|||
|
//Param<61>tres :
|
|||
|
// sTxt = cha<68>ne <20> <20>purer
|
|||
|
//Retour
|
|||
|
// cha<68>ne sans blanc <20> droite
|
|||
|
//************************************************************
|
|||
|
{
|
|||
|
var sTmp;
|
|||
|
var nI;
|
|||
|
|
|||
|
sTmp = sTxt;
|
|||
|
nI = sTmp.length - 1;
|
|||
|
while (nI>=0 && sTmp.charAt(nI)==" ")
|
|||
|
{
|
|||
|
nI--;
|
|||
|
}
|
|||
|
return(sTmp = sTmp.substr(0, nI + 1));
|
|||
|
}
|
|||
|
|
|||
|
function ToQueryString(sString)
|
|||
|
{
|
|||
|
if (sString.length!=0)
|
|||
|
{
|
|||
|
sString = replaceChar(sString, ' ', '%20');
|
|||
|
}
|
|||
|
return(sString);
|
|||
|
}
|