var numtext = 90; var timeout = 10; var activeMsgTime = true; var numMsgTime = 2; setInterval("retrieveSMS()", 4000); var nc = (document.layers) ? true:false var ie = (document.all) ? true:false var n6 = (document.getElementById) ? true:false var primeraVez = true; var active = false; var telefonos = new Array(); var effect_1 = null; var firstsend = false; var xmlHttpSms; var xmlHttpRSms; var xmlHttpISms; var xmlHttpCSms; var xmlHttpSSms; var xmlHttpWhis; var session = true; var numsmse = 0; var start = horaActual(); var pidepin = false; var pinNum = ""; var numMsgEnviado = 0; var isViva = true; function horaActual(){ var mydate = new Date(); var strDate = mydate.getTime()/1000; strDate = Math.ceil(strDate); return strDate; } function verificaT(){ var min = parseInt((horaActual() - start)/60); if (min > timeout ){ alert('La sesión expiró!'); window.location.reload(); } } function jsonXMLHttpRequestReplacer(name, value) { if (value && value instanceof XMLHttpRequest) { return { status: value.status, statusText: value.statusText }; } return value; } function createXMLHttpRequest(){ var xmlHttp = new XMLHttpRequest(); try{ xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(ex){ try{ xmlHttp = new XMLHttpRequest(); console.log(xmlHttp); }catch(exx){ console.log(exx); } } } return xmlHttp; } function handleSendSMS(){ if(xmlHttpSms.readyState == 4) { document.getElementById("field3").disabled = false; document.getElementById("field4").disabled = false; document.getElementById("new_img").disabled = false; document.getElementById("field99").disabled = false; document.getElementById("field99").value = "Enviar"; if(xmlHttpSms.status == 200) { if (xmlHttpSms.responseText == 0){ codeSMS(); document.getElementById("field4").disabled = false; document.getElementById("field4").value = ""; document.getElementById("field4").focus(); document.getElementById("message").innerHTML = "El código de la imagen es incorrecto!"; new Effect.Highlight(document.getElementById("messagebox"), {duration:7, startcolor:'#FFFF9A', endcolor:'#FFFFFF'}) } else if (xmlHttpSms.responseText == -1){ alert('La sesión expiró!'); window.location.reload(); } else if (xmlHttpSms.responseText == 2){ pidepin = true; pin(0); } else if (xmlHttpSms.responseText == 3){ pidepin = true; pin(1); }else if (xmlHttpSms.responseText == 5){ console.log("blacklist"); blacklist(); }else{ codeSMS(); numMsgEnviado++; document.getElementById("message3").innerHTML = "Escribe aqui tu mensaje:"; document.getElementById("field3").value = ""; document.getElementById("counter").innerHTML = "Quedan "+numtext+" caracteres"; document.getElementById("field4").value = ""; firstfocus = true; firstsend = true; numsmse = numsmse +1; crearTxt(xmlHttpSms.responseText); } } else { codeSMS(); alert("El mensaje no pudo ser enviado. ERROR: " + xmlHttpSms.statusText); } } else{ document.getElementById("field3").disabled = true; document.getElementById("field4").disabled = true; document.getElementById("new_img").disabled = true; document.getElementById("field99").disabled = true; document.getElementById("field99").value = "Enviando..."; } } function handleRetrieveSMS(){ if(xmlHttpRSms.readyState == 4){ if(xmlHttpRSms.status == 200){ if (xmlHttpRSms.responseText != "0"){ if (xmlHttpRSms.responseText == "-1"){ session = false; } else{ crearTxt(xmlHttpRSms.responseText); numMsgEnviado = 0; // resetea el contador DHTMLSound('sound/ding.wav'); start = horaActual(); } } } } } function handleInitSMS(){ if(xmlHttpISms.readyState == 4){ if(xmlHttpISms.status == 200){ if (xmlHttpISms.responseText == "1"){ document.getElementById("field99").disabled = false; document.getElementById("field99").value = "Enviar"; window.open('imagen.php', 'image'); }else{ window.location.href = "http://websms.nuevatel.com/websms3.php"; } } else { alert("WebSMS Interactivo\n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\nNo se pudo conectar al servidor.\nPor favor intente más tarde."); } } } function handleCodeSMS(){ if(xmlHttpCSms.readyState == 4){ document.getElementById("field4").disabled = false; document.getElementById("new_img").disabled = false; document.getElementById("field99").disabled = false; document.getElementById("field99").value = "Enviar"; window.open('imagen.php', 'image'); } else{ document.getElementById("field4").disabled = true; document.getElementById("new_img").disabled = true; document.getElementById("field99").disabled = true; document.getElementById("field99").value = "Generando imagen..."; } } function sendSMS(vars){ xmlHttpSms = createXMLHttpRequest(); xmlHttpSms.onreadystatechange = handleSendSMS; xmlHttpSms.open("GET" , 'send.php' + vars); xmlHttpSms.send(null); } function verificarNumeroViva(subscriber_id){ xmlHttpWhis = createXMLHttpRequest(); xmlHttpWhis.onreadystatechange = handleVerificarNumeroViva; xmlHttpWhis.open("GET" , 'whis.php?subscriber_id='+subscriber_id , false); xmlHttpWhis.send(null); } function handleVerificarNumeroViva(){ if(xmlHttpWhis.readyState == 4){ if(xmlHttpWhis.status == 200){ if(xmlHttpWhis.response == "NOVIVA"){ isViva = false; }else if(xmlHttpWhis.response == "VIVA"){ isViva = true; } } } } function retrieveSMS(){ if(numsmse!=0){ if ((firstsend == true) && (session == true)) { xmlHttpRSms = createXMLHttpRequest(); xmlHttpRSms.onreadystatechange = handleRetrieveSMS; xmlHttpRSms.open("GET" , 'retrieve.php'); xmlHttpRSms.send(null); } } } function initSMS(){ nSMS = 0; nCheck = 0; xmlHttpISms = createXMLHttpRequest(); xmlHttpISms.onreadystatechange = handleInitSMS; xmlHttpISms.open("GET" , 'connect.php'); xmlHttpISms.send(null); } function codeSMS(){ document.getElementById("message").innerHTML = ""; xmlHttpCSms = createXMLHttpRequest(); xmlHttpCSms.onreadystatechange = handleCodeSMS; xmlHttpCSms.open("GET" , 'new_img.php'); xmlHttpCSms.send(null); } function closeSMS(){ xmlHttpSSms = createXMLHttpRequest(); xmlHttpSSms.open("GET" , 'close.php', false); xmlHttpSSms.send(null); } function init() { mueveReloj(); if (active == false){ initSMS(); var pagina = document.getElementById('board'); var cajaNueva = document.createElement('div'); document.getElementById("message3").innerHTML = "Escribe aqui tu mensaje:"; document.getElementById("counter").innerHTML = "Quedan "+numtext+" caracteres"; active = true; cajaNueva.setAttribute('className','caja'); cajaNueva.setAttribute("class", "caja"); cajaNueva.innerHTML = "** Si responden a tu mensaje, lo verás aquí."; pagina.insertBefore(cajaNueva,pagina.firstChild); } else{ new Effect.toggle('revertbox','slide'); } } function cuenta(obj){ StrLen = obj.value.length; if (StrLen > numtext ) { obj.value = obj.value.substring(0,numtext); nchar = 0; } else nchar = numtext - StrLen; var sms = document.getElementById("field3").value; if (nchar<1){ sms = sms.substring(0,numtext); document.getElementById("field3").value = sms; document.getElementById("counter").innerHTML = "Quedan "+0+" caracteres"; } else document.getElementById("counter").innerHTML = "Quedan "+(numtext-sms.length)+" caracteres"; } function replaceChars(entry, out) { temp = "" + entry; while (temp.indexOf(out)>-1){ pos=temp.indexOf(out); temp = "" + (temp.substring(0, pos) + temp.substring((pos + out.length), temp.length)); } return temp; } function enviar(v,pi){ var f = new Array(); var vars="?"; if (pi==1){ pinNum = ""; element = document.getElementById("field8"); pinNum = element.value; if (pinNum==""){ element.style.backgroundColor = "#ffdbc3"; element.focus(); return false; } ajaxpin.hide(); pidepin = false; vars = vars+"valor8="+pinNum+"&"; } msgz = document.getElementById("message"); document.getElementById("message").innerHTML = ""; document.getElementById("messagebox").style.height = "0"; for (i=1;i<=v;i++){ f[i] = document.getElementById("field"+i).value; } for (i=1;i<=v;i++){ element = document.getElementById("field"+i); document.getElementById("message"+i).innerHTML = ""; if ((f[i] == "") && (f[5]==0) && i<5) { if (i == 1){ msgz.innerHTML = "Ingrese su nick" }else if (i == 2){ msgz.innerHTML = "Ingrese el número"; }else if (i == 3){ msgz.innerHTML = "Ingrese su mensaje"; }else if (i == 4){ msgz.innerHTML = "Escriba los caracteres que vea en la imagen."; } element.style.backgroundColor = "#ffdbc3"; element.focus(); return false; }else if((f[5]==1) && (f[i] == "")){ element.style.backgroundColor = "#FFC3C3"; element.focus(); return false; }else{ if (i == 1){expreg = /^\w+$/; }else if (i == 2){expreg = /\d{8}/; }else if (i == 3){ f[i] = replaceChars(f[i], "%"); // Añade el mensaje de responder a la seguna vez if ((numsmse==1) && (f[5]==0)) { } f[i] = alphas(f[i]); }else if (i == 4){ expreg = /[A-Za-z0-9]{4}/; } if ((i==1) || (i==2) || (i==4)){ if (i == 2){ verificarNumeroViva(f[i]); if(isViva == false){ msgz.innerHTML = "Ingrese un número VIVA"; element.style.backgroundColor = "#FFFF9A"; element.focus(); return false; } } if (!expreg.test(f[i])){ element.style.backgroundColor = "#FFFF9A"; element.focus(); return false; } vars = vars+"valor"+i+"="+f[i]+"&"; } element.style.backgroundColor = "#FFFFFF"; //================================== //= hora //================================== if(i == 6){ sHoras = f[i] + ":" + document.getElementById("minutos6").value; vars = vars+"valor"+i+"="+sHoras+"&"; }else{ vars = vars+"valor"+i+"="+f[i]+"&"; } //================================== } } if(activeMsgTime){ if(numMsgEnviado>=numMsgTime){ msgMin(); return false; } } verificaT(); // Verifica el tiempo sendSMS(vars); // Envia mensaje retrieveSMS(); // recoje nuevos mensajes start = horaActual(); // reinicia } function crearTxt(texto){ var pagina=document.getElementById('board'); var cajaNueva=document.createElement('div'); cajaNueva.setAttribute('className','caja'); cajaNueva.setAttribute("class", "caja"); cajaNueva.innerHTML = texto; pagina.insertBefore(cajaNueva,pagina.firstChild); light(pagina.firstChild); t = document.getElementById('field2').value; var found = false; for (j=0; j15){ pagina.removeChild(pagina.lastChild); } } function light(f){ new Effect.Highlight(f, {duration:20, startcolor:'#D3E16F', endcolor:'#FFFFFF'}) } function DHTMLSound(surl) { document.getElementById("dummyspan").innerHTML= ""; } function show(){ var inner = ""; if (telefonos.length==0){ inner = "
No tienes teléfonos guardados.
"; } else{ inner += ""; } document.getElementById("numbers").innerHTML = inner; new Effect.toggle('list','slide'); } function udpateList(){ var inner = ""; if (telefonos.length==0){ inner = "
No tienes teléfonos guardados.
"; } else{ inner += ""; } document.getElementById("numbers").innerHTML = inner; } function escribe(n){ document.getElementById("field2").value = n; show(); } function ayuda1(){ ajaxayuda1=dhtmlmodal.open("ajaxHelp1Win", "ajax", "html/ayuda1.php", "Ayuda", "width=270px,height=170px,center=1,resize=0,scrolling=0") ajaxayuda1.onclose=function(){return true; } } function ayuda2(){ ajaxayuda2=dhtmlmodal.open("ajaxHelp2Win", "ajax", "html/ayuda2.php", "Ayuda", "width=270px,height=170px,center=1,resize=0,scrolling=0") ajaxayuda2.onclose=function(){return true; } } function pin(w){ ajaxpin=dhtmlmodal.open("ajaxPinWin", "ajax", "html/pin.php?estado="+w, "Ingrese el número PIN", "width=270px,height=170px,center=1,resize=0,scrolling=0","recal") ajaxpin.onclose=function(){return true;} } function msgMin(){ ajaxMsgMin=dhtmlmodal.open("ajaxMsgMin", "ajax", "html/MsgMin.php", "Alerta", "width=270px,height=170px,center=1,resize=0,scrolling=0") ajaxMsgMin.onclose=function(){return true; } } function blacklist(){ ajaxMsgMin=dhtmlmodal.open("ajaxMsgMin", "ajax", "html/blacklist.php", "Alerta", "width=270px,height=170px,center=1,resize=0,scrolling=0") ajaxMsgMin.onclose=function(){return true; } } function alphas(n){ n=n.replace("Ñ","N"); n=n.replace("ñ","n"); n=n.replace("á","a"); n=n.replace("é","e"); n=n.replace("í","i"); n=n.replace("ó","o"); n=n.replace("ú","u"); n=n.replace("ü","u"); n=n.replace("Á","A"); n=n.replace("É","E"); n=n.replace("Í","I"); n=n.replace("Ó","O"); n=n.replace("Ú","U"); n=n.replace("Ü","U"); return (n); } function openTerAndCon() { //alert("Al hacer uso de WEB SMS aceptas las condiciones de los Productos Digitales de VIVA."); var win = window.open("http://websms.nuevatel.com/termsAndConditions.php", '_blank'); win.focus(); }