Source de js/utils.js
isIE=((document.defaultCharset&&document.protocol) ? true : false)
hasDOM=(document.getElementById ? true : false)
function getE(id)
{
return document.getElementById(id)
}
function getT(p,t)
{
return p.getElementsByTagName(t)[0]
}
function prn(s)
{
document.write(s)
}
function redraw()
{
if(isIE) return
st=document.body.style
st.visibility="hidden"
st.visibility="visible"
}
function clearInput(element,defaultValue)
{
if(element.value==defaultValue) element.value=''
return false
}
function isVK(event,withSpace)
{
keyPressed=0
if((event.charCode)&&(event.charCode!=0)) keyPressed=event.charCode
else if((event.keyCode)&&(event.keyCode!=0)) keyPressed=event.keyCode
if(withSpace) return ((keyPressed==13)||(keyPressed==32))
else return (keyPressed==13)
}
function getCookie(name)
{
co=document.cookie
start=co.indexOf(name+"=")
len=start+name.length+1
if((!start)&&(name!=co.substring(0,name.length))) return null
if(start==-1) return null
end=co.indexOf(";",len)
if(end==-1) end=co.length
return unescape(co.substring(len,end))
}
function setCookie(name,value)
{
expireDate=new Date()
expireDate.setTime(expireDate.getTime()+(365*24*3600*1000))
document.cookie=name+"="+escape(value)+";expires="+expireDate.toGMTString()+";path=/"
}
function delCookie (name)
{
expireDate=new Date()
expireDate.setTime(expireDate.getTime()-(24*3600*1000))
document.cookie=name+"="+'""'+";expires="+expireDate.toGMTString()+";path=/"
}
function getS(obj,CSSStyleProp,IEStyleProp)
{
if(obj.currentStyle) return obj.currentStyle[IEStyleProp]
else if(window.getComputedStyle) {
compStyle=getComputedStyle(obj,"")
return compStyle.getPropertyValue(CSSStyleProp)
} else if(obj.style) return obj.style.getPropertyValue(CSSStyleProp)
return ""
}
function getES(elemID,CSSStyleProp,IEStyleProp,elemTag)
{
if(elemTag) elem=getT(getE(elemID),elemTag)
else elem=getE(elemID)
return(getS(elem,CSSStyleProp,IEStyleProp))
}
function isFixed(obj)
{
elt=obj
while(elt.parentNode) {
if(getS(elt,'position','position')=='fixed') return true
elt=elt.parentNode
}
return false
}
function getTopOffset(elt)
{
isArea=false
if(elt.coords) {
coords=elt.coords.split(',')
elt=getE('img-map')
isArea=true
}
ot=elt.offsetTop
while((elt=elt.offsetParent)!=null) ot+=elt.offsetTop
if(isArea) ot+=new Number(coords[1])
return ot
}
function getLeftOffset (elt)
{
isArea=false
if(elt.coords) {
coords=elt.coords.split(',')
elt=getE('img-map')
isArea=true
}
ot=elt.offsetLeft
while((elt=elt.offsetParent)!=null) ot+=elt.offsetLeft
if(isArea) ot+=new Number(coords[0])
return ot
}
function getOH(elt)
{
if(elt.coords) {
coords=elt.coords.split(',')
oH=Number(coords[3])-Number(coords[1])
} else oH=((obj.offsetHeight)?obj.offsetHeight:20)
return oH
}
function getScrollOffset()
{
if(window.pageYOffset) return pageYOffset
else if(document.documentElement) return document.body.scrollTop+document.documentElement.scrollTop
}
function getClientHeight()
{
if(window.innerHeight) return innerHeight
else if((document.documentElement)&&(document.documentElement.clientHeight)) return document.documentElement.clientHeight
else return document.body.clientHeight
}
function getClientWidth()
{
if(window.innerWidth) return innerWidth
else if((document.documentElement)&&(document.documentElement.clientWidth)) return document.documentElement.clientWidth
else return document.body.clientWidth
}
function scrollToE(n)
{
elt=getE(n)
y=getTopOffset(elt)-(curSz/3)
if(y<2000) scrollTo(0,y)
else scrollTo(0,0)
}
function switchTheme(idp)
{
ths=getE('change-theme'+idp)
th=ths.options[ths.selectedIndex].value
sA=document.getElementsByTagName("link")
sAL=sA.length
for(i=0;i<sAL;i++) {
l=sA[i]
if(l.media=="screen") {
l.href = "http://www.c-sait.net" + "/themes/"+th+"/common.css"
}
}
setTimeout("scrollToE('change-theme"+idp+"')",500)
ths.focus()
hideTT()
setCookie("theme",th)
return false
}
function resetPreferences()
{
delCookie("boxesState")
delCookie("boxesBar")
delCookie("fontSize")
delCookie("theme")
delCookie("tooltips")
delCookie("PHPSESSID")
document.location.href=document.location.href.replace(/change_theme/,"old_theme")
document.location.reload()
}
function resetPreferencesKb(kbEvent)
{
if(isVK(kbEvent,false)) return resetPreferences()
else return true
}
function writeResetDefaultPrefs(tabIndex,wF)
{
if(!hasDOM) return
if(wF) prn('<fieldset><legend>Préférences d\'origine<br /></legend>')
else prn('<div id="default-prefs"><label>Préférences d\'origine</label>')
prn('<input value="Réinitialiser" type="button" class="submit-button" onclick="return resetPreferences()" onkeypress="return resetPreferencesKb(event)" tabindex="'+tabIndex+'" title="Rétablir les valeurs par défaut de toutes les préférences" />')
if(wF) prn('</fieldset>')
else prn('</div>')
}
function writeMinMaxButton(id,tag,title,tabindex)
{
if(!hasDOM) return
prn("<a title=\"Réduire la boîte ""+title+""\" href=\"#\" onclick=\"return changeDisplay('"+id+"','"+tag+"')\" onkeypress=\"return changeDisplayKb(event,'"+id+"','"+tag+"')\" class=\"min-box\" tabindex=\""+tabindex+"\"></a>")
}
function initDisplay()
{
if(!hasDOM) return
initZoom()
initHide()
initMove()
initTT()
redraw()
}
hasDOM=(document.getElementById ? true : false)
function getE(id)
{
return document.getElementById(id)
}
function getT(p,t)
{
return p.getElementsByTagName(t)[0]
}
function prn(s)
{
document.write(s)
}
function redraw()
{
if(isIE) return
st=document.body.style
st.visibility="hidden"
st.visibility="visible"
}
function clearInput(element,defaultValue)
{
if(element.value==defaultValue) element.value=''
return false
}
function isVK(event,withSpace)
{
keyPressed=0
if((event.charCode)&&(event.charCode!=0)) keyPressed=event.charCode
else if((event.keyCode)&&(event.keyCode!=0)) keyPressed=event.keyCode
if(withSpace) return ((keyPressed==13)||(keyPressed==32))
else return (keyPressed==13)
}
function getCookie(name)
{
co=document.cookie
start=co.indexOf(name+"=")
len=start+name.length+1
if((!start)&&(name!=co.substring(0,name.length))) return null
if(start==-1) return null
end=co.indexOf(";",len)
if(end==-1) end=co.length
return unescape(co.substring(len,end))
}
function setCookie(name,value)
{
expireDate=new Date()
expireDate.setTime(expireDate.getTime()+(365*24*3600*1000))
document.cookie=name+"="+escape(value)+";expires="+expireDate.toGMTString()+";path=/"
}
function delCookie (name)
{
expireDate=new Date()
expireDate.setTime(expireDate.getTime()-(24*3600*1000))
document.cookie=name+"="+'""'+";expires="+expireDate.toGMTString()+";path=/"
}
function getS(obj,CSSStyleProp,IEStyleProp)
{
if(obj.currentStyle) return obj.currentStyle[IEStyleProp]
else if(window.getComputedStyle) {
compStyle=getComputedStyle(obj,"")
return compStyle.getPropertyValue(CSSStyleProp)
} else if(obj.style) return obj.style.getPropertyValue(CSSStyleProp)
return ""
}
function getES(elemID,CSSStyleProp,IEStyleProp,elemTag)
{
if(elemTag) elem=getT(getE(elemID),elemTag)
else elem=getE(elemID)
return(getS(elem,CSSStyleProp,IEStyleProp))
}
function isFixed(obj)
{
elt=obj
while(elt.parentNode) {
if(getS(elt,'position','position')=='fixed') return true
elt=elt.parentNode
}
return false
}
function getTopOffset(elt)
{
isArea=false
if(elt.coords) {
coords=elt.coords.split(',')
elt=getE('img-map')
isArea=true
}
ot=elt.offsetTop
while((elt=elt.offsetParent)!=null) ot+=elt.offsetTop
if(isArea) ot+=new Number(coords[1])
return ot
}
function getLeftOffset (elt)
{
isArea=false
if(elt.coords) {
coords=elt.coords.split(',')
elt=getE('img-map')
isArea=true
}
ot=elt.offsetLeft
while((elt=elt.offsetParent)!=null) ot+=elt.offsetLeft
if(isArea) ot+=new Number(coords[0])
return ot
}
function getOH(elt)
{
if(elt.coords) {
coords=elt.coords.split(',')
oH=Number(coords[3])-Number(coords[1])
} else oH=((obj.offsetHeight)?obj.offsetHeight:20)
return oH
}
function getScrollOffset()
{
if(window.pageYOffset) return pageYOffset
else if(document.documentElement) return document.body.scrollTop+document.documentElement.scrollTop
}
function getClientHeight()
{
if(window.innerHeight) return innerHeight
else if((document.documentElement)&&(document.documentElement.clientHeight)) return document.documentElement.clientHeight
else return document.body.clientHeight
}
function getClientWidth()
{
if(window.innerWidth) return innerWidth
else if((document.documentElement)&&(document.documentElement.clientWidth)) return document.documentElement.clientWidth
else return document.body.clientWidth
}
function scrollToE(n)
{
elt=getE(n)
y=getTopOffset(elt)-(curSz/3)
if(y<2000) scrollTo(0,y)
else scrollTo(0,0)
}
function switchTheme(idp)
{
ths=getE('change-theme'+idp)
th=ths.options[ths.selectedIndex].value
sA=document.getElementsByTagName("link")
sAL=sA.length
for(i=0;i<sAL;i++) {
l=sA[i]
if(l.media=="screen") {
l.href = "http://www.c-sait.net" + "/themes/"+th+"/common.css"
}
}
setTimeout("scrollToE('change-theme"+idp+"')",500)
ths.focus()
hideTT()
setCookie("theme",th)
return false
}
function resetPreferences()
{
delCookie("boxesState")
delCookie("boxesBar")
delCookie("fontSize")
delCookie("theme")
delCookie("tooltips")
delCookie("PHPSESSID")
document.location.href=document.location.href.replace(/change_theme/,"old_theme")
document.location.reload()
}
function resetPreferencesKb(kbEvent)
{
if(isVK(kbEvent,false)) return resetPreferences()
else return true
}
function writeResetDefaultPrefs(tabIndex,wF)
{
if(!hasDOM) return
if(wF) prn('<fieldset><legend>Préférences d\'origine<br /></legend>')
else prn('<div id="default-prefs"><label>Préférences d\'origine</label>')
prn('<input value="Réinitialiser" type="button" class="submit-button" onclick="return resetPreferences()" onkeypress="return resetPreferencesKb(event)" tabindex="'+tabIndex+'" title="Rétablir les valeurs par défaut de toutes les préférences" />')
if(wF) prn('</fieldset>')
else prn('</div>')
}
function writeMinMaxButton(id,tag,title,tabindex)
{
if(!hasDOM) return
prn("<a title=\"Réduire la boîte ""+title+""\" href=\"#\" onclick=\"return changeDisplay('"+id+"','"+tag+"')\" onkeypress=\"return changeDisplayKb(event,'"+id+"','"+tag+"')\" class=\"min-box\" tabindex=\""+tabindex+"\"></a>")
}
function initDisplay()
{
if(!hasDOM) return
initZoom()
initHide()
initMove()
initTT()
redraw()
}
Si avez des problèmes ou des questions concernant ce fichier source, vous pouvez utiliser le Forum Sources du site