/** * * Base64 encode / decode * http://www.webtoolkit.info/ * **/ var Base64 = { // private property _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", // public method for encoding encode : function (input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = Base64._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); } return output; }, // public method for decoding decode : function (input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = Base64._utf8_decode(output); return output; }, // private method for UTF-8 encoding _utf8_encode : function (string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, // private method for UTF-8 decoding _utf8_decode : function (utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } } //End Base64 // Start Ajax functions window.urlData=Array(); var xmlHttp = createXMLHttpRequest(); function createXMLHttpRequest() { try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {} try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} try { return new XMLHttpRequest(); } catch(e) {} alert("XMLHttpRequest not supported"); return null; } var onLoadContentOverlibFunction=function(){ if (xmlHttp.readyState == 4) { changeOverlibContent(xmlHttp.responseText); } }; function loadOverlibContent(url, f){ // Open a connection to the server xmlHttp.open("GET", url, true); if (!f) { f=onLoadContentOverlibFunction; } // Setup a function for the server to run when it's done xmlHttp.onreadystatechange = f; // Send the request xmlHttp.send(null); } function handleAJAXCallStateChange(){ if (xmlHttp.readyState == 4) { alert("I am a dummy function [handleAJAXCallStateChange].\nYou must override me.\n\nBy the way the ready state is " + xmlHttp.readyState); } } function doAJAXPostCall(url, params, f){ //You have to either pass your function or override the handleAJAXCallStateChange // Open a connection to the server xmlHttp.open("POST", url, true); if (!f) { f=handleAJAXCallStateChange; } // Setup a function for the server to run when it's done xmlHttp.onreadystatechange = f; xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;"); xmlHttp.send(params); } function doAJAXGetCall(url, f){ //You have to either pass your function or override the handleAJAXCallStateChange // Open a connection to the server xmlHttp.open("GET", url, true); if (!f) { f=handleAJAXCallStateChange; } // Setup a function for the server to run when it's done xmlHttp.onreadystatechange = f; xmlHttp.send(null); } function changeOverlibContent(str){ showOverlib(str); return false; } function showOverlib(data,caption){ if (!caption) { if (window.overlibCaption){ caption=window.overlibCaption; } else { caption=" "; } } if (!window.overLibX) { window.overLibX=cursor.x; } if (!window.overLibY) { window.overLibY=cursor.y; } return overlib(data, CAPTION, caption, FIXX, window.overLibX, FIXY, window.overLibY, STICKY, FGCOLOR , '#bce0ec', BGCOLOR, '#153A46', CAPCOLOR , '#ffffff', CLOSETEXT, '', CLOSECLICK); } // -- end ajax functions function xoopsGetElementById(id){ if (document.getElementById) { return (document.getElementById(id)); } else if (document.all) { return (document.all[id]); } else { if ((navigator.appname.indexOf("Netscape") != -1) && parseInt(navigator.appversion == 4)) { return (document.layers[id]); } } } function xoopsSetElementProp(name, prop, val) { var elt=xoopsGetElementById(name); if (elt) elt[prop]=val; } function xoopsSetElementStyle(name, prop, val) { var elt=xoopsGetElementById(name); if (elt && elt.style) elt.style[prop]=val; } function getFormDataAsQueryString(fname){ var frm=document.forms[fname]; var text=""; var els = frm.elements; for(i=0; i0) { element.style.height=newHeight+"px"; } } if (d == "width"){ currWidth=parseInt(element.style.width); newWidth=currWidth+n; if (newWidth>0) { element.style.width=newWidth+"px"; } } } function resizeSelectBox(e, n, d){ element = document.getElementById(e); if (!d) { d="height"; } if (d=="height"){ currHeight=parseInt(element.style.height); newHeight=currHeight+n; if (newHeight>0) { element.style.height=newHeight+"px"; } } if (d=="width"){ currWidth = parseInt(element.style.width); newWidth = currWidth + n; if (!newWidth){ newWidth = "200"; } if (newWidth>0) { element.style.width=newWidth+"px"; } } } function makeBold(id){ var eleStyle = xoopsGetElementById(id).style; if (eleStyle.fontWeight != "bold" && eleStyle.fontWeight != "700") { eleStyle.fontWeight = "bold"; } else { eleStyle.fontWeight = "normal"; } } function makeItalic(id){ var eleStyle = xoopsGetElementById(id).style; if (eleStyle.fontStyle != "italic") { eleStyle.fontStyle = "italic"; } else { eleStyle.fontStyle = "normal"; } } function makeUnderline(id){ var eleStyle = xoopsGetElementById(id).style; if (eleStyle.textDecoration != "underline") { eleStyle.textDecoration = "underline"; } else { eleStyle.textDecoration = "none"; } } function makeLineThrough(id){ var eleStyle = xoopsGetElementById(id).style; if (eleStyle.textDecoration != "line-through") { eleStyle.textDecoration = "line-through"; } else { eleStyle.textDecoration = "none"; } } function appendSelectOption(selectMenuId, optionName, optionValue){ var selectMenu = xoopsGetElementById(selectMenuId); var newoption = new Option(optionName, optionValue); selectMenu.options[selectMenu.length] = newoption; selectMenu.options[selectMenu.length].selected = true; } function disableElement(target){ var targetDom = xoopsGetElementById(target); if (targetDom.disabled != true) { targetDom.disabled = true; } else { targetDom.disabled = false; } } function xoopsCheckAll(formname, switchid) { var ele = document.forms[formname].elements; var switch_cbox = xoopsGetElementById(switchid); for (var i = 0; i < ele.length; i++) { var e = ele[i]; if ( (e.name != switch_cbox.name) && (e.type == 'checkbox') ) { e.checked = switch_cbox.checked; } } } function xoopsCheckGroup(formname, switchid, groupid) { var ele = document.forms[formname].elements; var switch_cbox = xoopsGetElementById(switchid); for (var i = 0; i < ele.length; i++) { var e = ele[i]; if ( (e.type == 'checkbox') && (e.id == groupid) ) { e.checked = switch_cbox.checked; e.click(); e.click(); // Click to activate subgroups // Twice so we don't reverse effect } } } function xoopsCheckAllElements(elementIds, switchId) { var switch_cbox = xoopsGetElementById(switchId); for (var i = 0; i < elementIds.length; i++) { var e = xoopsGetElementById(elementIds[i]); if ((e.name != switch_cbox.name) && (e.type == 'checkbox')) { e.checked = switch_cbox.checked; } } } function xoopsSavePosition(id) { var textareaDom = xoopsGetElementById(id); if (textareaDom.createTextRange) { textareaDom.caretPos = document.selection.createRange().duplicate(); } } function xoopsInsertText(domobj, text) { if (domobj.createTextRange && domobj.caretPos){ var caretPos = domobj.caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text; } else if (domobj.getSelection && domobj.caretPos){ var caretPos = domobj.caretPos; caretPos.text = caretPos.text.charat(caretPos.text.length - 1) == ' ' ? text + ' ' : text; } else { domobj.value = domobj.value + text; } } function xoopsCodeSmilie(id, smilieCode) { var revisedMessage; var textareaDom = xoopsGetElementById(id); xoopsInsertText(textareaDom, smilieCode); textareaDom.focus(); return; } function showImgSelected(imgId, selectId, imgDir, extra, xoopsUrl) { if (xoopsUrl == null) { xoopsUrl = "./"; } imgDom = xoopsGetElementById(imgId); selectDom = xoopsGetElementById(selectId); imgDom.src = xoopsUrl + "/"+ imgDir + "/" + selectDom.options[selectDom.selectedIndex].value + extra; } function xoopsCodeUrl(id, enterUrlPhrase, enterWebsitePhrase){ if (enterUrlPhrase == null) { enterUrlPhrase = "Enter the URL of the link you want to add:"; } var text = prompt(enterUrlPhrase, ""); var domobj = xoopsGetElementById(id); if ( text != null && text != "" ) { if (enterWebsitePhrase == null) { enterWebsitePhrase = "Enter the web site title:"; } var text2 = prompt(enterWebsitePhrase, ""); if ( text2 != null ) { if ( text2 == "" ) { var result = "[url=" + text + "]" + text + "[/url]"; } else { var pos = text2.indexOf(unescape('%00')); if(0 < pos){ text2 = text2.substr(0,pos); } var result = "[url=" + text + "]" + text2 + "[/url]"; } xoopsInsertText(domobj, result); } } domobj.focus(); } function xoopsCodeImg(id, enterImgUrlPhrase, enterImgPosPhrase, imgPosRorLPhrase, errorImgPosPhrase){ if (enterImgUrlPhrase == null) { enterImgUrlPhrase = "Enter the URL of the image you want to add:"; } var text = prompt(enterImgUrlPhrase, ""); var domobj = xoopsGetElementById(id); if ( text != null && text != "" ) { if (enterImgPosPhrase == null) { enterImgPosPhrase = "Now, enter the position of the image."; } if (imgPosRorLPhrase == null) { imgPosRorLPhrase = "'R' or 'r' for right, 'L' or 'l' for left, or leave it blank."; } if (errorImgPosPhrase == null) { errorImgPosPhrase = "ERROR! Enter the position of the image:"; } var text2 = prompt(enterImgPosPhrase + "\n" + imgPosRorLPhrase, ""); while ( ( text2 != "" ) && ( text2 != "r" ) && ( text2 != "R" ) && ( text2 != "l" ) && ( text2 != "L" ) && ( text2 != null ) ) { text2 = prompt(errorImgPosPhrase + "\n" + imgPosRorLPhrase,""); } if ( text2 == "l" || text2 == "L" ) { text2 = " align=left"; } else if ( text2 == "r" || text2 == "R" ) { text2 = " align=right"; } else { text2 = ""; } var result = "[img" + text2 + "]" + text + "[/img]"; xoopsInsertText(domobj, result); } domobj.focus(); } function xoopsCodeEmail(id, enterEmailPhrase){ if (enterEmailPhrase == null) { enterEmailPhrase = "Enter the email address you want to add:"; } var text = prompt(enterEmailPhrase, ""); var domobj = xoopsGetElementById(id); if ( text != null && text != "" ) { var result = "[email]" + text + "[/email]"; xoopsInsertText(domobj, result); } domobj.focus(); } function xoopsCodeQuote(id, enterQuotePhrase){ if (enterQuotePhrase == null) { enterQuotePhrase = "Enter the text that you want to be quoted:"; } var text = prompt(enterQuotePhrase, ""); var domobj = xoopsGetElementById(id); if ( text != null && text != "" ) { var pos = text.indexOf(unescape('%00')); if(0 < pos){ text = text.substr(0,pos); } var result = "[quote]" + text + "[/quote]"; xoopsInsertText(domobj, result); } domobj.focus(); } function xoopsCodeCode(id, enterCodePhrase){ if (enterCodePhrase == null) { enterCodePhrase = "Enter the codes that you want to add."; } var text = prompt(enterCodePhrase, ""); var domobj = xoopsGetElementById(id); if ( text != null && text != "" ) { var result = "[code]" + text + "[/code]"; xoopsInsertText(domobj, result); } domobj.focus(); } function xoopsCodeText(id, hiddentext, enterTextboxPhrase){ var textareaDom = xoopsGetElementById(id); var textDom = xoopsGetElementById(id + "Addtext"); var fontDom = xoopsGetElementById(id + "Font"); var colorDom = xoopsGetElementById(id + "Color"); var sizeDom = xoopsGetElementById(id + "Size"); var xoopsHiddenTextDomStyle = xoopsGetElementById(hiddentext).style; var textDomValue = textDom.value; var fontDomValue = fontDom.options[fontDom.options.selectedIndex].value; var colorDomValue = colorDom.options[colorDom.options.selectedIndex].value; var sizeDomValue = sizeDom.options[sizeDom.options.selectedIndex].value; if ( textDomValue == "" ) { if (enterTextboxPhrase == null) { enterTextboxPhrase = "Please input text into the textbox."; } alert(enterTextboxPhrase); textDom.focus(); } else { if ( fontDomValue != "FONT") { textDomValue = "[font=" + fontDomValue + "]" + textDomValue + "[/font]"; fontDom.options[0].selected = true; } if ( colorDomValue != "COLOR") { textDomValue = "[color=" + colorDomValue + "]" + textDomValue + "[/color]"; colorDom.options[0].selected = true; } if ( sizeDomValue != "SIZE") { textDomValue = "[size=" + sizeDomValue + "]" + textDomValue + "[/size]"; sizeDom.options[0].selected = true; } if (xoopsHiddenTextDomStyle.fontWeight == "bold" || xoopsHiddenTextDomStyle.fontWeight == "700") { textDomValue = "[b]" + textDomValue + "[/b]"; xoopsHiddenTextDomStyle.fontWeight = "normal"; } if (xoopsHiddenTextDomStyle.fontStyle == "italic") { textDomValue = "[i]" + textDomValue + "[/i]"; xoopsHiddenTextDomStyle.fontStyle = "normal"; } if (xoopsHiddenTextDomStyle.textDecoration == "underline") { textDomValue = "[u]" + textDomValue + "[/u]"; xoopsHiddenTextDomStyle.textDecoration = "none"; } if (xoopsHiddenTextDomStyle.textDecoration == "line-through") { textDomValue = "[d]" + textDomValue + "[/d]"; xoopsHiddenTextDomStyle.textDecoration = "none"; } xoopsInsertText(textareaDom, textDomValue); textDom.value = ""; xoopsHiddenTextDomStyle.color = "#000000"; xoopsHiddenTextDomStyle.fontFamily = ""; xoopsHiddenTextDomStyle.fontSize = "12px"; xoopsHiddenTextDomStyle.visibility = "hidden"; textareaDom.focus(); } } function IsNumeric(strString){ // check for valid numeric strings (integer) var strValidChars = "0123456789"; var strChar; var isNum = true; if (strString.length == 0){ return false; } // test strString consists of valid characters listed above for (i = 0; i < strString.length && isNum == true; i++){ strChar = strString.charAt(i); if (strValidChars.indexOf(strChar) == -1){ isNum = false; } } return isNum; } function xoopsValidateFCK(subjectId, textareaId, submitId, plzCompletePhrase, msgTooLongPhrase, allowedCharPhrase, currCharPhrase) { var oEditor = FCKeditorAPI.GetInstance(textareaId) ; var editorcontent = oEditor.GetHTML(); var subjectDom = xoopsGetElementById(subjectId); var submitDom = xoopsGetElementById(submitId); if (editorcontent == "" || subjectDom.value == "") { if (plzCompletePhrase == null) { plzCompletePhrase = "Please complete the subject and message fields."; } alert(plzCompletePhrase); return false; } } function xoopsValidate(subjectId, textareaId, submitId, plzCompletePhrase, msgTooLongPhrase, allowedCharPhrase, currCharPhrase) { var maxchars = 65535; var subjectDom = xoopsGetElementById(subjectId); var textareaDom = xoopsGetElementById(textareaId); var submitDom = xoopsGetElementById(submitId); if (textareaDom.value == "" || subjectDom.value == "") { if (plzCompletePhrase == null) { plzCompletePhrase = "Please complete the subject and message fields."; } alert(plzCompletePhrase); return false; } if (maxchars != 0) { if (textareaDom.value.length > maxchars) { if (msgTooLongPhrase == null) { msgTooLongPhrase = "Your message is too long."; } if (allowedCharPhrase == null) { allowedCharPhrase = "Allowed max chars length: "; } if (currCharPhrase == null) { currCharPhrase = "Current chars length: "; } alert(msgTooLongPhrase + "\n\n" + allowedCharPhrase + maxchars + "\n" + currCharPhrase + textareaDom.value.length + ""); textareaDom.focus(); return false; } else { submitDom.disabled = true; return true; } } else { submitDom.disabled = true; return true; } } function printURL(){ if (window.printLayout) { printLayout=window.printLayout; } else { printLayout="print"; } if (window.printAuto) { printAuto=window.printAuto; } else { printAuto="0"; } var pathname=self.location.pathname; var query=self.location.search; // direct call for SEF startpage url (ie: http://{hostname}/) if (pathname == '/' && query == '') { return pathname+"index.php?layout="+printLayout+"&autoprint="+printAuto; } var parameters=new Array(); var params =new Array(); var seenLayout=false; var seenPrintAuto=false; query = query.substr(1, query.length - 1); query = query.replace(/%26/,'&'); params= query.split('&'); for (i = 0; i < params.length; i++){ if (params[i] != '') { parameters[i]=params[i].split('='); if (parameters[i][0]=="layout"){ seenLayout=true; parameters[i][1]=printLayout; } if (parameters[i][0]=="autoprint"){ seenPrintAutot=true; parameters[i][1]=printAuto; } } } if (!seenLayout){ parameters.push(new Array("layout", printLayout)); } if (!seenPrintAuto){ parameters.push(new Array("autoprint", printAuto)); } params=new Array(); for (i = 0; i < parameters.length; i++){ params[i]=parameters[i][0]+"="+parameters[i][1]; } query=params.join('&'); if (pathname.match(/^\/\d+$/)){ pathname +='/'; } return pathname + "?" + query; } function replaceParamFromLocation(param2replace, replacement_value){ // replaces value of a parameter from the URL var pathname=self.location.pathname; var query=self.location.search; var parameters=new Array(); var params =new Array(); var seenLayout=false; var seenParam2replace=false; query = query.substr(1, query.length - 1); query = query.replace(/%26/,'&'); params= query.split('&'); for (i = 0; i < params.length; i++){ parameters[i]=params[i].split('='); } params=new Array(); for (i = 0; i < parameters.length; i++){ if (parameters[i][0]==param2replace) { seenParam2replace=true; parameters[i][1]=replacement_value; } if (parameters[i][0] && parameters[i][1]) { params[i]=parameters[i][0]+"="+parameters[i][1]; } } if (!seenParam2replace) { params[i]=param2replace+"="+replacement_value; } query=params.join('&'); return pathname + "?" + query; } function replaceParamFromURL(url, param2replace, replacement_value){ // replaces value of a parameter from the URL var tokens=url.split("?"); var pathname=tokens[0]; var query=tokens[1]; var parameters=new Array(); var params =new Array(); var seenLayout=false; var seenParam2replace=false; query = query.replace(/%26/,'&'); params= query.split('&'); for (i = 0; i < params.length; i++){ parameters[i]=params[i].split('='); } params=new Array(); for (i = 0; i < parameters.length; i++){ if (parameters[i][0]==param2replace) { seenParam2replace=true; parameters[i][1]=replacement_value; } if (parameters[i][0] && parameters[i][1]) { params[i]=parameters[i][0]+"="+parameters[i][1]; } } if (!seenParam2replace) { params[i]=param2replace+"="+replacement_value; } query=params.join('&'); return pathname + "?" + query; } function getParamFromLocation(param2get){ // get value of a parameter from the URL var query=self.location.search; var parameters=new Array(); var params =new Array(); var seenLayout=false; query = query.substr(1, query.length - 1); query = query.replace(/%26/,'&'); params= query.split('&'); for (i = 0; i < params.length; i++){ parameters[i]=params[i].split('='); } params=new Array(); for (i = 0; i < parameters.length; i++){ if (parameters[i][0]==param2get) { return parameters[i][1]; } } // parameter not found return false; } function openPrintWindow(){ if(window.printLayout == 'wsContainerPrint'){ window.print(); } else { oNewWindow = window.open(printURL(), "_blank"); } } function gotoWsContentPage(pageId){ var pathname=self.location.pathname; if (window.location_id > 0) { var location_id = window.location_id; } else { var location_id = 0; } // Handle first page var gotoUrl=false; if (pathname=="/" ) { gotoUrl="/content/" + location_id + "/"+pageId+"/"; //alert("First Page!\nGotoURL is "+gotoUrl); } else { path_tokens=pathname.split('/'); if (typeof(path_tokens)=="object") { if (path_tokens[1]) { //alert(path_tokens[1]); if (path_tokens[1].match(/^\d\d*$/)) { gotoUrl="/content/"+path_tokens[1]+"/"+pageId+"/"; //alert("This is a location id\nGotoURL is "+gotoUrl); } else if (path_tokens[1].match(/^content*$/)) { gotoUrl="/content/"+path_tokens[2]+"/"+pageId+"/"; //alert("This is content\nGotURL is "+gotoUrl); } else if (path_tokens[1].match(/^modules*$/) && path_tokens[2].match(/^wsContent*$/)) { gotoUrl=replaceParamFromLocation("page", pageId); //alert("Module/wsContent.\nGotoURL is " + gotoUrl); } } } } if (!gotoUrl) { gotoUrl="/content/" + location_id + "/"+pageId+"/"; } if (gotoUrl) { self.location=gotoUrl; } return false; } function switchLanguage(lang_code){ // Match urls that have language in them // such as https://www.sailingworld.eu/en/content/61/48/sailing-jets url_path_info = URLPathInfo.getPathInfo(window.location.href); pathParts = url_path_info.path.split('/'); // console.log(url_path_info); // console.log(pathParts); // console.log(pathParts[1]); if (pathParts[1].match(/^[a-z][a-z]$/)){ if (pathParts[1] == lang_code){ console.log('same lang'); return; } // console.log('its a lang'); pathParts[1] = lang_code; new_url_path = pathParts.join('/'); console.log('Must go to ' + new_url_path); self.location = new_url_path; return; } gotoUrl=replaceParamFromLocation("wslanguage", lang_code); if (gotoUrl) { self.location=gotoUrl; } } function downloadFile(fileId) { var location_id = getParamFromLocation('location_id') || 0 ; var page_id = getParamFromLocation('page'); var hostname = self.location.host; var path_upload = '/modules/uploadmanager11/admin/index.php?action=file_download&file_id='+fileId; var href_file = 'http://'+hostname+path_upload+'&location_id='+location_id; window.open(href_file); //self.location.href = href_file; //return false; } function filemanagerDownload(fileId, fileName){ var location_id = getParamFromLocation('location_id') || 0 ; var page_id = getParamFromLocation('page'); var hostname = self.location.host; var path_upload = '/files/' + fileId + '/' + fileName; var href_file = 'http://'+hostname+path_upload; window.open(href_file); } function scrollToTop(){ window.scroll(0,0); } //window.onload=scrollToTop; //window.attachEvent("onload", scrollToTop); function argObject(name,value) { this.name=name; this.value=value; } function remoteCall (url,args){ var n = args[0]; var head = document.getElementsByTagName('head').item(0); var old = document.getElementById(n.value); if (old) { head.removeChild(old); } script = document.createElement('script'); script.type = 'text/javascript'; script.defer = true; script.id = n.value; // Just call it somehow.... var text="?"; for(var i=0;i '+attachment.display_name+' '; } else { display.innerHTML = attachment.display_name+' '; } if (matches = id.match(/^(.*)_multi_([0-9]+)$/)) { var fct = 'handler_'+matches[1].replace(/[\[\]]/g,"_"); var cmd = fct+"('"+id+"')"; eval(cmd); } else { var delete_btn_id = 'deletebutton'+id; var delete_btn = document.getElementById(delete_btn_id); if (delete_btn) { delete_btn.style.display='inline'; } } if (window.direct_execute_after_processing_attachment) { form_id=window.direct_execute_after_processing_attachment; form=document.getElementById(form_id); form.submit(); } } function resizeIFrame(frame){ //find the height of the internal page var the_height=frame.contentWindow. document.body.scrollHeight; var the_width=frame.contentWindow. document.body.scrollWidth; //change the height of the iframe frame.height=the_height+10; //change the width of the iframe frame.width=the_width+100; } function getDeleteLabel() { return "Delete"; } function addOption(parentNode, eleName, widget, size, maxlength){ var countId = eleName + "_counter"; var lastId = parseInt(document.getElementById(countId).value); var nextId = lastId + 1; var item = document.createElement("tr"); var td1 = document.createElement("td"); var td2 = document.createElement("td"); item.appendChild(td1); item.appendChild(td2); item.id = nextId; item.className = 'odd'; parentNode.parentNode.insertBefore(item,parentNode); var s1 = ""; var s2 = ""; td1.innerHTML = s1; td2.innerHTML = s2; document.getElementById(countId).value++; } function delOption(parentNode,eleName,next){ var countId = eleName + "_counter"; var count = document.getElementById(countId).value; if(count == 1){ return; } parentNode.parentNode.parentNode.removeChild(parentNode.parentNode); document.getElementById(countId).value--; /* if(next > 0){ var item = document.createElement("input"); item.type = "hidden"; item.name = eleName + "[delete_values]["+next+"]"; item.value = next; document.objects_form.appendChild(item); } */ } function changeStyle(o,c){ o.className = c; } function openWSMediaStreamer(url, width, height) { params="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no"; return openWithSelfMain(url,"wsMediaStreamer",width,height, params); } function openWSVideoStreamer(flv, width, height, videotype, autostart) { if (!flv) { return; } if (!width) { width=400; } if (!height) { height=300; } if (!videotype) { videotype="file"; } windowWidth=width; windowHeight=height+20; if (videotype=="yt") { _url="/modules/wsVideoStreamer/player/index.php?yt="+flv; } else { _url="/modules/wsVideoStreamer/player/index.php?file="+flv; } _url+="&autostart="+autostart; if (width) { _url+="&width="+width; } if (height) { _url+="&height="+height; } params="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no"; return openWithSelfMain(_url,"wsVideoStreamer",windowWidth,windowHeight, params); } function openIRCChatWindow(width, height) { if (!width) { width=640; } if (!height) { height=480; } if (!window.uid) { return; } if (!window._domain_id) { return; } if (!window.chatName) { return; } windowWidth=width; windowHeight=height; //_url="http://217.196.177.143:2001/chat.html?nickname=" + window.chatName + "&channel=" + window._domain; _url="http://chatserver.worldsoft-cms.info:2001/chat.html?key=u"+window.uid+"d"+window._domain_id; if (width) { _url+="&width="+width; } if (height) { _url+="&height="+height; } return openWithSelfMain(_url,"ircChatWindow",windowWidth,windowHeight, "status=no,location=no"); } function checkout(id,qty){ lyr=xoopsGetElementById("checkout_"+id); _url="/checkout.php?article_id="+id+"&quantity="+qty; //self.location="/checkout.php?article_id="+id+"&quantity="+qty; lyr.innerHTML="
";; //self.location="/checkout.php?article_id="+id+"&quantity="+qty; } function normalizeDomain(domain){ value = domain.toLowerCase(); value=value.replace(/\s/g, ''); value=value.replace(/^http:\/\//, ''); value=value.replace(/^https:\/\//, ''); value=value.replace(/^www\./, ''); value=value.replace(/\/.*/, ''); value=value.replace(/:.*/, ''); return value; } function doLostPassword(){ if (window._wbs) { window.location = window._wbs_widget_url + "/access/forgot-mode-choose/" + window._wbs_company_id; return; } return openDialog('/ajax/lost.pass.request.php'); } function doQuickLogin(type){ var url = type == 'wbsshop' ? '/modules/wbsShop/ajax/quickdlogin.php' : '/ajax/quicklogin.php'; console.log("xoops.js:doQuickLogin. Opening url: " + url); var params = ''; if (typeof(arguments[0])=='object') { for (var i in arguments[0]) { params += i + '=' + encodeURIComponent(arguments[0][i]); } } return openDialog(url+(params?'?'+params:''), 400); } function openDialog(url, width){ if (!width) { width=600; } if (!xoopsGetElementById("dialog")){ console.log("Creating a div with id dialog"); jQuery('body').append('
'); } if (xoopsGetElementById("dialog")){ // jQuery("#dialog").dialog("destroy"); jQuery("#dialog").load(url).dialog({ width: width, modal: true, draggable: false, resizable: false, open: function() { var $btn = $(this).closest('.ui-dialog').find('.ui-dialog-titlebar-close'); $btn.addClass('ui-button ui-corner-all ui-widget ui-button-icon-only') .html(' Close'); $(this).closest('.ui-dialog').css('max-width', width).css('width', '100%'); } }).parent('.ui-dialog').css('zIndex',9999999); if(jQuery("#dialog").hasClass("ui-dialog-content") && jQuery("#dialog").dialog("isOpen")) { jQuery("#dialog").closest('.ui-dialog').css('max-width', width).css('width', '100%'); } return; } } function openJQMWindow(url,width,height){ return openDialog(url, width); } // Returns the translation of a string for JS consumption function getPO(str){ translation_div_name="JSPO"+str; html=jQuery('#'+translation_div_name).html(); return (html)?html:str; } // Replace, remove or add js or css file. function removejscssfile(filename, filetype){ var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type to create nodelist from var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding attribute to test for var allsuspects=document.getElementsByTagName(targetelement) for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove if (allsuspects[i] && allsuspects[i].getAttribute(targetattr)!=null && allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1) allsuspects[i].parentNode.removeChild(allsuspects[i]) //remove element by calling parentNode.removeChild() } } function createjscssfile(filename, filetype){ if (filetype=="js"){ //if filename is a external JavaScript file var fileref=document.createElement('script'); fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src", filename); } else if (filetype=="css"){ //if filename is an external CSS file var fileref=document.createElement("link"); fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", filename); } return fileref; } function replacejscssfile(oldfilename, newfilename, filetype){ var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type to create nodelist using var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding attribute to test for var allsuspects=document.getElementsByTagName(targetelement) for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove if (allsuspects[i] && allsuspects[i].getAttribute(targetattr)!=null && allsuspects[i].getAttribute(targetattr).indexOf(oldfilename)!=-1){ var newelement=createjscssfile(newfilename, filetype) allsuspects[i].parentNode.replaceChild(newelement, allsuspects[i]) } } } // Open imagemanager to choose an image function openImagemanager(target){ openWithSelfMain("/modules/system/admin.php?fct=images&from_fck=1&target="+target+"&callback_function=manageImageAfterLoad()","imgmanager",700,450); return false; } // Callback for the imagemanager function manageImageAfterLoad(){ console.log("Running manageImageAfterLoad"); var img_id = $('#image_id').val(); console.log("img_id is " + img_id); if(img_id.substring(0, 8) == "[img id="){ var image_id = (img_id).substring(8,(img_id).indexOf("]",0)); console.log("image_id retrieved is " + image_id); $('#image_id').val(image_id); $('#thumbnail_image_id').attr('src', '/image.php?id=' + image_id); } } function isValidAscii(str){ if(typeof(str)!=='string'){ return false; } for(var i=0;i127){ return false; } } return true; } function scriptLoader() {}; scriptLoader.loaded = {}; scriptLoader.loadOnce = function(script) { if (!scriptLoader.loaded[script]) { loadScript(script); scriptLoader.loaded[script]=true; } }