1jQuery(document).ready(function() { 2 jQuery('.hamburger-button').click(function() { 3 jQuery('.vertical-menu').slideToggle(); 4 jQuery(this).toggleClass('active'); 5 }); 6 7 jQuery('.nav-bar-icons__search').click(function() { 8 jQuery('.search--header').slideToggle(); 9 jQuery(this).toggleClass('active'); 10 }); 11 12 const postData = { 13 action: 'post_view', // Replace with your desired action name 14 post_id: $('#post_counter').data('id'), // Get the current post ID 15 }; 16 17 jQuery.ajax({ 18 url: '/wp-content/themes/WNtheme/ajax.php', 19 type: 'POST', 20 data: postData, // No need for JSON.stringify with jQuery.ajax 21 success: function(data) { 22 //console.log(data); // This is for debugging purposes (optional) 23 }, 24 error: function(jqXHR, textStatus, errorThrown) { 25 //console.error('Error:', textStatus, errorThrown); // Handle errors 26 } 27 }); 28 29 jQuery('.social span').click(function() { 30 if (jQuery(this).data("type") === "pinterest") { 31 let url = "//pinterest.com/pin/create/link/?url="+jQuery(this).data("url")+"&description="+jQuery(this).data("title"); 32 window.open(url, '_blank'); 33 } else if (jQuery(this).data("type") === "X") { 34 let url = "//twitter.com/share?url="+jQuery(this).data("url")+"&description="+jQuery(this).data("title"); 35 window.open(url, '_blank'); 36 } 37 }); 38 39}); 40 41(function ($) { 42 'use strict'; 43 44 // Function to read cookie value 45 function wn_read_site_cookie(cookieName) { 46 const nameEQ = cookieName + "="; 47 const ca = document.cookie.split(';'); 48 for (let i = 0; i < ca.length; i += 1) { 49 let c = ca[i]; 50 while (c.charAt(0) === ' ') c = c.substring(1, c.length); 51 if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length); 52 } 53 return null; 54 } 55 56 // Function to set cookie with expiry 57 function wn_set_cookies_life(cookieData) { 58 const [cookieName, cookieValue, expiryDays] = cookieData; 59 const expires = new Date(); 60 expires.setTime(expires.getTime() + (expiryDays * 24 * 60 * 60 * 1000)); 61 const cookieString = `${cookieName}=${cookieValue};expires=${expires.toUTCString()};path=/`; 62 document.cookie = cookieString; 63 } 64 65 // Existing jQuery code utilizing the functions 66 const cookieNotice = wn_read_site_cookie('cookieNotice'); 67 if ('accepted' !== cookieNotice) { 68 $(".cookie-container").show(); 69 } 70 71 $("#acceptCookies").click(function () { 72 $(".cookie-container").hide(); 73 wn_set_cookies_life(['cookieNotice', 'accepted', 31536000000]); // One year in milliseconds 74 }); 75 76 $(window).scroll(function () { 77 const scrollPosition = $(window).scrollTop(); 78 if (scrollPosition > 200) { 79 $(".cookie-container").hide(); 80 wn_set_cookies_life(['cookieNotice', 'accepted', 31536000000]); // One year in milliseconds 81 } 82 }); 83})(jQuery); 84 85 86/* 87 * Ajax Loader 88 */ 89(function ($) { 90 const loaderElements = $('.ajax-loader'); 91 92 loaderElements.each(function(index, element) { 93 const currentEl = $(element); 94 const postId = currentEl.data('postid'); 95 const action = currentEl.data('action'); 96 const id = currentEl.attr('id'); 97 98 if (postId) { 99 jQuery.ajax({ 100 url: '/wp-content/themes/WNtheme/ajax.php', 101 type: 'POST', 102 data: {action: action, post_id: postId, type: "dynamic"}, 103 success: function (response) { 104 $("#"+id).after(response); 105 $("#"+id).remove(); 106 107 startAction(action); 108 } 109 }); 110 } 111 }); 112 113 114 function startAction(action) { 115 116 /* 117 * Vote 118 */ 119 if (action == "vote") { 120 121 if (jQuery('.vote-container').length) { 122 const yesCountEl = jQuery('.vote-column.yes'); 123 const noCountEl = jQuery('.vote-column.no'); 124 const maxHeight = 200; 125
126 function updateVoteCounts(yesCount, noCount, visible) { 127 128 if (visible == 0) { 129 yesCountEl.text(`ÐÐ `); 130 noCountEl.text(`ÐÐТ`); 131 } else { 132 yesCountEl.text(`ÐÐ (${yesCount})`); 133 noCountEl.text(`ÐÐТ (${noCount})`); 134 } 135 136 const ratio = Math.min(yesCount, noCount) / Math.max(yesCount, noCount); 137 138 let obj = { 139 'yesHeight': Math.round((maxHeight * ratio)), 140 'noHeight': Math.round((maxHeight * ratio)) 141 } 142 143 if (yesCount > noCount) { 144 obj['yesHeight'] = maxHeight; 145 } else { 146 obj['noHeight'] = maxHeight; 147 } 148 149 yesCountEl.css('height', obj['yesHeight'] + 'px'); 150 noCountEl.css('height', obj['noHeight'] + 'px'); 151 } 152 153 // Initial vote counts (replace with your actual logic) 154 let yesCount = jQuery('.vote-container').data('yes'); 155 let noCount = jQuery('.vote-container').data('no'); 156 157 let hasVoted = false; 158 159 updateVoteCounts(yesCount, noCount, 0); 160 161 // Add event listeners for voting 162 yesCountEl.click(function () { 163 if (!hasVoted) { 164 yesCount++; 165 hasVoted = true; 166 updateVoteCounts(yesCount, noCount, 1); 167 jQuery.ajax({ 168 url: '/wp-content/themes/WNtheme/ajax.php', 169 type: 'POST', 170 data: {vote: 'yes', post_id: jQuery('.vote-container').data('postid'), action: 'vote'}, 171 success: function (response) { 172 //console.log(response); 173 } 174 }); 175 jQuery('.vote-column.yes').addClass('voted'); 176 jQuery('.vote-column.no').addClass('voted'); 177 } 178 }); 179 180 noCountEl.click(function () { 181 if (!hasVoted) { 182 noCount++; 183 hasVoted = true; 184 updateVoteCounts(yesCount, noCount, 1); 185 jQuery.ajax({ 186 url: '/wp-content/themes/WNtheme/ajax.php', 187 type: 'POST', 188 data: {vote: 'no', post_id: jQuery('.vote-container').data('postid'), action: 'vote'}, 189 success: function (response) { 190 //console.log(response); 191 } 192 }); 193 jQuery('.vote-column.yes').addClass('voted'); 194 jQuery('.vote-column.no').addClass('voted'); 195 } 196 }); 197 } 198 } 199 } 200 201 202})(jQuery); 203 204 205/* 206 * Gallery 207 */ 208function hasGalleryFragment() { 209 return window.location.hash === '#gallery'; 210} 211 212jQuery(document).ready(function() { 213 214 // Get the total number of images 215 const totalImages = jQuery('.gallery_scrollWrapper img').length + 1; 216 217 // Set the current image index to 0 (starting from 0) 218 let currentImageIndex = 0; 219 let nextUrl = ""; 220 221 //console.log(totalImages); 222 223 if (totalImages > 2) { 224 // Update the gallery header and caption with the current image information 225 updateImageInfo(); 226 } 227 228 // Gallery was called in url open it 229 if (hasGalleryFragment()) { 230 jQuery(".gallery_overlay").show(); 231 } 232 233 // Handle show image gallery click 234 jQuery('.image-container').click(function() { 235 jQuery(".gallery_overlay").show(); 236 }); 237 238 // Handle previous button click 239 jQuery('.gallery_previousButton').click(function() { 240 if (currentImageIndex == -1){
241 window.location.href = nextUrl + "#gallery"; // Set new URL 242 } 243 if (currentImageIndex > 0) { 244 currentImageIndex--; 245 updateImageInfo(); 246 } 247 }); 248 249 // Handle next button click 250 jQuery('.gallery_nextButton').click(function() { 251 if (currentImageIndex == -1) { 252 window.location.href = nextUrl + "#gallery"; // Set new URL 253 } else { 254 if (currentImageIndex < totalImages - 2) { 255 currentImageIndex++; 256 updateImageInfo(); 257 } else { 258 // latest image was clicked 259 currentImageIndex = -1; 260 jQuery('.gallery_scrollWrapper img').hide(); 261 jQuery('.gallery_header').hide(); 262 jQuery('.gallery_caption').text(""); 263 jQuery('.gallery_slide').show(); 264 } 265 } 266 }); 267 268 // Close button 269 jQuery('.closeButton').click(function() { 270 jQuery(".gallery_overlay").hide(); 271 }); 272 273 // Gallery Social clicked 274 jQuery('.galleryInfo button').click(function() { 275 if (jQuery(this).data("type") === "pinterest") { 276 let url = "//pinterest.com/pin/create/link/?url="+jQuery(this).data("url")+"&description="+jQuery(this).data("title"); 277 window.open(url, '_blank'); 278 } else if (jQuery(this).data("type") === "X") { 279 let url = "//twitter.com/share?url="+jQuery(this).data("url")+"&description="+jQuery(this).data("title"); 280 window.open(url, '_blank'); 281 } 282 }); 283 284 // Function to update the displayed image and caption 285 function updateImageInfo() { 286 const totalImages = jQuery('.gallery_scrollWrapper img').length + 1; 287 jQuery('.gallery_header').text((currentImageIndex + 1) + ' из ' + totalImages); 288 289 // Hide all images 290 jQuery('.gallery_scrollWrapper img').hide(); 291 292 // Show the current image 293 const currentImage = jQuery('.gallery_scrollWrapper img').eq(currentImageIndex); 294 currentImage.show(); 295 296 // Update the caption text from the image's alt attribute 297 if (currentImage.attr('alt').indexOf("[") >= 0) { 298 jQuery('.gallery_caption').text(""); 299 } else { 300 jQuery('.gallery_caption').text(currentImage.attr('alt')); 301 } 302 303 // Update navigation buttons 304 updateNavigationButtons(); 305 } 306 307 // Function to update navigation button states 308 function updateNavigationButtons() { 309 if (currentImageIndex === 0) { 310 jQuery('.gallery_previousButton').prop('disabled', true); 311 } else { 312 jQuery('.gallery_previousButton').prop('disabled', false); 313 } 314 315 if (currentImageIndex === totalImages - 2) { 316 jQuery('.gallery_nextButton').prop('disabled', false); // true 317 // Show Gallery list box 318 // Download gallery list box 319 320 const galleryId = jQuery('#post_counter').data("id"); // Replace with the actual gallery ID 321 322 jQuery.ajax({ 323 url: "/wp-content/themes/WNtheme/ajax.php", 324 method: "POST", // Ensure it's a POST request 325 data: { 326 action: "galleryList", 327 post_id: galleryId, 328 }, 329 dataType: "json" // Specify that we expect JSON data 330 }) 331 .done(function(data) { 332 // Handle successful response 333 //console.log("Gallery data:", data); 334 335 let c = 0; 336 let style = ""; 337 338 jQuery.each(data, function(index, item) { 339 c = c + 1; 340 341 if (c > 4) { 342 style = "half"; 343 } 344 345 // Build the HTML element using template literals 346 const html = ` 347 <a class="item ${style}" href="${item.url}#gallery"> 348 <div> 349 <div class="imageBox" style="padding-bottom: 60.177%; background-image: url("${item.images[0][0]}");"></div> 350 </div> 351 <div class="imageStrip"> 352 <div class="itemImage"> 353 <div class="imageBox" style="padding-bottom: 73.333%; background-image: url("${item.images[1][0]}");"></div> 354 </div> 355 <div class="itemImage"> 356 <div class="imageBox" style="padding-bottom: 73.333%; background-image: url("${item.images[2][0]}");"></div> 357 </div> 358 <div class="itemImageCount">+${item.count}</div> 359 </div> 360 <div class="headline">${item.title}</div> 361 </a> 362 `; 363 364 if (c > 4) { 365 jQuery("#gallery-items-bottom").append(html); 366 } else { 367 jQuery("#gallery-items-top").append(html); 368 } 369 370 371 if (c == 1) { 372 nextUrl = item.url; 373 const html = `<div class="imageBox" style="padding-bottom: 74.62%; background-image: url("${item.images[0][0]}");"></div>`; 374 375 jQuery("#gallery-next-gallery").append(html); 376 jQuery(".viewNextHeadline").html(item.title); 377 } 378 379 }); 380 381 382 /* 383 * Add next gallery event 384 */ 385 386 jQuery('.viewNextWrapper').click(function(event) { 387 event.preventDefault(); // Prevent default behavior
388 window.location.href = nextUrl + "#gallery"; // Set new URL 389 }); 390 391 392 }) 393 .fail(function(jqXHR, textStatus, errorThrown) { 394 // Handle error response 395 console.error("Error:", textStatus, errorThrown); 396 // Display an error message to the user if needed 397 }); 398 399 } else { 400 jQuery('.gallery_nextButton').prop('disabled', false); 401 } 402 } 403 404}); 405 406 407/* 408 * Video image to video to image code 409 */ 410 411function extractAspectRatio(text) { 412 const match = text.match(/(\d+)\s*\/\s*(\d+)/); // Regular expression to extract numbers 413 if (match) { 414 return match[1] + "/" + match[2]; 415 } else { 416 return null; // Or handle the case where the format is not found as needed 417 } 418} 419 420function isDesktop() { 421 return !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); 422} 423 424 425$(document).ready(function() { 426 if (isDesktop()) { 427 // Add video label 428 $("img[data-video]").each(function() { 429 let $parentDiv = $(this).closest("div"); 430 if (!$parentDiv.hasClass("video_label")) { 431 $parentDiv.addClass("video_label"); 432 } 433 }); 434 435 // Delegate the mouseenter event to the document 436 $(document).on('mouseenter', 'img[data-video]', function () { 437 let $img = $(this); // Get the current image being hovered over 438 let preLoadTimer; // Timer for preloading 439 let displayTimer; 440 let videoUrl = $img.data('video'); 441 let $video; 442 let $parentDiv = $(this).parent().parent(); 443 444 // Check if a displayTimer is already running for this image (to prevent multiple timers) 445 if ($img.data('displayTimer')) { 446 return; // Exit early if timer already exists 447 } 448 449 // Animation Start 450 $parentDiv.removeClass('video_label'); 451 $parentDiv.addClass('video_label_animate'); 452 453 454 // Preload Timer (0.5 seconds) 455 preLoadTimer = setTimeout(() => { 456 $video = $('<video preload="auto">').attr('src', videoUrl).hide(); // Create hidden video element for preloading 457 }, 200); // 0.5 seconds 458 459 $img.data('preLoadTimer', preLoadTimer); 460 461 // Main Timer 462 displayTimer = setTimeout(() => { 463 464 // Animation End 465 $parentDiv.removeClass('video_label_animate'); 466 $parentDiv.addClass('video_label'); 467 468 $video = $('<video autoplay loop muted>'); 469 $video.attr('src', videoUrl); 470 471 // Copy attributes and styles (as before) 472 $.each($img[0].attributes, function () { 473 if (this.name !== 'src') { 474 $video.attr(this.name, this.value); 475 } 476 }); 477 $video.attr('style', $img.attr('style')); 478 479 // Get aspect ratio from the image 480 let aspectRatioString = extractAspectRatio($img.css('aspect-ratio')); 481 if (aspectRatioString) { 482 let aspectRatioParts = aspectRatioString.split('/'); // Split the string 483 if (aspectRatioParts.length === 2) { 484 let widthRatio = parseFloat(aspectRatioParts[0]); 485 let heightRatio = parseFloat(aspectRatioParts[1]); 486 487 if (!isNaN(widthRatio) && !isNaN(heightRatio)) { 488 // Calculate height based on image width and aspect ratio 489 let videoHeight = Math.ceil($img.width() * (heightRatio / widthRatio)); 490 $video.css('height', videoHeight); 491 492 // Small issue with image to video proportion, need to less video size to keep layout html 493 if (widthRatio === 260) { 494 $video.css('width', 259); 495 } else if (widthRatio === 217) { 496 $video.css('width', 210); 497 } 498 499 } 500 } 501 } 502 503 504 // Check video not ready for play 505 if ($video[0].readyState < 4) { 506 $parentDiv.removeClass('video_label'); 507 $parentDiv.addClass('video_download_animate'); 508 } 509 510 $video.on('canplay', function() { 511 $parentDiv.removeClass('video_download_animate'); 512 }); 513 514 // Mouseleave on the video 515 $video.on('mouseleave', function () { 516 let $newImg = $('<img>'); 517 $.each($img[0].attributes, function () { 518 $newImg.attr(this.name, this.value); 519 }); 520 $newImg.attr('style', $img.attr('style')); 521 $video.replaceWith($newImg); 522 $video = null; 523 $parentDiv.removeClass('video_download_animate'); 524 $parentDiv.addClass('video_label'); // Show video play label 525 }); 526 527 $img.replaceWith($video); 528 $img.removeData('displayTimer'); // Remove data after replacing 529 $img.removeData('preLoadTimer'); 530 531 // Hide video play label 532 $parentDiv.removeClass('video_label'); 533 534 }, 600); 535 536 $img.data('displayTimer', displayTimer); // Store the timer so we can access it later 537 538 }); 539 540 541 // Mouseleave (to handle exiting before the timeout) â also delegated
542 $(document).on('mouseleave', 'img[data-video]', function () { 543 let $img = $(this); 544 let $parentDiv = $(this).parent().parent(); 545 clearTimeout($img.data('displayTimer')); 546 clearTimeout($img.data('preLoadTimer')); // If you don't need preLoadTimer anymore 547 $img.removeData('displayTimer'); 548 $img.removeData('preLoadTimer'); 549 550 // Animation End 551 $parentDiv.removeClass('video_download_animate'); 552 $parentDiv.removeClass('video_label_animate'); 553 $parentDiv.addClass('video_label'); 554 555 if (typeof $video !== 'undefined' && $video) { // If the video was created, replace it back with the image 556 let $newImg = $('<img>'); 557 $.each($img[0].attributes, function () { 558 $newImg.attr(this.name, this.value); 559 }); 560 $newImg.attr('style', $img.attr('style')); 561 $video.replaceWith($newImg); 562 $video = null; 563 564 } 565 566 }); 567 } 568});
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.