// <------------------ Searcjh.js---------------> function redirectToPropertyList() { const city = document.getElementById('index_city').value.trim(); const available_date = document.getElementById('index_available_date').value.trim(); const metro = document.getElementById('index_metropolitan').value; //alert(`${city} | ${metro} | ${available_date}`); if (city && metro) { // both city and metro provided sessionStorage.setItem('city', city); sessionStorage.setItem('available_date', available_date); sessionStorage.setItem('metro', metro); window.location.href = "propertylist.html"; } else if (!city && metro) { // only metro provided sessionStorage.setItem('available_date', available_date); sessionStorage.setItem('metro', metro); window.location.href = "propertylist.html"; } else { alert("Please select a metropolitan area (and city if available)"); } } function profileViewAdmin() { window.location.href = "profile.html"; } function getUserDetails() { var xmlhttp1; var FirstName = document.getElementById("firstName"); var LastName = document.getElementById("lastName"); var Email = document.getElementById("email"); var Phone = document.getElementById("phone"); try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttp1.open("GET", baseurl + "/classifiedsecured/getuserinfo", true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "") { var res = JSON.parse(this.responseText); var response = JSON.parse(res['response']); // console.log(response); FirstName.value = response.firstName = ! null || response.firstName != "" ? response.firstName : "Not found" Email.value = response.emailID = ! null || response.emailID != "" ? response.emailID : "Not found" Phone.value = response.phoneNumber = ! null || response.phoneNumber != "" ? response.phoneNumber : "Not found" LastName.value = response.lastName = ! null || response.lastName != "" ? response.lastName : "Not found" } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/marketadmin/adminlogin.html" } else if (this.status == 500) { var res = JSON.parse(this.responseText); if (res.response === "403 FORBIDDEN") { window.location.href = window.location.protocol + "//" + window.location.host + "/marketadmin/adminlogin.html" } } }; xmlhttp1.send(); } // function getAllPropertiesByMetro(metro, available_date) { // if (metro) { // document.getElementById('index_metropolitan').value = metro; // document.getElementById('breadcrumb_city').innerText = metro; // document.getElementById('breadcrumb_city').classList.add("active"); // } // if (available_date) document.getElementById('available_date').value = available_date; // const xmlhttp = new XMLHttpRequest(); // let path = ""; // if (metro) { // path += "?metro=" + encodeURIComponent(metro); // } // if (available_date) { // path += (path.includes('?') ? '&' : '?') + "date=" + encodeURIComponent(available_date); // } // const apiUrl = baseurl + "/classifiedunsecured/getsspropertiesbymetro" + path; // xmlhttp.open("GET", apiUrl, true); // xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); // xmlhttp.onreadystatechange = function () { // if (this.readyState === 4 && this.status === 200 && this.responseText) { // const res = JSON.parse(this.responseText); // const properties = JSON.parse(res['response']); // const container = document.getElementById("search_house"); // container.innerHTML = ""; // Clear existing properties // // console.log(properties) // properties.forEach(property => { // const propertyData = JSON.parse(property.data); // console.log(propertyData) // const images = JSON.parse(property.image_list); // const imageUrl = // images && images.length > 0 // ? images[0]?.imageLink || "default-image.jpg" // : "https://s3.amazonaws.com/rental-secure-storage-dev/unsecured/imgs/1/1_imgs_image_1727622990453.jpg"; // container.innerHTML += ` //
//
// //
// ${propertyData.streetAddress || 'Address'} // ${propertyData.type} //
// //
// // Property Image // // // // ${property.city || 'Location'} // //
// // //
// $${propertyData.rentAmount || 'N/A'}/month // Avaialable From: ${new Date(property.available_date).toLocaleDateString() || 'N/A'} //
// //
// ${propertyData.squareFeet || 'N/A'} ft² // ${propertyData.bedrooms || 'N/A'} Beds // ${propertyData.bathrooms || 'N/A'} Bath //
//
//
// `; // }); // } // }; // xmlhttp.send(); // } // function for fethcing all properties on view page in admin section function getAllPropertiesAdmin(pageNum) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getadminproperties?pageSize=10&pageNum=${pageNum}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); let data = JSON.parse(property.data) console.log(data) tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` ` // tableData += ``; // tableData += ''; // tableData += ''; tableData += ''; document.getElementById('property_inventory_table').innerHTML = tableData; } // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // // else { // document.querySelector("#pageNext").style.display = "inline"; // } } } xmlhttp.send(); } // redirect to new tab for detailed property view (to unsecured page) function detailUnsecuredView(button) { //console.log("redirecting") const property_id = button.getAttribute('data-id') let url = window.location.protocol + "//" + window.location.host + `/propertydetail.html?propertyId=${property_id}`; window.location.href = url; //window.open(`http://classifiedsweb-dev.s3-website-us-east-1.amazonaws.com/propertydetail.html?propertyId=${property_id}`) } // function for fethcing all properties on view page in admin section filtered by city function getAllPropertiesAdminViaCity(pageNum, city) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getadminproperties?pageSize=10&pageNum=${pageNum}&city=${city}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); let data = JSON.parse(property.data) //onsole.log(data) tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` ` // tableData += ``; // tableData += ''; // tableData += ''; tableData += ''; document.getElementById('property_inventory_table').innerHTML = tableData; } // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // // else { // document.querySelector("#pageNext").style.display = "inline"; // } } } xmlhttp.send(); } // function for fethcing all properties on view page in admin section filtered by advertiser's email function getAllPropertiesAdminViaLandlordEmail(pageNum, landlord_email) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getadminproperties?pageSize=10&pageNum=${pageNum}&landlordemail=${landlord_email}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); let data = JSON.parse(property.data) //onsole.log(data) tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` ` // tableData += ``; // tableData += ''; // tableData += ''; tableData += ''; document.getElementById('property_inventory_table').innerHTML = tableData; } // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // } // else { // document.querySelector("#pageNext").style.display = "inline"; // } } } xmlhttp.send(); } // function for fethcing all properties on view page in admin section filtered by state function getAllPropertiesAdminViaState(pageNum, state) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getadminproperties?pageSize=10&pageNum=${pageNum}&state=${state}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); let data = JSON.parse(property.data) //onsole.log(data) tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` ` // tableData += ``; // tableData += ''; // tableData += ''; tableData += ''; document.getElementById('property_inventory_table').innerHTML = tableData; } // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // } // else { // document.querySelector("#pageNext").style.display = "inline"; // } } } xmlhttp.send(); } // function for fethcing all properties on view page in admin section filtered by property id function getAllPropertiesAdminViaP_id(pageNum, property_id) { console.log(property_id) var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getadminproperties?pageSize=10&pageNum=${pageNum}&propertyid=${property_id}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); let data = JSON.parse(property.data) //onsole.log(data) tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` ` // tableData += ``; // tableData += ''; // tableData += ''; tableData += ''; document.getElementById('property_inventory_table').innerHTML = tableData; } // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // } // else { // document.querySelector("#pageNext").style.display = "inline"; // } } } xmlhttp.send(); } // function for fethcing all properties on view page in admin section filtered by zip function getAllPropertiesAdminViaZip(pageNum, zip) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getadminproperties?pageSize=10&pageNum=${pageNum}&zip=${zip}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); let data = JSON.parse(property.data) //onsole.log(data) tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` ` // tableData += ``; // tableData += ''; // tableData += ''; tableData += ''; document.getElementById('property_inventory_table').innerHTML = tableData; } // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // } // else { // document.querySelector("#pageNext").style.display = "inline"; // } } } xmlhttp.send(); } //populate table at archive page in admin section and call propertyenabler function onClick function enablePropertiesAdmin(pageNum) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getarchiveproperties?pageSize=10&pageNum=${pageNum}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { // console.log(this.responseText) var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) //console.log(props) if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } var serial = (pageNum - 1) * 10; var tableData = ''; for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); console.log(props.length) let data = JSON.parse(property.data) if (property.delete_flag == 1) { tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` Property Deleted `; // tableData += ``; // tableData += ''; // tableData += ''; // tableData += ''; } else { document.getElementById('property_inventory_table').innerHTML = tableData; tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ``; // tableData += ``; // tableData += ''; // tableData += ''; // tableData += ''; } document.getElementById('property_inventory_table').innerHTML = tableData; } } } xmlhttp.send(); } //populate table at archive page in admin section and call propertyenabler function onClick, filtered by state function enablePropertiesAdminViaState(pageNum, state) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getarchiveproperties?pageSize=10&pageNum=${pageNum}&state=${state}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { // console.log(this.responseText) var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) //console.log(props) if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } var serial = (pageNum - 1) * 10; var tableData = ''; for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); console.log(props.length) let data = JSON.parse(property.data) if (property.delete_flag == 1) { tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` Property Deleted `; // tableData += ``; // tableData += ''; // tableData += ''; // tableData += ''; } else { document.getElementById('property_inventory_table').innerHTML = tableData; tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ``; // tableData += ``; // tableData += ''; // tableData += ''; // tableData += ''; } document.getElementById('property_inventory_table').innerHTML = tableData; } } } xmlhttp.send(); } //populate table at archive page in admin section and call propertyenabler function onClick , filtered by city function enablePropertiesAdminViaCity(pageNum, city) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getarchiveproperties?pageSize=10&pageNum=${pageNum}&city=${city}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { // console.log(this.responseText) var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) //console.log(props) if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } var serial = (pageNum - 1) * 10; var tableData = ''; for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); console.log(props.length) let data = JSON.parse(property.data) if (property.delete_flag == 1) { tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` Property Deleted `; // tableData += ``; // tableData += ''; // tableData += ''; // tableData += ''; } else { document.getElementById('property_inventory_table').innerHTML = tableData; tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ``; // tableData += ``; // tableData += ''; // tableData += ''; // tableData += ''; } document.getElementById('property_inventory_table').innerHTML = tableData; } } } xmlhttp.send(); } //populate table at archive page in admin section and call propertyenabler function onClick ,filtered by ZIP function enablePropertiesAdminViaZip(pageNum, zip) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getarchiveproperties?pageSize=10&pageNum=${pageNum}&zip=${zip}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { // console.log(this.responseText) var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) //console.log(props) if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } var serial = (pageNum - 1) * 10; var tableData = ''; for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); console.log(props.length) let data = JSON.parse(property.data) if (property.delete_flag == 1) { tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` Property Deleted `; // tableData += ``; // tableData += ''; // tableData += ''; // tableData += ''; } else { document.getElementById('property_inventory_table').innerHTML = tableData; tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ``; // tableData += ``; // tableData += ''; // tableData += ''; // tableData += ''; } document.getElementById('property_inventory_table').innerHTML = tableData; } } } xmlhttp.send(); } //populate table at archive page in admin section and call propertyenabler function onClick ,filtered by property id function enablePropertiesAdminViaPropertyID(pageNum, property_id) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getarchiveproperties?pageSize=10&pageNum=${pageNum}&propertyid=${property_id}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { // console.log(this.responseText) var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) //console.log(props) if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } var serial = (pageNum - 1) * 10; var tableData = ''; for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); console.log(props.length) let data = JSON.parse(property.data) if (property.delete_flag == 1) { tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` Property Deleted `; // tableData += ``; // tableData += ''; // tableData += ''; // tableData += ''; } else { document.getElementById('property_inventory_table').innerHTML = tableData; tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ``; // tableData += ``; // tableData += ''; // tableData += ''; // tableData += ''; } document.getElementById('property_inventory_table').innerHTML = tableData; } } } xmlhttp.send(); } //populate table at archive page in admin section and call propertyenabler function onClick ,filtered by landlord email function enablePropertiesAdminViaLandlordEmail(pageNum, landlord_email) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getarchiveproperties?pageSize=10&pageNum=${pageNum}&landlordemail=${landlord_email}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { // console.log(this.responseText) var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) //console.log(props) if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } var serial = (pageNum - 1) * 10; var tableData = ''; for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); console.log(props.length) let data = JSON.parse(property.data) if (property.delete_flag == 1) { tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` Property Deleted `; // tableData += ``; // tableData += ''; // tableData += ''; // tableData += ''; } else { document.getElementById('property_inventory_table').innerHTML = tableData; tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ``; // tableData += ``; // tableData += ''; // tableData += ''; // tableData += ''; } document.getElementById('property_inventory_table').innerHTML = tableData; } } } xmlhttp.send(); } //populate disable admin table and call propertydisabler function onClick // <<<<<<<<<< NOT IN USE >>>>>>>>>>>> // function disablePropertiesAdmin(pageNum) { // var xmlhttp // try { // xmlhttp = new XMLHttpRequest(); // } catch (error) { // try { // xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") // } catch (error) { // try { // xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") // } catch (error) { // alert("Browser unsupported") // } // } // } // xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getadminproperties?pageSize=10&pageNum=${pageNum}`, true); // xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); // xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); // xmlhttp.onreadystatechange = function () { // if (this.readyState == 4 && this.status == 200 && this.responseText != null) { // // console.log(this.responseText) // var response = JSON.parse(this.responseText) // var props = JSON.parse(response.response) // //console.log(props) // //pagination // if (props.length < 10) { // document.querySelector("#pageNext").style.display = "none"; // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // } // else { // document.querySelector("#pageNext").style.display = "inline"; // } // var serial = (pageNum - 1) * 10; // var tableData = ''; // for (var i = 0; i <= props.length - 1; i++) { // let property = props[i]; // var serialNo = serial + (i + 1); // let data = JSON.parse(property.data) // console.log(data, i) // tableData += ''; // tableData += '' + serialNo + ''; // tableData += '' + property.property_id + ''; // tableData += '' + data.landlordEmail + ''; // tableData += '' + data.type + ''; // tableData += '' + data.rentAmount + ' $' + ''; // tableData += '' + data.city + ''; // tableData += '' + data.state + ''; // tableData += '' + data.zip + ''; // tableData += ` `; // // tableData += ``; // // tableData += ''; // // tableData += ''; // tableData += ''; // document.getElementById('property_inventory_table').innerHTML = tableData; // } // // if (props == "") { // // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // // document.querySelector("#pageNext").style.display = "none"; // // console.log("no result") // // } // // else { // // document.querySelector("#pageNext").style.display = "inline"; // // } // } // } // xmlhttp.send(); // } //populate delete admin table and call propertydeleter function onClick function deletePropertiesAdmin(pageNum) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getadminproperties?pageSize=10&pageNum=${pageNum}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { // console.log(this.responseText) var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) //console.log(props) var serial = (pageNum - 1) * 10; var tableData = ''; for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); let data = JSON.parse(property.data) console.log(data, i) tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ``; // tableData += ``; // tableData += ''; // tableData += ''; tableData += ''; document.getElementById('property_inventory_table').innerHTML = tableData; } if (props.length() < 1) { document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; document.querySelector("#pageNext").style.display = "none"; console.log("no result") } else { document.querySelector("#pageNext").style.display = "inline"; } } } xmlhttp.send(); } // ENABLE DISABLED PROPERTY function propertyEnabler(button) { const property_id = button.getAttribute('data-id') var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported"); return false; } } } // xmlhttp.open("POST", "http://localhost:8088//classifiedsecured/enableadminproperty?propertyid=" + property_id, true) xmlhttp.open("POST", baseurl + "/classifiedsecured/enableadminproperty?propertyid=" + property_id, true) xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8') xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.onreadystatechange = () => { //console.log(xmlhttp.readyState) // console.log(xmlhttp.status) if (xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText != "") { var response = JSON.parse(xmlhttp.responseText) //console.log(response) var inResponse = JSON.parse(response.response) //console.log(inResponse) if (response.rspnsCode == 1000 && inResponse.message == "Property status : enabled") { alert("Property enabled succesfully") //let url = window.location.protocol + "//" + window.location.host + `admin/admin-delete.html`; window.location.reload() } } } xmlhttp.send() } // DISABLE PROPERTY function propertyDisabler(button) { const property_id = button.getAttribute('data-id') var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported"); return false; } } } // xmlhttp.open("POST", "http://localhost:8088/classifiedsecured/disableadminproperty?propertyid=" + property_id, true) xmlhttp.open("POST", baseurl + "/classifiedsecured/disableadminproperty?propertyid=" + property_id, true) xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8') xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.onreadystatechange = () => { //console.log(xmlhttp.readyState) // console.log(xmlhttp.status) if (xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText != "") { var response = JSON.parse(xmlhttp.responseText) //console.log(response) var inResponse = JSON.parse(response.response) //console.log(inResponse) if (response.rspnsCode == 1000 && inResponse.message == "Property status : disabled") { alert("Property disabled succesfully") //let url = window.location.protocol + "//" + window.location.host + `admin/admin-delete.html`; window.location.reload() } } } xmlhttp.send() } //DELETE PROPERTY function propertyDeleter(button) { const property_id = button.getAttribute('data-id') var xmlhttp if (confirm("Do you want to delete the property?") == true) { try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported"); return false; } } } // xmlhttp.open("POST", "http://localhost:8088/classifiedsecured/deleteadminproperty?propertyid=" + property_id, true) xmlhttp.open("POST", baseurl + "/classifiedsecured/deleteadminproperty?propertyid=" + property_id, true) xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8') xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.onreadystatechange = () => { //console.log(xmlhttp.readyState) // console.log(xmlhttp.status) if (xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText != "") { var response = JSON.parse(xmlhttp.responseText) //console.log(response) var inResponse = JSON.parse(response.response) //console.log(inResponse) if (response.rspnsCode == 1000 && inResponse.message == "Property status : deleted") { alert("Property deleted succesfully") //let url = window.location.protocol + "//" + window.location.host + `admin/admin-delete.html`; window.location.reload() } } } xmlhttp.send() } else { alert("Deletion terminated by user") return; } } function getAllPropertiesviaIndex(city, available_date, metro) { // alert(`${city} | ${metro} | ${available_date}`); if (available_date) { document.getElementById('available_date').value = available_date; } const xmlhttp = new XMLHttpRequest(); let path = ""; if (city && city.trim() !== "") { // city provided path += "getssproperties?city=" + encodeURIComponent(city); } else if (metro && metro.trim() !== "") { // no city, but metro provided path += "getssproperties?metro=" + encodeURIComponent(metro); } if (available_date) { path += (path.includes('?') ? '&' : '?') + "date=" + encodeURIComponent(available_date); } const apiUrl = baseurl + "/classifiedunsecured/" + path; // alert(apiUrl) xmlhttp.open("GET", apiUrl, true); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState === 4 && this.status === 200 && this.responseText) { const res = JSON.parse(this.responseText); const properties = JSON.parse(res['response']); const container = document.getElementById("search_house"); container.innerHTML = ""; // Clear existing properties // console.log(properties); if (properties.length === 0) { container.innerHTML += '

No available property

' return } properties.forEach(property => { const propertyData = JSON.parse(property.data); const images = JSON.parse(property.image_list); const imageUrl = images && images.length > 0 ? images[0]?.imageLink || "default-image.jpg" : "https://s3.amazonaws.com/rental-secure-storage-dev/unsecured/imgs/1/1_imgs_image_1727622990453.jpg"; container.innerHTML += `
${propertyData.showHouse ? propertyData.houseNo : propertyData.locality} ${propertyData.showHouse ? "," : ""} ${propertyData.showStreet ? propertyData.streetAddress : ""} ${propertyData.type}
Property Image ${property.city || 'Location'}, ${property.metropolitan || 'Location'}
$${propertyData.rentAmount || 'N/A'}/month Available From: ${property.available_date ? new Date(property.available_date).toLocaleDateString() : 'N/A'}
${propertyData.squareFeet || 'N/A'} ft² ${propertyData.bedrooms || 'N/A'} Beds ${propertyData.bathrooms || 'N/A'} Bath
`; }); } }; xmlhttp.send(); } //Property List Page function getAllProperties() { sessionStorage.clear(); var city = document.getElementById('index_city').value; var available_date = document.getElementById('available_date').value; var metro = document.getElementById('index_metropolitan').value; // alert("getAllProperties"+ metro) if (metro) { var xmlhttp; try { xmlhttp = new XMLHttpRequest(); } catch (e) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Browser unsupported"); return false; } } } var path = ""; if (city && city.trim() !== "") { // city provided path += "getssproperties?city=" + encodeURIComponent(city); } else if (metro && metro.trim() !== "") { // no city, but metro provided path += "getssproperties?metro=" + encodeURIComponent(metro); } if (available_date) { path += (path.includes('?') ? '&' : '?') + "date=" + encodeURIComponent(available_date); } const apiUrl = baseurl + "/classifiedunsecured/" + path; xmlhttp.open("GET", apiUrl, true); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText) { var res = JSON.parse(this.responseText); var properties = JSON.parse(res['response']); console.log(properties); var container = document.getElementById("search_house"); container.innerHTML = ""; // Clear the container before appending new content if (properties.length === 0) { container.innerHTML += '

No available property

' return } let order = { basic: 1, premium: 2, TBD: 3 }; properties.sort((a, b) => order[a.profile] - order[b.profile]); console.log(properties) for (var i = 0; i < properties.length; i++) { var property = properties[i]; //console.log(property); var propertyData = JSON.parse(property.data); // console.log(propertyData) var images = JSON.parse(property.image_list); // console.log(images) if (images !== null && images !== "") { // console.log('chacha2') var imageUrl = images[0].imageLink; } else { // console.log('chacha') imageUrl = "https://s3.amazonaws.com/rental-secure-storage-dev/unsecured/imgs/1/1_imgs_image_1727622990453.jpg"; } // console.log(propertyData); container.innerHTML += `
${propertyData.showHouse ? propertyData.houseNo : propertyData.locality} ${propertyData.showHouse ? " ," : ""} ${propertyData.showStreet ? propertyData.streetAddress : ""} ${propertyData.type}
Property Image ${property.city || 'Location'} , ${property.metropolitan || 'Location'}
$${propertyData.rentAmount || 'N/A'}/month Avaialable From: ${new Date(property.available_date).toLocaleDateString() || 'N/A'}
${propertyData.squareFeet || 'N/A'} ft² ${propertyData.bedrooms || 'N/A'} Beds ${propertyData.bathrooms || 'N/A'} Bath
`; } } }; } else { alert("Please select atleast a metropolitan area"); } xmlhttp.send(); } function filterCity(city) { document.getElementById('index_city').value = city; document.getElementById('breadcrumb_city').value = city; getAllProperties(); } function capitalize(str) { if (!str) return ""; return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); } // lOADS PROPERTY DETAILS (UNSECURED) function getPropertyDetails(propertyId, pageName) { // alert(pageName) var xmlhttp; try { xmlhttp = new XMLHttpRequest(); } catch (e) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Browser unsupported"); return false; } } } xmlhttp.open("GET", baseurl + "/" + "classifiedunsecured/getssproperty?propertyId=" + propertyId, true); // xmlhttp.open("GET", "http://localhost:8088/classifiedunsecured/getssproperty?propertyId=" + propertyId, true); xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); xmlhttp.onreadystatechange = function () { //console.log(propertyId) if (this.readyState === 4 && this.status === 200) { try { const res = JSON.parse(this.responseText); const property = JSON.parse(res.response)[0]; const propertyData = JSON.parse(property.data); const images = JSON.parse(property.image_list); //console.log(images); console.log(propertyData); if (pageName == "propertydetail") { document.getElementById("search_prop_add").textContent = ` ${propertyData.showHouse ? propertyData.houseNo + " " + "," : ""} ${propertyData.showStreet ? propertyData.streetAddress + " " + "," : ""} ${propertyData.city || "N/A"} , ${propertyData.state || "N/A"} ( ${propertyData.zip || "N/A"} )`; // document.getElementById("search_room_no").textContent = // ` ${propertyData.houseNo || "Not available"}`; document.getElementById("property_type").textContent = propertyData.type || "N/A"; const carouselInner = document.querySelector(".carousel-inner"); const carouselIndicators = document.querySelector(".carousel-indicators"); if (images) { carouselInner.innerHTML = images.map((image, index) => ` `).join(""); carouselIndicators.innerHTML = images.map((image, index) => ` `).join(""); } //document.getElementById("search_status").textContent = propertyData.status || "Unavailable"; document.getElementById("move_in_date").textContent = new Date(property.available_date).toLocaleDateString(); document.getElementById("prop_desc").textContent = propertyData.propertyDesc || "No description available"; document.getElementById("rentAmount").textContent = `$${propertyData.rentAmount || "0"}`; document.getElementById("terms_condition").textContent = propertyData.termsAndConditions || "No notes available"; document.getElementById("ss_area").textContent = `${propertyData.squareFeet || "N/A"} Sq.Ft.`; document.getElementById("search_bed").textContent = propertyData.bedrooms; document.getElementById("search_bathroom").textContent = propertyData.bathrooms || "N/A"; document.getElementById("car_parking").textContent = propertyData.carParking || "N/A"; document.getElementById("pets").textContent = propertyData.pets || "N/A"; document.getElementById("furnishing").textContent = propertyData.furnishing || "N/A"; } else if (pageName == "add-properties") { document.getElementById("property_id").value = property.property_id || ""; document.getElementById("landlord_email").value = propertyData.landlordEmail || ""; document.getElementById("type").value = propertyData.type || ""; document.getElementById("bedrooms").value = propertyData.bedrooms || ""; document.getElementById("bathrooms").value = propertyData.bathrooms || ""; document.getElementById("furnishing").value = propertyData.furnishing || ""; document.getElementById("squareFeet").value = propertyData.squareFeet || ""; document.getElementById("carParking").value = propertyData.carParking || ""; document.getElementById("carParkingType").value = propertyData.carParkingType || ""; document.getElementById("rentAmount").value = propertyData.rentAmount || ""; document.getElementById("rentalRate").value = propertyData.rentalRate || ""; document.getElementById("houseNo").value = propertyData.houseNo || ""; document.getElementById("streetAddress").value = propertyData.streetAddress || ""; document.getElementById("state").value = propertyData.state || ""; document.getElementById("city").value = propertyData.city || ""; document.getElementById("zip").value = propertyData.zip || ""; document.getElementById("country").value = propertyData.country || ""; document.getElementById("pets").value = propertyData.pets || ""; document.getElementById("termsAndConditions").value = propertyData.termsAndConditions || ""; document.getElementById("propertyDesc").value = propertyData.propertyDesc || ""; let imageView = ""; const imageContainer = document.getElementById("property_images_container"); if (images.length > 0) { if (imageContainer) { imageContainer.style.display = "block"; // Show the container if images exist } images.forEach((image, index) => { const indexOfFile = image.imageLink.indexOf("unsecured"); const fileName = image.imageLink.slice(indexOfFile); const indexOfImage = image.imageLink.indexOf("image"); const imageID = image.imageLink.slice(indexOfImage); imageView += `
Image ×
`; }); } else { if (imageContainer) { imageContainer.style.display = "none"; // Hide if no images } } document.getElementById("container_uploaded").innerHTML = imageView; if (property.status == "PUBLISHED") { const saveButton = document.getElementById("search_save"); if (saveButton) { saveButton.classList.add("d-none"); } const submitButton = document.getElementById("search_submit"); if (submitButton) { submitButton.textContent = "Update"; } } } } catch (error) { console.error(`Error parsing property details: ${error}`); } } }; xmlhttp.send(); } // HTML include another HTML function includeHTML() { var z, i, elmnt, file, xhttp; /*loop through a collection of all HTML elements:*/ z = document.getElementsByTagName("*"); for (i = 0; i < z.length; i++) { elmnt = z[i]; /*search for elements with a certain attribute:*/ file = elmnt.getAttribute("w3-include-html"); if (file) { /*make an HTTP request using the attribute value as the file name:*/ xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { if (this.readyState == 4) { if (this.status == 200) { elmnt.innerHTML = this.responseText; } if (this.status == 404) { elmnt.innerHTML = "Page not found."; } /*remove the attribute, and call this function once more:*/ elmnt.removeAttribute("w3-include-html"); includeHTML(); } } xhttp.open("GET", file, true); xhttp.send(); return; } } }; // POPULATES METROPOLITANS IN SEARCH SCREEN'S DROPDOWN IN add-property pages function populateMetroAddProperty() { var xmlhttp; try { xmlhttp = new XMLHttpRequest(); } catch (e) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Browser unsupported"); return false; } } } xmlhttp.open("GET", baseurl + "/" + "classifiedunsecured/getmetropolitan", true); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText) { var res = JSON.parse(this.responseText); if (res.rspnsCode === 1000) { var response = (res.response); console.log(response) var metro = JSON.parse(response) // console.log(metro) var dropdown = ''; metro.forEach(item => { dropdown += ''; }) } $("#Metropolitan").html(dropdown); }; }; xmlhttp.send(); } function populateMetroUpdateProperty(metroOld) { var xmlhttp; try { xmlhttp = new XMLHttpRequest(); } catch (e) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Browser unsupported"); return false; } } } xmlhttp.open("GET", baseurl + "/" + "classifiedunsecured/getmetropolitan", true); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText) { var res = JSON.parse(this.responseText); if (res.rspnsCode === 1000) { var response = (res.response); //console.log(response) var metro = JSON.parse(response) // console.log(metro) var dropdown = `'; metro.forEach(item => { if (item !== metroOld) { dropdown += ''; } }) } $("#Metropolitan").html(dropdown); }; }; xmlhttp.send(); } // POPULATES METROPOLITANS IN SEARCH SCREEN'S DROPDOWN function populateMetro(prev) { var xmlhttp; try { xmlhttp = new XMLHttpRequest(); } catch (e) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Browser unsupported"); return false; } } } xmlhttp.open("GET", baseurl + "/" + "classifiedunsecured/getmetropolitan", true); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText) { var res = JSON.parse(this.responseText); if (res.rspnsCode === 1000) { var response = (res.response); // console.log(response) var metro = JSON.parse(response) // console.log(metro) var metrop = sessionStorage.getItem('metro') var dropdown = ``; metro.forEach(item => { item.metro_name != prev ? dropdown += '' : "" }) } $("#index_metropolitan").html(dropdown); }; } xmlhttp.send(); } function populateMetroIndex() { var xmlhttp; try { xmlhttp = new XMLHttpRequest(); } catch (e) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Browser unsupported"); return false; } } } xmlhttp.open("GET", baseurl + "/" + "classifiedunsecured/getmetropolitan", true); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText) { var res = JSON.parse(this.responseText); if (res.rspnsCode === 1000) { var response = (res.response); // console.log(response) var metro = JSON.parse(response) //console.log(metro) var dropdown = ''; metro.forEach(item => { //console.log(dropdown) dropdown += ''; }) } // console.log(dropdown) $("#index_metropolitan").html(dropdown); }; } xmlhttp.send(); } // POPULATES CITIES IN SEARCH SCREEN'S DROPDOWN function populateCities(metro, prev) { // console.log(metro) var xmlhttp; try { xmlhttp = new XMLHttpRequest(); } catch (e) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Browser unsupported"); return false; } } } xmlhttp.open("GET", baseurl + "/" + "classifiedunsecured/populatecity?metro=" + metro, true); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText) { var res = JSON.parse(this.responseText); var cities = JSON.parse(res['response']); console.log(cities); // alert("previus city :" + prev) var selectElement = document.getElementById("index_city"); // selectElement.innerHTML = "" prev === null ? selectElement.innerHTML += '' : `` if (prev === undefined) selectElement.innerHTML += "" cities.forEach(function (item) { item.city_name !== prev ? selectElement.innerHTML += `` : "" }); prev !== null ? selectElement.innerHTML += '' : "" // Get city from sessionStorage and select it if available } } xmlhttp.send(); } function populateIndexCities(metro) { // console.log(metro) var xmlhttp; try { xmlhttp = new XMLHttpRequest(); } catch (e) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Browser unsupported"); return false; } } } xmlhttp.open("GET", baseurl + "/" + "classifiedunsecured/populatecity?metro=" + metro, true); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText) { var res = JSON.parse(this.responseText); var cities = JSON.parse(res['response']); console.log(cities); var selectElement = document.getElementById("index_city"); selectElement.innerHTML = '' cities.forEach(function (item) { selectElement.innerHTML += `` }); // Get city from sessionStorage and select it if available } } xmlhttp.send(); } function populateCityAddProperty(metro) { // console.log(metro) var xmlhttp; try { xmlhttp = new XMLHttpRequest(); } catch (e) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Browser unsupported"); return false; } } } xmlhttp.open("GET", baseurl + "/" + "classifiedunsecured/populatecity?metro=" + metro, true); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText) { var res = JSON.parse(this.responseText); var cities = JSON.parse(res['response']); console.log(cities); var selectElement = document.getElementById("city"); selectElement.innerHTML = ''; cities.forEach(function (item) { selectElement.innerHTML += ``; }); } } xmlhttp.send(); } // ADD PROPERTY UNSECURED function addProperty(propertyID, showHouse, showStreet) { // alert(propertyID); return new Promise((resolve, reject) => { // let token = localStorage.getItem("token") let landlordEmail = $("#landlord_email").val().trim().toLowerCase(); let city = $("#city").val().trim().toLowerCase(); let type = $("#type").val(); let squareFeet = $("#squareFeet").val(); let bedrooms = $("#bedrooms").val(); let bathrooms = $("#bathrooms").val(); let furnishing = $("#furnishing").val(); let carParking = $("#carParking").val(); let carParkingType = $("#carParkingType").val(); let rentAmount = $("#rentAmount").val(); let rentalRate = $("#rentalRate").val(); let houseNo = $("#houseNo").val(); let streetAddress = $("#streetAddress").val().toLowerCase(); let zip = $("#zip").val(); let state = $("#state").val(); let country = $("#country").val().toLowerCase(); let pets = $("#pets").val(); let available_date = $("#available_date").val(); let available_upto_date let metropolitan = $("#Metropolitan").val(); let locality = $("#locality").val(); if ($("#available_upto_date").val() == null || $("#available_upto_date").val() == "") { available_upto_date = null } else { available_upto_date = $("#available_upto_date").val() } let isValid = true; function showError(fieldId, message) { $(`#${fieldId}_error`).text(message); $(`#${fieldId}`).focus() isValid = false; } function validateField(value, fieldId, message) { if (!value || value.trim() === "") { showError(fieldId, message); } else { $(`#${fieldId}_error`).text(""); // Clear error message if valid } } // Validate mandatory fields validateField(landlordEmail, "landlord_email", "This field is mandatory"); validateField(type, "type", "This field is mandatory"); validateField(bedrooms, "bedrooms", "This field is mandatory"); validateField(bathrooms, "bathrooms", "This field is mandatory"); validateField(furnishing, "furnishing", "This field is mandatory"); validateField(squareFeet, "squareFeet", "This field is mandatory"); validateField(available_date, "available_date", "This field is mandatory"); validateField(carParking, "carParking", "This field is mandatory"); validateField(carParkingType, "carParkingType", "This field is mandatory"); validateField(rentAmount, "rentAmount", "This field is mandatory"); validateField(rentalRate, "rentalRate", "This field is mandatory"); validateField(houseNo, "houseNo", "This field is mandatory"); validateField(streetAddress, "streetAddress", "This field is mandatory"); validateField(city, "city", "This field is mandatory"); validateField(zip, "zip", "This field is mandatory"); validateField(state, "state", "This field is mandatory"); validateField(metropolitan, "Metropolitan", "This field is mandatory"); validateField(pets, "pets", "This field is mandatory"); validateField(locality, "locality", "This field is mandatory"); // Stop execution if validation fails if (!isValid) { $("#search_submit").prop('disabled', false) // alert('Please fill all mandatory fields.'); const validationModal = new bootstrap.Modal(document.getElementById('validationModal')); validationModal.show(); return; } // let images = []; // $("#container_uploaded img").each(function () { // let src = $(this).attr("src"); // if (src) { // images.push({ imageLink: src }); // } // }); console.log("Extracted Images:", JSON.stringify(images)); let payload = { // property_id: $("#property_id").val(), advertiser_id: landlordEmail, available_date: available_date, available_to: available_upto_date, city: city, delete_flag: 0, // image_list: JSON.stringify(images), searchData: { type: type, squareFeet: squareFeet, bedrooms: bedrooms, rentAmount: rentAmount, streetAddress: streetAddress, houseNo: houseNo, city: city, state: state, zip: zip, country: country, bathrooms: bathrooms, furnishing: furnishing, carParking: carParking, carParkingType: carParkingType, rentalRate: rentalRate, termsAndConditions: $("#termsAndConditions").val(), propertyDesc: $("#propertyDesc").val(), landlordEmail: landlordEmail, pets: pets, locality: locality, showHouse: showHouse, showStreet: showStreet }, metropolitan: metropolitan }; console.log(payload) // alert("ok") let xmlhttp1 = new XMLHttpRequest(); // alert(baseurl + "/classifiedsecured/addproperty?propertyid=" + propertyID) xmlhttp1.open("POST", baseurl + "/classifiedunsecured/addssproperty?propertyId=" + propertyID, true); //xmlhttp1.open("POST", "http://localhost:8088/classifiedsecured/addproperty?propertyid=" + propertyID, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); // xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (xmlhttp1.readyState === 4) { if (xmlhttp1.status === 200) { try { let res = JSON.parse(xmlhttp1.responseText); let responseData = JSON.parse(res.response); // console.log(res); // console.log(responseData.message); if (responseData.message == "Property updated/added successfully") { //createLandlordAccount(landlordEmail) resolve("success"); } else { alert("Failed to add property. Please try again."); reject("Add property failed 1"); } } catch (e) { // console.error(e) alert("Property added, but an error occurred while parsing the server response."); reject("Error in parsing response"); } } else { reject("Add property failed 2"); } } }; xmlhttp1.send(JSON.stringify(payload)); }); // return new Promise((resolve, reject) => { // let landlordEmail = $("#landlord_email").val().trim(); // let city = $("#city").val().trim(); // let type = $("#type").val(); // let squareFeet = $("#squareFeet").val(); // let bedrooms = $("#bedrooms").val(); // let bathrooms = $("#bathrooms").val(); // let furnishing = $("#furnishing").val(); // let carParking = $("#carParking").val(); // let carParkingType = $("#carParkingType").val(); // let rentAmount = $("#rentAmount").val(); // let rentalRate = $("#rentalRate").val(); // let houseNo = $("#houseNo").val(); // let streetAddress = $("#streetAddress").val(); // let zip = $("#zip").val(); // let state = $("#state").val(); // let country = $("#country").val(); // let pets = $("#pets").val(); // let locality = $("#locality").val(); // let isValid = true; // function showError(fieldId, message) { // $(`#${fieldId}_error`).text(message); // isValid = false; // } // function validateField(value, fieldId, message) { // if (!value || value.trim() === "") { // showError(fieldId, message); // } else { // $(`#${fieldId}_error`).text(""); // Clear error message if valid // } // } // // Validate mandatory fields // validateField(landlordEmail, "landlord_email", "This field is mandatory"); // validateField(type, "type", "This field is mandatory"); // validateField(bedrooms, "bedrooms", "This field is mandatory"); // validateField(bathrooms, "bathrooms", "This field is mandatory"); // validateField(furnishing, "furnishing", "This field is mandatory"); // validateField(squareFeet, "squareFeet", "This field is mandatory"); // validateField(carParking, "carParking", "This field is mandatory"); // validateField(carParkingType, "carParkingType", "This field is mandatory"); // validateField(rentAmount, "rentAmount", "This field is mandatory"); // validateField(rentalRate, "rentalRate", "This field is mandatory"); // validateField(houseNo, "houseNo", "This field is mandatory"); // validateField(streetAddress, "streetAddress", "This field is mandatory"); // validateField(city, "city", "This field is mandatory"); // validateField(zip, "zip", "This field is mandatory"); // validateField(state, "state", "This field is mandatory"); // validateField(locality, "locality", "This field is mandatory"); // validateField(pets, "pets", "This field is mandatory"); // // Stop execution if validation fails // if (!isValid) { // alert('Please fill all mandatory fields.'); // return reject("Validation failed"); // } // let images = []; // $("#container_uploaded img").each(function () { // let src = $(this).attr("src"); // if (src) { // images.push({ imageLink: src }); // } // }); // console.log("Extracted Images:", images); // let payload = { // property_id: $("#property_id").val(), // city: city, // delete_flag: 0, // image_list: JSON.stringify(images), // searchData: { // type: type, // squareFeet: squareFeet, // bedrooms: bedrooms, // rentAmount: rentAmount, // streetAddress: streetAddress, // houseNo: houseNo, // city: city, // state: state, // zip: zip, // country: country, // bathrooms: bathrooms, // furnishing: furnishing, // carParking: carParking, // carParkingType: carParkingType, // rentalRate: rentalRate, // termsAndConditions: $("#termsAndConditions").val(), // propertyDesc: $("#propertyDesc").val(), // landlordEmail: landlordEmail, // pets: pets, // locality: locality // } // }; // let xmlhttp1 = new XMLHttpRequest(); // xmlhttp1.open("POST", baseurl + "/classifiedunsecured/addssproperty?propertyId=" + propertyID, true); // xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); // xmlhttp1.onreadystatechange = function () { // if (xmlhttp1.readyState === 4) { // if (xmlhttp1.status === 200) { // try { // let res = JSON.parse(xmlhttp1.responseText); // let responseData = JSON.parse(res.response); // if (res.rspnsMsg === "good") { // alert("Please check your email for the OTP to proceed."); // resolve(responseData.otp); // } else { // alert("Failed to add property. Please try again."); // reject("Add property failed"); // } // } catch (e) { // alert("Property added, but an error occurred while parsing the server response."); // reject("Error parsing response"); // } // } else { // reject("Error in API call"); // } // } // }; // xmlhttp1.send(JSON.stringify(payload)); // }); } // ADD PROPERTY SECURED ADMIN function addAdminProperty(propertyID, showHouse, showStreet) { // alert(propertyID); return new Promise((resolve, reject) => { // let token = localStorage.getItem("token") let landlordEmail = $("#landlord_email").val().trim().toLowerCase(); let city = $("#city").val(); if (city) { city = city.trim().toLowerCase(); } else { city = ""; // or handle the missing case } let type = $("#type").val(); let squareFeet = $("#squareFeet").val(); let bedrooms = $("#bedrooms").val(); let bathrooms = $("#bathrooms").val(); let furnishing = $("#furnishing").val(); let carParking = $("#carParking").val(); let carParkingType = $("#carParkingType").val(); let rentAmount = $("#rentAmount").val(); let rentalRate = $("#rentalRate").val(); let houseNo = $("#houseNo").val(); let streetAddress = $("#streetAddress").val().toLowerCase(); let zip = $("#zip").val(); let state = $("#state").val(); let country = $("#country").val().toLowerCase(); let pets = $("#pets").val(); let available_date = $("#available_date").val(); let available_upto_date let metropolitan = $("#Metropolitan").val(); let locality = $("#locality").val(); let profile = $("#profile").val(); if ($("#available_upto_date").val() == null || $("#available_upto_date").val() == "") { available_upto_date = null } else { available_upto_date = $("#available_upto_date").val() } let isValid = true; function showError(fieldId, message) { $(`#${fieldId}_error`).text(message); $(`#${fieldId}`).focus() isValid = false; } function validateField(value, fieldId, message) { if (!value || value.trim() === "") { showError(fieldId, message); } else { $(`#${fieldId}_error`).text(""); // Clear error message if valid } } // Validate mandatory fields validateField(landlordEmail, "landlord_email", "This field is mandatory"); validateField(type, "type", "This field is mandatory"); validateField(bedrooms, "bedrooms", "This field is mandatory"); validateField(bathrooms, "bathrooms", "This field is mandatory"); validateField(furnishing, "furnishing", "This field is mandatory"); validateField(squareFeet, "squareFeet", "This field is mandatory"); validateField(available_date, "available_date", "This field is mandatory"); validateField(carParking, "carParking", "This field is mandatory"); validateField(carParkingType, "carParkingType", "This field is mandatory"); validateField(rentAmount, "rentAmount", "This field is mandatory"); validateField(rentalRate, "rentalRate", "This field is mandatory"); validateField(houseNo, "houseNo", "This field is mandatory"); validateField(streetAddress, "streetAddress", "This field is mandatory"); validateField(city, "city", "This field is mandatory"); validateField(zip, "zip", "This field is mandatory"); validateField(state, "state", "This field is mandatory"); validateField(metropolitan, "Metropolitan", "This field is mandatory"); validateField(pets, "pets", "This field is mandatory"); validateField(locality, "locality", "This field is mandatory"); validateField(profile, "profile", "This field is mandatory"); // Stop execution if validation fails if (!isValid) { $("#search_submit").prop('disabled', false) //alert('Please fill all mandatory fields.'); const validationModal = new bootstrap.Modal(document.getElementById('validationModal')); validationModal.show(); return; } // let images = []; // $("#container_uploaded img").each(function () { // let src = $(this).attr("src"); // if (src) { // images.push({ imageLink: src }); // } // }); console.log("Extracted Images:", JSON.stringify(images)); let payload = { // property_id: $("#property_id").val(), advertiser_id: landlordEmail, available_date: available_date, available_to: available_upto_date, city: city, delete_flag: 0, // image_list: JSON.stringify(images), searchData: { type: type, squareFeet: squareFeet, bedrooms: bedrooms, rentAmount: rentAmount, streetAddress: streetAddress, houseNo: houseNo, city: city, state: state, zip: zip, country: country, bathrooms: bathrooms, furnishing: furnishing, carParking: carParking, carParkingType: carParkingType, rentalRate: rentalRate, termsAndConditions: $("#termsAndConditions").val(), propertyDesc: $("#propertyDesc").val(), landlordEmail: landlordEmail, pets: pets, locality: locality, showHouse: showHouse, showStreet: showStreet }, profile: profile, metropolitan: metropolitan }; console.log(payload) // alert("ok") let xmlhttp1 = new XMLHttpRequest(); // alert(baseurl + "/classifiedsecured/addproperty?propertyid=" + propertyID) xmlhttp1.open("POST", baseurl + "/classifiedsecured/addproperty?propertyid=" + propertyID, true); //xmlhttp1.open("POST", "http://localhost:8088/classifiedsecured/addproperty?propertyid=" + propertyID, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (xmlhttp1.readyState === 4) { if (xmlhttp1.status === 200) { try { let res = JSON.parse(xmlhttp1.responseText); let responseData = JSON.parse(res.response); // console.log(res); // console.log(responseData.message); if (responseData.message == "Property status : Added ") { createLandlordAccount(landlordEmail) resolve("success"); } else { alert("Failed to add property. Please try again."); reject("Add property failed"); } } catch (e) { // console.error(e) alert("Property added, but an error occurred while parsing the server response."); reject("Error in parsing response"); } } else { reject("Add property failed"); } } }; xmlhttp1.send(JSON.stringify(payload)); }); } // this is ajax for forget password which would send account mail function sendResetMail(clientId, email) { var webBaseURL = window.location.protocol + "//" + window.location.host; document.getElementById('email').innerHTML = ""; if (email == null || email == "") { document.getElementById('username_error').innerHTML = "This field is mandatory" document.getElementById('email').focus(); return false; } else { document.getElementById('username_error').innerHTML = "" } var xmlhttp1; try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttp1.open("POST", baseurl + "/classifiedunsecured/sendresetpassmail?emailID=" + email + "&webBaseURL=" + webBaseURL + "&clientId=" + clientId, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "") { var res = JSON.parse(this.responseText); var response = res.response; var s = res.rspnsMsg; console.log(s); var s = s.replace(/[{}]/g, ""); const obj = Object.fromEntries([s.split("=")]) console.log(response); if (obj.error == "Invalid Mail Id!!") { var error = document.getElementById("username_error"); error.innerHTML = obj.error; } if (response == "ERROR SENDING RESET MAIL") { $('#success_message').hide() $('#error_msg').show() $('#error_msg').html(response); } else if (response == "PASSWORD RESET EMAIL SEND TO USER") { $('#error_msg').hide(); $('#success_message').show() } else if (response == "Please enter email id for which account has been created") { $('#success_message').hide() $('#error_msg').show() $('#error_msg').html(response); } } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { const Modal = new bootstrap.Modal(document.getElementById('notFoundModal')); Modal.show(); } else if (this.status == 500 && this.readyState == 4) { const Modal = new bootstrap.Modal(document.getElementById('notFoundModal')); Modal.show(); } }; xmlhttp1.send(); } function sendAddSuccessMail(property_id, email) { var webBaseURL = window.location.protocol + "//" + window.location.host; var xmlhttp1; try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttp1.open("POST", baseurl + "/classifiedsecured/sendsuccessmail?emailID=" + email + "&webBaseURL=" + webBaseURL + "&propertyid=" + property_id, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "") { var res = JSON.parse(this.responseText); var response = res.response; var s = res.rspnsMsg; } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { // window.location.href = window.location.protocol + "//" + window.location.host + "/error.html " } else if (this.status == 500 && this.readyState == 4) { // window.location.href = window.location.protocol + "//" + window.location.host + "/error.html" } }; xmlhttp1.send(); } // git S LANDLORD WHILE ADDING NEW PROPERTY IN ADMIN SECTION function createLandlordAccount(email) { return new Promise((resolve, reject) => { var webBaseURL = window.location.protocol + "//" + window.location.host; console.log(webBaseURL) if (email == null || email == "") { return; } var xmlhttp1; try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttp1.open("POST", baseurl + "/classifiedsecured/createlandlord?emailID=" + email + "&webBaseURL=" + webBaseURL, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (xmlhttp1.status == 200 && xmlhttp1.responseText != null && xmlhttp1.responseText != "" && xmlhttp1.readyState == 4) { var res = JSON.parse(this.responseText); console.log(res.response) resolve(res.response); } else if (xmlhttp1.readyState == 4) { reject("error") } } xmlhttp1.send(); }) } // function activateLandlordAccount(email) { return new Promise((resolve, reject) => { console.log(email) if (email == null || email == "") { return; } var xmlhttp1; try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttp1.open("POST", baseurl + "/classifiedsecured/activatelandlord?emailID=" + email, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (xmlhttp1.status == 200 && xmlhttp1.responseText != null && xmlhttp1.responseText != "" && xmlhttp1.readyState == 4) { var res = JSON.parse(this.responseText); console.log(res.response) resolve(res.response); } else if (xmlhttp1.readyState == 4) { reject("error") } } xmlhttp1.send(); }) } function uploadImages(file) { var xmlhttp1; try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttp1.open("POST", baseurl + "/classifiedUploadDownload/imageUpload", false); xmlhttp1.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) { var res = JSON.parse(this.responseText); if (res.response == "File Upload failed") { window.location.href = window.location.protocol + "//" + window.location.host + "/error.html"; } else { let url = window.location.protocol + "//" + window.location.host + "/submitted.html"; // alert(url); window.location.href = url; } } }; xmlhttp1.send(file); } function uploadAdminImages(file) { return new Promise((resolve, reject) => { var xmlhttp1; try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttp1.open("POST", baseurl + "/classifiedUploadDownload/secureImageUploadClassified", false); xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) { var res = JSON.parse(this.responseText); if (res.response == "File Upload failed") { alert("Image upload failed but property added without images , try reuploading images") window.location.href = window.location.protocol + "//" + window.location.host + "/error.html"; reject("error in image upload") } else { //window.location.href = window.location.protocol + "//" + window.location.host + "/marketadmin/admindashboard.html" resolve("success") } } else { alert("Image upload failed but property added without images , try reuploading images") window.location.href = window.location.protocol + "//" + window.location.host + "/error.html"; reject("error in image upload") } }; xmlhttp1.send(file); } ) } function saveProperty(propertyID) { // alert(propertyID); // return; var property_id = $("#property_id").val(); var landlordEmail = $("#landlord_email").val().trim(); var type = $("#type").val(); var bedrooms = $("#bedrooms").val(); var bathrooms = $("#bathrooms").val(); var furnishing = $("#furnishing").val(); var squareFeet = $("#squareFeet").val(); var carParking = $("#carParking").val(); var carParkingType = $("#carParkingType").val(); var rentAmount = $("#rentAmount").val(); var rentalRate = $("#rentalRate").val(); var houseNo = $("#houseNo").val(); var streetAddress = $("#streetAddress").val(); var city = $("#city").val(); city = city .toLowerCase() // Convert to lowercase to handle mixed case inputs .split(' ') // Split the string into an array of words .map(word => word.charAt(0).toUpperCase() + word.slice(1)) // Capitalize the first letter of each word .join(' '); // Join the words back into a single string // console.log(city); var zip = $("#zip").val(); var state = $("#state").val(); var country = $("#country").val(); var pets = $("#pets").val(); var image_list = $("#image_list").val(); var termsAndConditions = $("#termsAndConditions").val(); var propertyDesc = $("#propertyDesc").val(); let isValid = true; function showError(fieldId, message) { $(`#${fieldId}_error`).text(message); isValid = false; } // Validate mandatory fields if (!landlordEmail) showError('landlord_email', 'This field is mandatory'); // if (!type) showError('type', 'This field is mandatory'); // if (!bedrooms) showError('bedrooms', 'This field is mandatory'); // if (!bathrooms) showError('bathrooms', 'This field is mandatory'); // if (!furnishing) showError('furnishing', 'This field is mandatory'); // if (!squareFeet) showError('squareFeet', 'This field is mandatory'); // if (!carParking) showError('carParking', 'This field is mandatory'); // if (!carParkingType) showError('carParkingType', 'This field is mandatory'); // if (!rentAmount) showError('rentAmount', 'This field is mandatory'); // if (!rentalRate) showError('rentalRate', 'This field is mandatory'); // if (!houseNo) showError('houseNo', 'This field is mandatory'); // if (!streetAddress) showError('streetAddress', 'This field is mandatory'); // if (!city) showError('city', 'This field is mandatory'); // if (!zip) showError('zip', 'This field is mandatory'); // if (!state) showError('state', 'This field is mandatory'); // if (!country) showError('country', 'This field is mandatory'); // if (!pets) showError('pets', 'This field is mandatory'); // Stop further execution if validation fails if (!isValid) { alert('Please fill all mandatory fields.'); return; } var payload = { property_id: property_id, city: city, delete_flag: 0, image_list: image_list, searchData: { type: type, squareFeet: squareFeet, bedrooms: bedrooms, rentAmount: rentAmount, streetAddress: streetAddress, houseNo: houseNo, city: city, state: state, zip: zip, country: country, bathrooms: bathrooms, furnishing: furnishing, carParking: carParking, carParkingType: carParkingType, rentalRate: rentalRate, termsAndConditions: termsAndConditions, propertyDesc: propertyDesc, landlordEmail: landlordEmail, pets: pets } }; console.log("Payload to be sent:", payload); // alert("Request URL: " + baseurl + "/classifiedunsecured/savessproperty?propertyid=" + propertyID); var xmlhttp1 = new XMLHttpRequest(); xmlhttp1.open("POST", baseurl + "/classifiedunsecured/savessproperty?propertyId=" + propertyID, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.onreadystatechange = function () { if (this.readyState === 4) { if (this.status === 200) { console.log("Response received:", this.responseText); try { var res = JSON.parse(this.responseText); // Parse the server response // Check if the response message indicates success if (res.rspnsCode === 1000 && res.rspnsMsg === "good") { var successModal = new bootstrap.Modal(document.getElementById('successModal')); successModal.show(); console.log("Property added/updated successfully."); } else { // Handle failure based on response alert("Failed to add/update property. Server response: " + res.rspnsMsg); console.error("Unexpected response:", res); } } catch (e) { alert("Property added, but an error occurred while parsing the server response."); console.error("Error parsing response:", e); } } else { // Handle error in case of failed request alert("Error while processing request. Please try again later."); console.error("HTTP Request failed with status: " + this.status); } } }; xmlhttp1.send(JSON.stringify(payload)); console.log("Waiting for server response..."); } function updateSSpropertyOtp(propertyId, email) { // alert(propertyId); // alert(email); var xmlhttp1; try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX requests."); return false; } } } xmlhttp1.open("POST", baseurl + "/classifiedunsecured/updatesspropertyotp?propertyId=" + propertyId + "&email=" + email, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.onreadystatechange = function () { if (this.readyState === 4) { if (this.status === 200 && this.responseText) { console.log("Server Response:", this.responseText); try { var res = JSON.parse(this.responseText); var responseData = JSON.parse(res.response); if ( responseData.message === "Property OTP updated successfully" || responseData.message === "Property OTP inserted successfully" ) { const verifyModal = new bootstrap.Modal(document.getElementById('verifyModal')); verifyModal.show(); // Wait for 3 seconds before redirecting setTimeout(() => { window.location.href = `verify_otp.html?data=${btoa(responseData.property_id)}.${btoa(email)}`; }, 3000); } else if (responseData.message === "Property ID does not exist in classified_details.") { alert("Invalid Property Id or Email"); } } catch (e) { console.error("Error parsing response:", e); alert("An error occurred while processing the response."); } } else { alert("Failed to verify OTP. Please try again."); } } }; xmlhttp1.send(); } // Verify OTP function function verifyOtp(otp, propertyId, email) { // alert(propertyId); var xmlhttp1; try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX requests."); return false; } } } xmlhttp1.open("POST", baseurl + "/classifiedunsecured/validatessotp?otp=" + otp + "&propertyId=" + propertyId + "&email=" + email, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.onreadystatechange = function () { if (this.readyState === 4) { if (this.status === 200 && this.responseText) { console.log("Server Response:", this.responseText); try { var res = JSON.parse(this.responseText); var responseData = JSON.parse(res.response); let modalBody = ''; if (responseData.message == "OTP Validation Successful. Property status updated.") { alert("OTP validation successful!"); setTimeout(() => { window.location.href = `add-properties.html?data=${btoa(responseData.property_id)}.${btoa(otp)}.${btoa(email)}`; }, 3000); } else if (responseData.message == "Invalid OTP or OTP has expired.") { modalBody = "Invalid OTP or OTP has expired."; document.getElementById('modal-body').textContent = modalBody; const otpModal = new bootstrap.Modal(document.getElementById('otpModal')); otpModal.show(); } } catch (e) { console.error("Error parsing response:", e); alert("An error occurred while processing the response."); } } else { alert("Failed to verify OTP. Please try again."); } } }; xmlhttp1.send(); } // Validating the last step after this property will be published function publisedOtp(otp, propertyId, email) { // alert(propertyId); // return; var webBaseURL = window.location.protocol + "//" + window.location.host; var xmlhttp1; try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX requests."); return false; } } } xmlhttp1.open("POST", baseurl + "/classifiedunsecured/validatepublishssotp?otp=" + otp + "&propertyId=" + propertyId + "&email=" + email + "&webBaseURL=" + webBaseURL, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.onreadystatechange = function () { if (this.readyState === 4) { if (this.status === 200 && this.responseText) { console.log("Server Response:", this.responseText); try { var res = JSON.parse(this.responseText); var responseData = JSON.parse(res.response); let modalBody = ''; if (responseData.message == "OTP Validation Successful. Property status updated.") { // window.location.href = `add-properties.html?propertyId=${responseData.property_id}`; window.location.href = `submitted.html?propertyId=${btoa(responseData.property_id)}`; } else if (responseData.message == "Invalid OTP or OTP has expired.") { modalBody = "Invalid OTP or OTP has expired."; document.getElementById('modal-body').textContent = modalBody; const otpModal = new bootstrap.Modal(document.getElementById('otpModal')); otpModal.show(); } } catch (e) { console.error("Error parsing response:", e); alert("An error occurred while processing the response."); } } else { alert("Failed to verify OTP. Please try again."); } } }; xmlhttp1.send(); } // generates unique propertyid function generatePropertyId() { var today = new Date(); var day = today.getDate().toString().padStart(2, '0'); var month = (today.getMonth() + 1).toString().padStart(2, '0'); var year = (today.getFullYear()).toString().padStart(2, '0'); var time = (today.getHours()) + (today.getMinutes()) + (today.getMinutes()) + (today.getMilliseconds()); var randomNum = Math.floor(10 + Math.random() * 90); var propertyId = day + year + month + randomNum + time; document.getElementById("property_id").value = propertyId; } // generates unique propertyid function generateAdminPropertyId() { // var today = new Date(); // var day = today.getDate().toString().padStart(2, '0'); // var month = (today.getMonth() + 1).toString().padStart(2, '0'); // var randomNum = Math.floor(10 + Math.random() * 90); // var propertyId = "SS" + day + month + randomNum; var today = new Date(); var day = today.getDate().toString().padStart(2, '0'); var month = (today.getMonth() + 1).toString().padStart(2, '0'); var year = (today.getFullYear()).toString().padStart(2, '0'); var time = (today.getHours()) + (today.getMinutes()) + (today.getMinutes()) + (today.getMilliseconds()); var randomNum = Math.floor(10 + Math.random() * 90); var propertyId = day + year + month + randomNum + time; return propertyId; } function insertEmail(propertyId, email) { var xmlhttp1; try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX requests."); return false; } } } xmlhttp1.open("POST", baseurl + "/classifiedunsecured/insertemail?propertyId=" + propertyId + "&email=" + email, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.onreadystatechange = function () { if (this.readyState === 4) { if (this.status === 200 && this.responseText) { console.log("Server Response:", this.responseText); try { var res = JSON.parse(this.responseText); // First parse the main response var responseData = JSON.parse(res.response); // Parse the `response` field if it's a string if (res.rspnsMsg === "Success") { // Check from `res`, not `responseData` const verifyModal = new bootstrap.Modal(document.getElementById('verifyModal')); verifyModal.show(); // Wait for 3 seconds before redirecting setTimeout(() => { window.location.href = `verify_otp.html?data=${btoa(responseData.property_id)}.${btoa(email)}`; }, 3000); } else if (responseData.message === "Property ID does not exist in classified_details.") { alert("Invalid Property Id or Email"); } } catch (e) { console.error("Error parsing response:", e); alert("An error occurred while processing the response."); } } else { alert("Failed to verify OTP. Please try again."); } } }; xmlhttp1.send(); } // function for checking thatnthe already existing token if for admin or not . function checkAdminToken() { let token = localStorage.getItem('token'); var xmlhttpAuth; try { xmlhttpAuth = new XMLHttpRequest(); } catch (e) { try { xmlhttpAuth = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttpAuth = new ActiveXObject( "Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttpAuth.open("GET", baseurl + "/classifiedsecured/checkAdmin", true); xmlhttpAuth.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttpAuth.setRequestHeader('Authorization', 'Bearer ' + token); xmlhttpAuth.onreadystatechange = function () { if (this.status == 500 && this.responseText != null && this.responseText != "" && this.readyState == 4) { let url = window.location.protocol + "//" + window.location.host + `/marketadmin/adminlogin.html`; window.location.replace(url) } } xmlhttpAuth.send(); } function checkAdvertiserToken() { let token = localStorage.getItem('token'); var xmlhttpAuth; try { xmlhttpAuth = new XMLHttpRequest(); } catch (e) { try { xmlhttpAuth = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttpAuth = new ActiveXObject( "Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttpAuth.open("GET", baseurl + "/classifiedsecured/checkAdvertiser", true); xmlhttpAuth.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttpAuth.setRequestHeader('Authorization', 'Bearer ' + token); xmlhttpAuth.onreadystatechange = function () { if (this.status == 500 && this.responseText != null && this.responseText != "" && this.readyState == 4) { let url = window.location.protocol + "//" + window.location.host + `/advertiser/login.html`; window.location.replace(url) } } xmlhttpAuth.send(); } // function for admin login and token generation function initLogin() { var email = $("#username").val(); var pass = $("#password").val(); var xmlhttpAuth; try { xmlhttpAuth = new XMLHttpRequest(); } catch (e) { try { xmlhttpAuth = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttpAuth = new ActiveXObject( "Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttpAuth.open("POST", baseurl + "/authentication/getGenericJWTToken", true); xmlhttpAuth.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttpAuth.setRequestHeader('clientID', "SS000001"); xmlhttpAuth.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) { $("#login_form_submit").prop("disabled", false) var res = JSON.parse(this.responseText); console.log(res); if (res.token != "Invalid User or Password / Or Account Locked") { localStorage.setItem('token', res.token); window.location.href = window.location.protocol + "//" + window.location.host + "/marketadmin/admindashboard.html"; } else { $("#error_message").show(); $("#error_message").html("Invalid Username/Password OR Account Locked"); } } } xmlhttpAuth.send(JSON.stringify({ "username": email, "password": pass })); } function checkAdminProperty(propertyid) { var xmlhttpAuth; try { xmlhttpAuth = new XMLHttpRequest(); } catch (e) { try { xmlhttpAuth = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttpAuth = new ActiveXObject( "Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttpAuth.open("POST", baseurl + "/classifiedsecured/checkproperty?propertyid=" + propertyid, true); // xmlhttpAuth.open("POST", "http://localhost:8088/classifiedsecured/checkproperty?propertyid=" + propertyid , true); xmlhttpAuth.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttpAuth.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttpAuth.setRequestHeader('clientID', "SS000001"); xmlhttpAuth.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) { var res = JSON.parse(this.responseText); var message = JSON.parse(res.response); // console.log(res); if (message.message == "Property Found") { window.location.assign(window.location.protocol + "//" + window.location.host + "/marketadmin/updateAdminProperty.html?property_id=" + propertyid) } else { alert(message.message + ` , Please enter a valid propertyID`) } } } xmlhttpAuth.send(); } function signOut() { window.localStorage.removeItem("token") } function deleteImage(propertyID, fileName, imageID) { if (!confirm('Are you sure you want to delete this image?')) return; let xmlhttp1; try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("BROWSER BROKE"); return false; } } } const url = `${baseurl}/classifiedUploadDownload/secureImageDelete?propertyID=${propertyID}` + `&fileName=${encodeURIComponent(fileName)}&imageID=${encodeURIComponent(imageID)}`; xmlhttp1.open("POST", url, true); xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (this.readyState === 4 && this.status === 200 && this.responseText) { const res = JSON.parse(this.responseText); console.log("Image deleted:", res); location.reload(); } }; xmlhttp1.send(); } function tokenExpired() { // let token = 'eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJTUzAwMDAwMSIsInN1YiI6IjUyMDAuc2luZ2hhZGl0eWFAZ21haWwuY29tIiwiZXhwIjoxNzQ3NDIzNDU1LCJpYXQiOjE3NDc0MDU0NTV9.JWTcPnQhSsZKwBt1c5Y2xyeThozHiTd94C3CYNmrJhI' // let token ='eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJTUzAwMDAwMSIsInN1YiI6IjUyMDAuc2luZ2hhZGl0eWFAZ21haWwuY29tIiwiZXhwIjoxNzQ3NTgwMjA5LCJpYXQiOjE3NDc1NjIyMDl9.PVYAM8m5pg3KJeIrzX9SJAte1s1k99wCYGuKVooLjbg' var token = localStorage.getItem('token') if (token !== '') { const expiry = JSON.parse(atob(token.split('.')[1])).exp; return Math.floor(new Date().getTime() / 1000) >= expiry } else { return true; } } function requestForApplication(propertyID) { var webBaseURL = window.location.protocol + "//" + window.location.host; var email = $("#email").val(); var fullName = $("#full_name").val(); var phoneNumber = $("#phoneNumber").val(); var message = $("#message").val(); $("#error_name").html(""); $("#error_mail").html(""); $("#error_phoneNumber").html(""); $("#error_message").html(""); if (fullName == "" || fullName == null) { $("#error_name").html("Please fill your name"); $("#full_name").focus() return false; } if (email == "" || email == null) { $("#error_mail").html("Please fill your email address"); $("#email").focus() return false; } if (phoneNumber == "" || phoneNumber == null) { $("#error_phoneNumber").html("Please fill your number"); $("#phoneNumber").focus() return false; } //window.alert("Request is recorded"); var phoneRe = /^[+]*[(]{0,1}[0-9]{1,3}[)]{0,1}[-\s\./0-9]*$/g; var digits = phoneNumber.replace(/\D/g, ""); if (!phoneRe.test(digits)) { $("#error_phoneNumber").html("Please fill valid phone number"); return false; } const payload = { renter_email: email, renter_Name: fullName, renter_phone: phoneNumber, message: message, property_id: propertyID, } console.log(payload) var xmlhttp1; try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttp1.open("POST", baseurl + "/classifiedunsecured/saveinquiry?webBaseURL=" + webBaseURL, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) { var res = JSON.parse(this.responseText); if (res.response == "Inserted Successfully") { // Success alert let alertBox = document.getElementById("successAlert"); alertBox.classList.remove("d-none"); // 3 second baad alert hide karna setTimeout(() => { alertBox.classList.add("d-none"); }, 3000); } else { console.log(res.response) alert("please retry"); } } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { // window.location.href = window.location.protocol + "//" + window.location.host + "error.html" alert("error") } else { console.log(res); } }; xmlhttp1.send(JSON.stringify(payload)); //console.log("waiting for server response...."); } // This function sends email to advertiser when someone contacts for property using contact form // function sendContactFormMail(property_id) { // var email = $("#email").val(); // var fullName = $("#full_name").val(); // var phoneNumber = $("#phoneNumber").val(); // var message = $("#message").val(); // const payload = { // renter_email: email, // renter_Name: fullName, // renter_phone: phoneNumber, // message: message, // property_id: property_id, // } // var xmlhttp1; // try { // xmlhttp1 = new XMLHttpRequest(); // } catch (e) { // try { // xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); // } catch (e) { // try { // xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP") // } catch (e) { // alert("BROWSER BROKE"); // return false; // } // } // } // xmlhttp1.open("POST", baseurl + "/classifiedunsecured/sendresearchmail?webBaseURL=" // + webBaseURL, true); // xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); // xmlhttp1.onreadystatechange = function () { // if (this.status == 200 && this.responseText != null && this.responseText != "") { // var res = JSON.parse(this.responseText); // var response = res.response; // var s = res.rspnsMsg; // } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { // // window.location.href = window.location.protocol + "//" + window.location.host + "/error.html " // } else if (this.status == 500 && this.readyState == 4) { // // window.location.href = window.location.protocol + "//" + window.location.host + "/error.html" // } // }; // xmlhttp1.send(JSON.stringify(payload)); //} function contactLoader(pageNum) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getcontacts?pageSize=10&pageNum=${pageNum}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var contacts = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (contacts.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= contacts.length - 1; i++) { let contact = contacts[i]; let truncatedMessage var serialNo = serial + (i + 1); const message = contact.message || 'N/A' if (message != null) { truncatedMessage = message.length > 20 ? message.substring(0, 20) + '...' : message; } else { truncatedMessage = "N/A" } var safeMessage = message tableData += ''; tableData += '' + serialNo + ''; tableData += '' + contact.property_id + ''; tableData += '' + contact.renter_name + ''; tableData += '' + contact.renter_email + ''; tableData += '' + contact.renter_phone + ''; tableData += '' + `${truncatedMessage}` + `` ' '; tableData += `` + new Date(contact.contact_date).toLocaleDateString() + ''; tableData += ''; } document.getElementById('property_inventory_table').innerHTML = tableData; setTimeout(function () { var msgBtn = document.getElementsByClassName('messageButton') for (let i = 0; i < msgBtn.length; i++) { const element = msgBtn[i]; const msg = element.getAttribute('data-message'); if (msg && msg.length <= 20) { element.style.display = "none"; } } for (let i = 0; i < msgBtn.length; i++) { msgBtn[i].addEventListener('click', function () { const msg = decodeURIComponent(this.getAttribute('data-message')); showFullMessage(msg); }); } }, 0) // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // // else { // document.querySelector("#pageNext").style.display = "inline"; // } } } xmlhttp.send(); } function showFullMessage(message) { if (message != "" && message.length >= 20) { document.getElementById('fullMessageContent').innerHTML = `

" ${message} "

` const modal = new bootstrap.Modal(document.getElementById('messageModal')); modal.show(); } else { alert('error'); } } function contactLoaderViaPropertyID(pageNum, filter_val) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getcontacts?pageSize=10&pageNum=${pageNum}&propertyid=${filter_val}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var contacts = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (contacts.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= contacts.length - 1; i++) { let contact = contacts[i]; let truncatedMessage var serialNo = serial + (i + 1); const message = contact.message || 'N/A' if (message != null) { truncatedMessage = message.length > 20 ? message.substring(0, 20) + '...' : message; } else { truncatedMessage = "N/A" } var safeMessage = message tableData += ''; tableData += '' + serialNo + ''; tableData += '' + contact.property_id + ''; tableData += '' + contact.renter_name + ''; tableData += '' + contact.renter_email + ''; tableData += '' + contact.renter_phone + ''; tableData += '' + `${truncatedMessage}` + `` ' '; tableData += `` + new Date(contact.contact_date).toLocaleDateString() + ''; tableData += ''; } document.getElementById('property_inventory_table').innerHTML = tableData; // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // // else { // document.querySelector("#pageNext").style.display = "inline"; // } setTimeout(function () { var msgBtn = document.getElementsByClassName('messageButton') for (let i = 0; i < msgBtn.length; i++) { const element = msgBtn[i]; const msg = element.getAttribute('data-message'); if (msg && msg.length <= 20) { element.style.display = "none"; } } for (let i = 0; i < msgBtn.length; i++) { msgBtn[i].addEventListener('click', function () { const msg = decodeURIComponent(this.getAttribute('data-message')); showFullMessage(msg); }); } }, 0) } } xmlhttp.send(); } function contactLoaderViaName(pageNum, filter_val) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getcontacts?pageSize=10&pageNum=${pageNum}&renter_name=${filter_val}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var contacts = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (contacts.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= contacts.length - 1; i++) { let contact = contacts[i]; let truncatedMessage var serialNo = serial + (i + 1); const message = contact.message || 'N/A' if (message != null) { truncatedMessage = message.length > 20 ? message.substring(0, 20) + '...' : message; } else { truncatedMessage = "N/A" } var safeMessage = message tableData += ''; tableData += '' + serialNo + ''; tableData += '' + contact.property_id + ''; tableData += '' + contact.renter_name + ''; tableData += '' + contact.renter_email + ''; tableData += '' + contact.renter_phone + ''; tableData += '' + `${truncatedMessage}` + `` ' '; tableData += `` + new Date(contact.contact_date).toLocaleDateString() + ''; tableData += ''; } document.getElementById('property_inventory_table').innerHTML = tableData; // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // // else { // document.querySelector("#pageNext").style.display = "inline"; // } setTimeout(function () { var msgBtn = document.getElementsByClassName('messageButton') for (let i = 0; i < msgBtn.length; i++) { const element = msgBtn[i]; const msg = element.getAttribute('data-message'); if (msg && msg.length <= 20) { element.style.display = "none"; } } for (let i = 0; i < msgBtn.length; i++) { msgBtn[i].addEventListener('click', function () { const msg = decodeURIComponent(this.getAttribute('data-message')); showFullMessage(msg); }); } }, 0) } } xmlhttp.send(); } function contactLoaderViaDate(pageNum, filter_val) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getcontacts?pageSize=10&pageNum=${pageNum}&contact_date=${filter_val}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var contacts = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (contacts.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= contacts.length - 1; i++) { let contact = contacts[i]; let truncatedMessage var serialNo = serial + (i + 1); const message = contact.message || 'N/A' if (message != null) { truncatedMessage = message.length > 20 ? message.substring(0, 20) + '...' : message; } else { truncatedMessage = "N/A" } var safeMessage = message tableData += ''; tableData += '' + serialNo + ''; tableData += '' + contact.property_id + ''; tableData += '' + contact.renter_name + ''; tableData += '' + contact.renter_email + ''; tableData += '' + contact.renter_phone + ''; tableData += '' + `${truncatedMessage}` + `` ' '; tableData += `` + new Date(contact.contact_date).toLocaleDateString() + ''; tableData += ''; } document.getElementById('property_inventory_table').innerHTML = tableData; // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // // else { // document.querySelector("#pageNext").style.display = "inline"; // } setTimeout(function () { var msgBtn = document.getElementsByClassName('messageButton') for (let i = 0; i < msgBtn.length; i++) { const element = msgBtn[i]; const msg = element.getAttribute('data-message'); if (msg && msg.length <= 20) { element.style.display = "none"; } } for (let i = 0; i < msgBtn.length; i++) { msgBtn[i].addEventListener('click', function () { const msg = decodeURIComponent(this.getAttribute('data-message')); showFullMessage(msg); }); } }, 0) } } xmlhttp.send(); } // <----------------------landlord.js---------------------> function signOut() { window.localStorage.removeItem("token") } function tokenExpired() { var token = localStorage.getItem('token') if (token !== '') { const expiry = JSON.parse(atob(token.split('.')[1])).exp; return Math.floor(new Date().getTime() / 1000) >= expiry } else { return true; } } // login function for advertiser section function initLandlordLogin() { var email = $("#landlordUsername").val(); var pass = $("#landlordPassword").val(); var xmlhttpAuth; try { xmlhttpAuth = new XMLHttpRequest(); } catch (e) { try { xmlhttpAuth = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttpAuth = new ActiveXObject( "Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttpAuth.open("POST", baseurl + "/authentication/getGenericJWTToken", true); xmlhttpAuth.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttpAuth.setRequestHeader('clientID', "SS000002"); xmlhttpAuth.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "" && this.readyState == 4) { $("#login_form_submit").prop("disabled", false) var res = JSON.parse(this.responseText); // console.log(res); if (res.token != "Invalid User or Password / Or Account Locked") { localStorage.setItem('token', res.token); sessionStorage.setItem('email', email) window.location.href = window.location.protocol + "//" + window.location.host + "/advertiser/dashboard.html"; } else { $("#error_message").show(); $("#error_message").html("Invalid User or Password / Or Account Locked"); } } } xmlhttpAuth.send(JSON.stringify({ "username": email, "password": pass })); } // function for fethcing all properties on view page in advertiser section function getAllPropertiesLandlord(pageNum) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getlandlordproperties?pageSize=10&pageNum=${pageNum}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); // console.log(localStorage.getItem('token')) xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); let data = JSON.parse(property.data) console.log(data) tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` ` // tableData += ``; // tableData += ''; // tableData += ''; tableData += ''; document.getElementById('property_inventory_table').innerHTML = tableData; } // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // // else { // document.querySelector("#pageNext").style.display = "inline"; // } } } xmlhttp.send(); } // delete property function propertyLandlordDeleter(button) { const property_id = button.getAttribute('data-id') var xmlhttp if (confirm("Do you want to delete the property?") == true) { try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported"); return false; } } } // xmlhttp.open("POST", "http://localhost:8088/classifiedsecured/deleteadminproperty?propertyid=" + property_id, true) xmlhttp.open("POST", baseurl + "/classifiedsecured/deleteadvertiserproperty?propertyid=" + property_id, true) xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8') xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.onreadystatechange = () => { //console.log(xmlhttp.readyState) // console.log(xmlhttp.status) if (xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText != "") { var response = JSON.parse(xmlhttp.responseText) //console.log(response) var inResponse = JSON.parse(response.response) //console.log(inResponse) if (response.rspnsCode == 1000 && inResponse.message == "Property status : deleted") { alert("Property deleted succesfully") //let url = window.location.protocol + "//" + window.location.host + `admin/admin-delete.html`; window.location.reload() } } } xmlhttp.send() } else { alert("Deletion terminated by user") return; } } // disable property function propertyLandlordDisabler(button) { const property_id = button.getAttribute('data-id') var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported"); return false; } } } // xmlhttp.open("POST", "http://localhost:8088/classifiedsecured/disableadminproperty?propertyid=" + property_id, true) xmlhttp.open("POST", baseurl + "/classifiedsecured/disableadvertiserproperty?propertyid=" + property_id, true) xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8') xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.onreadystatechange = () => { //console.log(xmlhttp.readyState) // console.log(xmlhttp.status) if (xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText != "") { var response = JSON.parse(xmlhttp.responseText) //console.log(response) var inResponse = JSON.parse(response.response) //console.log(inResponse) if (response.rspnsCode == 1000 && inResponse.message == "Property status : disabled") { alert("Property disabled succesfully") //let url = window.location.protocol + "//" + window.location.host + `admin/admin-delete.html`; window.location.reload() } } } xmlhttp.send() } // LOADS DETAILS ON UPDATE PROPERTY PAGE function getAdminPropertyDetails(propertyid) { var xmlhttp; try { xmlhttp = new XMLHttpRequest(); } catch (e) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Browser unsupported"); return false; } } } xmlhttp.open("GET", baseurl + "/" + "classifiedsecured/getadminssproperty?propertyId=" + propertyid, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); // xmlhttp.open("GET", "http://localhost:8088/classifiedunsecured/getssproperty?propertyId=" + propertyid, true); xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); xmlhttp.onreadystatechange = function () { if (this.readyState === 4 && this.status === 200) { const res = JSON.parse(this.responseText); //console.log(res); const propertyData = JSON.parse(res.response)[0]; populateMetroUpdateProperty(propertyData.metropolitan) //console.log(propertyData) const innerData = JSON.parse(propertyData.data); // console.log(propertyData) //console.log(innerData) document.querySelector("#property_id").textContent = propertyData.property_id document.querySelector("#type").value = innerData.type; document.querySelector("#landlord_email").value = innerData.landlordEmail document.querySelector("#bedrooms").innerHTML = ` ` document.querySelector("#bathrooms").innerHTML = ` ` document.querySelector("#furnishing").innerHTML = ` ` document.querySelector("#squareFeet").value = innerData.squareFeet const date = new Date(propertyData.available_date); document.querySelector("#available_date").value = date.toISOString().split('T')[0]; if (propertyData.available_to != null) { const uptoDate = new Date(propertyData.available_to); document.querySelector("#available_upto_date").value = uptoDate.toISOString().split('T')[0]; } else { document.querySelector("#available_upto_date").value = null } document.querySelector("#carParking").innerHTML = ` ` document.querySelector("#carParkingType").innerHTML = ` ` document.querySelector("#rentAmount").value = innerData.rentAmount document.querySelector("#rentalRate").innerHTML = ` ` document.querySelector("#houseNo").value = innerData.houseNo document.querySelector("#streetAddress").value = innerData.streetAddress document.querySelector("#locality").value = innerData.locality || 'Not found' //document.querySelector("#Metropolitan").innerHTML = `` document.querySelector("#city").innerHTML = `` document.querySelector("#zip").value = innerData.zip document.querySelector("#state").value = innerData.state document.querySelector("#pets").value = innerData.pets const expireDate = new Date(propertyData.expiry_date); document.querySelector("#expire_date").value = expireDate.toISOString().split('T')[0]; document.querySelector("#termsAndConditions").value = innerData.termsAndConditions document.querySelector("#propertyDesc").value = innerData.propertyDesc document.querySelector("#profile").innerHTML = ` ` if (innerData.showHouse == true) { document.querySelector("#showHouse").checked = true } if (innerData.showStreet == true) { document.querySelector("#showStreet").checked = true } // Parse and display images let imageArray = []; try { imageArray = JSON.parse(propertyData.image_list); } catch (e) { console.error("Invalid image list format", e); } console.log(imageArray); let imageView = ""; if (imageArray != null) { if (imageArray.length > 0) { document.getElementById("property_images_container").style.display = "block"; } else { document.getElementById("property_images_container").style.display = "none"; } for (let i = 0; i < imageArray.length; i++) { const imageLink = imageArray[i].imageLink; if (imageArray[i].imageLink != null) { const indexOfFile = imageLink.indexOf("unsecured"); const fileName = imageLink.slice(indexOfFile); const indexOfImage = imageLink.indexOf("image"); const imageID = imageLink.slice(indexOfImage); imageView += `
Image ×
`; } else { console.log("image link unreadable") } } } document.getElementById("container_uploaded").innerHTML = imageView; // console.log(innerData) // console.log(innerData.type) return res; // const images = JSON.parse(property.image_list); } } xmlhttp.send(); } // load all details at update property page function getAdvertiserPropertyDetails(propertyid) { var xmlhttp; try { xmlhttp = new XMLHttpRequest(); } catch (e) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Browser unsupported"); return false; } } } xmlhttp.open("GET", baseurl + "/" + "classifiedsecured/getadvertiserproperty?propertyId=" + propertyid, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); // xmlhttp.open("GET", "http://localhost:8088/classifiedunsecured/getssproperty?propertyId=" + propertyid, true); xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); xmlhttp.onreadystatechange = function () { if (this.readyState === 4 && this.status === 200) { const res = JSON.parse(this.responseText); console.log(res); // const propertyData = JSON.parse(res.response)[0]; const innerData = JSON.parse(propertyData.data); console.log(propertyData) console.log(innerData) populateMetroUpdateProperty(propertyData.metropolitan) document.querySelector("#property_id").textContent = propertyData.property_id document.querySelector("#type").value = innerData.type; document.querySelector("#landlord_email").value = innerData.landlordEmail document.querySelector("#bedrooms").innerHTML = ` ` document.querySelector("#bathrooms").innerHTML = ` ` document.querySelector("#furnishing").innerHTML = ` ` document.querySelector("#squareFeet").value = innerData.squareFeet const date = new Date(propertyData.available_date); document.querySelector("#available_date").value = date.toISOString().split('T')[0]; if (propertyData.available_to != null) { const uptoDate = new Date(propertyData.available_to); document.querySelector("#available_upto_date").value = uptoDate.toISOString().split('T')[0]; } else { document.querySelector("#available_upto_date").value = null } document.querySelector("#carParking").innerHTML = ` ` document.querySelector("#carParkingType").innerHTML = ` ` document.querySelector("#rentAmount").value = innerData.rentAmount document.querySelector("#rentalRate").innerHTML = ` ` document.querySelector("#houseNo").value = innerData.houseNo document.querySelector("#streetAddress").value = innerData.streetAddress document.querySelector("#locality").value = innerData.locality || 'Not found' // document.querySelector("#Metropolitan").innerHTML = `` document.querySelector("#city").innerHTML = `` document.querySelector("#zip").value = innerData.zip document.querySelector("#state").value = innerData.state document.querySelector("#pets").value = innerData.pets // const expireDate = new Date(propertyData.expiry_date); //document.querySelector("#expire_date").value = expireDate.toISOString().split('T')[0]; document.querySelector("#termsAndConditions").value = innerData.termsAndConditions document.querySelector("#propertyDesc").value = innerData.propertyDesc if (innerData.showHouse == true) { document.querySelector("#showHouse").checked = true } if (innerData.showStreet == true) { document.querySelector("#showStreet").checked = true } // Parse and display images let imageArray = []; try { imageArray = JSON.parse(propertyData.image_list); } catch (e) { console.error("Invalid image list format", e); } console.log(imageArray); let imageView = ""; if (imageArray != null) { if (imageArray.length > 0) { document.getElementById("property_images_container").style.display = "block"; } else { document.getElementById("property_images_container").style.display = "none"; } for (let i = 0; i < imageArray.length; i++) { const imageLink = imageArray[i].imageLink; if (imageArray[i].imageLink != null) { const indexOfFile = imageLink.indexOf("unsecured"); const fileName = imageLink.slice(indexOfFile); const indexOfImage = imageLink.indexOf("image"); const imageID = imageLink.slice(indexOfImage); imageView += `
Image ×
`; } else { console.log("image link unreadable") } } } document.getElementById("container_uploaded").innerHTML = imageView; // console.log(innerData) // console.log(innerData.type) return res; // const images = JSON.parse(property.image_list); } } xmlhttp.send(); } function updateAdminProperty(propertyID, showHouse, showStreet) { $("#search_submit").prop('disabled', true) return new Promise((resolve, reject) => { let landlordEmail = $("#landlord_email").val().trim(); let city = $("#city").val().trim(); let type = $("#type").val(); let squareFeet = $("#squareFeet").val(); let bedrooms = $("#bedrooms").val(); let bathrooms = $("#bathrooms").val(); let furnishing = $("#furnishing").val(); let carParking = $("#carParking").val(); let carParkingType = $("#carParkingType").val(); let rentAmount = $("#rentAmount").val(); let rentalRate = $("#rentalRate").val(); let houseNo = $("#houseNo").val(); let streetAddress = $("#streetAddress").val(); let zip = $("#zip").val(); let state = $("#state").val(); let country = $("#country").val(); let pets = $("#pets").val(); let available_date = $("#available_date").val(); let available_upto_date let metropolitan = $("#Metropolitan").val(); let locality = $("#locality").val(); let profile = $("#profile").val(); if ($("#available_upto_date").val() == null || $("#available_upto_date").val() == "") { available_upto_date = null } else { available_upto_date = $("#available_upto_date").val() } let expire_date = $("#expire_date").val(); let isValid = true; function showError(fieldId, message) { $(`#${fieldId}_error`).text(message); $(`#${fieldId}`).focus(); isValid = false; } function validateField(value, fieldId, message) { if (!value || value.trim() === "") { showError(fieldId, message); } else { $(`#${fieldId}_error`).text(""); } } // Validate fields validateField(landlordEmail, "landlord_email", "This field is mandatory"); validateField(type, "type", "This field is mandatory"); validateField(bedrooms, "bedrooms", "This field is mandatory"); validateField(bathrooms, "bathrooms", "This field is mandatory"); validateField(furnishing, "furnishing", "This field is mandatory"); validateField(squareFeet, "squareFeet", "This field is mandatory"); validateField(available_date, "available_date", "This field is mandatory"); // validateField(expire_date, "expire_date", "This field is mandatory"); validateField(carParking, "carParking", "This field is mandatory"); validateField(carParkingType, "carParkingType", "This field is mandatory"); validateField(rentAmount, "rentAmount", "This field is mandatory"); validateField(rentalRate, "rentalRate", "This field is mandatory"); validateField(houseNo, "houseNo", "This field is mandatory"); validateField(streetAddress, "streetAddress", "This field is mandatory"); validateField(city, "city", "This field is mandatory"); validateField(zip, "zip", "This field is mandatory"); validateField(state, "state", "This field is mandatory"); validateField(pets, "pets", "This field is mandatory"); validateField(expire_date, "expire_date", "This field is mandatory"); validateField(metropolitan, "Metropolitan", "This field is mandatory"); validateField(locality, "locality", "This field is mandatory"); validateField(profile, "profile", "This field is mandatory"); if (!isValid) { const validationModal = new bootstrap.Modal(document.getElementById('validationModal')); validationModal.show(); $("#search_submit").prop('disabled', false) return; } let payload = { // property_id: $("#property_id").val(), advertiser_id: landlordEmail, available_date: available_date, available_to: available_upto_date, expiry_date: expire_date, city: city, delete_flag: 0, searchData: { type: type, squareFeet: squareFeet, bedrooms: bedrooms, rentAmount: rentAmount, streetAddress: streetAddress, houseNo: houseNo, city: city, state: state, zip: zip, country: country, bathrooms: bathrooms, furnishing: furnishing, carParking: carParking, carParkingType: carParkingType, rentalRate: rentalRate, termsAndConditions: $("#termsAndConditions").val(), propertyDesc: $("#propertyDesc").val(), landlordEmail: landlordEmail, pets: pets, locality: locality, showHouse: showHouse, showStreet: showStreet }, profile :profile , metropolitan: metropolitan }; const xmlhttp1 = new XMLHttpRequest(); xmlhttp1.open("POST", baseurl + "/classifiedsecured/updateadminproperty?propertyid=" + propertyID, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (xmlhttp1.readyState === 4) { if (xmlhttp1.status === 200) { try { const res = JSON.parse(xmlhttp1.responseText); const responseData = JSON.parse(res.response); //console.log("Raw response:", responseData.message); if (responseData.message && responseData.message.includes("Property status")) { resolve("success"); } else { alert("Failed to update property. Server response: " + responseData.message); reject("update property failed"); } } catch (e) { console.error("JSON parse error:", e); reject("Error parsing response"); } } else { console.error("HTTP error status:", xmlhttp1.status); reject("Error in API call"); } } }; xmlhttp1.send(JSON.stringify(payload)); }); } // update property function updateAdvertiserProperty(propertyID, showHouse, ShowStreet) { $("#search_submit").prop('disabled', true) return new Promise((resolve, reject) => { let landlordEmail = $("#landlord_email").val().trim(); let city = $("#city").val().trim(); let type = $("#type").val(); let squareFeet = $("#squareFeet").val(); let bedrooms = $("#bedrooms").val(); let bathrooms = $("#bathrooms").val(); let furnishing = $("#furnishing").val(); let carParking = $("#carParking").val(); let carParkingType = $("#carParkingType").val(); let rentAmount = $("#rentAmount").val(); let rentalRate = $("#rentalRate").val(); let houseNo = $("#houseNo").val(); let streetAddress = $("#streetAddress").val(); let zip = $("#zip").val(); let state = $("#state").val(); let country = $("#country").val(); let pets = $("#pets").val(); let available_date = $("#available_date").val(); let available_upto_date = "" let metropolitan = $("#Metropolitan").val(); let locality = $("#locality").val(); if ($("#available_upto_date").val() == null || $("#available_upto_date").val() == "") { available_upto_date = null } else { available_upto_date = $("#available_upto_date").val() } // let expire_date = $("#expire_date").val(); let isValid = true; function showError(fieldId, message) { $(`#${fieldId}_error`).text(message); $(`#${fieldId}`).focus() isValid = false; } function validateField(value, fieldId, message) { if (!value || value.trim() === "") { showError(fieldId, message); } else { $(`#${fieldId}_error`).text(""); } } // Validate fields validateField(landlordEmail, "landlord_email", "This field is mandatory"); validateField(type, "type", "This field is mandatory"); validateField(bedrooms, "bedrooms", "This field is mandatory"); validateField(bathrooms, "bathrooms", "This field is mandatory"); validateField(furnishing, "furnishing", "This field is mandatory"); validateField(squareFeet, "squareFeet", "This field is mandatory"); validateField(available_date, "available_date", "This field is mandatory"); // validateField(expire_date, "expire_date", "This field is mandatory"); validateField(carParking, "carParking", "This field is mandatory"); validateField(carParkingType, "carParkingType", "This field is mandatory"); validateField(rentAmount, "rentAmount", "This field is mandatory"); validateField(rentalRate, "rentalRate", "This field is mandatory"); validateField(houseNo, "houseNo", "This field is mandatory"); validateField(streetAddress, "streetAddress", "This field is mandatory"); validateField(city, "city", "This field is mandatory"); validateField(zip, "zip", "This field is mandatory"); validateField(state, "state", "This field is mandatory"); validateField(pets, "pets", "This field is mandatory"); validateField(metropolitan, "Metropolitan", "This field is mandatory"); validateField(locality, "locality", "This field is mandatory"); // validateField(expire_date, "expire_date", "This field is mandatory"); if (!isValid) { const validationModal = new bootstrap.Modal(document.getElementById('validationModal')); validationModal.show(); return; } let payload = { // property_id: $("#property_id").val(), advertiser_id: landlordEmail, available_date: available_date, available_to: available_upto_date, //expiry_date: expire_date, city: city, delete_flag: 0, searchData: { type: type, squareFeet: squareFeet, bedrooms: bedrooms, rentAmount: rentAmount, streetAddress: streetAddress, houseNo: houseNo, city: city, state: state, zip: zip, country: country, bathrooms: bathrooms, furnishing: furnishing, carParking: carParking, carParkingType: carParkingType, rentalRate: rentalRate, termsAndConditions: $("#termsAndConditions").val(), propertyDesc: $("#propertyDesc").val(), landlordEmail: landlordEmail, pets: pets, locality: locality, showHouse: showHouse, showStreet: ShowStreet }, metropolitan: metropolitan }; const xmlhttp1 = new XMLHttpRequest(); xmlhttp1.open("POST", baseurl + "/classifiedsecured/updateadvertiserproperty?propertyid=" + propertyID, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (xmlhttp1.readyState === 4) { if (xmlhttp1.status === 200) { try { const res = JSON.parse(xmlhttp1.responseText); const responseData = JSON.parse(res.response); //console.log("Raw response:", responseData.message); if (responseData.message && responseData.message.includes("Property status")) { resolve("success"); } else { alert("Failed to update property. Server response: " + responseData.message); reject("update property failed"); } } catch (e) { console.error("JSON parse error:", e); reject("Error parsing response"); } } else { console.error("HTTP error status:", xmlhttp1.status); reject("Error in API call"); } } }; xmlhttp1.send(JSON.stringify(payload)); }); } // add new property function addAdvertiserProperty(propertyID, showHouse, showStreet) { // alert(propertyID); return new Promise((resolve, reject) => { // let token = localStorage.getItem("token") let landlordEmail = $("#landlord_email").val().trim().toLowerCase(); let city = $("#city").val().trim().toLowerCase(); let type = $("#type").val(); let squareFeet = $("#squareFeet").val(); let bedrooms = $("#bedrooms").val(); let bathrooms = $("#bathrooms").val(); let furnishing = $("#furnishing").val(); let carParking = $("#carParking").val(); let carParkingType = $("#carParkingType").val(); let rentAmount = $("#rentAmount").val(); let rentalRate = $("#rentalRate").val(); let houseNo = $("#houseNo").val(); let streetAddress = $("#streetAddress").val().toLowerCase(); let zip = $("#zip").val(); let state = $("#state").val(); let country = $("#country").val().toLowerCase(); let pets = $("#pets").val(); let available_date = $("#available_date").val(); let metropolitan = $("#Metropolitan").val(); let locality = $("#locality").val(); let available_upto_date if ($("#available_upto_date").val() == null || $("#available_upto_date").val() == "") { available_upto_date = null } else { available_upto_date = $("#available_upto_date").val() } let isValid = true; function showError(fieldId, message) { $(`#${fieldId}_error`).text(message); $(`#${fieldId}`).focus(); isValid = false; } function validateField(value, fieldId, message) { if (!value || value.trim() === "") { showError(fieldId, message); } else { $(`#${fieldId}_error`).text(""); // Clear error message if valid } } // Validate mandatory fields validateField(landlordEmail, "landlord_email", "This field is mandatory"); validateField(type, "type", "This field is mandatory"); validateField(bedrooms, "bedrooms", "This field is mandatory"); validateField(bathrooms, "bathrooms", "This field is mandatory"); validateField(furnishing, "furnishing", "This field is mandatory"); validateField(squareFeet, "squareFeet", "This field is mandatory"); validateField(available_date, "available_date", "This field is mandatory"); validateField(carParking, "carParking", "This field is mandatory"); validateField(carParkingType, "carParkingType", "This field is mandatory"); validateField(rentAmount, "rentAmount", "This field is mandatory"); validateField(rentalRate, "rentalRate", "This field is mandatory"); validateField(houseNo, "houseNo", "This field is mandatory"); validateField(streetAddress, "streetAddress", "This field is mandatory"); validateField(city, "city", "This field is mandatory"); validateField(zip, "zip", "This field is mandatory"); validateField(state, "state", "This field is mandatory"); validateField(metropolitan, "Metropolitan", "This field is mandatory"); validateField(locality, "locality", "This field is mandatory"); validateField(pets, "pets", "This field is mandatory"); // Stop execution if validation fails if (!isValid) { $("#search_submit").prop('disabled', false) const validationModal = new bootstrap.Modal(document.getElementById('validationModal')); validationModal.show(); return; } // let images = []; // $("#container_uploaded img").each(function () { // let src = $(this).attr("src"); // if (src) { // images.push({ imageLink: src }); // } // }); console.log("Extracted Images:", JSON.stringify(images)); let payload = { // property_id: $("#property_id").val(), advertiser_id: landlordEmail, available_date: available_date, available_to: available_upto_date, city: city, delete_flag: 0, // image_list: JSON.stringify(images), searchData: { type: type, squareFeet: squareFeet, bedrooms: bedrooms, rentAmount: rentAmount, streetAddress: streetAddress, houseNo: houseNo, city: city, state: state, zip: zip, country: country, bathrooms: bathrooms, furnishing: furnishing, carParking: carParking, carParkingType: carParkingType, rentalRate: rentalRate, termsAndConditions: $("#termsAndConditions").val(), propertyDesc: $("#propertyDesc").val(), landlordEmail: landlordEmail, pets: pets, locality: locality, showHouse: showHouse, showStreet: showStreet }, locality: locality }; let xmlhttp1 = new XMLHttpRequest(); // alert(baseurl + "/classifiedsecured/addproperty?propertyid=" + propertyID) xmlhttp1.open("POST", baseurl + "/classifiedsecured/addadvertiserproperty?propertyid=" + propertyID, true); //xmlhttp1.open("POST", "http://localhost:8088/classifiedsecured/addproperty?propertyid=" + propertyID, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (xmlhttp1.readyState === 4) { if (xmlhttp1.status === 200) { try { let res = JSON.parse(xmlhttp1.responseText); let responseData = JSON.parse(res.response); // console.log(res); // console.log(responseData.message); if (responseData.message == "Property status : Added ") { createLandlordAccount(landlordEmail) resolve("success"); } else { alert("Failed to add property. Please try again."); reject("Add property failed"); } } catch (e) { // console.error(e) alert("Property added, but an error occurred while parsing the server response."); reject("Error in parsing response"); } } else { reject("Add property failed"); } } }; xmlhttp1.send(JSON.stringify(payload)); }); } // redirect to new tab for detailed property view (to unsecured page) function detailView(button) { console.log("redirecting") const property_id = button.getAttribute('data-id') window.open(window.location.protocol + "//" + window.location.host + `/propertydetail.html?propertyId=${property_id}`, "_blank"); } // function for fethcing all properties on view page in advertiser section filter by city function getAllPropertiesLandlordViaCity(pageNum, city) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured//getlandlordproperties?pageSize=10&pageNum=${pageNum}&city=${city}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); let data = JSON.parse(property.data) //onsole.log(data) tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` ` // tableData += ``; // tableData += ''; // tableData += ''; tableData += ''; document.getElementById('property_inventory_table').innerHTML = tableData; } // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // // else { // document.querySelector("#pageNext").style.display = "inline"; // } } } xmlhttp.send(); } // function getAllPropertiesLandlordViaLandlordEmail(pageNum, landlord_email) { // var xmlhttp // try { // xmlhttp = new XMLHttpRequest(); // } catch (error) { // try { // xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") // } catch (error) { // try { // xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") // } catch (error) { // alert("Browser unsupported") // } // } // } // xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getadminproperties?pageSize=10&pageNum=${pageNum}&landlordemail=${landlord_email}`, true); // xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); // xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); // xmlhttp.onreadystatechange = function () { // if (this.readyState == 4 && this.status == 200 && this.responseText != null) { // var response = JSON.parse(this.responseText) // var props = JSON.parse(response.response) // var serial = (pageNum - 1) * 10; // var tableData = ''; // // pagination // if (props.length < 10) { // document.querySelector("#pageNext").style.display = "none"; // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // } // else { // document.querySelector("#pageNext").style.display = "inline"; // } // // table populating // for (var i = 0; i <= props.length - 1; i++) { // let property = props[i]; // var serialNo = serial + (i + 1); // let data = JSON.parse(property.data) // //onsole.log(data) // tableData += ''; // tableData += '' + serialNo + ''; // tableData += '' + property.property_id + ''; // tableData += '' + data.landlordEmail + ''; // tableData += '' + data.type + ''; // tableData += '' + data.rentAmount + ' $' + ''; // tableData += '' + data.city + ''; // tableData += '' + data.state + ''; // tableData += '' + data.zip + ''; // tableData += ` // // // // ` // // tableData += ``; // // tableData += ''; // // tableData += ''; // tableData += ''; // document.getElementById('property_inventory_table').innerHTML = tableData; // } // // if (props == "") { // // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // // document.querySelector("#pageNext").style.display = "none"; // // console.log("no result") // // } // // else { // // document.querySelector("#pageNext").style.display = "inline"; // // } // } // } // xmlhttp.send(); // } // function for fethcing all properties on view page in advertiser section filter by state function getAllPropertiesLandlordViaState(pageNum, state) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getlandlordproperties?pageSize=10&pageNum=${pageNum}&state=${state}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); let data = JSON.parse(property.data) //onsole.log(data) tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` ` // tableData += ``; // tableData += ''; // tableData += ''; tableData += ''; document.getElementById('property_inventory_table').innerHTML = tableData; } // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // } // else { // document.querySelector("#pageNext").style.display = "inline"; // } } } xmlhttp.send(); } // // function for fethcing all properties on view page in advertiser section filter by property id function getAllPropertiesLandlordViaP_id(pageNum, property_id) { console.log(property_id) var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getlandlordproperties?pageSize=10&pageNum=${pageNum}&propertyid=${property_id}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); let data = JSON.parse(property.data) //onsole.log(data) tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` ` // tableData += ``; // tableData += ''; // tableData += ''; tableData += ''; document.getElementById('property_inventory_table').innerHTML = tableData; } // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // } // else { // document.querySelector("#pageNext").style.display = "inline"; // } } } xmlhttp.send(); } // function for fethcing all properties on view page in advertiser section filter by zip function getAllPropertiesLandlordViaZip(pageNum, zip) { var xmlhttp try { xmlhttp = new XMLHttpRequest(); } catch (error) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (error) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (error) { alert("Browser unsupported") } } } xmlhttp.open("GET", baseurl + "/" + `classifiedsecured/getlandlordproperties?pageSize=10&pageNum=${pageNum}&zip=${zip}`, true); xmlhttp.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText != null) { var response = JSON.parse(this.responseText) var props = JSON.parse(response.response) var serial = (pageNum - 1) * 10; var tableData = ''; // pagination if (props.length < 10) { document.querySelector("#pageNext").style.display = "none"; document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; } else { document.querySelector("#pageNext").style.display = "inline"; } // table populating for (var i = 0; i <= props.length - 1; i++) { let property = props[i]; var serialNo = serial + (i + 1); let data = JSON.parse(property.data) //onsole.log(data) tableData += ''; tableData += '' + serialNo + ''; tableData += '' + property.property_id + ''; tableData += '' + data.landlordEmail + ''; tableData += '' + data.type + ''; tableData += '' + data.rentAmount + ' $' + ''; tableData += '' + data.city + ''; tableData += '' + data.state + ''; tableData += '' + data.zip + ''; tableData += ` ` // tableData += ``; // tableData += ''; // tableData += ''; tableData += ''; document.getElementById('property_inventory_table').innerHTML = tableData; } // if (props == "") { // document.getElementById('property_inventory_table').innerHTML = "NO DATA / END OF LIST"; // document.querySelector("#pageNext").style.display = "none"; // console.log("no result") // } // else { // document.querySelector("#pageNext").style.display = "inline"; // } } } xmlhttp.send(); } function resetPassword(clientId, tokenId, userId) { var password = document.getElementById("password").value; var confirmPassword = document.getElementById("confirmPassword").value; if (password == null || password == "") { document.getElementById('password_error').innerHTML = "This field is mandatory" document.getElementById('password').focus(); return false; } if (confirmPassword == null || confirmPassword == "") { document.getElementById('confirmpass_error').innerHTML = "This field is mandatory" document.getElementById('confirmPassword').focus(); return false; } if (password != confirmPassword) { document.getElementById('confirmpass_error').innerHTML = "Confirm Password does not matches password" document.getElementById('confirmPassword').focus(); return false; } var xmlhttp1; try { xmlhttp1 = new XMLHttpRequest(); } catch (e) { try { xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { alert("BROWSER BROKE"); return false; } } } xmlhttp1.open("POST", baseurl + "/classifiedunsecured/resetpassword?tokenID=" + tokenId + "&user_id=" + userId + "&clientId=" + clientId, true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.onreadystatechange = function () { if (this.status == 200 && this.responseText != null && this.responseText != "") { var res = JSON.parse(this.responseText); var response = res.response;; if (response == "PASSWORD UPDATED SUCCESSFULLY") { $('#error_msg').hide(); $('#success_message').show() var submitBtn = $("#login_form_submit"); submitBtn.prop('disabled', true); } else { $('#success_message').hide() $('#error_msg').show(); } } else if ((this.status == 403 || this.status == 401) && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/error.html" } else if (this.status == 500 && this.readyState == 4) { window.location.href = window.location.protocol + "//" + window.location.host + "/error.html" } }; xmlhttp1.send(JSON.stringify({ "emailID": userId, "password": password })); } function updateProfile() { return new Promise((resolve, reject) => { let firstName = $("#firstName").val().trim(); let lastName = $("#lastName").val().trim(); let phone = $("#phone").val().trim(); let isValid = true; function showError(fieldId, message) { $(`#error_${fieldId}`).text(message); $(`#${fieldId}`).focus() isValid = false; } function validateField(value, fieldId, message) { if (!value || value.trim() === "") { showError(fieldId, message); } else { $(`#error_${fieldId}`).text(""); } } // Validate validateField(firstName, "firstName", "Fill details here"); validateField(lastName, "lastName", "Fill details here"); validateField(phone, "phone", "Fill details here"); // validateField(expire_date, "expire_date", "This field is mandatory"); //alert(isValid) if (!isValid) { // alert('chacha2') const validateModal = new bootstrap.Modal(document.getElementById('validateModal')); validateModal.show(); return; } let payload = { firstName: firstName, lastName: lastName, phoneNumber: phone }; const xmlhttp1 = new XMLHttpRequest(); xmlhttp1.open("POST", baseurl + "/classifiedsecured/updateProfile", true); xmlhttp1.setRequestHeader('Content-type', 'application/json;charset=UTF-8'); xmlhttp1.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token')); xmlhttp1.onreadystatechange = function () { if (xmlhttp1.readyState === 4) { if (xmlhttp1.status === 200) { try { console.log(xmlhttp1.responseText); const res = JSON.parse(xmlhttp1.responseText); console.log(res.response) const responseData = res.response; if (responseData.includes("ACCOUNT MANIPULATED")) { resolve("success"); } else { alert("Failed to update ACCOUNT. Server response: " + res.response); reject("update property failed"); } } catch (e) { console.error("JSON parse error:", e); reject("Error parsing response"); } } else { console.error("HTTP error status:", xmlhttp1.status); reject("Error in API call"); } } }; xmlhttp1.send(JSON.stringify(payload)); }); }