// ------------------------------------------------------------------------------------------------------------------ if(typeof(window["arrOnLoad"])=="undefined") var arrOnLoad = new Array(); window.onload= function() { for (var t=0;t -1; // if(!isset(FIREFOX)) var FIREFOX = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; // if(!isset(CHROME)) var CHROME = navigator.userAgent.toLowerCase().indexOf('chrome') > -1; // // ------------------------------------------------------------------------------------------------------------------ // ON RESIZE IS NOT CURRENTLY WORKING if(typeof(window["arrOnResize"])=="undefined") var arrOnResize = new Array(); /*if(window.addEventListener) { window.addEventListener("resize", function() { for (var t=0; t naptime){ sleeping = false; } } //alert("Wakeup!"); return; } /* ------------------------------------------------------------------------------------- */ function fnGetSCOID (inFile) { //alert(inFile + ' / ' + parent.arrFiles.length + ' / ' + parent.arrRealSCOID.length) ; for (i = 0; i < parent.arrFiles.length; i++) { if (inFile == parent.arrFiles[i]) { parent.intCount = i; //alert(i); } } } /* ------------------------------------------------------------------------------------- */ function fnGetSCOSequence (inFile) { //alert(inFile + ' / ' + parent.arrFiles.length + ' / ' + parent.arrRealSCOID.length) ; for (i = 0; i < parent.arrFiles.length; i++) { if (inFile == parent.arrFiles[i]) { return parent.arrSequences[i]; } } } function loadStyleSheet(whichSheet) { if(document.styleSheets){ var c = document.styleSheets.length; if (doAlerts) alert('Change to Style '+(whichSheet+1)); for(var i=0;i\n' + '\n' + '\n'; } else if (whichSheet == 1) { var strImages = '\n' + '\n' + '\n'; } else { var strImages = '\n' + '\n' + '\n'; } document.getElementById('text_size').innerHTML = strImages; } } /**************************************NEW FUNCTION************************************/ function changeFont(size, chImg) { for(i = 4; i < 7; i++) { if(i != size) { document.styleSheets[i].disabled=true; } else { document.styleSheets[i].disabled=false; } } fnSetFontCookie(size); varHideLink = ' style="cursor:pointer;" title="Adjust text size" alt="Adjust text size" onmouseover="window.status=\'Adjust text size\'; return true;" onmouseout="window.status=\'\'; return true;" '; switch(size) { case 6: var strImages = '\n' + '\n' + '\n'; break; case 5: var strImages = '\n' + '\n' + '\n'; break; case 4: var strImages = '\n' + '\n' + '\n'; break; } if(chImg != false) { document.getElementById('text_size').innerHTML = strImages; } } /************************************** /NEW FUNCTION************************************/ function changeSheetsPublic(whichSheet){ if(document.styleSheets){ var c = document.styleSheets.length; if (doAlerts) alert('Change to Style '+(whichSheet+1)); for(var i=0;i\n' + '\n' + '\n'; } else if (whichSheet == 1) { var strImages = '\n' + '\n' + '\n'; } else { var strImages = '\n' + '\n' + '\n'; } document.getElementById('text_size').innerHTML = strImages; } } function ConfirmLogout(){ if(confirm('Are you sure you want to logout?')) document.location.href='/index.php?fuseaction=authentication.sessionkiller'; } var enableHTMLArea = 0; var enableSubmitExam = 0; /* ------------------------------------------------------------------------------------- */ function divToggle(div1,div2,div3,div4,div5,div6) { var elem1 = document.getElementById(div1); elem1.style.display = (elem1.style.display == "none")?"":"none"; var elem2 = document.getElementById(div2); elem2.style.display = (elem2.style.display == "none")?"":"none"; var elem3 = document.getElementById(div3); elem3.style.display = (elem3.style.display == "none")?"":"none"; var elem4 = document.getElementById(div4); elem4.style.display = (elem4.style.display == "none")?"":"none"; var elem5 = document.getElementById(div5); elem5.style.display = (elem5.style.display == "none")?"":"none"; var elem6 = document.getElementById(div6); elem6.className = (elem6.className == "left_collum")?"":"left_collum"; //alert(theDiv + ' - ' + objectWalk(elem)); } /* ------------------------------------------------------------------------------------- */ function divToggleSideMenu(theDiv,theImg) { styTog('sidebar','display','display','none'); styTog('tab','display','display','none'); styTog('tabflat','display','display','tabflat'); /* var elem = document.getElementById(theDiv); var elemImg = document.getElementById(theImg); elem.style.display = (elem.style.display == "none")?"":"none"; //document.getElementById('tab').style.display = (document.getElementById('tab').style.display == "tab")?"tabCollapsed":"tab"; alert(objectWalk(elemImg)); */ } /* ------------------------------------------------------------------------------------- */ // FONT SIZER STUFF - NOT STABLE YET, BUT DIDN'T WANT TO LOSE THE CHANGES function fnFontAJObject() { if (window.XMLHttpRequest) { inVar = new XMLHttpRequest(); } else if (window.ActiveXObject) { inVar = new ActiveXObject("Microsoft.XMLHTTP"); } else { inVar = false; } return inVar; } function fnFontSizeLoop(s) { var t=0; var x = Math.abs(s); for (t=0;t " + obj[k] + '\n'; } } return string; } /* ------------------------------------------------------------------------------------- */ var lvl = 0; function objectWalk(inObj) { spcr = '___ '; spcq = ''; for(i=0;i \n'+objectWalk(inObj[k]); lvl--; } else { strtemp += spc + '[' + k + '] => ' + inObj[k] + '\n'; } } strtemp += spcq+'}'+'\n'; } else { strtemp += inObj; } return strtemp; } /* ------------------------------------------------------------------------------------- */ function objectWalkFlat(inObj) { if (!w) { var w = window.open ("/blank.html","tempWindow","width=800, height=600, scrollbars=yes, status=yes, resizable=yes"); } for (var prop in inObj) { var strtemp = strtemp + 'Name: ' + prop + '= ' + inObj[prop] + '\n'; } //return strtemp; w.document.writeln('
' + strtemp + '
'); } // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- function is_array(input){ return typeof(input)=='object'&&(input instanceof Array); } function addslashes(str) { str=str.replace(/\\/g,'\\\\'); str=str.replace(/\'/g,'\\\''); str=str.replace(/\"/g,'\\"'); str=str.replace(/\0/g,'\\0'); return str; } // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- function stripslashes(str) { str=str.replace(/\\'/g,'\''); str=str.replace(/\\"/g,'"'); str=str.replace(/\\0/g,'\0'); str=str.replace(/\\\\/g,'\\'); return str; } // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- function strjsonIfy(obj) { var tmp = ''; if(obj instanceof Array || obj instanceof Object) { strJSON = ''; i = 0; for(k in obj) { //if(obj[k] instanceof Array || obj[k] instanceof Object) { if(Object.prototype.toString.call(obj[k])=="[object Array]"||Object.prototype.toString.call(obj[k])=="[object Object]") { strJSON += '\'' + k + '\'' + ':' + strjsonIfy(obj[k]); } else { if(isNaN(obj[k])) { var tmp = String(obj[k]); tmp = tmp.replace(/\x0B/g,''); tmp = tmp.replace(/\0/g,''); } else { tmp = obj[k]; } strJSON += '\'' + k + '\'' + ':' + '\'' + tmp + '\''; } strJSON += ','; i++; } strJSON = strJSON.substr(0,strJSON.lastIndexOf(',')); strJSON = '{' + strJSON + '}'; } return strJSON; } // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- function jsonIfy(obj) { //alert(strjsonIfy(obj)); tmp = eval('('+strjsonIfy(obj)+')'); //alert(objWalk(tmp)); //alert((eval(strjsonify(obj)))); //return eval('('+strjsonIfy(obj)+')'); return tmp; } /* ------------------------------------------------------------------------------------- */ function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i=0?document.body.scrollTop+10:event.clientY+10); if ((event.clientX > tooltipLft) && (event.clientY < (tooltipOBJ.scrollHeight?tooltipOBJ.scrollHeight:tooltipOBJ.style.pixelHeight) + 10)) { tooltipTop = (document.body.scrollTop?document.body.scrollTop:document.body.offsetTop) + event.clientY + 20; } tooltipOBJ.style.pixelLeft = tooltipLft; tooltipOBJ.style.pixelTop = tooltipTop; } tooltipOBJ.style.visibility = "visible"; } }; /* ------------------------------------------------------------------------------------- */ function HideTip(fArg) { var tooltipOBJ = (document.getElementById) ? document.getElementById('tt' + fArg) : eval("document.all['tt" + fArg + "']"); if (tooltipOBJ != null) { tooltipOBJ.style.visibility = "hidden"; } }; /* ------------------------------------------------------------------------------------- */ function mOvr(src) {{ src.style.cursor = 'pointer'; }} function mOut(src) {{ src.style.cursor = 'default'; }} function TopLeftopenWindow(theURL,winName,features) { var _W=window.open(theURL,winName,features); _W.focus(); _W.moveTo(0,0); } /* ------------------------------------------------------------------------------------- */ function addbookmark(argVal){ var bookData = new Array(); bookData = argVal.split("|"); if (document.all) window.external.AddFavorite(bookData[0], bookData[1]); } /* ------------------------------------------------------------------------------------- */ function MoveSelected(frmObj,src,quotes,onChange){ s = frmObj.elements[src]; source = s.options.length; //t = frmObj.elements[tgt]; //target = t.options.length; changed = false; for(i=0;i= 0; count--) { destinationList.options[count] = null; } for(var i = 0; i < sourceList.options.length; i++) { if (sourceList.options[i] != null) destinationList.options[i] = new Option(sourceList.options[i].text, sourceList.options[i].value ); } } /* ------------------------------------------------------------------------------------- */ function addSelectedItemsToParent() { self.opener.addToParentList(window.document.forms[0].destList); window.close(); } /* ------------------------------------------------------------------------------------- */ // Fill the selected item list with the items already present in parent. function fillInitialDestList() { var destList = window.document.forms[0].destList; var srcList = self.opener.window.document.forms[0].SR; for (var count = destList.options.length - 1; count >= 0; count--) { destList.options[count] = null; } for(var i = 0; i < srcList.options.length; i++) { if (srcList.options[i] != null) destList.options[i] = new Option(srcList.options[i].text, srcList.options[i].value, false, false); } } /* ------------------------------------------------------------------------------------- */ // Add the selected items from the source to destination list function addSrcToDestList() { destList = window.document.forms[0].destList; srcList = window.document.forms[0].srcList; var len = destList.length; for(var i = 0; i < srcList.length; i++) { if ((srcList.options[i] != null) && (srcList.options[i].selected)) { //Check if this value already exist in the destList or not //if not then add it otherwise do not add it. var found = false; for(var count = 0; count < len; count++) { if (destList.options[count] != null) { if (srcList.options[i].text == destList.options[count].text) { found = true; break; } } } if (found != true) { newoption = new Option(srcList.options[i].text, srcList.options[i].value, false, false); document.FrmSelectNews.destList.options[len] = newoption; len++; } } } } /* ------------------------------------------------------------------------------------- */ // Deletes from the destination list. function deleteFromDestList() { var destList = window.document.forms[0].destList; var len = destList.options.length; for(var i = (len-1); i >= 0; i--) { if ((destList.options[i] != null) && (destList.options[i].selected == true)) { destList.options[i] = null; } } } /* ------------------------------------------------------------------------------------- */ function SelectAllEdit(){ for (i=0; i= 4){win.window.focus();} }; /* ------------------------------------------------------------------------------------- */ /* var openImg = new Image(); openImg.src = "/portal/images/minus.gif"; var closedImg = new Image(); closedImg.src = "/portal/images/plus.gif"; */ function showBranch(branch){ var objBranch = document.getElementById(branch).style; if(objBranch.display=="block") objBranch.display="none"; else objBranch.display="block"; }; /* ------------------------------------------------------------------------------------- */ function swapFolder(img){ objImg = document.getElementById(img); if(objImg.src.indexOf('plus.gif')>-1) objImg.src = openImg.src; else objImg.src = closedImg.src; }; /* ------------------------------------------------------------------------------------- */ // type 1 = Popup // type 2 = Alert // type "" = Nothing function MM_jumpMenu(targ,selObj,restore){ //v3.0 if (selObj.options[selObj.selectedIndex].value != "") { var linkType = new Array(); linkType = selObj.options[selObj.selectedIndex].value.split("|"); if (linkType[2] == "1"){ eval(linkType[1]); } else if (linkType[2] == "2"){ if (confirm(linkType[0])) location.replace(linkType[1]); } else { eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } } }; /* ------------------------------------------------------------------------------------- */ function GenFn() { if (enableHTMLArea == 1) { initDocument(); } }; /* ------------------------------------------------------------------------------------- */ function GenUnloadFn(){ if (enableSubmitExam == 1){ // document.forms['FrmCert'].time_left.value = document.forms['FrmCert'].clock.value; document.forms['FrmCert'].time_left.value = x; document.forms['FrmCert'].submit(); } }; /* ------------------------------------------------------------------------------------- */ /* name - name of the cookie value - value of the cookie [expires] - expiration date of the cookie (defaults to end of current session) [path] - path for which the cookie is valid (defaults to path of calling document) [domain] - domain for which the cookie is valid (defaults to domain of calling document) [secure] - Boolean value indicating if the cookie transmission requires a secure transmission * an argument defaults when it is assigned null as a placeholder * a null placeholder is not required for trailing omitted arguments */ function setCookie(name, value, expires, path, domain, secure) { var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + /*((path) ? "; path=" + path : "") +*/ "; path=/" + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); document.cookie = curCookie; } /* ------------------------------------------------------------------------------------- */ /* name - name of the desired cookie return string containing value of specified cookie or null if cookie does not exist */ function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); } /* ------------------------------------------------------------------------------------- */ /* name - name of the cookie [path] - path of the cookie (must be same as path used to create cookie) [domain] - domain of the cookie (must be same as domain used to create cookie) path and domain default if assigned null or omitted if no explicit argument proceeds */ function deleteCookie(name, path, domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } /* ------------------------------------------------------------------------------------- */ // date - any instance of the Date object // * hand all instances of the Date object to this function for "repairs" function fixDate(date) { var base = new Date(0); var skew = base.getTime(); if (skew > 0) date.setTime(date.getTime() - skew); } /* ------------------------------------------------------------------------------------- */ function fnSetCookie(sidebar,fontsize,sectionid) { var now = new Date(); fixDate(now); now.setTime(now.getTime() + 24 * 60 * 60 * 1000); var preferences = getCookie("preferences"); preferences = sidebar + ':' + fontsize + ':' + sectionid; // the value for the new cookie setCookie("preferences", preferences, now); } function fnSetFontCookie(size) { var now = new Date(); fixDate(now); now.setTime(now.getTime() + 24 * 60 * 60 * 1000); var fontpref = getCookie("fontpref"); fontpref = size; setCookie("fontpref", fontpref, now); } /* ------------------------------------------------------------------------------------- */ function fnChangeMyProfilePass() { var proceed = confirm('If you have made changes to the contents of this form, please make sure to save them before changing your password, otherwise your changes will be lost.\n\nAre you sure you wish to proceed?'); if (proceed) { window.location = './index.php?fuseaction=myprofile.mypassword'; return true; } else { return false; } } var dtCh= "-"; var minYear=1900; var maxYear=2100; function isInteger(s){ var i; for (i = 0; i < s.length; i++){ // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } /* ------------------------------------------------------------------------------------- */ function stripCharsInBag(s, bag){ var i; var returnString = ""; // Search through string's characters one by one. // If character is not in bag, append to returnString. for (i = 0; i < s.length; i++){ var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += c; } return returnString; } /* ------------------------------------------------------------------------------------- */ function daysInFebruary (year){ // February has 29 days in any year evenly divisible by four, // EXCEPT for centurial years which are not also divisible by 400. return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); } /* ------------------------------------------------------------------------------------- */ function DaysArray(n) { for (var i = 1; i <= n; i++) { this[i] = 31 if (i==4 || i==6 || i==9 || i==11) {this[i] = 30} if (i==2) {this[i] = 29} } return this } /* ------------------------------------------------------------------------------------- */ function isDate(dtStr){ var daysInMonth = DaysArray(12) var pos1=dtStr.indexOf(dtCh) var pos2=dtStr.indexOf(dtCh,pos1+1) var strYear=dtStr.substring(0,pos1) var strMonth=dtStr.substring(pos1+1,pos2) var strDay=dtStr.substring(pos2+1) strYr=strYear if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1) if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1) for (var i = 1; i <= 3; i++) { if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1) } month=parseInt(strMonth) day=parseInt(strDay) year=parseInt(strYr) if (pos1==-1 || pos2==-1){ alert("The date format is invalid. It should be YYYY-MM-DD.") return false } if (strMonth.length<1 || month<1 || month>12){ alert("The date format is invalid. It should be YYYY-MM-DD.") return false } if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){ alert("The date format is invalid. It should be YYYY-MM-DD.") return false } if (strYear.length != 4 || year==0 || yearmaxYear){ alert("The date format is invalid. It should be YYYY-MM-DD.") return false } if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){ alert("The date format is invalid. It should be YYYY-MM-DD.") return false } return true } /* ------------------------------------------------------------------------------------- */ function compareDates (value1, value2) { var date1, date2; var month1, month2; var year1, year2; year1 = value1.substring (0, value1.indexOf ("-")); date1 = value1.substring (value1.indexOf ("-")+1, value1.lastIndexOf ("-")); month1 = value1.substring (value1.lastIndexOf ("-")+1, value1.length); year2 = value2.substring (0, value2.indexOf ("-")); date2 = value2.substring (value2.indexOf ("-")+1, value2.lastIndexOf ("-")); month2 = value2.substring (value2.lastIndexOf ("-")+1, value2.length); if (year1 > year2) return 1; else if (year1 < year2) return -1; else if (month1 > month2) return 1; else if (month1 < month2) return -1; else if (date1 > date2) return 1; else if (date1 < date2) return -1; else return 0; } /* ------------------------------------------------------------------------------------- */ function fnOutputDateTime() { Stamp = new Date(); year = Stamp.getYear(); if(year < 1000) { year += 1900; } month = (Stamp.getMonth() + 1); if(month < 10) { month = "0" + month; } day = Stamp.getDate(); if(day < 10) { day = "0" + day; } var Hours; var Mins; var Time; Hours = Stamp.getHours(); if (Hours >= 12) { Time = " PM"; } else { Time = " AM"; } if (Hours > 12) { Hours -= 12; } if (Hours == 0) { Hours = 12; } Mins = Stamp.getMinutes(); if (Mins < 10) { Mins = "0" + Mins; } document.write(Hours + ":" + Mins + Time); document.write(" on " + year +"/"+month+ "/"+ day); } function NewWindow(url, windowName, w, h, status, scroll) { var winl = (screen.availWidth - w) / 2; var wint = (screen.availHeight - h) / 2; winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',status=' + status +', scrollbars='+scroll+',resizable=0'; win = window.open(url, windowName, winprops); if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } } function trim(str) { return trimAll(str); } // this function is BUSTED on "e", WTF!?! /*function trim( str, charlist ) { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: mdsjack (http://www.mdsjack.bo.it) // + improved by: Alexander Ermolaev (http://snippets.dzone.com/user/AlexanderErmolaev) // + input by: Erkekjetter // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + input by: DxGx // + improved by: Steven Levithan (http://blog.stevenlevithan.com) // + tweaked by: Jack // + bugfixed by: Onno Marsman // * example 1: trim(' Kevin van Zonneveld '); // * returns 1: 'Kevin van Zonneveld' // * example 2: trim('Hello World', 'Hdle'); // * returns 2: 'o Wor' // * example 3: trim(16, 1); // * returns 3: 6 var whitespace, l = 0, i = 0; str += ''; charlist += ''; if (!charlist) { whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000'; } else { whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1'); } l = str.length; for (i = 0; i < l; i++) { if (whitespace.indexOf(str.charAt(i)) === -1) { str = str.substring(i); break; } } l = str.length; for (i = l - 1; i >= 0; i--) { if (whitespace.indexOf(str.charAt(i)) === -1) { str = str.substring(0, i + 1); break; } } return whitespace.indexOf(str.charAt(0)) === -1 ? str : ''; }*/ function serialize( mixed_value ) { var _getType = function( inp ) { var type = typeof inp, match; if (type == 'object' && !inp) { return 'null'; } if (type == "object") { if (!inp.constructor) { return 'object'; } var cons = inp.constructor.toString(); if (match = cons.match(/(\w+)\(/)) { cons = match[1].toLowerCase(); } var types = ["boolean", "number", "string", "array"]; for (key in types) { if (cons == types[key]) { type = types[key]; break; } } } return type; }; var type = _getType(mixed_value); var val; switch (type) { case "undefined": val = "N"; break; case "boolean": val = "b:" + (mixed_value ? "1" : "0"); break; case "number": val = (Math.round(mixed_value) == mixed_value ? "i" : "d") + ":" + mixed_value; break; case "string": val = "s:" + mixed_value.length + ":\"" + mixed_value + "\""; break; case "array": case "object": val = "a"; var count = 0; var vals = ""; var okey; for (key in mixed_value) { okey = (key.match(/^[0-9]+$/) ? parseInt(key) : key); vals += serialize(okey) + serialize(mixed_value[key]); count++; } val += ":" + count + ":{" + vals + "}"; break; } if (type != "object" && type != "array") val += ";"; return val; } function unserialize(data){ // http://kevin.vanzonneveld.net // + original by: Arpad Ray (mailto:arpad@php.net) // + improved by: Pedro Tainha (http://www.pedrotainha.com) // + bugfixed by: dptr1988 // + revised by: d3x // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // % note: We feel the main purpose of this function should be to ease the transport of data between php & js // % note: Aiming for PHP-compatibility, we have to translate objects to arrays // * example 1: unserialize('a:3:{i:0;s:5:"Kevin";i:1;s:3:"van";i:2;s:9:"Zonneveld";}'); // * returns 1: ['Kevin', 'van', 'Zonneveld'] // * example 2: unserialize('a:3:{s:9:"firstName";s:5:"Kevin";s:7:"midName";s:3:"van";s:7:"surName";s:9:"Zonneveld";}'); // * returns 2: {firstName: 'Kevin', midName: 'van', surName: 'Zonneveld'} var error = function (type, msg, filename, line){throw new window[type](msg, filename, line);}; //var error = function (arg0,arg1){alert( 'arg0: '+arg0+' -- arg1: '+arg1);}; var read_until = function (data, offset, stopchr){ var buf = []; var chr = data.slice(offset, offset + 1); var i = 2; while(chr != stopchr){ if((i+offset) > data.length){ error('Error', 'Invalid'); } buf.push(chr); chr = data.slice(offset + (i - 1),offset + i); i += 1; } return [buf.length, buf.join('')]; }; var read_chrs = function (data, offset, length){ buf = []; for(var i = 0;i < length;i++){ var chr = data.slice(offset + (i - 1),offset + i); buf.push(chr); } return [buf.length, buf.join('')]; }; var _unserialize = function (data, offset){ if(!offset) offset = 0; var buf = []; var dtype = (data.slice(offset, offset + 1)).toLowerCase(); var dataoffset = offset + 2; var typeconvert = new Function('x', 'return x'); var chrs = 0; var datalength = 0; switch(dtype){ case "i": typeconvert = new Function('x', 'return parseInt(x)'); var readData = read_until(data, dataoffset, ';'); var chrs = readData[0]; var readdata = readData[1]; dataoffset += chrs + 1; break; case "b": typeconvert = new Function('x', 'return (parseInt(x) == 1)'); var readData = read_until(data, dataoffset, ';'); var chrs = readData[0]; var readdata = readData[1]; dataoffset += chrs + 1; break; case "d": typeconvert = new Function('x', 'return parseFloat(x)'); var readData = read_until(data, dataoffset, ';'); var chrs = readData[0]; var readdata = readData[1]; dataoffset += chrs + 1; break; case "n": readdata = null; break; case "s": var ccount = read_until(data, dataoffset, ':'); var chrs = ccount[0]; var stringlength = ccount[1]; dataoffset += chrs + 2; var readData = read_chrs(data, dataoffset+1, parseInt(stringlength)); var chrs = readData[0]; var readdata = readData[1]; dataoffset += chrs + 2; if(chrs != parseInt(stringlength) && chrs != readdata.length){ error('SyntaxError', 'String length mismatch'); } break; case "a": var readdata = {}; var keyandchrs = read_until(data, dataoffset, ':'); var chrs = keyandchrs[0]; var keys = keyandchrs[1]; dataoffset += chrs + 2; for(var i = 0;i < parseInt(keys);i++){ var kprops = _unserialize(data, dataoffset); var kchrs = kprops[1]; var key = kprops[2]; dataoffset += kchrs; var vprops = _unserialize(data, dataoffset); var vchrs = vprops[1]; var value = vprops[2]; dataoffset += vchrs; readdata[key] = value; } dataoffset += 1; break; default: error('SyntaxError', 'Unknown / Unhandled data type(s): ' + dtype); break; } return [dtype, dataoffset - offset, typeconvert(readdata)]; }; return _unserialize(data, 0)[2]; } // Replaces all instances of the given substring. String.prototype.replaceAll = function( strTarget, // The substring you want to replace strSubString // The string you want to replace in. ){ var strText = this; var intIndexOfMatch = strText.indexOf( strTarget ); // Keep looping while an instance of the target string // still exists in the string. while (intIndexOfMatch != -1){ // Relace out the current instance. strText = strText.replace( strTarget, strSubString ) // Get the index of any next matching substring. intIndexOfMatch = strText.indexOf( strTarget ); } // Return the updated string with ALL the target strings // replaced out with the new substring. return( strText ); } function is_array( mixed_var ) { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: Legaev Andrey // + bugfixed by: Cord // * example 1: is_array(['Kevin', 'van', 'Zonneveld']); // * returns 1: true // * example 2: is_array('Kevin van Zonneveld'); // * returns 2: false return ( mixed_var instanceof Array ); } /* ------------------------------------------------------------------------------------- */ /*function trimAll(strValue) { if(strValue==null||strValue==undefined) strValue = ''; var objRegExp = /^(\s*)$/; if(objRegExp.test(strValue)) { strValue = strValue.replace(objRegExp, ''); if(strValue.length == 0) return strValue; } objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/; if(objRegExp.test(strValue)) { strValue = strValue.replace(objRegExp, '$2'); } return strValue; }*/ function trimAll( strValue ) { var objRegExp = /^(\\s*)$/; if(objRegExp.test(strValue)) { strValue = strValue.replace(objRegExp, ''); if( strValue.length == 0) return strValue; } objRegExp = /^(\\s*)([\\W\\w]*)(\\b\\s*$)/; if(objRegExp.test(strValue)) { strValue = strValue.replace(objRegExp, '$2'); } return strValue; } /* ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- */ // Added the following 2 functions (fnAJAXIdle, fnToolTip). Also touched up trimAll. /* ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- */ /* -- Used to invoke idle session message/redirection via ajax calls. */ intAJAXIdler = 0; function fnAJAXIdle() { if (intAJAXIdler==0) { intAJAXIdler = 1; alert ('Session has idled'); document.location.href="https://ede2course.com/index.php?fuseaction=authentication.idle"; } } /* ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- ~~ -- */ /* -- Fetches a tagid from a specified url, for use with tooltips */ var arrTips = new Array(); var mouseOnTT = false; function fnToolTip(tagid,url,title) { if(!isset(title)) title = 'Help'; for (g=0; g < arrTips.length; g++) { tmp = arrTips[g].split('~~**~~'); if (tmp[0]==tagid) { if (mouseOnTT==true){ Tip('
' + tmp[1] + '
', CLOSEBTN, true, STICKY, true, BGCOLOR, '', BORDERCOLOR, '#000000', DELAY, 500, TITLE, title); mouseOnTT = false; } return false; } } document.body.style.cursor='wait'; if (window.XMLHttpRequest) { inObject1 = new XMLHttpRequest(); } else if (window.ActiveXObject) { inObject1 = new ActiveXObject("Microsoft.XMLHTTP"); } else { inObject1 = false; } inObject1.open("GET", url + tagid); inObject1.onreadystatechange = function() { if (inObject1.readyState == 4 && inObject1.status == 200) { if (trimAll(inObject1.responseText)=='~999~') {fnAJAXIdle();} arrTips.push(tagid + '~~**~~' + trimAll(inObject1.responseText)); fnToolTip(tagid,url,title); } } inObject1.send(null); } /* ------------------------------------------------------------------------------------- */ function trimAll(strValue) { if(strValue==null||strValue==undefined||strValue=='') strValue = ''; var objRegExp = /^(\s*)$/; if(objRegExp.test(strValue)) { strValue = strValue.replace(objRegExp, ''); if(strValue.length == 0) return strValue; } objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/; if(objRegExp.test(strValue)) { strValue = strValue.replace(objRegExp, '$2'); } return strValue; } /* ------------------------------------------------------------------------------------- */ function strlen(string) { if(string!=null) { return string.length; } else { return 0; } } /* ------------------------------------------------------------------------------------- */ function sleep(milliseconds) { var start = new Date().getTime(); while ((new Date().getTime() - start) < milliseconds){ // Do nothing } } /* ------------------------------------------------------------------------------------- */ function is_numeric (mixed_var) { return (typeof(mixed_var) === 'number' || typeof(mixed_var) === 'string') && mixed_var !== '' && !isNaN(mixed_var); } /* ------------------------------------------------------------------------------------- */ function strip_tags (str, allowed_tags) { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: Luke Godfrey // + input by: Pul // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + bugfixed by: Onno Marsman // + input by: Alex // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + input by: Marc Palau // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + input by: Brett Zamir (http://brett-zamir.me) // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + bugfixed by: Eric Nagel // + input by: Bobby Drake // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + bugfixed by: Tomasz Wesolowski // * example 1: strip_tags('

Kevin


van Zonneveld', ''); // * returns 1: 'Kevin van Zonneveld' // * example 2: strip_tags('

Kevin van Zonneveld

', '

'); // * returns 2: '

Kevin van Zonneveld

' // * example 3: strip_tags("Kevin van Zonneveld", ""); // * returns 3: 'Kevin van Zonneveld' // * example 4: strip_tags('1 < 5 5 > 1'); // * returns 4: '1 < 5 5 > 1' var key = '', allowed = false; var matches = []; var allowed_array = []; var allowed_tag = ''; var i = 0; var k = ''; var html = ''; var replacer = function (search, replace, str) { return str.split(search).join(replace); }; // Build allowes tags associative array if (allowed_tags) { allowed_array = allowed_tags.match(/([a-zA-Z0-9]+)/gi); } str += ''; // Match tags matches = str.match(/(<\/?[\S][^>]*>)/gi); // Go through all HTML tags for (key in matches) { if (isNaN(key)) { // IE7 Hack continue; } // Save HTML tag html = matches[key].toString(); // Is tag not in allowed list? Remove from str! allowed = false; // Go through all allowed tags for (k in allowed_array) { // Init allowed_tag = allowed_array[k]; i = -1; if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+'>');} if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+' ');} if (i != 0) { i = html.toLowerCase().indexOf(''); strOut = strOut.replace(/\"/g,'"'); strOut = strOut.replace(/\\/g,'&92;'); strOut = encodeURIComponent(strOut); return strOut; } function fnCheckArrLen(arrIn) { if(Object.prototype.toString.call(arrIn)=='[object Array]') { var len = 0; for(var i in arrIn) { if(arrIn[i]!=null) { len++; } } return len; } else { return null; } } function fnTextareaForceMaxLen(object,intMaxLen) { if(object) { // OBJECT EXISTS if(object.type=="textarea") { // IS TEXTAREA var strString = object.value; // GET INPUT STRING var intLen = strString.length; // CURRENT LENGTH INT CHARS if(intLen > intMaxLen) { strString = strString.substr(0,intMaxLen); object.value = strString; alert("Note: you've reached the maximum length("+intMaxLen+" characters) for this field."); // ALERT THE USER, SO HE/SHE KNOWS TO STOP } } } } function fnForceTextareaMaxLinesByNumRows(object) { if(object) { // OBJECT EXISTS if(object.type=="textarea") { // IS TEXTAREA var intMaxLines = new Number(object.rows); // MAXIMUM LINES = NUMBER OF ROWS var strString = new String(object.value); // GET INPUT STRING strString = strString.replace(/\r/g,''); // REMOVE WINDOWS RETURN (NEWLINE IS SUFFICIENT) var intMaxChars = object.rows * object.cols; // CHECK FOR CHARACTERS FIRST if(strString.length>intMaxChars) { strString = strString.substr(0,intMaxChars); // TRIM OFF EXCESS CHARACTERS AT THE END (OVER MAX CHARS) object.value = strString; // RE-ASSIGN OUR STRING TO THE VALUE PROPERTY alert("Note: you've reached the maximum number of characters ("+intMaxChars+") for this field."); // ALERT THE USER, SO HE/SHE KNOWS TO STOP return; } // THEN CHECK FOR LINES var arrLines = strString.split("\n"); // GET ARRAY AS STRING SPLIT BY NEWLINE if(fnCheckArrLen(arrLines)>intMaxLines) { // WE'VE GONE OVER MAX LINES, TRIM OUT LAST ENTERED LINE var arrNewLines = arrLines.slice(0,intMaxLines); strString = arrNewLines.join("\n"); object.value = strString; alert("Note: you've reached the maximum number of lines ("+intMaxLines+") for this field."); // ALERT THE USER, SO HE/SHE KNOWS TO STOP return; } } } } /** * count(), counts the number of elements, much like PHP's count (returns 0 if it's not an Array and not an Object) */ function count(obj) { var intCount = 0; /* if(Object.prototype.toString.call(obj)=='[object Array]') { intCount = obj.length; } else if(Object.prototype.toString.call(obj)=='[object Object]') { */ for(var k in obj) { intCount++; } //} return intCount; } //-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // NOTE: You could probably stick the document.body.style.cursor = 'auto' / document.body.style.cursor = 'wait' // stuff in the function below. function fnWait(inMode,inMsgEN,inMsgFR) { window.location.href = '#top'; if(document.body) { // Basically, if our page is completely loaded, otherwise there's no use. if(document.getElementById('idWaitWhileLoading')) { var elem = document.getElementById('idWaitWhileLoading'); document.body.removeChild(elem); delete elem; } if(document.getElementById('idWaitWhileLoadingIFrame')) { var elem = document.getElementById('idWaitWhileLoadingIFrame'); document.body.removeChild(elem); delete elem; } if (inMode==1) { var iFrame = document.createElement("iframe"); //iFrame.style.zIndex = 149; iFrame.style.position = 'absolute'; //iFrame.style.width = document.body.scrollWidth+'px' iFrame.style.width = '100%' iFrame.style.height = document.body.scrollHeight+'px'; iFrame.style.opacity=0.1; iFrame.style.filter='alpha(opacity=10)'; iFrame.style.top = '0px'; iFrame.style.left = '0px'; iFrame.setAttribute("id","idWaitWhileLoadingIFrame"); document.body.appendChild(iFrame); delete iFrame; var wwl = document.createElement("div"); wwl.setAttribute('id','idWaitWhileLoading'); wwl.style.display = ''; wwl.textAlign = 'center'; wwl.style.backgroundColor= '#ffffff'; wwl.style.margin= '0 auto'; wwl.style.width= '100%'; //wwl.style.width= document.body.scrollWidth+'px';//'100%'; wwl.style.height= document.body.scrollHeight+'px';//'100%'; wwl.style.position= 'absolute'; wwl.style.top= '0px'; wwl.style.left= '0px'; wwl.style.opacity=0.8; wwl.style.filter='alpha(opacity=80)'; wwl.style.zIndex= 150; var p = document.createElement("p"); p.style.marginTop = 100 + "px"; p.style.textAlign = "center"; var img = document.createElement("img"); img.src = '/styles/ede2/_images/ajax-loader.gif'; p.appendChild(img); var br = document.createElement("br"); p.appendChild(br); var br = document.createElement("br"); p.appendChild(br); var msgEN = inMsgEN!=null ? inMsgEN : 'Loading...'; var msgFR = inMsgFR!=null ? inMsgFR : 'Chargement...'; var b = document.createElement("b"); var txt = document.createTextNode(msgEN); b.appendChild(txt); var br = document.createElement("br"); b.appendChild(br); var txt = document.createTextNode(msgFR); b.appendChild(txt); p.appendChild(b); delete b; wwl.appendChild(p); delete p; document.body.appendChild(wwl); delete wwl; } }} function isset () { // !No description available for isset. @php.js developers: Please update the function summary text file. // // version: 1009.2513 // discuss at: http://phpjs.org/functions/isset // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: FremyCompany // + improved by: Onno Marsman // + improved by: RafaƂ Kukawski // * example 1: isset( undefined, true); // * returns 1: false // * example 2: isset( 'Kevin van Zonneveld' ); // * returns 2: true var a = arguments, l = a.length, i = 0, undef; if (l === 0) { throw new Error('Empty isset'); } while (i !== l) { if (a[i] === undef || a[i] === null) { return false; } i++; } return true; } function in_array (needle, haystack, argStrict) { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: vlado houba // + input by: Billy // + bugfixed by: Brett Zamir (http://brett-zamir.me) // * example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']); // * returns 1: true // * example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'}); // * returns 2: false // * example 3: in_array(1, ['1', '2', '3']); // * returns 3: true // * example 3: in_array(1, ['1', '2', '3'], false); // * returns 3: true // * example 4: in_array(1, ['1', '2', '3'], true); // * returns 4: false var key = '', strict = !!argStrict; if (strict) { for (key in haystack) { if (haystack[key] === needle) { return true; } } } else { for (key in haystack) { if (haystack[key] == needle) { return true; } } } return false; } function findPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) { do { curleft += obj.offsetLeft; curtop += obj.offsetTop; } while (obj = obj.offsetParent); } return {left: curleft,top: curtop}; } // Used in LPMT to log link click. function fnLinkLog(intLinkID, strLink) { if (window.XMLHttpRequest) { inObject = new XMLHttpRequest(); } else if (window.ActiveXObject) { inObject = new ActiveXObject("Microsoft.XMLHTTP"); } else { return false; } inObject.open("GET", '/fusebox/circuit_learningpaths/dspAjax.php?mode=loglink&id=' + intLinkID + '&link=' + encodeURIComponent(strLink)); inObject.send(null); } /** * parseQuery: parse passed arguments (e.g. ) * Example usage: * // fetch all scripts loaded (up to current script) * var scripts = document.getElementsByTagName('script'); * // this script would be the last loaded so far * var myScript = scripts[ scripts.length - 1 ]; * // get the bit after the filename, that's the query * var queryString = myScript.src.replace(/^[^\?]+\??/,''); * // parse the query string into a params object {name: 'val', ...} * var params = parseQuery( queryString ); */ function parseQuery ( query ) { var Params = new Object (); if ( ! query ) return Params; // return empty object var Pairs = query.split(/[;&]/); for ( var i = 0; i < Pairs.length; i++ ) { var KeyVal = Pairs[i].split('='); if ( ! KeyVal || KeyVal.length != 2 ) continue; var key = unescape( KeyVal[0] ); var val = unescape( KeyVal[1] ); val = val.replace(/\+/g, ' '); Params[key] = val; } return Params; } function fnArrLen(array) { var count = 0; for(var k in array) { count++; } return count; } function fnArrDeleteElemByVal(array, value) { var len = array.length; if(in_array(value,array)) { for(var k in array) { if(array[k]==value) { delete(array[k]); len--; break; } } array.sort(); } if(len==0) array = []; // return array; } function fnPrintMyParent(o) { var p = o.parentNode.parentNode; var w=window.open(); w.document.write(p.innerHTML); w.print(); if(!CHROME && !IE9 && !IE8 && !IE7) w.close(); } function str_pad (input, pad_length, pad_string, pad_type) { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + namespaced by: Michael White (http://getsprink.com) // + input by: Marco van Oort // + bugfixed by: Brett Zamir (http://brett-zamir.me) // * example 1: str_pad('Kevin van Zonneveld', 30, '-=', 'STR_PAD_LEFT'); // * returns 1: '-=-=-=-=-=-Kevin van Zonneveld' // * example 2: str_pad('Kevin van Zonneveld', 30, '-', 'STR_PAD_BOTH'); // * returns 2: '------Kevin van Zonneveld-----' var half = '', pad_to_go; var str_pad_repeater = function (s, len) { var collect = '', i; while (collect.length < len) { collect += s; } collect = collect.substr(0, len); return collect; }; input += ''; pad_string = pad_string !== undefined ? pad_string : ' '; if (pad_type != 'STR_PAD_LEFT' && pad_type != 'STR_PAD_RIGHT' && pad_type != 'STR_PAD_BOTH') { pad_type = 'STR_PAD_RIGHT'; } if ((pad_to_go = pad_length - input.length) > 0) { if (pad_type == 'STR_PAD_LEFT') { input = str_pad_repeater(pad_string, pad_to_go) + input; } else if (pad_type == 'STR_PAD_RIGHT') { input = input + str_pad_repeater(pad_string, pad_to_go); } else if (pad_type == 'STR_PAD_BOTH') { half = str_pad_repeater(pad_string, Math.ceil(pad_to_go / 2)); input = half + input + half; input = input.substr(0, pad_length); } } return input; }