-
Notifications
You must be signed in to change notification settings - Fork 0
/
tapToMsgMakeUrl.html
204 lines (182 loc) · 7.29 KB
/
tapToMsgMakeUrl.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<title> Tap to message, Create Url to message Whats app, telegram user etc</title>
</head>
<body>
<header>
<div class="collapse bg-dark" id="navbarHeader">
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-7 py-4">
<h4 class="text-white">About</h4>
<p class="text-muted">A free open source utility. Code is at <h ref=https://github.com/tgkprog/htmlUtils>Html Utils</a>
Convert a phone number to a link that you can tap, and whatsapp (if installed on that device or web.whatsapp.com if logged in) will start a message to that number.
Optional add a message to type for initial message. <br>
This page supports two get params - n for number and t for text. Example : https://sel2in.com/pages/prog/tapToMsgMakeUrl.html?n=917000&t=hi+there
</p>
</div>
<div class="col-sm-4 offset-md-1 py-4">
<h4 class="text-white">Contact</h4>
<ul class="list-unstyled">
<li><a href="https://sel2in.com/" class="text-white">Sel2in.com</a></li>
<li><a href="https://twitter.com/tushar_kapila" class="text-white">Tushar Twitter</a></li>
<li><a href="https://www.facebook.com/Sel2inCom-102255914881700" class="text-white">Sel2in Facebook</a></li>
<li><a href="https://m.me/102255914881700" class="text-white">Sel2in Fb messenger</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="navbar navbar-dark bg-dark box-shadow">
<div class="container d-flex justify-content-between">
<a href="https://sel2in.com" class="navbar-brand d-flex align-items-center">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 48 48" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="mr-2">
<circle cx="6" cy="9" r="2" stroke="red" ></circle>
<circle cx="27" cy="9" r="2" stroke="red" ></circle>
<!-- <path d="M 10 20 C 20 15, 35 35, 50 20" stroke="purple" /> -->
<path d="M 3 27 Q 14 34, 31 28" stroke="purple" />
</svg>
<img src='s2nlogoA.png'>
<strong>Url Tap Message</strong>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarHeader" aria-controls="navbarHeader" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
</header>
<section class="jumbotron text-center">
<div class="container">
<h1 class="jumbotron-heading">Tap to chat</h1>
<p> </p>
</div>
</section>
<form name=f1>
<div class="container">
<div class="row">
<div class="col-bg-1"><b>Type mobile number (country code too) : <input type=text name=t1 len=12></b></div>
<div class="col-bg-2"> </div>
<div class="col-bg-3"> Or <a role="button" href='javascript:pasteFromClip()'>Paste</a> number in clipboard
(you must grant permission to read your clipboard). Tap link below to send them a message. Now you do not need to make a contact to send a quick message to someone. </div>
</div>
<div class="row">
<div class="col-md-1">Optional text</div>
<div class="col-md-2"><textarea rows=5 cols=110 name=t2 ></textarea> </div>
</div>
<div class="row">
<div class="col-bg-2"><input class="btn btn-default" type=button onclick="proc(document.forms['f1'].t1.value)" value="[ Go ]"></div>
</div>
<br>
<div class="row">
<div class="col-bg-2" id=oo>Output here </div>
</div>
</form>
<div class="footer">Version 1.2.003.
</div>
<script>
async function pasteFromClip(){
/* navigator.clipboard.readText()
.then(text => {
console.log('Pasted content: ', text);
s = text;
})
.catch(err => {
console.error('Failed to read clipboard contents: ', err);
}); */
const text = await navigator.clipboard.readText();
proc(text);
}
function proc(s){
console.log('entrd content: ', s);
var nos = "0123456789";
var s2 = s;
var i = 0;
var s4 = '', s5 = '';
i = s2.indexOf('\n');
if(i > 0)s2 = s2.substring(0, i);
i = s2.indexOf('\r');
if(i > 0)s2 = s2.substring(0, i);
var ln = s2.length;
i = 0;
for(i = 0 ; i < ln; i++){
var cc = s2.charAt(i);
if(nos.indexOf(cc) < 0){
if(i> 0){
s4 = s2.substring(0, i)
}else{
s4 = '';
}
if(i < (s2.length - 1)){
s5 = s2.substring(i+1);
}else{
s5 = '';
}
s2 = s4 + s5;
i--;
}
ln = s2.length;
}
if(s2 == ''){
s3 = "<Strong><font color=red size=+2>No number found</font></strong>";
}else{
var txt = encodeURI(document.f1.t2.value);
var msgTxt = '';
if(txt.length > 0){
msgTxt = "Optional text " + txt + "<br>\n" ;
}
var s3 = "Entered :" + s + "<br>\n" +
msgTxt +
"<br>Tap to Whatsapp message : <br><font size=+2><a href=\"https://wa.me/" + s2
+ "?app_absent=web&text=" + txt + "&source=https://sel2in.com/&data=&\">" + s2 +
"</a>"
+ " OR <a href=\"https://api.whatsapp.com/send?phone=" + s2 +
"&app_absent=web&text=" + txt + "&source=https://sel2in.com/&data=&\">"
+ s2 + "</a></font> (click)<br> For whats app need to put country code and no other characters"
+ " example https://wa.me/9177799922 here 91 is the country code (followed by "
+ "part mobile number, usually its 10 digits long)";
}
console.log('s3: ', s3);
document.getElementById("oo").innerHTML = s3;
}
function load(){
var p =getParams(window.location.href);
var n = '';
var t = '';
if('n' in p){
n = p['n'];
}
if('t' in p){
t = p['t'];
}
if(t != '')document.f1.t2.value = t;
if(n != ''){
document.f1.t1.value = n;
proc(n);
}
}
var getParams = function (url) {
var params = {};
var parser = document.createElement('a');
parser.href = url;
var query = parser.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
params[pair[0]] = decodeURIComponent(pair[1]);
}
return params;
};
load();
</script>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
</body>
</html>