/** * Kelare * --------------------------------------------------------------------------- * Copyright, Akretio SPRL. All Rights Reserved. * * This file is part of the Kelare project and can not be distributed or * used in any application without prior consent of Akretio SPRL. * Contact us for any information or authorisation. * ---------------------------------------------------------------------------- * Created: July 18, 2008 * ---------------------------------------------------------------------------- */ /** * BBEditor * --------------------------------------------------------------------------- */ var BBEditors = new Array(); var BBEditorClicked = false; var BBClipboard = ''; var BBMapCount = 0; function BBFindPosX(AObject) { var result = 0; if (AObject.offsetParent) { while (AObject.offsetParent) { if (AObject.currentStyle) lPosition = AObject.currentStyle["position"]; else if (window.getComputedStyle){ var lStyle = window.getComputedStyle(AObject, ""); lPosition = lStyle.getPropertyValue("position"); } else lPosition = ""; result += AObject.offsetLeft; AObject = AObject.offsetParent; } } else if (AObject.x) result += AObject.x; return result; } function BBFindPosY(AObject) { var result = 0; if (AObject.offsetParent) { while (AObject.offsetParent) { if (AObject.currentStyle) lPosition = AObject.currentStyle["position"]; else if (window.getComputedStyle){ var lStyle = window.getComputedStyle(AObject, ""); lPosition = lStyle.getPropertyValue("position"); } else lPosition = ""; result += AObject.offsetTop; AObject = AObject.offsetParent; } } else if (AObject.y) result += AObject.y; return result; } function BBEditorAddTag(AName, ABeginTag, AEndTag) { var lElem = document.getElementById(AName); if (document.selection) { //This is IE lText = document.selection.createRange().text; lElem.focus(); document.selection.createRange().text = ABeginTag + lText + AEndTag; } else if ((lElem.selectionStart) || (lElem.selectionStart == '0')) { //This is Mozilla/Gecko lStart = lElem.selectionStart; lStop = lElem.selectionEnd; lText = lElem.value.substring(lStart, lStop); lSubst = ABeginTag + lText + AEndTag; lElem.value = lElem.value.substring(0, lStart) + lSubst + lElem.value.substring(lStop, lElem.value.length); lStart += ABeginTag.length; if (lText.length > 0) lStart += lText.length + AEndTag.length; lStart--; lElem.selectionStart = lStart; lElem.selectionEnd = lStart; lElem.setSelectionRange(lStart, lStart+1); var ev = document.createEvent ('KeyEvents'); ev.initKeyEvent('keypress', true, true, window,false, false, false, false, 0, lElem.value.charCodeAt(lStart)); lElem.dispatchEvent(ev); lElem.focus(); } else { lElem.value = lElem.value + ABeginTag + AEndTag; lElem.focus(); } } function BBEditorShow(AButton, AName) { var lElem = document.getElementById(AName); if (lElem.style.visibility != "visible") { BBEditorHideAll(); lElem.style.top = (BBFindPosY(AButton) + AButton.offsetHeight + 5) + "px"; lElem.style.left = BBFindPosX(AButton) + "px"; lWidth = window.innerWidth; if (!(lWidth > 0)) lWidth = document.body.clientWidth; if ((BBFindPosX(AButton) + lElem.clientWidth + 10 > lWidth) && (lWidth > 0)) lElem.style.left = lWidth - (lElem.clientWidth + 30) + "px"; lElem.style.visibility = "visible"; document.onclick = BBEditorHideAll; BBEditors[BBEditors.length] = AName; BBEditorClicked = true; } else lElem.style.visibility = "hidden"; } function BBEditorHide(AName) { var lElem = document.getElementById(AName); lElem.style.visibility = "hidden"; document.onclick = ""; } function BBEditorHideAll() { if (BBEditorClicked) BBEditorClicked = false; else { for(i=0;i-1) lText=lText.replace("+","%2b") lText = escape(lText); while (lText.indexOf("%252b")>-1) lText=lText.replace("%252b","%2b") BBShowIFrame("index.ks?kelbbcodepreview=" + lText); } function BBEditorCheck(AName) { lArea = document.getElementById(AName); lText = lArea.value; while (lText.indexOf("+")>-1) lText=lText.replace("+","%2b") lText = escape(lText); while (lText.indexOf("%252b")>-1) lText=lText.replace("%252b","%2b") BBShowIFrame("index.ks?kelaspell=" + lText); } function BBEditorSmileys(AButton, AName, AForm) { BBShowIFrame("index.ks?page=bbcode_smileyslist&form=" + AForm); } function BBEditorHTML2BB(AButton, AForm) { BBShowIFrame("index.ks?page=bbcode_html2bb&form=" + AForm); } function BBEditorRepository(AButton, AName, AForm) { BBShowIFrame("index.ks?page=repository_images&form=" + AForm); } function BBEditorRepositoryCombo(AButton, AName, AForm) { BBEditorHideAll(); var newdiv = document.createElement('iframe'); newdiv.id = "BBRepository"; newdiv.className = 'bbsmileys'; newdiv.src = "index.ks?page=repository_imagescombo&form=" + AForm; newdiv.frameBorder = 0; newdiv.style.top = 100 + BBEditorGetTop() + "px"; document.body.appendChild(newdiv); BBPlaceCenter(newdiv); var newdiv = document.createElement('div'); newdiv.id = "BBDocumentOverlay"; newdiv.className = 'bbdocumentoverlay'; newdiv.top = window.pageYOffset; newdiv.style.top = BBEditorGetTop() + "px"; document.body.appendChild(newdiv); } function BBEditorWiki(AButton, AName, AForm) { BBShowIFrame('index.ks?page=wiki_browse&form=' + AForm); } function BBEditorCopy(AName) { var lElem = document.getElementById(AName); if (document.selection) { //This is IE lText = document.selection.createRange().text; BBClipboard = lText; } else if ((lElem.selectionStart) || (lElem.selectionStart == '0')) { //This is Mozilla/Gecko lStart = lElem.selectionStart; lStop = lElem.selectionEnd; lText = lElem.value.substring(lStart, lStop); BBClipboard = lText; } lElem.focus(); } function BBEditorPaste(AName) { BBEditorAddTag(AName, BBClipboard, ''); lElem.focus(); } function BBEditorCut(AName) { BBEditorCopy(AName); var lElem = document.getElementById(AName); if (document.selection) document.selection.clear(); else if ((lElem.selectionStart) || (lElem.selectionStart == '0')) { //This is Mozilla/Gecko lStart = lElem.selectionStart; lStop = lElem.selectionEnd; lText = lElem.value.substring(0, lStart) + lElem.value.substring(lStop, lElem.value.length); lElem.value = lText; } lElem.focus(); } function BBEditorClear(AName) { var lElem = document.getElementById(AName); lElem.value = ''; } function BBEditorSelectAll(AName) { var lElem = document.getElementById(AName); lElem.focus(); lElem.select(); } function BBEditorAdaptRows(AElement) { var text = AElement.value; var split = text.split("\n"); if (split.length + 1 > AElement.rows) AElement.rows = split.length + 1; } function BBEditorYouTube(AName, AText) { var lValue = prompt(AText,"http://www.youtube.com/watch?v=00000000000"); var lIndex = lValue.indexOf("watch?v"); if (lIndex > 0) { lValue = lValue.substring(lIndex + 8, lIndex + 30); lIndex = lValue.indexOf("&"); if (lIndex > 0) lValue = lValue.substring(0, lIndex); lValue = '[youtube]' + lValue + '[/youtube]'; BBEditorAddTag(AName, lValue, ''); } } function BBEditorDailyMotion(AName, AText) { var lValue = prompt(AText,"
"); lValues = lValue.split('"'); lSearch = 'http://www.dailymotion.com/swf/'; for (i=0; i 0) lValue = lValue.substring(0, lIndex); lValue = '[dailymotion]' + lValue + '[/dailymotion]'; BBEditorAddTag(AName, lValue, ''); return true; } } } function BBEditorGoogleVideo(AName, AText) { var lValue = prompt(AText,"http://video.google.com/videoplay?docid=00000000000000000"); lValue = lValue.replace("http://video.google.com/videoplay?docid=",""); lValue = '[googlevideo]' + lValue + '[/googlevideo]'; BBEditorAddTag(AName, lValue, ''); } function BBEditorYahooVideo(AName, AText) { var lValue = prompt(AText," 0) lValue = lValue.substring(0, lIndex); lValue = '[yahoovideo]' + lValue + '[/yahoovideo]'; BBEditorAddTag(AName, lValue, ''); return true; } } } function BBEditorStage6(AName, AText) { var lValue = prompt(AText,"http://www.stage6.com/user/xyz/video/0000000/NameOfTheVideo"); var lIndex = lValue.indexOf("video/"); if (lIndex > 0) { lValue = lValue.substring(lIndex + 6, lIndex + 16); lIndex = lValue.indexOf("/"); lValue = lValue.substring(0, lIndex); lValue = '[stage6]' + lValue + '[/stage6]'; BBEditorAddTag(AName, lValue, ''); } } function BBEditoreBay(AName, AText) { var lValue = prompt(AText,"http://cgi.befr.ebay.be/item-name_W0QQitemZ0000000000..."); var lIndex = lValue.indexOf("QQitemZ"); if (lIndex > 0) { lValue = lValue.substring(lIndex + 7, lIndex + 30); lIndex = lValue.indexOf("QQ"); lValue = lValue.substring(0, lIndex); lValue = '[ebay]' + lValue + '[/ebay]'; BBEditorAddTag(AName, lValue, ''); } } function BBEditorMetaCafe(AName, AText) { var lValue = prompt(AText,"http://www.metacafe.com/watch/00000/videoname"); var lIndex = lValue.indexOf("watch/"); if (lIndex > 0) { lValue = lValue.substring(lIndex + 6, lIndex + 30); lIndex = lValue.indexOf("/"); lValue = lValue.substring(0, lIndex); lValue = '[metacafe]' + lValue + '[/metacafe]'; BBEditorAddTag(AName, lValue, ''); } } function BBEditorFlickr(AName, AText) { var lValue = prompt(AText,"http://www.flickr.com/photos/0000000@N00/"); var lIndex = lValue.indexOf("photos/"); if (lIndex > 0) { lValue = lValue.substring(lIndex + 7, lIndex + 30); lIndex = lValue.indexOf("/"); lValue = lValue.substring(0, lIndex); lValue = '[flickr]' + lValue + '[/flickr]'; BBEditorAddTag(AName, lValue, ''); } } function BBEditorVeoh(AName, AText) { var lValue = prompt(AText,"http://www.veoh.com/videos/v123456Dm00JcJ?source=..."); var lIndex = lValue.indexOf("videos/"); if (lIndex > 0) { lValue = lValue.substring(lIndex + 7, lIndex + 30); lIndex = lValue.indexOf("?"); lValue = lValue.substring(0, lIndex); lValue = '[veoh]' + lValue + '[/veoh]'; BBEditorAddTag(AName, lValue, ''); } } function BBEditorGetTop() { var scrOfX = 0, scrOfY = 0; if( typeof( window.pageYOffset ) == 'number' ) { //Netscape compliant scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { //DOM compliant scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { //IE6 standards compliant mode scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } return scrOfY; } function BBEditorGoogleMaps(AName, AText) { var newdiv = document.createElement('iframe'); newdiv.id = "BBGoogleMap"; newdiv.className = 'bbgooglemap'; newdiv.src = "index.ks?kelbbgooglemap=google&name=" + AName; newdiv.frameBorder = 0; newdiv.style.top = 100 + BBEditorGetTop() + "px"; document.body.appendChild(newdiv); var newdiv = document.createElement('div'); newdiv.id = "BBDocumentOverlay"; newdiv.className = 'bbdocumentoverlay'; newdiv.top = window.pageYOffset; newdiv.style.top = BBEditorGetTop() + "px"; document.body.appendChild(newdiv); } function BBEditorGoogleMapsDone(AName, AValue) { BBEditorAddTag(AName, AValue, ''); BBEditorGoogleMapsClose(); } function BBEditorGoogleMapsGenerate(ADocument) { var lLatitude = ADocument.getElementById("Latitude"); var lLongitude = ADocument.getElementById("Longitude"); var lWidth = ADocument.getElementById("Width"); var lHeight = ADocument.getElementById("Height"); var lZoom = ADocument.getElementById("Zoom"); var lName = 'map' + BBMapCount; BBMapCount++; var lReturn = "[googlemap=" + lName + "," + lWidth.value + "," + lHeight.value + "]" + lLatitude.value + "," + lLongitude.value + "," + lZoom.value + "[/googlemap]"; for (var i=0; i<5; i++) { lLatitude = ADocument.getElementById("Point"+i+"Latitude"); lLongitude = ADocument.getElementById("Point"+i+"Longitude"); lDescription = ADocument.getElementById("Point"+i+"Description"); if (lLatitude.value != "") lReturn += "\n" + "[googlemappoint=" + lLatitude.value + "," + lLongitude.value + "," + lName + "]" + lDescription.value + "[/googlemappoint]"; } return lReturn; } function BBEditorGoogleMapsPreview(ADocument) { var lFrame = ADocument.getElementById('mappreviewframe'); lText = BBEditorGoogleMapsGenerate(ADocument); while (lText.indexOf("+")>-1) lText=lText.replace("+","%2b") lText = escape(lText); while (lText.indexOf("%252b")>-1) lText=lText.replace("%252b","%2b") lFrame.src = "index.ks?kelbbcodepreview=" + lText; } function BBEditorGoogleMapsSend(ADocument, AName) { BBEditorAddTag(AName, BBEditorGoogleMapsGenerate(ADocument), ''); BBEditorGoogleMapsClose(); } function BBEditorGoogleMapsClose() { document.body.removeChild(document.getElementById('BBGoogleMap')); document.body.removeChild(document.getElementById('BBDocumentOverlay')); } function BBSmileysClose() { BBHideIFrame(); } function BBHTML2BBClose() { BBHideIFrame(); } function BBRepositoryClose() { document.body.removeChild(document.getElementById('BBRepository')); document.body.removeChild(document.getElementById('BBDocumentOverlay')); } function setCookie(c_name,value,expiredays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + expiredays); document.cookie = c_name + "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); } function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1) { c_start=c_start + c_name.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; } function BBGetClientHeight() { var myWidth = 0, myHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } return myHeight; } function BBPlaceCenter(AElem) { AElem.style.top = (BBEditorGetTop() + ((BBGetClientHeight() - AElem.offsetHeight) / 2)) + "px"; } /** * BBGoogleMaps * --------------------------------------------------------------------------- */ var GMapsPoint = new Array(); var GMapsPointCenter = new Array(); var GMapsInit = new Array(); function BBMapAddPointReal(AMapName, AMap, ALatitude, ALongitude, ADescription) { var point = new GLatLng(ALatitude, ALongitude); var GMapGeneral = new GIcon(G_DEFAULT_ICON); var marker = new GMarker(point, {icon: GMapGeneral}); var html = "
" + ADescription + "
"; GEvent.addListener(marker, 'click', function() {marker.openInfoWindowHtml(html);}); AMap.addOverlay(marker); } function BBMapCenter(AMap, ALatitude, ALongitude, AZoom) { var map = new GMap2(document.getElementById(AMap)); if (map != null) { map.setCenter(new GLatLng(ALatitude, ALongitude), AZoom); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); GMapsInit[GMapsInit.length] = new Array(AMap, map); for (var i=0; i GBBMaxWidth) { AImage.width = GBBMaxWidth; AImage.onclick = bbimgzoom; AImage.style.border = "2px dotted red"; } } else if (AImage.naturalWidth > AImage.ownerDocument.width - (AImage.offsetLeft + 50) ) AImage.style.border = "2px dotted red"; } function bbimgzoom() { if (this.naturalWidth != this.width) { this.width = this.naturalWidth; this.style.border = "0px"; this.style.marginTop = "2px"; this.style.marginBottom = "2px"; } else { this.width = GBBMaxWidth; this.style.marginTop = "0px"; this.style.marginBottom = "0px"; this.style.border = "2px dotted red"; } } function bbimgtestzoom(AImage) { if (document.all) { //Fix for IE not returning the click to the parent href if ((AImage.parentNode.parentNode.href != "")) { var lRef = AImage.parentNode.parentNode.href; if ((lRef != "undefined") && (lRef != "") && (lRef != undefined)) document.location = AImage.parentNode.parentNode.href; } } if (((document.all) && (AImage.naturalWidth <= GBBMaxWidth)) || (AImage.naturalWidth <= AImage.parentNode.clientWidth)) return; if (AImage.className != 'bbimgfull') { AImage.className = 'bbimgfull'; AImage.style.border = '0px'; AImage.style.marginTop = '2px'; AImage.style.marginBottom = '2px'; } else { AImage.className = 'bbimgreduced'; AImage.style.border = '2px dotted red'; AImage.style.marginTop = '0px'; AImage.style.marginBottom = '0px'; } } /** * BBSlideShow * --------------------------------------------------------------------------- */ var BBSlides = new Array(); var BBSlideImages = new Array(); var BBSlideDelay = 5000; function BBSlideGetItem(AName) { for (i=0; i= BBSlideImages[i].length) lImage[2] = 1; lImage[1].src = BBSlideImages[i][lImage[2]]; lImage[3] = BBSlideImages[i][lImage[2]]; lImage[2]++ ; } } function BBCheckImage(AName) { for (k=0; k= BBSlideImages[i].length) lImage[2] = 1; document.getElementById(AName).src = BBSlideImages[i][lImage[2]]; } BBSlideStop(AName); } function BBSlideStop(AName) { for (i=0; i