///////////////////////////////////////////////////////////////////////////// /// /// BIBLIOTECA DE JAVASCRIPTS /// /// (c) Paco Calvo Savall - OPENSOLUTIONS, S.L. /// paco.calvo@opensolutions.es /// ///////////////////////////////////////////////////////////////////////////// ///========================================== /// /// vistaCookie() /// /// Guardem en una Cookie la vista actual per saber /// en tot moment de d'on hem ober un document. /// ///========================================== function vistaCookie() { document.cookie = 'name=vistaActual%vista=' + escape(document.forms[0].vista.value) + '%'; } ///========================================== /// /// recuperaVistaCookie /// /// Obté la vista actual que hem guardat previament amb /// "vistaCookie()" /// ///========================================== function recuperaVistaCookie() { var vista = ''; if (document.cookie != '') { var c1 = document.cookie; var vistaCad = '%vista='; var c2 = c1.indexOf(vistaCad); if (c2 >= 0) { var c3 = c1.substring((c2 + vistaCad.length),c1.length); vistaCad = '%' c2 = c3.indexOf(vistaCad); if (c2 >= 0) { vista = c3.substring(0,c2); } else { vista = c3; } } } return unescape(vista); } ///========================================== /// /// obriFinestra(URL, titol,param) /// /// Descripció: /// Permet obrir una URL en una altra finestra. /// /// Paràmetres: /// URL: adreça a obrir. /// titol: identificador de la nova finestra. /// param: cadena separada per comes amb les opcions que volem /// aplicar a la finestra. /// ///========================================== function obriFinestra(URL,titol,parametres) { var u, t, p; u = URL; t = titol; p = parametres; if (p == '') { novaFinestra = window.open(u, t); } else { novaFinestra = window.open(u, t, p); } novaFinestra.focus() } ///========================================== /// /// posicionaEn(camp) /// /// Descripció: /// Situa el cursor en "camp", transferint-li el focus i seleccionant el contingut. /// /// Paràmetres: /// camp: nom de l'objecte que volem que tinga el focus. /// ///========================================== function posicionaEn(camp) { if (document.forms) { var obj = eval('document.forms[0].' + camp); obj.focus(); obj.select(); } } function posicionaEnLlista(camp) { if (document.forms) { var obj = eval('document.forms[0].' + camp); obj.focus(); } } ///========================================== /// /// esBlanc(cad) /// /// Descripció: /// Retorna "true" si la cadena "cad" conté sols espais en blanc. /// /// Paràmetres: /// cad: cadena a avaluar. /// ///========================================== function esBlanc(cad) { var text = String(cad); var longitut = text.length; for(var i = 0; i < longitut; i++) { var c = cad.charAt(i); if ((c != ' ') && (c != '\n') && (c != '\t')) return false; } return true; } ///========================================== /// /// ltrim(camp) /// /// Descripció: /// Elimina els blancs inicials d'un camp. /// /// Paràmetres: /// camp: camp a processar. /// ///========================================== function ltrim(camp) { var cadena = ""; var a = ""; var text = String(camp); var longitut = text.length; var i = 0; while (i <= longitut) { a = text.substr(i, 1); if (a != " ") { cadena = cadena + a; } i++ } return cadena } ///========================================== /// /// efecteBoto /// /// Controlador de l'aspecte d'un objecte en funció dels events de la rata. /// ///========================================== function efecteBoto(obj, accio) { var cDamunt = 'rgb(255, 255, 255)'; var cBarra = 'rgb(225, 235, 245)'; var cTextBarra = 'rgb(16, 25, 135)'; var cTextDamunt = 'rgb(16, 25, 135)'; if (accio == 'damunt') { obj.style.backgroundColor= cDamunt; obj.style.color= cTextDamunt; // obj.style.borderTop='solid #cccccc 1px'; // obj.style.borderLeft='solid #cccccc 1px'; // obj.style.borderRight='solid black 1px'; // obj.style.borderBottom='solid black 1px'; } else if (accio == 'dalt') { obj.style.backgroundColor= cDamunt; obj.style.color= cBarra; // obj.style.borderTop='solid #cccccc 1px'; // obj.style.borderLeft='solid #cccccc 1px'; // obj.style.borderRight='solid black 1px'; // obj.style.borderBottom='solid black 1px'; } else if (accio == 'baix') { obj.style.backgroundColor= cDamunt; obj.style.color= cBarra; // obj.style.borderTop='solid black 1px'; // obj.style.borderLeft='solid black 1px'; // obj.style.borderRight='solid #cccccc 1px'; // obj.style.borderBottom='solid #cccccc 1px'; } else if (accio == 'fora') { obj.style.backgroundColor= cBarra; obj.style.color= cTextBarra; // obj.style.border='solid ' + cBarra + ' 1px'; } } function efecteBoto2(obj, accio) { var cDamunt = 'rgb(255, 255, 255)'; var cBarra = 'rgb(226, 226, 226)'; var cTextBarra = 'rgb(0, 0, 0)'; var cTextDamunt = 'rgb(0, 0, 0)'; if (accio == 'damunt') { obj.style.backgroundColor= cDamunt; obj.style.color= cTextDamunt; // obj.style.borderTop='solid #cccccc 1px'; // obj.style.borderLeft='solid #cccccc 1px'; // obj.style.borderRight='solid black 1px'; // obj.style.borderBottom='solid black 1px'; } else if (accio == 'dalt') { obj.style.backgroundColor= cDamunt; obj.style.color= cBarra; // obj.style.borderTop='solid #cccccc 1px'; // obj.style.borderLeft='solid #cccccc 1px'; // obj.style.borderRight='solid black 1px'; // obj.style.borderBottom='solid black 1px'; } else if (accio == 'baix') { obj.style.backgroundColor= cDamunt; obj.style.color= cBarra; // obj.style.borderTop='solid black 1px'; // obj.style.borderLeft='solid black 1px'; // obj.style.borderRight='solid #cccccc 1px'; // obj.style.borderBottom='solid #cccccc 1px'; } else if (accio == 'fora') { obj.style.backgroundColor= cBarra; obj.style.color= cTextBarra; // obj.style.border='solid ' + cBarra + ' 1px'; } }