| 1 |
window.onload = function () { |
| 2 |
var bookingPageUrl = document.querySelector("#setmore_booking_page_url").value; |
| 3 |
|
| 4 |
if (bookingPageUrl && bookingPageUrl != "https://my.setmore.com" && bookingPageUrl != null && bookingPageUrl != "") { |
| 5 |
document.querySelector(".sm-acc-info").style.display = "block"; |
| 6 |
} |
| 7 |
else { |
| 8 |
document.querySelector(".sm-acc-info").style.display = "none"; |
| 9 |
} |
| 10 |
var optionList = document.querySelector('.sm-dropdown ul'); |
| 11 |
document.querySelector("#dropDown").onclick = function () { |
| 12 |
optionList.style.display = "block "; |
| 13 |
} |
| 14 |
var langList = document.querySelectorAll('.sm-dropdown ul li'); |
| 15 |
|
| 16 |
for (var i = 0; i < langList.length; i++) { |
| 17 |
langList[i].onclick = function () { |
| 18 |
document.querySelector(".sm-dropdown input").value = this.textContent; |
| 19 |
optionList.style.display = "none "; |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
document.addEventListener("click", function (event) { |
| 24 |
if (event.target.className == "fa fa-sort-down" || event.target.className == "langaugeList") { |
| 25 |
optionList.style.display = "block "; |
| 26 |
} else { |
| 27 |
optionList.style.display = "none"; |
| 28 |
} |
| 29 |
}); |
| 30 |
|
| 31 |
document.querySelector(".btn-login").onclick = function () { |
| 32 |
var siteUrl = this.getAttribute("siteurl"); |
| 33 |
var popupWindow = window.open('https://my.setmore.com/integration/wordpress/oauth?siteUrl=' + siteUrl, "_blank", "scrollbars=yes,resizable=yes,top=108,left=0,right=0,width=821,height=625,margin= 0 auto;"); |
| 34 |
popupWindow.focus(); |
| 35 |
var pollTimer = window.setInterval(function () { |
| 36 |
console.log('the popupwindow', popupWindow.location.href); |
| 37 |
if (popupWindow.location.href.indexOf("status=true") != -1) { |
| 38 |
const urlParams = new URLSearchParams(popupWindow.location.search); |
| 39 |
document.querySelector(".sm-acc-info").style.display = "block"; |
| 40 |
document.querySelector("#setmore_booking_page_url").value = urlParams.get("bookingpageurl"); |
| 41 |
window.clearInterval(pollTimer); |
| 42 |
popupWindow.close(); |
| 43 |
} |
| 44 |
}, 1000); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|