set:function(mid,nama,nohp){
//alert('set');
quick_sms.makeform();
document.from_quick_sms.mid.value=mid;
document.from_quick_sms.nama.value=nama;
document.from_quick_sms.nohp.value=nohp;
},
convertCharsForHttp:function (msg) {
result = msg;
result = result.replace("%","%25");
result = result.replace(" ","%20");
result = result.replace("!","%21");
result = result.replace("\"","%22");
result = result.replace("#","%23");
result = result.replace("$","%24");
result = result.replace("&","%26");
result = result.replace("'","%27");
result = result.replace("(","%28");
result = result.replace(")","%29");
result = result.replace("*","%2A");
result = result.replace("+","%2B");
result = result.replace(",","%2C");
result = result.replace("-","%2D");
result = result.replace(".","%2E");
result = result.replace("/","%2F");
result = result.replace(":","%3A");
result = result.replace("-","%3B");
result = result.replace("<","%3C");
result = result.replace("=","%3D");
result = result.replace(">","%3E");
result = result.replace("@","%40");
result = result.replace("_","%5F");
return result;
},
clearmess:function(){
//alert("clear");
document.from_quick_sms.mess.value="";
quick_sms.hitchar();
},
messkeyup:function(event){
if(event.keyCode==13){
mess=document.from_quick_sms.mess.value;
l=mess.length;
document.from_quick_sms.mess.value=mess.substring(0,(l-1));
return;
}
quick_sms.hitchar();
},
hitchar:function(){
mess=document.from_quick_sms.mess.value;
l=mess.length;
document.from_quick_sms.charlength.value=l;
limit=320;
if(l>limit){
alert("maaf pesan anda melebihi batas maksimum");
document.from_quick_sms.mess.value=mess.substring(0,limit);
mess=document.from_quick_sms.mess.value;
l=mess.length;
document.from_quick_sms.charlength.value=l;
}
if((l>0)&&(l<=160)) {csms=1;}else if((l>160)&&(l<=320)) {csms=2;}else{csms=0;}
document.from_quick_sms.countsms.value=csms;
},
kirim:function(){
mess=document.from_quick_sms.mess.value;
//nohp="6285221005500";
nohp=document.from_quick_sms.nohp.value;
nohp=quick_sms.validhp(nohp);
mess=quick_sms.convertCharsForHttp(mess);
if(mess!=""){
alert('http://192.168.1.23/smscc2/process.php?act=smsout&idin=0&nohp='+nohp+'&mess='+mess);
}else{
alert('anda belum menuliskan pesan yang akan dikirimkan');
}
},
replacinghp:function(nohp,f,r){
l=nohp.length;
lf=f.length;
out=r+nohp.substring(lf,l);
//alert(out);
return out;
},
validhp:function(nohp){
if(nohp.substring(0,2)=="08"){
//alert(1);
return quick_sms.replacinghp(nohp,"08","08");
}else if(nohp.substring(0,2)=="02"){
//alert(2);
return quick_sms.replacinghp(nohp,"02","02");
}else if(nohp.substring(0,2)=="62"){
//alert(3);
return quick_sms.replacinghp(nohp,"62","0");
}else if(nohp.substring(0,3)=="+62"){
//alert(4);
return quick_sms.replacinghp(nohp,"+62","0");
}
},
cancel:function(){
/*
document.from_quick_sms.mid.value="";
document.from_quick_sms.nama.value="";
document.from_quick_sms.nohp.value="";
quick_sms.clearmess();
*/
document.getElementById("quick_sms").innerHTML="";
},
makeform:function(){
out='<form action="" method="post" name="from_quick_sms" id="from_quick_sms">'+
'<table border="0">'+
'<tr>'+
'<td colspan="3">'+
'Quick Sms'+
'<input name="charlength" type="text" id="charlength" size="1" value="0">'+
'<input name="countsms" type="text" id="countsms" size="1" value="0">'+
'<input type="button" name="Button" value="clear" onClick="quick_sms.clearmess();">'+
'</td>'+
'</tr>'+
'<tr>'+
'<td>Mid</td>'+
'<td>:</td>'+
'<td><input name="mid" type="text" id="mid"></td>'+
'</tr>'+
'<tr>'+
'<td>Nama</td>'+
'<td>:</td>'+
'<td><input name="nama" type="text" id="nama"></td>'+
'</tr>'+
'<tr>'+
'<td>NoHp </td>'+
'<td>:</td>'+
'<td><input name="nohp" type="text" id="nohp"></td>'+
'</tr>'+
'<tr>'+
'<td>Pesan</td>'+
'<td>:</td>'+
'<td><textarea name="mess" id="mess" onKeyUp="quick_sms.messkeyup(event);"></textarea></td>'+
'</tr>'+
'<tr>'+
'<td> </td>'+
'<td> </td>'+
'<td><input type="button" name="Submit2" value="kirim" onClick="quick_sms.kirim();"> '+
'<input type="button" name="Submit3" value="Cancel" onClick="quick_sms.cancel();">'+
'</td>'+
'</tr>'+
'</table>'+
'</form>';
document.getElementById("quick_sms").innerHTML=out;
}
}
document.getElementById("quick_sms").innerHTML="";
var a=10;
htmlnya
<style type="text/css">
<!--
#quick_sms {
border: 1px solid #0000FF;
width: 300px;
z-index: 100;
margin-left: 300px;
position: absolute;
left: -21px;
top: 12px;
background-color: #FFFFFF;
}
-->
</style>
<div id="quick_sms">
<form action="" method="post" name="from_quick_sms" id="from_quick_sms">
<table border="0">
<tr>
<td colspan="3">
Quick Sms
<input name="charlength" type="text" id="charlength" size="1" value="0">
<input name="countsms" type="text" id="countsms" size="1" value="0">
<input type="button" name="Button" value="clear" onClick="quick_sms.clearmess();">
</td>
</tr>
<tr>
<td>Mid</td>
<td>:</td>
<td><input name="mid" type="text" id="mid"></td>
</tr>
<tr>
<td>Nama</td>
<td>:</td>
<td><input name="nama" type="text" id="nama"></td>
</tr>
<tr>
<td>NoHp </td>
<td>:</td>
<td><input name="nohp" type="text" id="nohp"></td>
</tr>
<tr>
<td>Pesan</td>
<td>:</td>
<td><textarea name="mess" id="mess" onKeyUp="quick_sms.messkeyup(event);"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="button" name="Submit2" value="kirim" onClick="quick_sms.kirim();">
<input type="button" name="Submit3" value="Cancel" onClick="quick_sms.cancel();">
</td>
</tr>
</table>
</form>
</div>
<input type="submit" name="Submit" value="set quick sms" onClick="setquick_sms('89063','Gunawan','+6285221005500');">
<script language="javascript">
function bageerjs(file){
var js = document.createElement("script");
js.src=file;
document.getElementsByTagName("head")[0].appendChild(js);
}
function setquick_sms(mid,nama,nohp){
if (typeof quick_sms == "undefined") {
alert('blm ada');
bageerjs('testload.js');
quick_sms.set(mid,nama,nohp);
}else{
alert("sudah ada");
}
quick_sms.set(mid,nama,nohp);
}
</script>
No comments:
Post a Comment