-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhatsapp-sender-script.js
58 lines (50 loc) · 2.15 KB
/
whatsapp-sender-script.js
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
// script.js
document.addEventListener('DOMContentLoaded', function() {
const pricingForm = document.getElementById('pricingForm');
const pricePerMessageElement = document.getElementById('pricePerMessage');
const totalPriceElement = document.getElementById('totalPrice');
pricingForm.addEventListener('submit', function(e) {
e.preventDefault();
const country = document.getElementById('country').value;
const messageType = document.getElementById('messageType').value;
const numberOfMessages = parseInt(document.getElementById('numberOfMessages').value);
// This is a simplified pricing logic. You should replace it with your actual pricing data.
const basePrice = 0.05; // Base price per message
let priceMultiplier = 1;
switch(country) {
case 'EG':
case 'SA':
case 'AE':
priceMultiplier = 1.2;
break;
case 'BH':
case 'KW':
case 'QA':
priceMultiplier = 1.5;
break;
// Add more country-specific pricing as needed
}
switch(messageType) {
case 'service':
case 'authentication':
priceMultiplier *= 0.9;
break;
case 'marketing':
priceMultiplier *= 1.2;
break;
// Add more message type-specific pricing as needed
}
const pricePerMessage = basePrice * priceMultiplier;
const totalPrice = pricePerMessage * numberOfMessages;
pricePerMessageElement.textContent = `$${pricePerMessage.toFixed(2)}`;
totalPriceElement.textContent = `$${totalPrice.toFixed(2)}`;
});
// Language switcher functionality
const languageSelector = document.querySelector('#languageSelector select');
languageSelector.addEventListener('change', function() {
const selectedLanguage = this.value;
// Implement language switching logic here
console.log(`Language changed to: ${selectedLanguage}`);
// You would typically load new language strings and update the UI here
});
});