bathroomIn: {
"shower room - tub": "غرفة الاستحمام - حوض الاستحمام",
},
};
let types = [];
let branch = [];
let brands = [];
function allSubCategories(subCategory: string) {
switch (replaceChar(subCategory)) {
case "apartments-for-sale":
case "apartments-for-rent":
types = allUrls("apartments", 0, 1);
brands = [];
branch = [];
break;
case "villas-for-sale":
case "villas-for-rent":
types = allUrls("villas", 0, 1);
brands = [];
branch = [];
break;
case "vacation-homes-for-sale":
case "vacation-homes-for-rent":
types = allUrls("vacation", 0, 1);
brands = [];
branch = [];
break;
case "commercial-for-sale":
case "commercial-for-rent":
branch = [];
brands = [];
types = allUrls("commercial-for", 0, 1);
break;
case "buildings-lands":
branch = [];
brands = [];
types = allUrls("buildings", 0, 1);
break;
case "tires-batteries-oils-accessories":
branch = [];
brands = [];
types = allUrls("tires", 0, 1);
break;
case "cars-spare-parts":
types = allUrls("cars-spare", 0, 1);
branch = [];
brands = allUrls("carsBrands", 0, 1);
break;
case "cars-for-rent":
case "cars-for-sale":
brands = allUrls("carsBrands", 0, 1);
types = [];
branch = [];
break;
case "motorcycles-accessories":
brands = allUrls("motorCyclesB", 0, 1);
types = [];
branch = [];
break;
case "boats-watercraft":
brands = [];
types = allUrls("boats", 0, 1);
branch = [];
break;
case "heavy-trucks-buses-other-vehicles":
brands = [];
types = allUrls("heavy", 0, 1);
branch = [];
break;
case "mobile-phones":
case "tablets":
brands = allUrls("tabletsB", 0, 1);
types = [];
branch = [];
break;
case "mobile-numbers":
brands = allUrls("mobileNumberB", 0, 1);
types = [];
branch = [];
break;
case "mobile-tablet-accessories":
branch = [];
brands = [];
types = allUrls("mobile", 0, 1);
break;
case "tv-audio-video":
brands = allUrls("tvBrands", 0, 1);
types = allUrls("tv", 0, 1);
branch = [];
break;
case "home-appliances":
types = allUrls("appliances", 0, 1);
brands = allUrls("tvBrands", 0, 1);
branch = [];
break;
case "computers-accessories":
brands = allUrls("computersB", 0, 1);
types = [];
branch = allUrls("desktop-br", 0, 1);
break;
case "video-games-consoles":
branch = allUrls("video-br", 0, 1);
brands = allUrls("videoGamesB", 0, 1);
types = [];
break;
case "cameras-photography":
types = allUrls("cameras", 0, 1);
brands = [];
branch = [];
break;
case "furniture-decor":
types = allUrls("furniture", 0, 1);
brands = [];
branch = [];
break;
case "bathroom":
types = allUrls("bathroomIn", 0, 1);
brands = [];
branch = [];
break;
case "accounting-finance-banking":
types = allUrls("accounting", 0, 1);
branch = [];
brands = [];
break;
case "engineering":
types = allUrls("engineeringIn", 0, 1);
brands = [];
branch = [];
break;
case "designers":
types = allUrls("designersIn", 0, 1);
branch = [];
brands = [];
break;
case "hr":
types = allUrls("hrIn", 0, 1);
branch = [];
brands = [];
break;
case "tourism-travel-hospitality":
types = allUrls("tourism", 0, 1);
branch = [];
brands = [];
break;
case "medical-healthcare-nursing":
types = allUrls("medicalIN", 0, 1);
branch = [];
brands = [];
break;
case "sales":
types = allUrls("salesIn", 0, 1);
branch = [];
brands = [];
break;
case "bedroom":
types = allUrls("bedroomIn", 0, 1);
branch = [];
brands = [];
break;
case "dining-room":
types = allUrls("dining", 0, 1);
branch = [];
brands = [];
break;
case "fabrics-curtains-carpets":
types = allUrls("fabrics", 0, 1);
branch = [];
brands = [];
break;
case "garden-outdoor":
types = allUrls("garden", 0, 1);
branch = [];
brands = [];
break;
case "home-decoration":
types = allUrls("decoration", 0, 1);
branch = [];
brands = [];
break;
case "kitchen-kitchenware":
types = allUrls("kitchen", 0, 1);
brands = [];
branch = [];
break;
case "lightings":
types = allUrls("lightingsIN", 0, 1);
branch = [];
brands = [];
break;
case "living-room":
types = allUrls("living", 0, 1);
branch = [];
brands = [];
break;
case "other-items":
case "luggage":
case "books":
case "board-card-games":
case "events":
case "other-services":
case "other-baby-items":
case "birds-pigeons":
case "dogs":
case "cats":
case "workers-technicians":
case "marketing-and-public-relations":
case "management-consulting":
case "legal-lawyers":
case "it-telecom":
case "guarding-security":
case "drivers-delivery":
case "customer-service-call-center":
case "other-business-industrial-agriculture":
case "whole-business-for-sale":
case "medical-equipment":
case "other-furniture":
types = [];
branch = [];
brands = [];
break;
case "women-clothing":
types = allUrls("women", 0, 1);
brands = [];
branch = [];
break;
case "men-clothing":
types = allUrls("men", 0, 1);
brands = [];
branch = [];
break;
case "women-accessories-cosmetics-personal-care":
types = allUrls("women-acc", 0, 1);
brands = [];
branch = [];
break;
case "men-accessories-personal-care":
types = allUrls("men-acc", 0, 1);
branch = [];
brands = [];
break;
case "other-pets-animals":
types = allUrls("other-pets", 0, 1);
branch = [];
brands = [];
break;
case "accessories-pet-care-products":
types = allUrls("accessories-pet", 0, 1);
branch = [];
brands = [];
break;
case "baby-mom-healthcare":
types = allUrls("baby-mom", 0, 1);
branch = [];
brands = [];
break;
case "baby-clothing":
types = allUrls("baby-clothingIn", 0, 1);
branch = [];
brands = [];
break;
case "baby-feeding-tools":
types = allUrls("baby-feeding", 0, 1);
branch = [];
brands = [];
break;
case "cribs-strollers-carriers":
types = allUrls("cribs", 0, 1);
branch = [];
brands = [];
break;
case "toys":
types = allUrls("toysIn", 0, 1);
brands = [];
branch = [];
break;
case "antiques-collectibles":
types = allUrls("antiques", 0, 1);
branch = [];
brands = [];
break;
case "bicycles":
types = allUrls("bicyclesIn", 0, 1);
branch = [];
brands = [];
break;
case "movies-audios":
types = allUrls("movies", 0, 1);
branch = [];
brands = [];
break;
case "sports-equipment":
types = allUrls("sports", 0, 1);
branch = [];
brands = [];
break;
case "study-tools":
types = allUrls("study", 0, 1);
branch = [];
brands = [];
break;
case "tickets-vouchers":
types = allUrls("tickets", 0, 1);
branch = [];
brands = [];
break;
case "agriculture":
branch = [];
types = allUrls("agricultureIn", 0, 1);
brands = [];
break;
case "construction":
types = allUrls("constructionIn", 0, 1);
brands = [];
branch = [];
break;
case "industrial-equipment":
types = allUrls("industrial", 0, 1);
brands = [];
branch = [];
break;
case "office-furniture-equipment":
types = allUrls("office", 0, 1);
brands = [];
branch = [];
break;
case "restaurants-equipment":
types = allUrls("restaurants", 0, 1);
brands = [];
branch = [];
break;
case "business":
types = allUrls("businessIn", 0, 1);
brands = [];
branch = [];
break;
case "cars":
types = allUrls("carsIn", 0, 1);
brands = [];
branch = [];
break;
case "health-beauty":
types = allUrls("health", 0, 1);
brands = [];
branch = [];
break;
case "home-services-maintenance":
types = allUrls("home-services", 0, 1);
brands = [];
branch = [];
break;
case "medical":
types = allUrls("medicalIn", 0, 1);
brands = [];
branch = [];
break;
case "movers":
types = allUrls("moversIn", 0, 1);
brands = [];
branch = [];
break;
case "pets":
types = allUrls("petsIn", 0, 1);
brands = [];
branch = [];
break;
case "education":
branch = [];
brands = [];
types = allUrls("educationIn", 0, 1);
break;
}
}
function allBranches(branch) {
switch (replaceChar(branch)) {
case "desktop-computers":
case "laptop-computers":
types = [];
break;
case "video-game-consoles":
types = allUrls("video-game", 0, 1);
break;
case "video-games-accessories":
types = allUrls("video-games", 0, 1);
break;
case "computer-accessories-spare-parts":
types = allUrls("computer-acc", 0, 1);
break;
}
}
function replaceChar(ele) {
if (ele) {
return ele
.trim()
.replace(/(all in |»|❭|\n +)/gi, "")
.replace(/ ( |(|)|/|,|&|%20|%2C|%26|'s +|’s +) /gi, "-")
.replace(/(--|---|----)/gi, "-")
.replace(/--/gi, "-")
.toLowerCase();
}
}
function allUrls(search, lang, node) {
let url = [];
if (node) {
for (const i in urls[search]) {
url.push(i);
}
} else {
if (lang) {
for (const i in urls) {
if (typeof urls[i] === "object") {
for (const e in urls[i]) {
if (replaceChar(e) === replaceChar(search)) {
url = urls[i][e];
}
}
} else {
if (replaceChar(i) === replaceChar(search)) {
url = urls[i];
}
}
}
} else {
for (const i in urls) {
if (typeof urls[i] === "object") {
for (const e in urls[i]) {
url.push(e);
}
} else {
url.push(i);
}
}
url = url.flat().find((r) => replaceChar(r) === replaceChar(search));
}
}
return url || search;
}
function trans(ifTrue, ifFalse = ifTrue) {
return ar ? allUrls(ifTrue, 1) : allUrls(ifFalse);
}
const locSearch = location.search;
const pathname = location.pathname;
const currentUrl = location.href;
// function capitalize(el) {
// const r = el.split(' ');
// const s = [];
// for (const a of r) {
// s.push(a[0].toUpperCase() + a.slice(1));
// }
// return s.join(' ');
// }
const checkLog = (".hamburger−me(".search-header");
const selectCategory = (".search-result");
const categoryIn = (".parent-click:not(:first-of-type), .nav-links > div");
const clickShow = ('.sign-in-form input[type="submit"]');
const url = new URLSearchParams(locSearch);
const g = ("footer");
function checkLength(input, from, to) {
const inputText = {input}#{from} على الأقلMust contain at least {to} حرفًاIt must not contain more than ();
const retPass = {retpa}#("#lang");
const urlLoc = new URLSearchParams(locSearch);
urlLoc.set("lang", replaceChar(TX(lang)));
lang.href = urlLoc.toString().includes("?") ? urlLoc : "?" + urlLoc;
const hrefS = (".search-result a").length;
a = a <= 1 ? g : a;
a = a >= g ? 1 : a;
remove(".search-result a", "active");
const s = {a})/ads/?{r.length * 16}px[value='{TX(rs).length * 14}px/ads/?{url.get("area")}&location=("header").style.top = "0";
} else {
("#nav").style.top = "0";
} else {
("#welName");
T(t, TX(t) ? : "");
}
function isMobile() {
const toMatch = [
/Android/i,
/webOS/i,
/iPhone/i,
/iPad/i,
/iPod/i,
/BlackBerry/i,
/Windows Phone/i,
/mobile/i,
];
return toMatch.some((toMatchItem) => navigator.userAgent.match(toMatchItem));
}
function duplicate(array) {
return array.filter((key, index) => array.indexOf(key) === index);
}
const cardFavorite = (".card-fav-fill");
cardFavorite.forEach((element) => {
element.onclick = (ele) => {
if ((".sign-in-form").classList.toggle("flex");
}
ele.target.classList.toggle("card-fav-fill");
};
});
cardFavoriteFill.forEach((element) => {
element.onclick = (ele) => {
ele.target.classList.toggle("card-fav-fill");
ele.target.classList.toggle("card-fav");
};
});
const scrollingElement = doc.scrollingElement || doc.body;
const toBottom = (ele = scrollingElement) => {
ele.scrollTop = ele.scrollHeight;
};
// eslint-disable-next-line no-unused-vars
const backTop = (ele = scrollingElement) => {
ele.scrollTop = 0;
};
function radInput(type, array, ele, lang, name = ele) {
const el = ("[class='alert'],[id='alert'], .thanks");
for (let i = 0; i < removeMessage.length; i++) {
removeMessage[i].onclick = () => {
removeMessage[i].style.display = "none";
};
}
const alertLocation = ("#alert-location");
function getLocation(fun) {
if (!navigator.geolocation.getCurrentPosition) {
I(
alertLocation,
ar
? "متصفحك لا يدعم تحديد الموقع!"
: "Your browser doesn't support location identification!"
);
} else {
navigator.geolocation.getCurrentPosition(fun, errHand);
}
}
function errHand(err) {
alertLocation.style.display = "flex";
switch (err.code) {
case err.PERMISSION_DENIED:
T(
alertLocation,
ar
? "التطبيق ليس لديه إذن تحديد الموقع."
: "The app does not have location permission."
);
break;
case err.POSITION_UNAVAILABLE:
T(
alertLocation,
ar ? "موقع الجهاز غير مؤكد." : "Device location is uncertain."
);
break;
case err.TIMEOUT:
T(
alertLocation,
ar
? "انتهت المهلة للحصول على موقع المستخدم."
: "Timed out to get the user's location."
);
break;
case err.UNKNOWN_ERROR:
T(
alertLocation,
ar ? "حدث خطأ ما حاول مرة أخرى." : "Something went wrong!, Try again."
);
break;
}
}
const locationUrl = new URLSearchParams(locSearch);
let locations = $$(".filter-location-in > div > a, .header-map a");
locationUrl.delete("page");
locationUrl.delete("ad");
locationUrl.delete("area");
for (let i = 0; i < locations.length; i++) {
locationUrl.set("location", locations[i].id);
locations[i].setAttribute("href", `/ads/?{locationUrl}); } // / ///////////// START home.js const cards = $$(".cards-row, .listen-cards"); for (const i of cards) { if (TX(i).length <= 20) { if (!i.classList.contains("listen-cards")) { i.parentElement.remove(); } } else { const t = JSON.parse(TX(i)); let s = ""; for (const e of t) { s += e.price</span><h4class={
e.title
}trans(e.area),{trans(
e.location
)}.e.created</div></div></di{e.class} value='{
e.id
}'></article>`;
}
I(i, s);
}
}
function price(num) {
if (num.indexOf("allowance") >= 0) {
return trans("for allowance");
}
return new Intl.NumberFormat(ar ? "ar" : undefined, {
maximumSignificantDigits: 21,
style: "currency",
currency: "egp",
}).format(num);
}
function home() {
// const listen = $$(".listen-title");
// const listenImg = $$(".listen-card a");
// for (let i = 0; i < listen.length; i++) {
// if (listenImg[i]) {
// listenImg[i].setAttribute(
// "href",
// `/ad/?ad={encodeURIComponent(TX(listen[i]))}// ); // } // T(listen[i], TX(listen[i]).replace(/-[0-9]{0,}$/, "")); // } // date($$(".date")); // const listenImgDir = $$(".listen-card a > img, .ad-img"); // for (let i = 0; i < listenImgDir.length; i++) { // const gt = listenImgDir[i].getAttribute("src"); // const tg = gt.split(" -^- "); // listenImgDir[i].setAttribute("src",/uploads/{tg[parseInt(tg[0]) + 1]}`);
// }
// for (const i of $$(".price:not(#sell .price)")) {
// T(i, price(TX(i)));
// }
// // console.clear();
}
const formatter = new Intl.RelativeTimeFormat(ar ? "ar" : undefined, {
numeric: "auto",
});
const DIVISIONS = [
{ amount: 60, name: "seconds" },
{ amount: 60, name: "minutes" },
{ amount: 24, name: "hours" },
{ amount: 7, name: "days" },
{ amount: 4.34524, name: "weeks" },
{ amount: 12, name: "months" },
{ amount: Number.POSITIVE_INFINITY, name: "years" },
];
function formatTimeAgo(date) {
let duration = (new Date(date) - new Date()) / 1000;
for (let i = 0; i < DIVISIONS.length; i++) {
const division = DIVISIONS[i];
if (Math.abs(duration) < division.amount) {
return formatter.format(Math.round(duration), division.name);
}
duration /= division.amount;
}
}
function date(listenDate) {
for (let i = 0; i < listenDate.length; i++) {
T(listenDate[i], formatTimeAgo(TX(listenDate[i])) + ".");
}
}
// //////////////// END home.js
// //////////////// START save.js
if (currentUrl.search(/\/myads\//gi) !== -1) {
const r = ("#dash-cards");
const st = $("#new-chats");
let chatsRes = 0;
if (TX(r).length > 10) {
const t = JSON.parse(TX(r));
let s = "";
for (const e of t) {
s += `
convert this javascript code to typescript:
function replaceChar(ele) {
if (ele) {
return ele
.trim()
.replace(/(all in |»|❭|\n +)/gi, "")
.replace(/ ( |(|)|/|,|&|%20|%2C|%26|'s +|’s +) /gi, "-")
.replace(/(--|---|----)/gi, "-")
.replace(/--/gi, "-")
.toLowerCase();
}
}
function allUrls(search, lang, node) {
let url = [];
if (node) {
for (const i in urls[search]) {
url.push(i);
}
} else {
if (lang) {
for (const i in urls) {
if (typeof urls[i] === "object") {
for (const e in urls[i]) {
if (replaceChar(e) === replaceChar(search)) {
url = urls[i][e];
}
}
} else {
if (replaceChar(i) === replaceChar(search)) {
url = urls[i];
}
}
}
} else {
for (const i in urls) {
if (typeof urls[i] === "object") {
for (const e in urls[i]) {
url.push(e);
}
} else {
url.push(i);
}
}
url = url.flat().find((r) => replaceChar(r) === replaceChar(search));
}
}
return url || search;
}
function trans(ifTrue, ifFalse = ifTrue) {
return ar ? allUrls(ifTrue, 1) : allUrls(ifFalse);
}
const locSearch = location.search;
const pathname = location.pathname;
const currentUrl = location.href;
// function capitalize(el) {
// const r = el.split(' ');
// const s = [];
// for (const a of r) {
// s.push(a[0].toUpperCase() + a.slice(1));
// }
// return s.join(' ');
// }
const checkLog = (".hamburger−menu.btn");constsearch=(".search-header");
const selectCategory = (".selectCategory");constresults=(".search-result");
const categoryIn = (
"#nav:not(#sell #nav) .parent-click div a:not(:first-of-type), .nav-links div div > a:not(:first-of-type)"
);
const parentClick = (".parent-click:not(:first-of-type), .nav-links > div");
const clickShow = (".click−show:('.sign-in-form input[type="submit"]');
const url = new URLSearchParams(locSearch);
const g = (".my−chatspan");constfooter=("footer");
function checkLength(input, from, to) {
const inputText = (`#{input}); const errorRes = $(#{input} ~ .inv`);
inputText.onchange = () => {
if (inputText.value.length < from) {
T(
errorRes,
ar
? `يجب أن يحتوي على أحرف {from} على الأقل:Must contain at least {from} characters`
);
} else if (inputText.value.length >= to) {
T(
errorRes,
ar
? `يجب ألا يحتوي على أكثر من {to} حرفًا:It must not contain more than {to} characters`
);
} else {
T(errorRes, "");
}
};
}
function valNewPass(newpa, retpa) {
const newPass = (#${newpa});
const retPass = (`#{retpa}); const g = $(#{retpa} ~ .inv`);
for (let i = 0; i < submit.length; i++) {
if (newPass.value !== retPass.value) {
T(
g,
ar ? "كلمتا المرور غير متطابقتان" : "The two passwords do not match"
);
submit[i].setAttribute("type", "button");
checkLength(newpa, 6);
} else {
submit[i].setAttribute("type", "submit");
T(g, "");
checkLength(newpa, 6);
}
}
retPass.oninput = () => {
valNewPass(newpa, retpa);
newPass.oninput = () => {
valNewPass(newpa, retpa);
};
};
}
if (g || footer) {
for (let i = 0; i < parentClick.length; i++) {
parentClick[i].onclick = () => {
clickShow[i].classList.add("block");
parentClick[i].onmouseleave = () => {
clickShow[i].classList.remove("block");
};
};
}
}
if (!checkLog) {
add(".sign-in-header", "none");
}
if (g) {
const lang = ("#lang");
const urlLoc = new URLSearchParams(locSearch);
urlLoc.set("lang", replaceChar(TX(lang)));
lang.href = urlLoc.toString().includes("?") ? urlLoc : "?" + urlLoc;
const hrefS = (
'.header > a, .hamburger-menu a:not(#lang, [onclick], [href="/help"])'
);
if (checkLog) {
for (const i of hrefS) {
i.href = "#";
i.onclick = () => {
toggle(".log", "flex");
};
}
}
if (!parseInt(TX(g))) {
g.remove();
}
const liTag = (value) => {
url.set("search", value);
return `<a href="/ads/?${url}">${value}</a>`;
};
const searches = (keyWord = "all") => {
if (keyWord === "all" || !keyWord) {
results.classList.add("trend-result");
} else {
results.classList.remove("trend-result");
}
let list = [];
fetch("https://exxeer.com/components/head.php?query=" + (keyWord || "all"))
.then((rs) => rs.json())
.then((result) => {
list = result.map((data) => (data = liTag(data)));
I(results, list.join("") || liTag(search.value));
});
};
// searches()
search.onfocus = () => {
results.classList.add("block");
};
abort(
"!e.target.classList.contains('search-result') && !e.target.classList.contains('search-header')",
"remove('.search-result', 'block');add('.search-result', 'none')"
);
let a = 0;
search.onkeyup = (r) => {
const t = r.target.value;
const f = r.key === "ArrowDown";
const c = r.key === "ArrowUp";
const e = r.key === "Enter";
if (f || c || e) {
if (f) {
a++;
} else if (c) {
a--;
}
const g = (".search-result a").length;
a = a <= 1 ? g : a;
a = a >= g ? 1 : a;
remove(".search-result a", "active");
const s = (‘.search−resulta:nth−child({a})); s.classList.add("active"); search.value = f || c ? s.textContent : search.value; if (e) { url.set("search", t); location.href = /ads/?{url}`;
}
} else {
searches(t);
}
};
selectCategory.oninput = () => {
const t = selectCategory.value;
url.delete("type[]");
url.delete("branch");
url.delete("subcategory");
url.delete("brand[]");
if (t === "all") {
url.delete("category");
} else {
url.set("category", t);
}
st(t);
};
const st = (r = selectCategory.value) => {
selectCategory.style.width = `{r.length * 16}px; }; if (url.has("category")) { const rs = selectCategory.querySelector([value='{url.get("category")}']`);
for (let i = 0; i < selectCategory.querySelectorAll("option").length; i++) {
if (url.has("category") && rs) {
selectCategory.style.width = `{TX(rs).length * 14}px; rs.selected = true; st(); } } } $("#search").onclick = () => { if (!search.value) { url.delete("search"); } else { url.set("search", search.value); } location.href = /ads/?{url}`;
};
if (url.has("location") || url.has("area")) {
for (const i of $$("#nav a[href]")) {
i.href += url.has("area")
? `&area={url.get("area")}:&location={url.get("location")}`;
}
}
if (screen.availWidth < 1152) {
const navLinks = $$("nav > div > a, .nav-links > div > a");
for (let i = 0; i < navLinks.length; i++) {
navLinks[i].setAttribute("href", "#");
}
}
if (screen.availWidth < 768) {
let prevScroll = window.scrollY;
window.onscroll = () => {
const currentScroll = window.scrollY;
if (prevScroll > currentScroll) {
("header").style.top = "0";
} else {
("header").style.top = "-48px";
}
prevScroll = currentScroll;
};
}
if (screen.availWidth > 768) {
let prevScroll = window.scrollY;
window.onscroll = () => {
const currentScroll = window.scrollY;
if (prevScroll < currentScroll) {
("#nav").style.top = "0";
} else {
("#nav").style.top = "65px";
}
prevScroll = currentScroll;
};
}
const t = ("#welName");
T(t, TX(t) ? , ${TX(t).split(" ")[0]} : "");
}
function isMobile() {
const toMatch = [
/Android/i,
/webOS/i,
/iPhone/i,
/iPad/i,
/iPod/i,
/BlackBerry/i,
/Windows Phone/i,
/mobile/i,
];
return toMatch.some((toMatchItem) => navigator.userAgent.match(toMatchItem));
}
function duplicate(array) {
return array.filter((key, index) => array.indexOf(key) === index);
}
const cardFavorite = (".card−fav");constcardFavoriteFil(".card-fav-fill");
cardFavorite.forEach((element) => {
element.onclick = (ele) => {
if ((".sign-in")) {
(".sign-in-form").classList.toggle("flex");
}
ele.target.classList.toggle("card-fav-fill");
};
});
cardFavoriteFill.forEach((element) => {
element.onclick = (ele) => {
ele.target.classList.toggle("card-fav-fill");
ele.target.classList.toggle("card-fav");
};
});
const scrollingElement = doc.scrollingElement || doc.body;
const toBottom = (ele = scrollingElement) => {
ele.scrollTop = ele.scrollHeight;
};
// eslint-disable-next-line no-unused-vars
const backTop = (ele = scrollingElement) => {
ele.scrollTop = 0;
};
function radInput(type, array, ele, lang, name = ele) {
const el = (`.${ele} label:not(.checked)`);
for (let i = 0; i < el.length; i++) {
I(
el[i],
`<input type='${type}' name='${name + array}' value='${
lang ? el[i].id : replaceChar(TX(el[i]))
}'>${TX(el[i])}`
);
}
}
const removeMessage = ("[class='alert'],[id='alert'], .thanks");
for (let i = 0; i < removeMessage.length; i++) {
removeMessage[i].onclick = () => {
removeMessage[i].style.display = "none";
};
}
const alertLocation = ("#alert-location");
function getLocation(fun) {
if (!navigator.geolocation.getCurrentPosition) {
I(
alertLocation,
ar
? "متصفحك لا يدعم تحديد الموقع!"
: "Your browser doesn't support location identification!"
);
} else {
navigator.geolocation.getCurrentPosition(fun, errHand);
}
}
function errHand(err) {
alertLocation.style.display = "flex";
switch (err.code) {
case err.PERMISSION_DENIED:
T(
alertLocation,
ar
? "التطبيق ليس لديه إذن تحديد الموقع."
: "The app does not have location permission."
);
break;
case err.POSITION_UNAVAILABLE:
T(
alertLocation,
ar ? "موقع الجهاز غير مؤكد." : "Device location is uncertain."
);
break;
case err.TIMEOUT:
T(
alertLocation,
ar
? "انتهت المهلة للحصول على موقع المستخدم."
: "Timed out to get the user's location."
);
break;
case err.UNKNOWN_ERROR:
T(
alertLocation,
ar ? "حدث خطأ ما حاول مرة أخرى." : "Something went wrong!, Try again."
);
break;
}
}
const locationUrl = new URLSearchParams(locSearch);
let locations = $$(".filter-location-in > div > a, .header-map a");
locationUrl.delete("page");
locationUrl.delete("ad");
locationUrl.delete("area");
for (let i = 0; i < locations.length; i++) {
locationUrl.set("location", locations[i].id);
locations[i].setAttribute("href", `/ads/?{locationUrl}); } // / ///////////// START home.js const cards = $$(".cards-row, .listen-cards"); for (const i of cards) { if (TX(i).length <= 20) { if (!i.classList.contains("listen-cards")) { i.parentElement.remove(); } } else { const t = JSON.parse(TX(i)); let s = ""; for (const e of t) { s += e.price</span><h4class={
e.title
}trans(e.area),{trans(
e.location
)}.e.created</div></div></di{e.class} value='{
e.id
}'></article>`;
}
I(i, s);
}
}
function price(num) {
if (num.indexOf("allowance") >= 0) {
return trans("for allowance");
}
return new Intl.NumberFormat(ar ? "ar" : undefined, {
maximumSignificantDigits: 21,
style: "currency",
currency: "egp",
}).format(num);
}
function home() {
// const listen = $$(".listen-title");
// const listenImg = $$(".listen-card a");
// for (let i = 0; i < listen.length; i++) {
// if (listenImg[i]) {
// listenImg[i].setAttribute(
// "href",
// `/ad/?ad={encodeURIComponent(TX(listen[i]))}// ); // } // T(listen[i], TX(listen[i]).replace(/-[0-9]{0,}$/, "")); // } // date($$(".date")); // const listenImgDir = $$(".listen-card a > img, .ad-img"); // for (let i = 0; i < listenImgDir.length; i++) { // const gt = listenImgDir[i].getAttribute("src"); // const tg = gt.split(" -^- "); // listenImgDir[i].setAttribute("src",/uploads/{tg[parseInt(tg[0]) + 1]}`);
// }
// for (const i of $$(".price:not(#sell .price)")) {
// T(i, price(TX(i)));
// }
// // console.clear();
}
const formatter = new Intl.RelativeTimeFormat(ar ? "ar" : undefined, {
numeric: "auto",
});
const DIVISIONS = [
{ amount: 60, name: "seconds" },
{ amount: 60, name: "minutes" },
{ amount: 24, name: "hours" },
{ amount: 7, name: "days" },
{ amount: 4.34524, name: "weeks" },
{ amount: 12, name: "months" },
{ amount: Number.POSITIVE_INFINITY, name: "years" },
];
function formatTimeAgo(date) {
let duration = (new Date(date) - new Date()) / 1000;
for (let i = 0; i < DIVISIONS.length; i++) {
const division = DIVISIONS[i];
if (Math.abs(duration) < division.amount) {
return formatter.format(Math.round(duration), division.name);
}
duration /= division.amount;
}
}
function date(listenDate) {
for (let i = 0; i < listenDate.length; i++) {
T(listenDate[i], formatTimeAgo(TX(listenDate[i])) + ".");
}
}
// //////////////// END home.js
// //////////////// START save.js
if (currentUrl.search(/\/myads\//gi) !== -1) {
const r = ("#dash-cards");
const st = $("#new-chats");
let chatsRes = 0;
if (TX(r).length > 10) {
const t = JSON.parse(TX(r));
let s = "";
for (const e of t) {
s += `