Skip to content

Commit b4b2272

Browse files
committed
changes in country code format
1 parent 509b036 commit b4b2272

File tree

2 files changed

+66
-57
lines changed

2 files changed

+66
-57
lines changed

whatsapp/index.html

Lines changed: 17 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -11,71 +11,31 @@
1111
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
1212
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
1313
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
14+
<!-- <link rel="manifest" href="/manifest.json"> -->
1415

1516
</head>
1617
<body>
1718
<div class="container">
19+
<div class="m-5 align-self-center align-items-center justify-content-center">
20+
Send message on whatsapp without adding to your contacts
21+
</div>
1822
<form class="m-5 align-self-center align-items-center justify-content-center">
19-
<div class="form-group">
20-
<label for="sel1">Select Country:</label>
21-
<select class="form-control" id="sel1">
22-
<option value="+91">+91(India)</option>
23-
<option value="+1">+1(USA)</option>
24-
</select>
23+
<div class="form-group">
24+
<label for="mobileNumber">Country Code</label>
25+
<a href="https://countrycode.org/" target="_blank">(What is mine?)</a>
26+
<input type="text" class="form-control" id="countryCode" placeholder="91" />
2527
</div>
26-
<div class="form-group">
27-
<label for="mobileNumber">Mobile No</label>
28-
<input type="number" class="form-control" id="mobileNumber" placeholder="+9180******19" />
29-
</div>
30-
<div class="d-flex align-items-center">
31-
<button type="button" id="send" class="btn btn-primary align-self-center">
32-
Send
33-
</button>
28+
<div class="form-group">
29+
<label for="mobileNumber">Mobile No</label>
30+
<input type="number" class="form-control" id="mobileNumber" placeholder="88******9292" />
31+
</div>
32+
<div class="d-flex align-items-center">
33+
<button type="button" id="send" class="btn btn-primary align-self-center">
34+
Send
35+
</button>
3436
</div>
3537
</form>
3638
</div>
37-
38-
<script>
39-
$(document).ready(function(){
40-
console.log(
41-
`
42-
%c
43-
*******************************
44-
*******************************
45-
*******************************
46-
*******************************
47-
*******************************
48-
********DHEERJ KUMAR RAO*******
49-
*https://twitter.com/rao123dk**
50-
*******************************
51-
*******************************
52-
*******************************
53-
*******************************
54-
*******************************
55-
`,
56-
'background: #fcdf03; color: #000'
57-
)
58-
var countryCode = '+91';
59-
var mobile = '';
60-
$('select').on('change, click', function() {
61-
countryCode = $(this).val();
62-
});
63-
64-
$('#mobileNumber').on('change paste keyup', function() {
65-
mobile = $(this).val();
66-
});
67-
68-
$("#send").click(function(e){
69-
if(countryCode && mobile){
70-
e.preventDefault();
71-
var url = "https://api.whatsapp.com/send?phone="+countryCode+mobile;
72-
window.open(url, '_blank');
73-
return;
74-
}
75-
alert("Please enter correct info");
76-
});
77-
});
78-
</script>
79-
39+
<script src="./whatsapp.js"> </script>
8040
</body>
8141
</html>

whatsapp/whatsapp.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
$(document).ready(function(){
2+
console.log(
3+
`
4+
%c
5+
*******************************
6+
*******************************
7+
*******************************
8+
*******************************
9+
*******************************
10+
********DHEERJ KUMAR RAO*******
11+
*https://twitter.com/rao123dk**
12+
*******************************
13+
*******************************
14+
*******************************
15+
*******************************
16+
*******************************
17+
`,
18+
'background: #fcdf03; color: #000'
19+
)
20+
var CommentNode = document.createComment("Send whatsapp message without saving a number");
21+
document.body.appendChild(CommentNode);
22+
var countryCode = '+91';
23+
var mobile = '';
24+
25+
$('#countryCode').on('change paste keyup', function() {
26+
countryCode = $(this).val().trim();
27+
if(countryCode.indexOf('+') === -1){
28+
countryCode = '+' + countryCode;
29+
}
30+
});
31+
32+
33+
$('#mobileNumber').on('change paste keyup', function() {
34+
mobile = $(this).val().trim();
35+
});
36+
37+
$("#send").click(function(e){
38+
if(countryCode && mobile){
39+
e.preventDefault();
40+
var url = "https://api.whatsapp.com/send?phone=+"+countryCode+mobile;
41+
window.open(url, '_blank');
42+
setTimeout(()=>{
43+
location.reload(false);
44+
},2000)
45+
return;
46+
}
47+
alert("Please enter correct info");
48+
});
49+
});

0 commit comments

Comments
 (0)