//=========== Cross browser adding/removing/stopping event listeners var htmlLastSelected=''; var documentRange=''; var tablePointer=""; var formPointer=""; var blockQuotePointer=""; var columnPointer=""; var browser=''; function domHide(id){ var elem=document.getElementById(id); if(elem && elem.style){ elem.style.display="none"; } } function domShow(id){ var elem=document.getElementById(id); if(elem && elem.style){ elem.style.display="block"; } } function duoAlert(message){ alert(message);//wrapper to fix issue with duo desktop } function setStatus(message){ if(document.getElementById('statusbar')){ document.getElementById('statusbar').innerHTML=message; } } function parseJSON(data){ if(browser=="ie" && browserVersion=="7.0"){ var retdat=eval('('+data.responseText+')'); }else{ try{var retdat=JSON.parse(data.responseText);}catch(e){var retdat=eval('('+data.responseText+')');}//faster to use json.parse than eval } return retdat; } function whichBrs() { var agt=navigator.userAgent.toLowerCase(); if (agt.indexOf("opera") != -1) return 'opera'; if (agt.indexOf("staroffice") != -1) return 'star office'; if (agt.indexOf("chrome") != -1) return 'chrome'; if (agt.indexOf("webtv") != -1) return 'webtv'; if (agt.indexOf("beonex") != -1) return 'beonex'; if (agt.indexOf("chimera") != -1) return 'chimera'; if (agt.indexOf("netpositive") != -1) return 'netpositive'; if (agt.indexOf(" firefox/3") != -1) return 'firefox3'; if (agt.indexOf(" firefox/4") != -1) return 'firefox3'; if (agt.indexOf("firefox") != -1) return 'firefox'; if (agt.indexOf("safari") != -1) return 'safari'; if (agt.indexOf("skipstone") != -1) return 'skipstone'; if (agt.indexOf("msie") != -1) return 'ie'; if (agt.indexOf("netscape") != -1) return 'netscape'; if (agt.indexOf("mozilla/5.0") != -1) return 'mozilla'; if (agt.indexOf('\/') != -1) { if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') { return navigator.userAgent.substr(0,agt.indexOf('\/'));} else return 'Netscape';} else if (agt.indexOf(' ') != -1) return navigator.userAgent.substr(0,agt.indexOf(' ')); else return navigator.userAgent; } //================== Cross browser event handling function objectListen(theObject,theEvent,thefunction){ if(browser && browser=="ie" && theObject){//stop ie adding event multiple times objectStopListen(theObject,theEvent,thefunction); theObject.attachEvent("on"+theEvent, thefunction); return; } if(document.addEventListener && theObject){theObject.addEventListener(theEvent, thefunction, false); }else if(document.attachEvent && theObject){theObject.attachEvent("on"+theEvent, thefunction);} } function objectStopListen(theObject,theEvent,thefunction){ if(document.removeEventListener && theObject){theObject.removeEventListener(theEvent, thefunction, false); } else if(document.detachEvent && theObject){theObject.detachEvent("on"+theEvent, thefunction);} } function stopEvent(event){ //if(event.stopPropagation){event.stopPropagation();event.preventDefault();} //if(event.cancelBubble){event.cancelBubble = true;event.returnValue = false;} if(event.cancelBubble) event.cancelBubble=true; if(event.stopPropogation) event.stopPropogation(); if(event.preventDefault) event.preventDefault(); if(event.returnValue) event.returnValue=false; try{if(event.keyCode) event.keyCode=0;} catch(e) { } } function getFlashVersion(){ // ie try { try { // avoid fp6 minor version lookup issues // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); try { axo.AllowScriptAccess = 'always'; } catch(e) { return '6,0,0'; } } catch(e) {} return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; // other browsers } catch(e) { try { if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; } } catch(e) {} } return 0; } //============== Get Object Co-ordianted function getAbsX(elt) { return parseInt(elt.x) ? elt.x : getAbsPos(elt,"Left"); } function getAbsY(elt) { return parseInt(elt.y) ? elt.y : getAbsPos(elt,"Top"); } function getAbsPos(elt,which) { iPos = 0; while (elt != null) {iPos += elt["offset" + which]; elt = elt.offsetParent; } return iPos;} function findPos(obj) { try{ var curleft = curtop = 0; if (obj.offsetParent) { do { curleft += obj.offsetLeft; curtop += obj.offsetTop; } while (obj = obj.offsetParent); } return [curleft,curtop]; }catch(e){ return [false,false]; } } function getElementsByClassName(object,name){ try{//fix error in ie7 var allNodes=object.getElementsByTagName('*'); if(!allNodes){ var allNodes=object.all; } var returnObj=new Array; var count=0; for(var i=0;i1){ documentRange = editdoc.selection.createRange(); reloadSelection(); }else{ documentRange=''; } } function reloadSelection(){ if (documentRange){ documentRange.select(); } } function getSelectionNode(){ if(browser==''){browser=whichBrs();} if(browser=="ie"){ if(editdoc.selection.type=="Text"){ var node=editdoc.selection.createRange().parentElement(); }else if(editdoc.selection.type=="Control"){ var range = getRange(); var node =range(0).parentElement; } if(editdoc.getElementById("duocms_Selection")){ var node=editdoc.getElementById("duocms_Selection"); } return node; }else{ var selection = editwindow.getSelection(); //var range=selection.getRangeAt( 0 ); //if(range.commonAncestorContainer){return range.commonAncestorContainer;} //if(range.parentElement){return range.parentElement;} if(selection && selection.anchorNode){ var node = selection.anchorNode; if(!node.tagName){ node = node.parentNode;//ff fix } /* var offsetA = selection.anchorOffset; var offsetB = selection.focusOffset; console.log(offsetA+" "+offsetB+" "+node.tagName); */ return node; } } return false; } function getSelection(){ if(browser==''){browser=whichBrs();} if(browser=="ie"){ var selection = getRange(); }else{ var selection = editwindow.getSelection(); } return selection; } //setup tooltips function setupTooltips(){ count=0; var tbicons=getElementsByClassName(document,'tbIcons'); for(i=0;i]*>"); var current_html = editdoc.body.innerHTML = editdoc.body.innerHTML.replace(pat, html); systemSetup();//reinitialise after whole doc change } function getEl(sTag,start) { while ((start!=null) && (start.tagName!=sTag) && (start.className.substring(0,11)!="duoEditArea")){ start = start.parentElement; } if(start!=null){ if (start.id.substring(0,6)=="column" && sTag!="DIV"){ start = null; } } return start; } function cookieMaker(myName,fileid){ document.cookie=myName+'='+fileid+'; path=/'; } function cookieVal(cookieName){ var thisCookie=document.cookie.split("; "); if(thisCookie.length>0){ for (cook=0; cook 122 ) && (keycode < 45 || keycode > 57) && keycode!=95){ return false; } }else if (NumberFilter) { if (keycode < 45 || keycode > 57){ return false; } } } //============================ var _emptyTags = { "IMG": true, "BR": true, "INPUT": true, "META": true, "LINK": true, "PARAM": true, "HR": true }; function getOuterHTML(thisNode){ if(whichBrs()=="firefox" || whichBrs()=="firefox3"){ var attr, attrs = thisNode.attributes; var str = "<" + thisNode.tagName; for (var i = 0; i < attrs.length; i++) { attr = attrs[i]; if (attr.specified && attr.name.substring(0,4)!="_moz") str += " " + attr.name + '="' + attr.value + '"'; } if (_emptyTags[thisNode.tagName]) return str + ">"; return str + ">" + thisNode.innerHTML + ""; }else{ return thisNode.outerHTML; } } function setOuterHTML(thisNode,sHTML){ if(!thisNode){return;} if(whichBrs()=="firefox" || whichBrs()=="firefox3" ){ var r = thisNode.ownerDocument.createRange(); r.setStartBefore(thisNode); var df = r.createContextualFragment(sHTML); thisNode.parentNode.replaceChild(df, thisNode); }else{ thisNode.outerHTML=sHTML; } } function change_opacity(element,opac){ var object =element.style; if(opac=="100"){ object.opacity = ''; object.filter = ""; }else{ object.opacity = (opac/100); object.filter = "alpha(opacity=" + opac + ")"; } } Array.prototype.find = function(searchStr) { var returnArray = false; for (i=0; i \"" + value + "\"\n"; } } } else { //Stings/Chars/Numbers etc. dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; } return dumped_text; } // Simulates PHP's date function Date.prototype.format = function(format) { var returnStr = ''; var replace = Date.replaceChars; for (var i = 0; i < format.length; i++) { var curChar = format.charAt(i); if (replace[curChar]) returnStr += replace[curChar].call(this); else returnStr += curChar; } return returnStr; }; Date.replaceChars = { shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // Day d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); }, D: function() { return Date.replaceChars.shortDays[this.getDay()]; }, j: function() { return this.getDate(); }, l: function() { return Date.replaceChars.longDays[this.getDay()]; }, N: function() { return this.getDay() + 1; }, S: function() { return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th'))); }, w: function() { return this.getDay(); }, z: function() { return "Not Yet Supported"; }, // Week W: function() { return "Not Yet Supported"; }, // Month F: function() { return Date.replaceChars.longMonths[this.getMonth()]; }, m: function() { return (this.getMonth() < 11 ? '0' : '') + (this.getMonth() + 1); }, M: function() { return Date.replaceChars.shortMonths[this.getMonth()]; }, n: function() { return this.getMonth() + 1; }, t: function() { return "Not Yet Supported"; }, // Year L: function() { return "Not Yet Supported"; }, o: function() { return "Not Supported"; }, Y: function() { return this.getFullYear(); }, y: function() { return ('' + this.getFullYear()).substr(2); }, // Time a: function() { return this.getHours() < 12 ? 'am' : 'pm'; }, A: function() { return this.getHours() < 12 ? 'AM' : 'PM'; }, B: function() { return "Not Yet Supported"; }, g: function() { return this.getHours() == 0 ? 12 : (this.getHours() > 12 ? this.getHours() - 12 : this.getHours()); }, G: function() { return this.getHours(); }, h: function() { return (this.getHours() < 10 || (12 < this.getHours() < 22) ? '0' : '') + (this.getHours() < 10 ? this.getHours() + 1 : this.getHours() - 12); }, H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); }, i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); }, s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); }, // Timezone e: function() { return "Not Yet Supported"; }, I: function() { return "Not Supported"; }, O: function() { return (this.getTimezoneOffset() < 0 ? '-' : '+') + (this.getTimezoneOffset() / 60 < 10 ? '0' : '') + (this.getTimezoneOffset() / 60) + '00'; }, T: function() { return "Not Yet Supported"; }, Z: function() { return this.getTimezoneOffset() * 60; }, // Full Date/Time c: function() { return "Not Yet Supported"; }, r: function() { return this.toString(); }, U: function() { return this.getTime() / 1000; } }