diff --git a/i18n.js b/i18n.js
new file mode 100644
index 0000000..3ed2fcb
--- /dev/null
+++ b/i18n.js
@@ -0,0 +1,28 @@
+var arrlang={
+ 'en':{
+ 'description':"Add a stranger's phone number to your WhatsApp in three step!",
+ 'country-code':'Country code',
+ 'phone-number':'Phone numberPhone number',
+ 'add':'Add to WhatsApp'
+
+ },
+ 'zh':{
+ 'description':"在三步之內在你的WhatsApp中加一個陌生人的電話號碼",
+ 'country-code':'國家號碼',
+ 'phone-number':'電話號碼',
+ 'add':'加到WhatsApp'
+
+ }
+}
+window.onload=(i18n)
+function i18n()
+{
+ var userLang = navigator.language || navigator.userLanguage;
+ userLang = userLang.substring(0,2) ;
+ for(var i=0;i<6;i++){
+ if(document.getElementsByTagName('span')[i].getAttribute('for')){
+ document.getElementsByTagName('span')[i].innerHTML = arrlang[userLang][document.getElementsByTagName('span')[i].getAttribute('for')];
+ }
+ }
+}
+
\ No newline at end of file
diff --git a/index.html b/index.html
index 75261ac..c48508e 100644
--- a/index.html
+++ b/index.html
@@ -9,6 +9,7 @@
+
@@ -30,7 +31,7 @@
- Add a stranger's phone number to your WhatsApp in three step!
+ Add a stranger's phone number to your WhatsApp in three step!
@@ -40,20 +41,20 @@
@@ -127,13 +128,15 @@
function formSubmit() {
var whatsaddForm = document.getElementById("whatsadd-form");
- var countryCode = whatsaddForm.querySelector("#country-code");
- var phoneNumber = whatsaddForm.querySelector("#phone-number");
+ var countryCode = whatsaddForm.querySelector("#country-code").value;
+ var phoneNumber = whatsaddForm.querySelector("#phone-number").value;
- whatsadd(countryCode.value + phoneNumber.value, true);
+ //default country code = 852
+ countryCode==''?countryCode=852:countryCode
+ whatsadd(countryCode + phoneNumber, true);
- countryCode.value = "";
- phoneNumber.value = "";
+ countryCode = "";
+ phoneNumber = "";
}
diff --git a/whatsadd.js b/whatsadd.js
index 5414814..a01a28c 100644
--- a/whatsadd.js
+++ b/whatsadd.js
@@ -1,9 +1,9 @@
const baseUrl = "https://api.whatsapp.com/send?phone=";
function whatsadd(phoneNumber, newTab) {
- whatsappUrl = baseUrl + phoneNumber;
+ var whatsappUrl = baseUrl + phoneNumber;
- if (newTab == true) {
+ if (newTab) {
var whatsappTab = window.open(whatsappUrl, "_blank");
whatsappTab.focus;
} else {