1/** 2Utiles.class.js 3 4Descripcion: 5Contiene funciones basicas y utiles para el uso comun. 6Próximamente podrÃa quedar obsoleto o ser modificado masivamente, por lo tanto, 7la documentación es básica 8 9Dependencias: 10Ninguna 11 12Versión: 133.1.0 - 04/07/2011 14Más información en Utiles.txt 15 16**/ 17 18var Utiles = { 19 20 /** 21 * Zona de Configuraciones 22 */ 23 dirCgiBin: '/cgi-bin', 24 prontusName: '/cencosud', 25 serverName: 'http://www.tusitio.cl', 26 27 cgiNameImprimir: 'prontus_imprimir.cgi', 28 formEnviar: '/stat/enviar/formulario.html', 29 configComun: 'toolbar=0,status=0,menubar=0,location=0,directories=0', 30 msgWin: 'Debes habilitar las ventanas emergentes en tu navegador para acceder a esta funcionalidad.', 31 msgBadBrowser: 'Su browser no soporta esta caracterÃstica', 32 widthEnviar: 400, 33 heightEnviar: 455, 34 35 /** 36 * Para el Envio de noticia por e-mail. 37 * Sólo abre el formulario, no llama directamente a la CGI 38 * @param file Ruta al artÃculo, se puede usar %%_FILE%% (opcional) 39 * @param w Ancho de la ventana (opcional) 40 * @param h alto de la ventana (opcional) 41 */ 42 enviarArticulo: function (file, w, h, subject) { 43 var url; 44 if(typeof file !== 'undefined' && file!='') { 45 url = file; 46 } else { 47 url = document.URL; 48 }; 49 50 w = (typeof w !== 'undefined' && w !== null && w !== '') ? w : Utiles.widthEnviar; 51 h = (typeof h !== 'undefined' && h !== null && h !== '') ? h : Utiles.heightEnviar; 52 var strsubject = ''; 53 if(typeof subject !== 'undefined' && subject !== null && subject !== '') { 54 strsubject = '&_SUB='+window.escape(subject); 55 } 56 57 var loc = Utiles.prontusName + Utiles.formEnviar+'?_URL=' + window.escape(url) + strsubject; 58 var config = 'width='+w+',height='+h+',scrollbars=0,resizable=0,' + Utiles.configComun; 59 var envia = window.open(loc,'enviar', config); 60 if(envia) { 61 envia.focus(); 62 } else { 63 alert(Utiles.msgWin); 64 return; 65 } 66 envia.focus(); 67 }, 68 69 /** 70 * Abre la ventana para imprimir el artÃculo actual. 71 * Con soporte para multivistas 72 * @param file Ruta al artÃculo, se puede usar %%_FILE%% 73 * @param mv nombre de la multivista 74 * @param w Ancho de la ventana (opcional) 75 * @param h alto de la ventana (opcional) 76 */ 77 imprimirArticulo: function (file, mv, w, h) { 78 var url; 79 if(typeof file !== 'undefined' && file!='') { 80 var matches = file.match(/^(.*?\/pags)\-\w+(\/.*?)$/); 81 if(matches === null || matches.length != 3) { 82 url = file; 83 } else { 84 url = matches[1] + matches[2]; 85 } 86 } else { 87 url = document.URL; 88 }; 89 var mvcookie; 90 if(typeof mv !== 'undefined' && mv!='') { 91 mvcookie = '_MV='+mv+'&'; 92 } else { 93 mvcookie = ''; 94 } 95 var loc = Utiles.dirCgiBin+'/'+Utiles.cgiNameImprimir+'?'+mvcookie+'_url=' + window.escape(url); 96 w = (typeof w !== 'undefined') ? w : screen.availWidth/2; 97 h = (typeof h !== 'undefined') ? h : screen.availHeight*0.9; 98 99 var config = 'width='+w+',height='+h+',scrollbars=1,resizable=0,'+Utiles.configComun; 100 var imprimir = window.open(loc,'imprimir', config); 101 if(imprimir) { 102 imprimir.focus(); 103 } else { 104 alert(Utiles.msgWin); 105 return; 106 } 107 imprimir.focus(); 108 }, 109 110 /** 111 * Abre una ventana pop generica 112 * @param loc Url de la pagina que se abrira en la pop 113 * @param nom nombre de la ventana 114 * @param ancho ancho de la ventana 115 * @param alto alto de la ventana 116 * @param posx posicion X de la ventana 117 * @param posy posicion Y de la ventana 118 */ 119 subWin: function (loc, nom, ancho, alto, posx, posy) { 120 var thisposx = posx; 121 var thisposy = posy; 122 if(typeof thisposx === 'undefined') { 123 thisposx = 20; 124 } 125 if(typeof thisposy === 'undefined') { 126 thisposy = 10; 127 } 128 if ((typeof loc === 'undefined') || (loc === "")){ 129 return false;
130 } 131 132 var options = 'width=' + ancho + ',height=' + alto + ',scrollbars=1,resizable=1,' + 133 Utiles.configComun; 134 var win = window.open(loc, nom, options); 135 if(win) { 136 win.focus(); 137 } else { 138 alert(Utiles.msgWin); 139 return; 140 } 141 win.focus(); 142 win.moveTo(thisposx, thisposy); 143 }, 144 145 /** 146 * Agrega pagina a favoritos del browser. 147 * Ojo que sólo funcionará con algunos navegadores 148 * url y titulo son opcionales 149 */ 150 addBookmark: function(url, titulo) { 151 152 if(typeof url == 'undefined' || url === null) { 153 url = window.location.href; 154 }; 155 if(typeof titulo == 'undefined' || titulo === null) { 156 titulo = document.title; 157 }; 158 159 // Para IE 160 if (window.external && typeof window.external.AddFavorite != 'undefined') { 161 window.external.AddFavorite(url, titulo); 162 163 // Posible compatibilidad con IE8 164 } else if (window.external && typeof window.external.AddToFavoritesBar != 'undefined') { 165 window.external.AddToFavoritesBar(url, titulo); 166 167 // Mozilla Firefox Bookmark 168 } else if (window.sidebar) { 169 window.sidebar.addPanel(titulo, url, ""); 170 171 } else { 172 alert(Utiles.msgBadBrowser); 173 } 174 }, 175 176 177 /** 178 * Agrega pagina a favoritos del browser. 179 * Ojo que sólo funcionará con algunos navegadores. 180 */ 181 setHomePage: function(obj) { 182 if (document.all) { 183 obj.style.behavior = 'url(#default#homepage)'; 184 obj.setHomePage(Utiles.serverName); 185 186 } else { 187 alert(Utiles.msgBadBrowser); 188 } 189 }, 190 191 /** 192 * Agrega una Funcion al onload de la pagina 193 * @param func funcion que se desea agregar 194 * @param params parametros de la funcion 195 */ 196 addLoadEvent: function (func, params) { 197 var oldonload = window.onload; 198 window.onload = function() { 199 if (oldonload) { 200 oldonload(); 201 } 202 func(params); 203 }; 204 }, 205 206 /** 207 * Obtiene un parametro del querystring. 208 * @param nom Nmobre del parametro a leer 209 */ 210 getParam: function (nom) { 211 var request = window.location.href; 212 if ((nom !== null) && (nom !== 'undefined') && (nom !== '')) { 213 var re = new RegExp(nom + '=([^&]*)'); 214 var found = request.match(re); 215 if(found !== null && found.length >= 2) { 216 return found[1]; 217 } else { 218 return ''; 219 } 220 } 221 return ''; 222 }, 223 224 /** 225 * Abre la ventana POP para el Zoom de Imágenes 226 * @param loc url de la pagina que se abrira en la pop 227 * @param nom nombre de la ventana 228 * @param ancho ancho de la ventana 229 * @param alto alto de la ventana 230 * @param posx posicion X de la ventana 231 * @param posy posicion Y de la ventana 232 */ 233 popZoom: function (loc, nom, ancho, alto, posx, posy) { 234 var thisposx = posx; 235 var thisposy = posy; 236 if(typeof thisposx === 'undefined') { 237 thisposx = 20; 238 } 239 if(typeof thisposy === 'undefined') { 240 thisposy = 10; 241 } 242 if ((typeof loc === 'undefined') || (loc === "")){ 243 return false; 244 } 245 var options='width='+ancho+',height='+alto+',scrollbars=0,resizable=1'+Utiles.configComun; 246 var winzoom = window.open(loc, nom, options); 247 if(winzoom) { 248 winzoom.focus(); 249 } else { 250 alert(Utiles.msgWin); 251 return; 252 } 253 winzoom.focus(); 254 winzoom.moveTo(thisposx, thisposy); 255 }, 256 257 /** 258 * Destilda un String 259 * @param texto String que se desea destildar 260 */ 261 destilda: function (texto) { 262 var txt = texto; 263 txt = txt.replace(/Ã/g,'a'); 264 txt = txt.replace(/Ã/g,'e'); 265 txt = txt.replace(/Ã/g,'i'); 266 txt = txt.replace(/Ã/g,'o'); 267 txt = txt.replace(/Ã/g,'u'); 268 txt = txt.replace(/á/g,'a'); 269 txt = txt.replace(/é/g,'e');
270 txt = txt.replace(/Ã/g,'i'); 271 txt = txt.replace(/ó/g,'o'); 272 txt = txt.replace(/ú/g,'u'); 273 txt = txt.replace(/Ã/g,'n'); 274 txt = txt.replace(/ñ/g,'n'); 275 txt = txt.replace(/Ã/g,'u'); 276 txt = txt.replace(/ü/g,'u'); 277 txt = txt.replace(/á/g,'a'); 278 txt = txt.toLowerCase(); 279 txt = txt.replace(/[^0-9a-z\_\-]/g,''); 280 return txt; 281 } 282 283};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.