var backend_ip = "https://api.supernative.ai"; var frontend_addr = "https://supernative.ai"; if (localStorage.getItem("segment_user_id") != null) { analytics.identify(localStorage.getItem("segment_user_id"), { 'first_name': localStorage.getItem("first_name"), 'last_name': localStorage.getItem("last_name"), 'email': localStorage.getItem("email") }); } document.addEventListener('click', function(event) { // Get current timestamp var timestamp = new Date().toISOString(); // Get current URL var currentUrl = window.location.href; // Get current page title var pageTitle = document.title; // Get the clicked element's name (if it has a name attribute) var clickedButtonName = event.target.getAttribute('name'); // Track the click event with the gathered information analytics.track('Click Event', { timestamp: timestamp, url: currentUrl, pageTitle: pageTitle, clickedButtonName: clickedButtonName }); }); // Function to add click outside event listener to overlay function addClickOutsideListener(overlay, className) { var element = overlay.querySelector(`.${className}`); var closeOverlay = function (event) { if (!element.contains(event.target) && overlay.contains(event.target)) { overlay.style.display = 'none'; document.removeEventListener('click', closeOverlay); } }; document.addEventListener('click', closeOverlay); } function checkUserprofile() { window.location.href = "settings-free-user"; } // Function to load a script dynamically function loadScript(scriptSrc, callback) { var script = document.createElement('script'); script.type = 'text/javascript'; script.src = scriptSrc; script.onload = callback; // Append the script to the document body document.body.appendChild(script); } function logoClick() { window.location.href = "/index"; } // Function to encode S3 Path in case there's speical characters. function encodeS3ObjectName(s3ObjectName) { return encodeURIComponent(s3ObjectName).replace(/'/g, '%27'); } // Function to deencode S3 Path in case there's speical characters. function decodeS3ObjectName(s3ObjectName) { return decodeURIComponent(s3ObjectName.replace(/%27/g, "'")); } //* Function to get pricing tier function getPricingTier() { return new Promise(function (resolve, reject) { let user_id = localStorage.getItem("user_id") let backend_url = backend_ip + "/users/" + user_id + "/get_user_pricing_tier/"; var xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.onreadystatechange = function () { if (xhr.readyState === XMLHttpRequest.DONE) { msg = "" if (xhr.status === 200) { parsed_response = JSON.parse(xhr.responseText) // console.log(parsed_response) localStorage.setItem("total_allowed_mins", parsed_response.total_allowed_mins); localStorage.setItem("allowed_mins", parsed_response.allowed_mins); localStorage.setItem("remaining_mins", parsed_response.remaining_mins); localStorage.setItem("pricing_tier", parsed_response.pricing_tier); if (parsed_response.pricing_tier == "free") { renderFreeSubscriptions(); } else { // Get subscription details getSubscriptions(); } resolve(parsed_response); } else if (xhr.status === 406) { msg = "Please provide valid name." } else if (xhr.status === 0) { let dom = document.getElementById('checkModalCenter') let navRight = document.querySelector('.three-column') dom && (dom.style.display = 'block') navRight && (navRight.style.display = 'none') // msg = "Server is down, please wait." } else if (xhr.status === 404) { msg = 'Requested page not found. [404]'; } else if (xhr.status === 500) { let dom = document.getElementById('checkModalCenter') let navRight = document.querySelector('.three-column') dom && (dom.style.display = 'block') navRight && (navRight.style.display = 'none') // msg = 'Internal Server Error [500].'; } else if (xhr.status === 401) { localStorage.clear(); window.location.href = "logged-out?login"; } if (msg != "") { console.log(msg) } } }; xhr.open("GET", backend_url); xhr.setRequestHeader("Authorization", 'Token ' + localStorage.getItem("token")); xhr.send(); }) } $(function () { $('.close-button').on('click', function () { $('#image1').toggle(); $('#image2').toggle(); }); $(".closing").click(function () { $('.modal').hide(); $("body").removeClass("modal-open"); $(".modal.in").removeClass("in"); $(".modal-backdrop.in").removeClass("in"); $(".modal-backdrop").remove(); }); $(".selectable .form-check-radio input").click(function () { $(".inactive").removeClass(); }); $("[data-toggle=modal]").click(function () { $('.modal').hide(); $("body").removeClass("modal-open"); $(".modal.in").removeClass("in"); $(".modal-backdrop.in").removeClass("in"); $(".modal-backdrop").remove(); }); $('#myModal').on('shown.bs.modal', function () { $('#myInput').trigger('focus') }); $(".toggle-password").on("click", function () { var passwordField = $(this).siblings("input[type='password']"); var notVisible = passwordField.attr("type"); if (notVisible === "password") { passwordField.attr("type", "text"); } else { passwordField.attr("type", "password"); } }); // Function to toggle password visibility icon $(".toggle-password").click(function () { $(this).toggleClass("fa-eye fa-eye-slash"); }); // Function to handle form submission $("#resetpassword").submit(function (event) { event.preventDefault(); var newPassword = $(this).find("#password-field"); var reenterPassword = $(this).find("#reenter-password-field"); var errorElement = $(this).find("#error"); var reenterErrorElement = $(this).find("#reenter-error"); // Reset previous error messages and styles errorElement.text(""); newPassword.removeClass("error-border"); $("label[for='password-field']").removeClass("error-text"); reenterErrorElement.text(""); reenterPassword.removeClass("error-border"); $("label[for='reenter-password-field']").removeClass("error-text"); if (newPassword.val().length < 8) { errorElement.text("Password must be at least 8 characters long."); newPassword.addClass("error-border"); $("label[for='password-field']").addClass("error-text"); } if (reenterPassword.val() !== newPassword.val()) { reenterErrorElement.text("Passwords do not match."); reenterPassword.addClass("error-border"); $("label[for='reenter-password-field']").addClass("error-text"); } if (newPassword.val().length >= 8 && reenterPassword.val() === newPassword.val()) { // Your validation or submission logic here alert("Password reset: " + newPassword.val()); // Redirect to the main page (replace 'YOUR_MAIN_PAGE_URL' with the actual URL) window.location.href = 'file:///C:/Users/DuoTech%20X/Downloads/v2%20(2)/logged-out.html'; } }); $('.switch input').on("click", function () { $(this).parent().toggleClass('active'); if ($('label.switch').hasClass('active')) { $('.monthly-price').show(); $('.annual-plans').hide(); } else { $('.monthly-price').hide(); $('.annual-plans').show(); } }); // // copy text function // $("#copyButton").on("click", function() { // var inputText = $("#myInput").val(); // var tempInput = $(""); // $("body").append(tempInput); // tempInput.val(inputText).select(); // document.execCommand("copy"); // tempInput.remove(); // // alert("Text copied to clipboard: " + inputText); // }); // // copy link confirm btn // jQuery("#copyButton").click(function() { // // Toggle the class to show or hide the confirmation box // jQuery("#general-sharing .confirmation-box").toggleClass("copy-btn-show"); // }); }); // Function to open the popup function openPopup(headerText='') { if (headerText != '') { const paywallHeader = document.getElementById('paywall-header'); paywallHeader.textContent = headerText; } document.getElementById('popupOverlay').style.display = 'flex'; $('.row.star-steps').show(); $('h2.optional').show(); $('.form-group.star-steps').show(); $('.rating-steps button.btn.btns-primary.link-login').show(); } function signuptwo() { document.getElementById('signup-two-section').style.display = 'flex'; } function signupone() { document.getElementById('signup-section').style.display = 'flex'; } function loginpopup() { document.getElementById('login-section').style.display = 'flex'; document.getElementById('signup-section').style.display = 'none'; document.getElementById('signup-two-section').style.display = 'none'; } function signupclose() { document.getElementById('signup-two-section').style.display = 'none'; document.getElementById('signup-section').style.display = 'none'; } // Function to close the popup function closePopup() { document.getElementById('popupOverlay').style.display = 'none'; document.getElementById('login-section').style.display = 'none'; document.getElementById('changepopupOverlay').style.display = 'none'; } function viewsubchange() { document.getElementById('subscription-change-plan').style.display = 'flex'; } // Function to close the popup function closeviewsubchange() { document.getElementById('subscription-change-plan').style.display = 'none'; } function viewsubplan() { document.getElementById('subscription-cancel-plan').style.display = 'flex'; } // Function to close the popup function closeviewsubplan() { document.getElementById('subscription-cancel-plan').style.display = 'none'; } function viewcancelsub() { document.getElementById('cancel-subscription').style.display = 'flex'; } // Function to close the popup function closeviewcancelsub() { document.getElementById('cancel-subscription').style.display = 'none'; } function resetPassword() { document.getElementById('reset-password').style.display = 'flex'; } // Function to close the popup function closeresetPassword() { document.getElementById('reset-password').style.display = 'none'; } function openResetPasswordLoggedOut() { document.getElementById('reset-password-logged-out').style.display = 'flex'; } // Function to close the popup function closeResetPasswordLoggedOut() { document.getElementById('reset-password-logged-out').style.display = 'none'; } function opendeleteaccount() { document.getElementById('delete-account').style.display = 'flex'; } // Function to close the popup function deleteaccount() { document.getElementById('delete-account').style.display = 'none'; } // Function to close the popup function deleteaccountconfirm() { document.getElementById('delete-account-confirm').style.display = 'none'; } function closesharing() { document.getElementById('general-sharing').style.display = 'none'; } // Function to close the popup function successfullsec() { event.preventDefault(); $(".star-steps").hide(); $(".optional").hide(); $("button.btn.btns-primary.link-login").hide(); $("div#successfull-sec").show(); } function successfullsecclose() { document.getElementById('successfull-sec').style.display = 'none'; $("div#popupOverlay").hide(); // $("div#successfull-sec").hide(); // $("div#popup-two").hide(); } function triggerFileInput() { document.getElementById('photoUpload').click(); } function displayPhoto(input) { const profilePhoto = document.getElementById('profilePhoto'); const file = input.files[0]; if (file) { const reader = new FileReader(); reader.onload = function (e) { profilePhoto.innerHTML = `Profile Photo`; }; reader.readAsDataURL(file); } } function confirmDelete() { // Add logic here to confirm and handle account deletion var confirmDelete = confirm("Are you sure you want to delete this account?"); if (confirmDelete) { // Perform the delete action (e.g., send a request to the server) alert("Account deleted successfully."); } else { // Do nothing or handle cancellation alert("Account deletion cancelled."); } } setTimeout(function () { $('.loading-skeleton').addClass('loaded').removeClass('loading-skeleton'); }, 1000); $(document).ready(function () { $("div#header-logged-out").addClass("loaded"); $("div#header-logged-in").addClass("loaded"); $("div#header-logged-in-unlimited").addClass("loaded"); }); // Function to get initials from a username function getInitials(username) { // Split the username into words var words = username.split(' '); // Get the first letter of the first word var initials = username.charAt(0).toUpperCase(); // Return the initials return initials; } // Call ASR API function runASRTranscribe() { return new Promise(function (resolve, reject) { var backend_url = backend_ip + "/chat/asr_transcribe/"; let s3_object_name = sessionStorage.getItem("s3_object_name_no_encode"); var data = new FormData(); data.append("s3_obj_name", s3_object_name); const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.onreadystatechange = function () { if (xhr.readyState === XMLHttpRequest.DONE) { if (xhr.status === 200) { parsed_response = JSON.parse(xhr.responseText); resolve(parsed_response); } else if (xhr.status === 401) { localStorage.clear(); window.location.href = "logged-out?login"; } else if (xhr.status == 429) { // FIXME: add proper error message display alert("Too many requests in a short time. Please try later"); } else { alert("An error has occured. Please contact admin"); } } }; xhr.open("POST", backend_url); if (localStorage.getItem("user_login") == "true") { xhr.setRequestHeader( "Authorization", "Token " + localStorage.getItem("token") ); } xhr.send(data); }); } function redirectTermsPage() { window.location.href = "terms-of-use.html"; }