Просмотр файла topo.js

Размер файла: 2.48Kb
  1. //Cuenta atrбs con recarga opcional
  2. function CuentaAtras(valor,recargar) {
  3. if(valor!=0) tiempo=valor-1;
  4. horas=Math.floor(valor/3600);
  5. valor-=3600*horas;
  6. min=Math.floor(valor/60);
  7. valor-=60*min;
  8. seg=valor;
  9. horas=(horas<10)? "0"+horas : horas;
  10. min=(min<10)? "0"+min : min;
  11. seg=(seg<10)? "0"+seg : seg;
  12. horas=(horas=="00")? "" : horas+":";
  13. min=(min=="00" && horas=="")? "" : min+":";
  14. seg=(seg=="00" && min=="")? "Booommm!!" : seg+"''";
  15. document.clock.CuentaAtras.value=horas+min+seg;
  16. if(seg=="Booommm!!" && recargar==1) window.location.reload();
  17. setTimeout("CuentaAtras(tiempo)",1000);
  18. }
  19. //Abre nueva ventana centrada en el centro de la pantalla
  20. function ventana(theURL,winName,winWidth,winHeight) {
  21. var w = (screen.width - winWidth)/2;
  22. var h = (screen.height - winHeight)/2 - 50;
  23. features = 'directories=no,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=no,width='+winWidth+',height='+winHeight+',top='+h+',left='+w;
  24. window.open(theURL,winName,features);
  25. }
  26.  
  27. function submitOnce(theform) {
  28. if (document.all || document.getElementById) {
  29. for(i=0 ; i < theform.length ; i++) {
  30. var tempobj = theform.elements[i];
  31. if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") {
  32. tempobj.disabled=true;
  33. }
  34. }
  35. }
  36. }
  37.  
  38. function validate(obj,modo,porDefecto, min) {
  39. var texto = obj.value;
  40. do {
  41. texto = texto.replace(/\|\|/,"|");
  42. } while(/\|\|/.test(texto));
  43. if(modo=="url") {
  44. if(texto.substr(0,7)!="http://" && texto.substr(0,8)!="https://") texto = "http://" + texto;
  45. texto = texto.replace(/ /,"");
  46. }
  47. if(modo=="email") {
  48. if(!/(.+)@(.+)\.(.+)/.test(texto)) texto = porDefecto;
  49. if(/[\s]+/.test(texto)) texto = porDefecto;
  50. if(texto.indexOf('@') != texto.lastIndexOf('@')) texto = porDefecto;
  51. var dominio = texto.substring(1+texto.lastIndexOf('.'));
  52. if( dominio.length>3 || dominio.length<2) texto = porDefecto;
  53. }
  54. if(modo=="icq") {
  55. do {
  56. texto = texto.replace(/[^0-9]/,"");
  57. } while(/[^0-9]/.test(texto));
  58. }
  59. if(modo=="number") {
  60. do {
  61. texto = texto.replace(/[^0-9]/,"");
  62. } while(/[^0-9]/.test(texto));
  63. if(texto=='') texto = porDefecto;
  64. }
  65. if(modo=="numberMin") {
  66. do {
  67. texto = texto.replace(/[^0-9]/,"");
  68. } while(/[^0-9]/.test(texto));
  69. if(texto=='') texto = porDefecto;
  70. if(parseInt(texto) < min) texto = porDefecto;
  71. }
  72. if(modo=="text") {
  73. if(texto=='') texto = porDefecto;
  74. }
  75. obj.value = texto;
  76. }