1function getWidth() { 2 let width = null; 3 if (window.screen) { 4 width = window.screen.availWidth; 5 } 6 if (window.innerWidth) { 7 width = window.innerWidth; 8 } 9 if (document.body) { 10 width = document.body.clientWidth; 11 } 12 return width; 13} 14 15// Select all spans with the class 'rating' 16const ratingSpans = document.querySelectorAll("span.rating"); 17ratingSpans.forEach((span) => { 18 const textLength = span.textContent.trim().length; 19 20 if (textLength === 1) { 21 if (span.classList.contains("px-2")) { 22 span.classList.remove("px-2"); 23 } 24 if (!span.classList.contains("px-[0.9rem]")) { 25 span.classList.add("px-[0.9rem]"); 26 } 27 } 28 29 if (textLength === 2) { 30 if (span.classList.contains("px-3.5")) { 31 span.classList.remove("px-3.5"); 32 } 33 if (!span.classList.contains("px-2.5")) { 34 span.classList.add("px-2.5"); 35 } 36 } 37 38 if (textLength === 3) { 39 if (span.classList.contains("px-3.5")) { 40 span.classList.remove("px-3.5"); 41 } 42 if (!span.classList.contains("px-2")) { 43 span.classList.add("px-2"); 44 } 45 } 46}); 47 48// Theme Toggle â the same id="theme-toggle" is used on several buttons (desktop nav, 49// mobile nav, and the off-canvas mobile menu). getElementById only returns the first, 50// which left the mobile toggle dead â so wire EVERY matching button and keep all of 51// their icon pairs in sync. 52// const themeToggleButtons = document.querySelectorAll("#theme-toggle"); 53// const darkIcons = document.querySelectorAll("#theme-toggle-dark-icon"); 54// const lightIcons = document.querySelectorAll("#theme-toggle-light-icon"); 55// const rootElement = document.documentElement; 56 57// function applyTheme(theme) { 58// const isDark = theme === "dark"; 59// rootElement.classList.toggle("dark", isDark); 60// // Light mode shows the dark (moon) icon; dark mode shows the light (sun) icon. 61// darkIcons.forEach((icon) => icon.classList.toggle("hidden", isDark)); 62// lightIcons.forEach((icon) => icon.classList.toggle("hidden", !isDark)); 63// } 64 65// if (themeToggleButtons.length) { 66// applyTheme(localStorage.getItem("theme") || "light"); 67 68// themeToggleButtons.forEach((button) => { 69// button.addEventListener("click", () => { 70// const nextTheme = rootElement.classList.contains("dark") ? "light" : "dark"; 71// localStorage.setItem("theme", nextTheme); 72// applyTheme(nextTheme); 73// }); 74// }); 75// } 76 77const themeToggleButtons = document.querySelectorAll("#theme-toggle"); 78const darkIcons = document.querySelectorAll("#theme-toggle-dark-icon"); 79const lightIcons = document.querySelectorAll("#theme-toggle-light-icon"); 80const rootElement = document.documentElement; 81 82function applyTheme(theme) { 83 const isDark = theme === "dark"; 84 85 rootElement.classList.toggle("dark", isDark); 86 87 // Light mode shows the moon icon; dark mode shows the sun icon. 88 darkIcons.forEach((icon) => icon.classList.toggle("hidden", isDark)); 89 lightIcons.forEach((icon) => icon.classList.toggle("hidden", !isDark)); 90 91 // Update the button titles 92 themeToggleButtons.forEach((button) => { 93 button.title = isDark ? "اÙÙØ¶Ø¹ اÙÙÙØ§Ø±Ù" : "اÙÙØ¶Ø¹ اÙÙÙÙÙ"; 94 }); 95} 96 97if (themeToggleButtons.length) { 98 applyTheme(localStorage.getItem("theme") || "light"); 99 100 themeToggleButtons.forEach((button) => { 101 button.addEventListener("click", () => { 102 const nextTheme = rootElement.classList.contains("dark") 103 ? "light" 104 : "dark"; 105 106 localStorage.setItem("theme", nextTheme); 107 applyTheme(nextTheme); 108 }); 109 }); 110} 111 112// Search Popup 113const searchButton = document.getElementById("search-button"); 114const searchPopup = document.getElementById("search-popup"); 115const closePopup = document.getElementById("close-popup"); 116 117if (searchButton && searchPopup && closePopup) { 118 searchButton.addEventListener("click", () => { 119 searchPopup.classList.remove("hidden"); 120 }); 121 122 closePopup.addEventListener("click", () => { 123 searchPopup.classList.add("hidden"); 124 }); 125 126 searchPopup.addEventListener("click", (e) => { 127 if (e.target === searchPopup) { 128 searchPopup.classList.add("hidden"); 129 } 130 }); 131} 132 133// Offset the fixed mobile nav/menu below the WordPress admin bar for logged-in users. 134// (The previous version toggled arbitrary Tailwind offset classes that were never 135// compiled into the stylesheet, so it did nothing. Set the offset directly instead, 136// using the admin bar's real height, and drop to 0 once it scrolls out of view.) 137document.addEventListener("scroll", () => { 138 if (!document.body.classList.contains("loggedin-class")) return; 139 const mobileDiv = document.getElementById("MenuMobile"); 140 const mobileSidebar = document.getElementById("menu-mobile"); 141 const adminBar = document.getElementById("wpadminbar"); 142 const offset = adminBar && window.scrollY <= 0 ? adminBar.offsetHeight + "px" : "0px"; 143 if (mobileDiv) mobileDiv.style.top = offset; 144 if (mobileSidebar) mobileSidebar.style.top = offset; 145}); 146 147// Scroll to Top Function
148function topFunction() { 149 window.scrollTo({ 150 top: 0, 151 behavior: "smooth", 152 }); 153} 154 155// Show/Hide "To the Top" Button 156document.addEventListener("DOMContentLoaded", function () { 157 const btnTop = document.getElementById("btnTop"); 158 window.addEventListener("scroll", function () { 159 if (btnTop) { 160 if (window.scrollY > 0) { 161 btnTop.classList.remove("hidden"); 162 } else { 163 btnTop.classList.add("hidden"); 164 } 165 } 166 }); 167}); 168 169// Adblock Check 170function checkForAdblock() { 171 if (typeof window.canRunAds === "undefined") { 172 const adblockSection = document.querySelector(".post-content"); 173 if (adblockSection) { 174 adblockSection.innerHTML = "..."; 175 } 176 } 177} 178 179// Copy Post ID 180function copyPostId(text) { 181 var tempInput = document.createElement("input"); 182 tempInput.value = text; 183 document.body.appendChild(tempInput); 184 tempInput.select(); 185 document.execCommand("copy"); 186 document.body.removeChild(tempInput); 187} 188 189// Toggle Menu Visibility 190function toggleMenuVisibility() { 191 const screenWidth = getWidth(); 192 const menuDesktop = document.getElementById("MenuDesktop"); 193 const menuMobile = document.getElementById("MenuMobile"); 194 195 if (screenWidth <= 1023) { 196 if (menuDesktop) hideElement(menuDesktop); 197 if (menuMobile) showElement(menuMobile, "block"); 198 } else { 199 if (menuDesktop) showElement(menuDesktop, "flex"); 200 if (menuMobile) hideElement(menuMobile); 201 } 202} 203 204function hideElement(element) { 205 if (element) { 206 element.style.display = "none"; 207 } 208} 209 210function showElement(element, displayValue) { 211 if (element) { 212 element.style.display = displayValue; 213 } 214} 215 216function initializePage() { 217 toggleMenuVisibility(); 218 window.addEventListener("resize", toggleMenuVisibility); 219} 220 221window.addEventListener("load", initializePage); 222 223// Initialize Swiper Instances if Elements Exist 224if (document.querySelector(".mySwiper")) { 225 var swiper = new Swiper(".mySwiper", { 226 loop: 1, 227 navigation: { 228 nextEl: ".swiper-button-next-1", 229 prevEl: ".swiper-button-prev-1", 230 }, 231 rtl: true, 232 }); 233} 234 235if (document.querySelector(".trading")) { 236 var swiperTrading = new Swiper(".trading", { 237 loop: 1, 238 navigation: { 239 nextEl: ".swiper-button-next-2", 240 prevEl: ".swiper-button-prev-2", 241 }, 242 rtl: true, 243 }); 244} 245 246if (document.querySelector(".most-read")) { 247 var swiperMostRead = new Swiper(".most-read", { 248 loop: 1, 249 navigation: { 250 nextEl: ".swiper-button-next-3", 251 prevEl: ".swiper-button-prev-3", 252 }, 253 rtl: true, 254 }); 255} 256 257// Share Action Button 258var shareActionBtn = document.querySelector(".shareActionBtn"); 259if (shareActionBtn) { 260 if (!navigator.share) { 261 shareActionBtn.classList.add("hidden"); 262 shareActionBtn.classList.remove("inline-flex"); 263 } else { 264 shareActionBtn.addEventListener("click", function () { 265 shareAction(); 266 }); 267 } 268} 269 270// Get Meta Content Function 271function getMetaContent(name) { 272 var meta = document.querySelector('meta[name="' + name + '"]'); 273 return meta ? meta.getAttribute("content") : ""; 274} 275 276// Share Action Function 277function shareAction() { 278 if (navigator.share) { 279 navigator 280 .share({ 281 title: document.title, 282 text: getMetaContent("description"), 283 url: window.location.href, 284 }) 285 .then(() => console.log("Successful share")) 286 .catch((error) => console.log("Error sharing", error)); 287 } 288} 289 290// Social Share Popup and Buttons 291document.addEventListener("DOMContentLoaded", function () { 292 const shareButton = document.getElementById("share_action"); 293 const popup = document.getElementById("share_popup"); 294 const closePopupButton = document.getElementById("close_popup"); 295 const copyLinkButton = document.getElementById("copy_link"); 296 297 const shareFacebook = document.getElementById("share_facebook"); 298 const shareTwitter = document.getElementById("share_twitter"); 299 const shareLinkedin = document.getElementById("share_linkedin"); 300 const shareWhatsapp = document.getElementById("share_whatsapp");
301 const shareEmail = document.getElementById("share_email"); 302 const shareInstagram = document.getElementById("share_instagram"); 303 const shareDiscord = document.getElementById("share_discord"); 304 305 const currentURL = window.location.href; 306 const postTitle = document.title; 307 308 if (shareFacebook) { 309 shareFacebook.href = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent( 310 currentURL 311 )}`; 312 } 313 if (shareTwitter) { 314 shareTwitter.href = `https://twitter.com/intent/tweet?text=${encodeURIComponent( 315 postTitle 316 )}&url=${encodeURIComponent(currentURL)}`; 317 } 318 if (shareLinkedin) { 319 shareLinkedin.href = `https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent( 320 currentURL 321 )}&title=${encodeURIComponent(postTitle)}`; 322 } 323 if (shareWhatsapp) { 324 shareWhatsapp.href = `https://wa.me/?text=${encodeURIComponent( 325 postTitle 326 )}%20${encodeURIComponent(currentURL)}`; 327 } 328 if (shareEmail) { 329 shareEmail.href = `mailto:?subject=${encodeURIComponent( 330 postTitle 331 )}&body=${encodeURIComponent(currentURL)}`; 332 } 333 if (shareInstagram) { 334 shareInstagram.addEventListener("click", async () => { 335 const currentURL = window.location.href; 336 const postTitle = document.title; 337 const shareText = `${postTitle}\n${currentURL}`; 338 if (navigator.share) { 339 try { 340 await navigator.share({ 341 title: postTitle, 342 text: postTitle, 343 url: currentURL, 344 }); 345 console.log("ت٠ت Ù Ø´Ø§Ø±ÙØ© Ø§ÙØ±Ø§Ø¨Ø· Ø¨ÙØ¬Ø§Ø!"); 346 } catch (error) { 347 console.error("ÙØ´Ùت ع٠ÙÙØ© اÙÙ Ø´Ø§Ø±ÙØ©:", error); 348 } 349 } else { 350 alert("ØªÙ ÙØ³Ø® Ø§ÙØ±Ø§Ø¨Ø·!"); 351 window.open("https://www.instagram.com/direct/inbox/", "_blank"); 352 navigator.clipboard.writeText(shareText); 353 } 354 }); 355 } 356 if (shareDiscord) { 357 shareDiscord.addEventListener("click", async () => { 358 const currentURL = window.location.href; 359 const postTitle = document.title; 360 const shareText = `${postTitle}\n${currentURL}`; 361 if (navigator.share) { 362 try { 363 await navigator.share({ 364 title: postTitle, 365 text: postTitle, 366 url: currentURL, 367 }); 368 console.log("ت٠ت Ù Ø´Ø§Ø±ÙØ© Ø§ÙØ±Ø§Ø¨Ø· Ø¨ÙØ¬Ø§Ø!"); 369 } catch (error) { 370 console.error("ÙØ´Ùت ع٠ÙÙØ© اÙÙ Ø´Ø§Ø±ÙØ©:", error); 371 } 372 } else { 373 alert("ØªÙ ÙØ³Ø® Ø§ÙØ±Ø§Ø¨Ø·!"); 374 window.open("https://discord.com/channels/@me", "_blank"); 375 navigator.clipboard.writeText(shareText); 376 } 377 }); 378 } 379 if (copyLinkButton) { 380 copyLinkButton.addEventListener("click", () => { 381 navigator.clipboard 382 .writeText(currentURL) 383 .then(() => alert("ØªÙ ÙØ³Ø® Ø§ÙØ±Ø§Ø¨Ø·!")) 384 .catch((err) => { 385 alert("ØØ¯Ø« خطأ Ø£Ø«ÙØ§Ø¡ ÙØ³Ø® Ø§ÙØ±Ø§Ø¨Ø·."); 386 console.error(err); 387 }); 388 }); 389 } 390 if (shareButton && popup) { 391 shareButton.addEventListener("click", () => { 392 popup.classList.remove("hidden"); 393 }); 394 } 395 if (closePopupButton && popup) { 396 closePopupButton.addEventListener("click", () => { 397 popup.classList.add("hidden"); 398 }); 399 } 400 if (popup) { 401 popup.addEventListener("click", (e) => { 402 if (e.target === popup) { 403 popup.classList.add("hidden"); 404 } 405 }); 406 } 407}); 408 409document.addEventListener("DOMContentLoaded", function () { 410 const checkboxes = document.querySelectorAll("[id$='_enabled']"); 411 const adBanners = document.querySelectorAll(".ad-banner"); 412 413 function toggleAds() { 414 checkboxes.forEach(checkbox => { 415 const adClass = checkbox.id.replace("_enabled", ""); // Match the ad's class 416 const adElement = document.querySelector("." + adClass); 417 if (adElement) { 418 adElement.style.display = checkbox.checked ? "block" : "none"; 419 } 420 }); 421 } 422
423 checkboxes.forEach(checkbox => { 424 checkbox.addEventListener("change", toggleAds); 425 }); 426 427 toggleAds(); // Initialize based on saved values 428}); 429
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.