Edit C:\galaxie\deploy\Tomcat6\webapps\galaxie\js\utils.js
/****************************************************************************** * Copyright (c) 2000-2011 e-Deal * * e-Deal S.A. * 55 rue Brillat Savarin * 75013 Paris * France * * T: +33 (0)1 53 80 80 30 * F: +33 (0)1 73 01 69 77 * http://www.e-deal.com * * La diffusion de ce code source sous quelque forme que ce soit sans * l'autorisation de E-DEAL est interdite. * * Vous �tes autoris�s � modifier ce code source uniquement pour votre usage * propre et sous r�serve que les mentions de copyright demeurent intactes. * * Ce code est fourni en l'�tat. Aucune garantie d'aucune sorte, explicite ou * implicite n'est donn�e. En aucun cas E-DEAL ne pourra �tre tenu pour * responsable des dommages pouvant r�sulter de l'utilisation de ce code * source. ******************************************************************************/ /** * Remove all selected items from a select multiple object. * fldName specified an hidden input containing list the values separated by '$$multivalSeparator'. * The name of the select multiple element is 'lbl' + fldName. If not exist, it is just fldName and * the string representation of the values list doesn't be store. * * @param fldName name of the field (required). * @param frmName name of the form (optional, default is forms[0]). */ function unselectMultiple(fldName, frmName) { var f = null; var i; if(frmName) { f = document.forms[frmName]; } else { f = document.forms[0]; } if(!f) return; var lblFld = f.elements['lbl' + fldName]; var realFld = f.elements[fldName]; var multivalSeparator = (f.elements['$$multivalSeparator'] ? f.elements['$$multivalSeparator'].value : '|'); var usedFld = lblFld ? lblFld : realFld; if(usedFld && usedFld.selectedIndex != -1) { if(lblFld) { var vectValue = realFld.value.split(multivalSeparator); for(i = lblFld.options.length - 1; i >= 0; i--) { fldValue = lblFld.options[i].value; if(fldValue != '_blank') { if(lblFld.options[i].selected) { lblFld.options[i] = null; vectValue[i] = null; } } } realFld.value = ''; for(i = 0, j = 0; i < vectValue.length; i++) { realFld.value += (vectValue[i] == null ? '' : (j++ == 0 ? '' : multivalSeparator) + vectValue[i]); } } else { for(i = realFld.options.length - 1; i >= 0; i--) { fldValue = realFld.options[i].value; if(fldValue != '_blank') { if(realFld.options[i].selected) { realFld.options[i] = null; } } } } } } /** * Convert money (in String) in another currency * Conversion can be only from a euro-zone currency to euro or reverse * Symbols : * frf : Franc francais * dem : Deutsch mark * itl : Lire italienne * iep : Livre irlandaise * esp : Peseta espagnole * pte : Escudo portugais * nlg : Florin hollandais * fim : Mark finlandais * bef : Franc belge * luf : Franc luxembourgeois * ats : Shilling autrichien * eur : Euro */ function convert(money, curr1, curr2) { if (money == '') { return ''; } var value = parseFloat(money); if (isNaN(value)) { return ''; } var convVal; if (curr1.toLowerCase() == 'frf' && curr2.toLowerCase() == 'eur') { // conversion franc francais -> euro convVal = (100 *parseFloat(value)) / 6.55957; } else if (curr1.toLowerCase() == 'eur' && curr2.toLowerCase() == 'frf') { // conversion euro -> franc francais convVal = (100 *parseFloat(value)) * 6.55957; } else if (curr1.toLowerCase() == 'dem' && curr2.toLowerCase() == 'eur') { // conversion mark (Allemagne) -> euro convVal = (100 *parseFloat(value)) / 1.95583; } else if (curr1.toLowerCase() == 'eur' && curr2.toLowerCase() == 'dem') { // conversion euro -> mark (Allemagne) convVal = (100 *parseFloat(value)) * 1.95583; } else if (curr1.toLowerCase() == 'itl' && curr2.toLowerCase() == 'eur') { // conversion lire (Italie) -> euro convVal = (100 *parseFloat(value)) / 1936.27; } else if (curr1.toLowerCase() == 'eur' && curr2.toLowerCase() == 'itl') { // conversion euro -> lire (Italie) convVal = (100 *parseFloat(value)) * 1936.27; } else if (curr1.toLowerCase() == 'iep' && curr2.toLowerCase() == 'eur') { // conversion livre irlandaise -> euro convVal = (100 *parseFloat(value)) / 0.787564; } else if (curr1.toLowerCase() == 'eur' && curr2.toLowerCase() == 'iep') { // conversion euro -> livre irlandaise convVal = (100 *parseFloat(value)) * 0.787564; } else if (curr1.toLowerCase() == 'esp' && curr2.toLowerCase() == 'eur') { // conversion peseta (Espagne) -> euro convVal = (100 *parseFloat(value)) / 166.386; } else if (curr1.toLowerCase() == 'eur' && curr2.toLowerCase() == 'esp') { // conversion euro -> peseta (Espagne) convVal = (100 *parseFloat(value)) * 166.386; } else if (curr1.toLowerCase() == 'pte' && curr2.toLowerCase() == 'eur') { // conversion escudo (Portugal) -> euro convVal = (100 *parseFloat(value)) / 200.482; } else if (curr1.toLowerCase() == 'eur' && curr2.toLowerCase() == 'pte') { // conversion euro -> escudo (Portugal) convVal = (100 *parseFloat(value)) * 200.482; } else if (curr1.toLowerCase() == 'nlg' && curr2.toLowerCase() == 'eur') { // conversion florin (Pays-Bas) -> euro convVal = (100 *parseFloat(value)) / 2.20371; } else if (curr1.toLowerCase() == 'eur' && curr2.toLowerCase() == 'nlg') { // conversion euro -> florin (Pays-Bas) convVal = (100 *parseFloat(value)) * 2.20371; } else if (curr1.toLowerCase() == 'fim' && curr2.toLowerCase() == 'eur') { // conversion Mark finlandais (Finlande) -> euro convVal = (100 *parseFloat(value)) / 5.94573; } else if (curr1.toLowerCase() == 'eur' && curr2.toLowerCase() == 'fim') { // conversion euro -> Mark finlandais (Finlande) convVal = (100 *parseFloat(value)) * 5.94573; } else if (curr1.toLowerCase() == 'bef' && curr2.toLowerCase() == 'eur') { // conversion franc belge -> euro convVal = (100 *parseFloat(value)) / 40.3399; } else if (curr1.toLowerCase() == 'eur' && curr2.toLowerCase() == 'bef') { // conversion euro -> franc belge convVal = (100 *parseFloat(value)) * 40.3399; } else if (curr1.toLowerCase() == 'luf' && curr2.toLowerCase() == 'eur') { // conversion franc luxembourgeois -> euro convVal = (100 *parseFloat(value)) / 40.3399; } else if (curr1.toLowerCase() == 'eur' && curr2.toLowerCase() == 'luf') { // conversion euro -> franc luxembourgeois convVal = (100 *parseFloat(value)) * 40.3399; } else if (curr1.toLowerCase() == 'ats' && curr2.toLowerCase() == 'eur') { // conversion schilling (Autriche) -> euro convVal = (100 *parseFloat(value)) / 13.7603; } else if (curr1.toLowerCase() == 'eur' && curr2.toLowerCase() == 'ats') { // conversion euro -> schilling (Autriche) convVal = (100 *parseFloat(value)) * 13.7603; } return (Math.round(convVal)/100).toString(); } /* removing leading and tail spaces and replaces mlti^le spaces by one single space */ function trimStr(str) { if (str == "") { return str; } var res = str; while (res.indexOf(" ") > -1) { res = res.split(" ").join(" "); } if (res.indexOf(" ") == 0) { res = res.substring(1); } if (res.lastIndexOf(" ") == (res.length - 1)) { res = res.substring(0, res.length - 1); } return res; } function flEscape(str) { if (str == "") { return str; }else { //return escape(str).split("+").join("%2b"); return encodeURIComponent(str).split("+").join("%2b"); } } /** * replaces some special caracters by corresponding codes */ function formatToWeb(str, edit) { var result; // if (!str || trimStr(str).length == 0) if (false) result = edit ? "" : " "; else { var buffer = ""; var c; var i; for (i = 0; i < str.length; i++) { c = str.substring(i, i+1); switch (c) { case '\n' : buffer += edit ? "\n" : "<br>"; break; case '<' : buffer += "<"; break; case '>' : buffer += ">"; break; case '&' : buffer += "&"; break; case '"' : buffer += """; break; case 'à' : buffer += "à"; break; case 'â' : buffer += "â"; break; case 'ä' : buffer += "ä"; break; case 'é' : buffer += "é"; break; case 'è' : buffer += "è"; break; case 'ê' : buffer += "ê"; break; case 'ë' : buffer += "ë"; break; case 'î' : buffer += "î"; break; case 'ï' : buffer += "ï"; break; case 'ô' : buffer += "ô"; break; case 'ö' : buffer += "ö"; break; case 'ù' : buffer += "ù"; break; case 'û' : buffer += "û"; break; case 'ü' : buffer += "ü"; break; case '¤' : buffer += "¤"; break; case '£' : buffer += "£"; break; case 'µ' : buffer += "µ"; break; case '²' : buffer += "²"; break; case '§' : buffer += "§"; break; case 'ç' : buffer += "ç"; break; default : buffer += c; } } result = buffer; } return result; } /** * replaces some special caracters by corresponding codes */ function formatToJavascript(pStr) { var i = 0; var strResult = ''; // if (!str || trimStr(str).length == 0) if(pStr) { for(i = 0; i < pStr.length; i++) { c = pStr.charAt(i); switch (c) { case '\n' : strResult += '\\n'; break; case '"' : strResult += '\\\"'; break; case '\'' : strResult += '\\\''; break; case '\\' : strResult += '\\\\'; break; default : strResult += c; } } } return strResult; } /** * returns the given number rounded up to the given number of decimals */ function roundDecimal(nbr , nbDecimals) { var multi = 1; var i; var nbDec = 2; if (nbDecimals) nbDec = nbDecimals; for (i=0 ; i < nbDec ; i++) multi *= 10; return (Math.round(multi * nbr)/multi); } /** * replace key by value in specified string */ function strReplace(pStr, pKey, pValue) { return pStr.split(pKey).join(pValue); } /** * lite Vector class */ function FlVector(pArray) { this.elements = pArray ? pArray : new Array(); this.size = FlVectorSize; this.isEmpty = FlVectorIsEmpty; this.addElement = FlVectorAddElement; this.removeElementAt = FlVectorRemoveElementAt; this.removeElement = FlVectorRemoveElement; this.elementAt = FlVectorElementAt; this.contains = FlVectorContains; this.toString = FlVectorToString; } function FlVectorSize() { return this.elements.length; } function FlVectorIsEmpty() { return this.elements.length == 0; } function FlVectorAddElement(pObj) { this.elements[this.elements.length] = pObj; } function FlVectorRemoveElementAt(pIndex) { var i = 0; if(pIndex >= 0 && pIndex < this.elements.length) { this.elements[pIndex] = null; for(i = pIndex + 1; i < this.elements.length; i++) { this.elements[i - 1] = this.elements[i]; } this.elements.length = this.elements.length - 1; } } function FlVectorRemoveElement(pObj) { var i = 0; for(i = 0; i < this.elements.length; i++) { if(this.elements[i] == pObj) { this.removeElementAt(i); } } } function FlVectorElementAt(pIndex) { if(pIndex >= 0 && pIndex < this.elements.length) { return this.elements[pIndex]; } else { return null; } } function FlVectorContains(pObj) { var i = 0; for(i = 0; i < this.elements.length; i++) { if(this.elements[i] == pObj) { return true; } } return false; } function FlVectorToString(pSeparator) { return this.elements.join(pSeparator ? pSeparator : ';'); } function trimString(str) { str = this != window? this : str; return str.replace(/^\s+/g, '').replace(/\s+$/g, ''); } String.prototype.trim = trimString; function arrayIndexOf(value, array) { array = this != window ? this : array; if (array) { for (var i = 0; i < array.length; i++) { if (array[i] == value) { return i; } } } return -1; } function arrayLastIndexOf(value, array) { array = this != window ? this : array; if (array) { for (var i = array.length - 1; i <= 0; i--) { if (array[i] == value) { return i; } } } return -1; } function replaceParam(url, paramName, newValue){ if (!url) { return; } var queryStringIdx = url.indexOf("?"); if (queryStringIdx == -1) { return url + "?" + paramName + "=" + encodeURIComponent(newValue); } var queryString = url.substring(queryStringIdx + 1, url.length); var paramNames = new Array(); var paramValues = new Array(); var params = queryString.split('&'); var paramIdx = -1; for (var i = 0; i < params.length; i++) { var idx = params[i].indexOf("="); paramNames[i] = params[i].substring(0, idx); if (paramNames[i] == paramName && paramIdx == -1) { paramIdx = i; } paramValues[i] = params[i].substring(idx + 1, params[i].length); } if (paramIdx == -1) { paramNames.push(paramName); paramValues.push(newValue); } else { paramValues[paramIdx] = newValue; } var newQueryArray = new Array(); for (var i =0; i < paramNames.length; i++) { if (paramValues[i]) { newQueryArray.push(paramNames[i] + "=" + paramValues[i]); } } return url.substring(0, queryStringIdx) + "?" + newQueryArray.join("&"); } /* * Allowing to impose a max length for * provided object (textarea for example) * And display specified message in order * to inform current user if its text is * truncate */ function imposeMaxLength(Event, Object) { var MaxLenght = 3000; if(Event.type="blur" && Object.value.length > MaxLenght){ alert(getMessage("M903F","Champ tronqué à la limite de taille suivante:", true)+" "+MaxLenght); Object.value = Object.value.substring(0, MaxLenght); } return (Object.value.length < MaxLenght)||(Event.keyCode == 8 ||Event.keyCode==46||(Event.keyCode>=35&&Event.keyCode<=40)); }
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de