-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
83 lines (68 loc) · 2.62 KB
/
Copy pathscripts.js
File metadata and controls
83 lines (68 loc) · 2.62 KB
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
const button = document.getElementById("submit_button");
//LANGUAGES
const lang_heb = {
title: "תודה לך שנרשמת!",
sub_title: "עכשיו נשאר רק להכניס פרטים, והבוט מיד שולח לך הודעה!",
mail: "המייל שאיתו שילמת (בפייפאל)",
name: "שם",
phone_number: "מספר טלפון",
button_text: "תרשמו אותי"
}
const lang_en = {
title: "Thank you for signing up!",
sub_title: "Now all that is left is to enter details, and the bot will immediately send you a message",
mail: "The email you paid with (on PayPal)",
name: "Name",
phone_number: "Phone number",
button_text: "Submit!"
}
//LANG SELECTION CHANGED
document.getElementById("language").onchange = function(){
if(this.value == "heb")
Render(lang_heb);
if(this.value == "en")
Render(lang_en);
}
//RENDER
const Render = (lang) =>{
if(lang == lang_heb)
document.body.setAttribute("dir", "rtl");
else
document.body.setAttribute("dir", "ltr");
document.getElementById("title").innerHTML = lang.title;
document.getElementById("sub_title").innerHTML = lang.sub_title;
document.getElementById("mail").placeholder = lang.mail;
document.getElementById("name").placeholder = lang.name;
document.getElementById("phoneNumber").placeholder = lang.phone_number;
document.getElementById("submit_button").innerHTML = lang.button_text;
}
window.onload = function(){
Render(lang_en);
if(!document.referrer.includes("paypal")){
alert("הדף זמין רק לאחר תשלום!");
document.getElementById("submit_button").disabled = true;
}
}
button.addEventListener("click",async function(e){
let email = document.getElementById("mail").value;
let phone_number = document.getElementById("phoneNumber").value;
let name = document.getElementById("name").value;
if(phone_number.length != 10){
alert("מספר טלפון לא תקין");
return;
}
//RIGHT FORMAT FOR DB
phone_number = phone_number.substring(1);
if(email.length == 0 || phone_number.length == 0 || name.length == 0){
alert("נא למלא את כל השדות");
return;
}
if(!email.includes("@") || !email.includes(".")){
alert("כתובת מייל לא תקינה");
return;
}
window.location = `http://api.whatsapp.com/send?phone=972502332823&text=%F0%9F%91%8B%F0%9F%91%8B%F0%9F%91%8B`;
let url = `https://botbenda.appspot.com/addUserWeb?phone=${phone_number}&name=${name}&mail=${email}`;
await fetch((url),{method:"GET"})
return;
});