Source de js/of_utils.js
expandTooltip=""
collapseTooltip=""
alreadyOpenedInvite=""
defaultMessageText=""
openedTags=""
tA=new Array()
tF=new Array()
tB=new Array()
tA["g"]="g"
tA["i"]="i"
tA["citer"]="q"
tA["code"]="c"
tA["lien"]="l"
tF["g"]="g"
tF["i"]="i"
tF["q"]="citer"
tF["c"]="code"
tF["l"]="lien"
tB["g"]="bold-button"
tB["i"]="italic-button"
tB["q"]="quote-button"
tB["c"]="code-button"
tB["l"]="link-button"
function expcolAll(dir,rowNum)
{
for(x=0;x < rowNum;x++) {
try {
getE('of-gen'+x).style.display=dir
if(dir=="none") getE('of-switch'+x).innerHTML="+"
else getE('of-switch'+x).innerHTML="–"
}
catch(err) { }
}
if(dir=="none") setCookie("of_collapse","true")
else setCookie("of_collapse","false")
}
function setTooltips(expand,collapse)
{
expandTooltip=expand
collapseTooltip=collapse
}
function writeExpandAllControls(text1,text2,enabled,rowNumber,tooltip1,tooltip2,tooltip3,tooltip4)
{
if(!hasDOM) return
setTooltips(tooltip3,tooltip4)
if(enabled) {
properties1="class=\"submit-button\" onclick=\"expcolAll('block','"+rowNumber+"')\" title=\""+tooltip1+"\""
properties2="class=\"submit-button\" onclick=\"expcolAll('none','"+rowNumber+"')\" title=\""+tooltip2+"\""
} else {
properties1="class=\"disabled-button\" disabled=\"disabled\""
properties2="class=\"disabled-button\" disabled=\"disabled\""
}
prn("<input type=\"button\" value=\""+text1+"\" "+properties1+" />")
prn("<input type=\"button\" value=\""+text2+"\" "+properties2+" />")
}
function toggleDisplay(id,swt)
{
if((getE(id).style.display=="")||(getE(id).style.display=="none")) {
getE(id).style.display="block"
getE(swt).innerHTML="–"
if (getE(swt).mytitle) getE(swt).mytitle=collapseTooltip
else getE(swt).title=collapseTooltip
} else {
getE(id).style.display="none"
getE(swt).innerHTML="+"
if (getE(swt).mytitle) getE(swt).mytitle=expandTooltip
else getE(swt).title=expandTooltip
}
return false
}
function writeExpandControl(elementId,collapse)
{
if(!hasDOM) return
if(elementId!="") prn("<a href=\"#\" class=\"of-post-expand\" id=\"of-switch"+elementId+"\" onclick=\"return toggleDisplay('of-gen"+elementId+"','of-switch"+elementId+"');\" title=\""+((collapse) ? expandTooltip : collapseTooltip)+"\">"+((collapse) ? "+" : "–")+"</a>")
else prn("<span class=\"of-post-expand\"> </span>")
}
function ofValidate(text1,text2,text3,text4)
{
if(!getE('of-msgarea').value) {
if(!getE('of-pstsubject').value) {
alert(text1)
return false
}
if(!confirm(text2)) return false
}
if((!getE('of-pstauthor').value)&&(!confirm(text3))) return false
if((!getE('of-pstsubject').value)&&(!confirm(text4))) return false
closeAllTags()
return true
}
function writePostStyles(invite,text1,text2,text3,text4,text5,tooltip1,tooltip2,tooltip3,tooltip4,tooltip5,openedInvite,defaultText)
{
if(!hasDOM) return
alreadyOpenedInvite=openedInvite
defaultMessageText=defaultText
prn("<input type=\"button\" id=\"bold-button\" class=\"unselected\" value=\""+text2+"\" title=\""+tooltip2+"\" onclick=\"stylize(this,'g');\" /> ")
prn("<input type=\"button\" id=\"italic-button\" class=\"unselected\" value=\""+text3+"\" title=\""+tooltip3+"\" onclick=\"stylize(this,'i');\" /> ")
prn("<input type=\"button\" id=\"quote-button\" class=\"unselected\" value=\""+text1+"\" title=\""+tooltip1+"\" onclick=\"stylize(this,'citer');\" /> ")
prn("<input type=\"button\" id=\"code-button\" class=\"unselected\" value=\""+text4+"\" title=\""+tooltip4+"\" onclick=\"stylize(this,'code');\" /> ")
prn("<input type=\"button\" id=\"link-button\" class=\"unselected\" value=\""+text5+"\" title=\""+tooltip5+"\" onclick=\"stylize(this,'lien','"+invite+"');\" /> ")
}
function stylize(element,tag,invite)
{
if(!checkOpenedTags(tag)) return
scrollTop=-1
msgArea=getE("of-msgarea")
if(msgArea.value==defaultMessageText) msgArea.value=""
useGeneric=true
position=-1
if(msgArea.selectionStart!=null) {
positionStart=msgArea.selectionStart
positionEnd=msgArea.selectionEnd
scrollTop=msgArea.scrollTop
if(positionEnd!=positionStart) {
useGeneric=false
textString=msgArea.value
modifiedText=textString.substring(positionStart,positionEnd)
valueText=""
if(invite) {
valueText=prompt(invite,"http://")
if(valueText==null) return
else valueText="="+valueText
}
revisedMessage=textString.substring(0,positionStart)+"["+tag+valueText+"]"+modifiedText+"[/"+tag+"]"+ textString.substring(positionEnd,textString.length)
msgArea.value=revisedMessage
msgArea.focus()
msgArea.setSelectionRange(positionStart,positionStart+modifiedText.length+(2*tag.length)+valueText.length+5)
} else position=positionStart
} else if(document.selection) {
strSelection=document.selection.createRange().text
position=-2
if(strSelection!="") {
useGeneric=false
valueText=""
if(invite) {
valueText=prompt(invite,"http://")
if(valueText==null) return
else valueText="="+valueText
}
msgArea.focus()
document.selection.createRange().text="["+tag+valueText+"]"+strSelection+"[/"+tag+"]"
}
}
if(useGeneric) {
stringToAdd=""
if(element.className=="selected") {
stringToAdd="[/"+tag+"]"
element.className="unselected"
idx=openedTags.indexOf(tA[tag])
openedTags=openedTags.substring(0,idx)+openedTags.substring(idx+1)
} else {
valueText=""
if(invite) {
valueText=prompt(invite,"http://")
if(valueText==null) return
else valueText="="+valueText
}
stringToAdd="["+tag+valueText+"]"
element.className="selected"
openedTags=openedTags+tA[tag]
}
msgArea.focus()
if(position==-2) document.selection.createRange().text=stringToAdd
else if(position==-1) msgArea.value += stringToAdd
else {
msgArea.value=msgArea.value.substring(0,position)+stringToAdd+ msgArea.value.substring(position,msgArea.value.length)
msgArea.setSelectionRange(position+stringToAdd.length,position+stringToAdd.length)
}
}
if(scrollTop!=-1) msgArea.scrollTop=scrollTop;
}
function activatePassword(inputElt,adminName)
{
if(inputElt.value==adminName) getE('of-pstpasswdzone').style.display='block'
else getE('of-pstpasswdzone').style.display='none'
return false
}
function deActivatePassword()
{
getE('of-pstpasswdzone').style.display='none'
return false
}
function checkOpenedTags(tag)
{
idx=openedTags.indexOf(tA[tag])
if((idx==-1)||(idx==(openedTags.length-1))) return true
else {
toBeClosed=""
autoClose=""
for(i=openedTags.length-1;i>idx;i--) toBeClosed=toBeClosed+"["+tF[openedTags.charAt(i)]+"]"+","
toBeClosed=toBeClosed.substr(0,toBeClosed.length-1)
invite=alreadyOpenedInvite.replace(/%s/,toBeClosed)
invite=invite.replace(/%s/,"["+tag+"]")
if(confirm(invite)) {
msgArea=getE('of-msgarea')
autoClose=""
for(j=openedTags.length-1;j>idx;j--) {
getE(tB[openedTags.charAt(j)]).className="unselected"
autoClose=autoClose+"[/"+tF[openedTags.charAt(j)]+"]"
}
if(msgArea.selectionStart!=null) {
pStart=msgArea.selectionStart
pEnd=msgArea.selectionEnd
scrollTop=msgArea.scrollTop
textString=msgArea.value
revisedMessage=textString.substring(0,pStart)+autoClose+textString.substring(pEnd,textString.length)
msgArea.value=revisedMessage
msgArea.focus()
msgArea.setSelectionRange(pStart+autoClose.length,pStart+autoClose.length)
msgArea.scrollTop=scrollTop;
} else if(document.selection) {
msgArea.focus()
document.selection.createRange().text=autoClose
} else msgArea.value=msgArea.value+autoClose
openedTags=openedTags.substring(0,idx+1)
return true
} else return false
}
}
function closeAllTags()
{
textArea=getE('of-msgarea')
for(i=openedTags.length-1;i >= 0;i--) textArea.value=textArea.value+"[/"+tF[openedTags.charAt(i)]+"]"
}
function initForum()
{
textArea=getE('of-msgarea')
textArea.cols = Math.floor((getE('of-msgpostzone').offsetWidth * textArea.cols)/ textArea.offsetWidth);
}
collapseTooltip=""
alreadyOpenedInvite=""
defaultMessageText=""
openedTags=""
tA=new Array()
tF=new Array()
tB=new Array()
tA["g"]="g"
tA["i"]="i"
tA["citer"]="q"
tA["code"]="c"
tA["lien"]="l"
tF["g"]="g"
tF["i"]="i"
tF["q"]="citer"
tF["c"]="code"
tF["l"]="lien"
tB["g"]="bold-button"
tB["i"]="italic-button"
tB["q"]="quote-button"
tB["c"]="code-button"
tB["l"]="link-button"
function expcolAll(dir,rowNum)
{
for(x=0;x < rowNum;x++) {
try {
getE('of-gen'+x).style.display=dir
if(dir=="none") getE('of-switch'+x).innerHTML="+"
else getE('of-switch'+x).innerHTML="–"
}
catch(err) { }
}
if(dir=="none") setCookie("of_collapse","true")
else setCookie("of_collapse","false")
}
function setTooltips(expand,collapse)
{
expandTooltip=expand
collapseTooltip=collapse
}
function writeExpandAllControls(text1,text2,enabled,rowNumber,tooltip1,tooltip2,tooltip3,tooltip4)
{
if(!hasDOM) return
setTooltips(tooltip3,tooltip4)
if(enabled) {
properties1="class=\"submit-button\" onclick=\"expcolAll('block','"+rowNumber+"')\" title=\""+tooltip1+"\""
properties2="class=\"submit-button\" onclick=\"expcolAll('none','"+rowNumber+"')\" title=\""+tooltip2+"\""
} else {
properties1="class=\"disabled-button\" disabled=\"disabled\""
properties2="class=\"disabled-button\" disabled=\"disabled\""
}
prn("<input type=\"button\" value=\""+text1+"\" "+properties1+" />")
prn("<input type=\"button\" value=\""+text2+"\" "+properties2+" />")
}
function toggleDisplay(id,swt)
{
if((getE(id).style.display=="")||(getE(id).style.display=="none")) {
getE(id).style.display="block"
getE(swt).innerHTML="–"
if (getE(swt).mytitle) getE(swt).mytitle=collapseTooltip
else getE(swt).title=collapseTooltip
} else {
getE(id).style.display="none"
getE(swt).innerHTML="+"
if (getE(swt).mytitle) getE(swt).mytitle=expandTooltip
else getE(swt).title=expandTooltip
}
return false
}
function writeExpandControl(elementId,collapse)
{
if(!hasDOM) return
if(elementId!="") prn("<a href=\"#\" class=\"of-post-expand\" id=\"of-switch"+elementId+"\" onclick=\"return toggleDisplay('of-gen"+elementId+"','of-switch"+elementId+"');\" title=\""+((collapse) ? expandTooltip : collapseTooltip)+"\">"+((collapse) ? "+" : "–")+"</a>")
else prn("<span class=\"of-post-expand\"> </span>")
}
function ofValidate(text1,text2,text3,text4)
{
if(!getE('of-msgarea').value) {
if(!getE('of-pstsubject').value) {
alert(text1)
return false
}
if(!confirm(text2)) return false
}
if((!getE('of-pstauthor').value)&&(!confirm(text3))) return false
if((!getE('of-pstsubject').value)&&(!confirm(text4))) return false
closeAllTags()
return true
}
function writePostStyles(invite,text1,text2,text3,text4,text5,tooltip1,tooltip2,tooltip3,tooltip4,tooltip5,openedInvite,defaultText)
{
if(!hasDOM) return
alreadyOpenedInvite=openedInvite
defaultMessageText=defaultText
prn("<input type=\"button\" id=\"bold-button\" class=\"unselected\" value=\""+text2+"\" title=\""+tooltip2+"\" onclick=\"stylize(this,'g');\" /> ")
prn("<input type=\"button\" id=\"italic-button\" class=\"unselected\" value=\""+text3+"\" title=\""+tooltip3+"\" onclick=\"stylize(this,'i');\" /> ")
prn("<input type=\"button\" id=\"quote-button\" class=\"unselected\" value=\""+text1+"\" title=\""+tooltip1+"\" onclick=\"stylize(this,'citer');\" /> ")
prn("<input type=\"button\" id=\"code-button\" class=\"unselected\" value=\""+text4+"\" title=\""+tooltip4+"\" onclick=\"stylize(this,'code');\" /> ")
prn("<input type=\"button\" id=\"link-button\" class=\"unselected\" value=\""+text5+"\" title=\""+tooltip5+"\" onclick=\"stylize(this,'lien','"+invite+"');\" /> ")
}
function stylize(element,tag,invite)
{
if(!checkOpenedTags(tag)) return
scrollTop=-1
msgArea=getE("of-msgarea")
if(msgArea.value==defaultMessageText) msgArea.value=""
useGeneric=true
position=-1
if(msgArea.selectionStart!=null) {
positionStart=msgArea.selectionStart
positionEnd=msgArea.selectionEnd
scrollTop=msgArea.scrollTop
if(positionEnd!=positionStart) {
useGeneric=false
textString=msgArea.value
modifiedText=textString.substring(positionStart,positionEnd)
valueText=""
if(invite) {
valueText=prompt(invite,"http://")
if(valueText==null) return
else valueText="="+valueText
}
revisedMessage=textString.substring(0,positionStart)+"["+tag+valueText+"]"+modifiedText+"[/"+tag+"]"+ textString.substring(positionEnd,textString.length)
msgArea.value=revisedMessage
msgArea.focus()
msgArea.setSelectionRange(positionStart,positionStart+modifiedText.length+(2*tag.length)+valueText.length+5)
} else position=positionStart
} else if(document.selection) {
strSelection=document.selection.createRange().text
position=-2
if(strSelection!="") {
useGeneric=false
valueText=""
if(invite) {
valueText=prompt(invite,"http://")
if(valueText==null) return
else valueText="="+valueText
}
msgArea.focus()
document.selection.createRange().text="["+tag+valueText+"]"+strSelection+"[/"+tag+"]"
}
}
if(useGeneric) {
stringToAdd=""
if(element.className=="selected") {
stringToAdd="[/"+tag+"]"
element.className="unselected"
idx=openedTags.indexOf(tA[tag])
openedTags=openedTags.substring(0,idx)+openedTags.substring(idx+1)
} else {
valueText=""
if(invite) {
valueText=prompt(invite,"http://")
if(valueText==null) return
else valueText="="+valueText
}
stringToAdd="["+tag+valueText+"]"
element.className="selected"
openedTags=openedTags+tA[tag]
}
msgArea.focus()
if(position==-2) document.selection.createRange().text=stringToAdd
else if(position==-1) msgArea.value += stringToAdd
else {
msgArea.value=msgArea.value.substring(0,position)+stringToAdd+ msgArea.value.substring(position,msgArea.value.length)
msgArea.setSelectionRange(position+stringToAdd.length,position+stringToAdd.length)
}
}
if(scrollTop!=-1) msgArea.scrollTop=scrollTop;
}
function activatePassword(inputElt,adminName)
{
if(inputElt.value==adminName) getE('of-pstpasswdzone').style.display='block'
else getE('of-pstpasswdzone').style.display='none'
return false
}
function deActivatePassword()
{
getE('of-pstpasswdzone').style.display='none'
return false
}
function checkOpenedTags(tag)
{
idx=openedTags.indexOf(tA[tag])
if((idx==-1)||(idx==(openedTags.length-1))) return true
else {
toBeClosed=""
autoClose=""
for(i=openedTags.length-1;i>idx;i--) toBeClosed=toBeClosed+"["+tF[openedTags.charAt(i)]+"]"+","
toBeClosed=toBeClosed.substr(0,toBeClosed.length-1)
invite=alreadyOpenedInvite.replace(/%s/,toBeClosed)
invite=invite.replace(/%s/,"["+tag+"]")
if(confirm(invite)) {
msgArea=getE('of-msgarea')
autoClose=""
for(j=openedTags.length-1;j>idx;j--) {
getE(tB[openedTags.charAt(j)]).className="unselected"
autoClose=autoClose+"[/"+tF[openedTags.charAt(j)]+"]"
}
if(msgArea.selectionStart!=null) {
pStart=msgArea.selectionStart
pEnd=msgArea.selectionEnd
scrollTop=msgArea.scrollTop
textString=msgArea.value
revisedMessage=textString.substring(0,pStart)+autoClose+textString.substring(pEnd,textString.length)
msgArea.value=revisedMessage
msgArea.focus()
msgArea.setSelectionRange(pStart+autoClose.length,pStart+autoClose.length)
msgArea.scrollTop=scrollTop;
} else if(document.selection) {
msgArea.focus()
document.selection.createRange().text=autoClose
} else msgArea.value=msgArea.value+autoClose
openedTags=openedTags.substring(0,idx+1)
return true
} else return false
}
}
function closeAllTags()
{
textArea=getE('of-msgarea')
for(i=openedTags.length-1;i >= 0;i--) textArea.value=textArea.value+"[/"+tF[openedTags.charAt(i)]+"]"
}
function initForum()
{
textArea=getE('of-msgarea')
textArea.cols = Math.floor((getE('of-msgpostzone').offsetWidth * textArea.cols)/ textArea.offsetWidth);
}
Si avez des problèmes ou des questions concernant ce fichier source, vous pouvez utiliser le Forum Sources du site