1var windowResizeTimer; 2var windowScrollTimer; 3var lastUpdate = 0; 4 5var siteLocation = window.location.href; 6var isLiveSite = siteLocation.indexOf("//top-channel.tv") > -1; 7 8function logg(msg) { 9 if (!isLiveSite) console.log(msg); 10} 11 12function maar(theid) { 13 $.ajax({ 14 type: "POST", 15 url: "/extras/maar.php", 16 data: { akey: theid, action: "maar" }, 17 success: function (data) { 18 logg("MAAR: " + data); 19 }, 20 }); 21} 22 23$.fn.isInViewport = function () { 24 var elementTop = $(this).offset().top; 25 var elementBottom = elementTop + $(this).outerHeight(); 26 var viewportTop = $(window).scrollTop(); 27 var viewportBottom = viewportTop + $(window).height(); 28 return elementBottom > viewportTop && elementTop < viewportBottom; 29}; 30 31jQuery(document).ready(function ($) { 32 var windowWidth = $(window).width(); 33 34 $(".menuIcon").on("click", function () { 35 // $("html, body").animate({ scrollTop: 0 }); 36 $(".searchBox").slideUp(); 37 // $(".mainMenu").height($(window).height() - 82); 38 $(".mainMenu").slideToggle(); 39 $(".bigMenu").fadeToggle(); 40 return false; 41 }); 42 43 $(".searchIcon").on("click", function () { 44 // $("html, body").animate({ scrollTop: 0 }); 45 $(".mainMenu").slideUp(); 46 $(".searchBox").slideToggle(); 47 $(".searchBox input.txt").focus(); 48 return false; 49 }); 50 51 $(".mainMenu .menuUL").each(function () { 52 if ($(this).attr("id") != "newsMenu2") { 53 $(this) 54 .find("li") 55 .first() 56 .append( 57 '<a class="pull-right toggleSubMenu visible-xs" href="#"><i class="fa fa-chevron-down" aria-hidden="true"></i></a>' 58 ); 59 //$(this).find('li').not(":nth-child(1)").hide(); 60 } 61 }); 62 63 /* 64 $(".mainMenu #newsMenu2").hide(); 65 */ 66 67 $(".toggleSubMenu").on("click", function () { 68 toggleMenu($(this)); 69 return false; 70 }); 71 72 function toggleMenu(element) { 73 parentMenu = element.parent().parent(); 74 if (element.find(".fa").hasClass("fa-chevron-down")) { 75 closeAllMenus(); 76 element 77 .find(".fa") 78 .removeClass("fa-chevron-down") 79 .addClass("fa-chevron-up"); 80 parentMenu.find("li").slideDown(); 81 if (parentMenu.attr("id") == "newsMenu1") { 82 $("#newsMenu2 li").slideDown(); 83 $("#newsMenu2").slideDown(); 84 } 85 } else { 86 closeAllMenus(); 87 } 88 } 89 90 function closeAllMenus() { 91 $(".toggleSubMenu") 92 .find(".fa") 93 .removeClass("fa-chevron-up") 94 .addClass("fa-chevron-down"); 95 $(".mainMenu .menuUL") 96 .not("#newsMenu2") 97 .each(function () { 98 $(this).find("li").not(":nth-child(1)").slideUp(); 99 }); 100 101 $(".mainMenu #newsMenu2").hide(); 102 } 103 104 var breakingNewsCookie = Cookies.get("tch_breaking"); 105 var hideBreakingNews = false; 106 if (breakingNewsCookie == "hide") hideBreakingNews = true; 107 var breakingNewsTimer = null; 108 var breakingNewsIndex = 1; 109 var breakingArticles = 0; 110 111 if ($(".breakingNews").length > 0 && !hideBreakingNews) { 112 breakingArticles = $(".breakingNews").attr("count"); 113 114 $(".breakingNews .bni").not(":first").hide(); 115 $(".breakingNews").slideDown("normal"); 116 117 if (breakingArticles > 1) { 118 breakingNewsTimer = setInterval(function () { 119 breakingNewsIndex++; 120 if (breakingNewsIndex > breakingArticles) breakingNewsIndex = 1; 121 $(".breakingNews .bni").hide("300"); 122 $(".breakingNews #bni-" + breakingNewsIndex).show("500"); 123 }, 5000); 124 } 125 } 126 127 $(".closeBN").on("click", function () { 128 Cookies.set("tch_breaking", "hide", { expires: 0.042 }); 129 clearInterval(breakingNewsTimer); 130 $(".breakingNews").slideUp(); 131 return false; 132 }); 133 134 $(".mediaPageTitle, .closeMediaFilter").on("click", function () { 135 $(".mediaSide").toggleClass("hidden-xs"); 136 return false; 137 }); 138 139 $("img").each(function () { 140 i = $(this); 141 if (i.attr("src").indexOf("youtube.com") > 0) { 142 var image = new Image(); 143 image.src = i.attr("src"); 144 image.onload = function () { 145 if (this.width <= 120) { 146 newSrc = this.src.replace("maxresdefault", "0"); 147 $("img[src='" + this.src + "']").attr("src", newSrc); 148 } 149 }; 150 } 151 }); 152 153 $(".single p iframe") 154 .not(".single p iframe.dnw") 155 .wrap("<div class='videoWrapper'></div>"); 156 $(".single .fb-post").wrap("<div class='socialWrapper'></div>"); 157 //$('.single .twitter-tweet').wrap("<div class='socialWrapper'></div>"); 158 $(".socialWrapper").append("<div class='clearfix'></div>"); 159 $(".socialWrapper").after("<div class='clearfix'></div>"); 160
161 //moveVideo(); 162 repositionText(); 163 resizeGalleries(); 164 resizeFeaturedNewsBox(); 165 // resizeVideoPlaylist(); 166 resizeSlider(); 167 equalizeShowBoxes(); 168 169 /* 170 $(window).on('scroll', function() { 171 clearTimeout(windowScrollTimer); 172 windowScrollTimer = setTimeout(function() { 173 moveVideo(); 174 }, 250); 175 }); 176 */ 177 178 // Homepage refresh 179 180 // if ($("body").hasClass("home")) { 181 // $.ajax({ 182 // type: "GET", 183 // url: ajaxurl, 184 // data: { action: "lastUpdate" }, 185 // success: function (rLastUpdate) { 186 // console.log("LU: " + rLastUpdate); 187 // if (rLastUpdate != 0) { 188 // lastUpdate = rLastUpdate; 189 // var refreshTimer = setInterval(refreshHomepage, 120000); 190 // } 191 // }, 192 // }); 193 // } 194 195 // function refreshHomepage() { 196 // $(".homepage-refresher").fadeIn("fast"); 197 // $.ajax({ 198 // type: "GET", 199 // url: ajaxurl, 200 // data: { action: "lastUpdate" }, 201 // success: function (rLastUpdate) { 202 // console.log("LU: " + rLastUpdate); 203 // if (rLastUpdate != 0 && lastUpdate != rLastUpdate) { 204 // window.location.reload(); 205 // // lastUpdate = rLastUpdate; 206 // } 207 // $(".homepage-refresher").fadeOut("fast"); 208 // }, 209 // }); 210 // } 211 212 // End of Homepage refresh 213 214 $(window).on("resize", function () { 215 clearTimeout(windowResizeTimer); 216 windowResizeTimer = setTimeout(function () { 217 //moveVideo(); 218 repositionText(); 219 resizeGalleries(); 220 resizeFeaturedNewsBox(); 221 // resizeVideoPlaylist(); 222 223 equalizeShowBoxes(); 224 if (windowWidth != $(window).width() && $(".showSlider").length > 0) 225 location.reload(); 226 }, 250); 227 }); 228 229 function moveVideo() { 230 if ($(".single .videoInner").length <= 0) return false; 231 logg("moving video"); 232 if ($(".videoInner").isInViewport()) { 233 if ($(".mainVideo").hasClass("fixedSmall")) { 234 $(".mainVideo").removeClass("fixedSmall"); 235 } 236 237 $(".mainVideo").parent().width($(".mainVideo").outerWidth()); 238 $(".mainVideo").parent().height($(".mainVideo").outerHeight()); 239 } else { 240 if (!$(".mainVideo").hasClass("fixedSmall")) { 241 $(".mainVideo").addClass("fixedSmall"); 242 } 243 } 244 } 245 246 $(".home .otherVideosHead a").on("click", function () { 247 otherVideosHead = $(this).parent(); 248 otherVideos = otherVideosHead.parent(); 249 otherVideosHead.find("a").removeClass("selected"); 250 $(this).addClass("selected"); 251 252 if ($(this).attr("id") == "videoA") { 253 otherVideos.find(".theVideos").slideDown(); 254 otherVideos.find(".categories").slideUp(); 255 } else { 256 otherVideos.find(".categories").slideDown(); 257 otherVideos.find(".theVideos").slideUp(); 258 } 259 260 return false; 261 }); 262 263 function resizeFeaturedNewsBox() { 264 if ($(".galleryGrid .galleryContainer .gallery img").length <= 0) 265 return false; 266 logg("resizing featured news box"); 267 $(".galleryGrid .galleryContainer .gallery img").imgpreload(function () { 268 $(".featuredGrid .article .articleTitle") 269 .not(".featuredGrid .article.article-1 .articleTitle") 270 .height("auto"); 271 $(".featuredGrid .article .PDS_Poll").height("auto"); 272 273 if ($(window).width() < 768) { 274 $(".featuredGrid .article .articleTitle") 275 .not(".featuredGrid .article.article-1 .articleTitle") 276 .height("auto"); 277 return false; 278 } 279 280 var featureMaxHeight = 0; 281 var currentElementHeight = 0; 282 283 $(".featuredGrid .article") 284 .not(".article-1") 285 .each(function () { 286 currentElementHeight = $(this).find(".articleTitle").height(); 287 if (currentElementHeight > featureMaxHeight) 288 featureMaxHeight = currentElementHeight; 289 }); 290 $(".featuredGrid .article .articleTitle") 291 .not(".featuredGrid .article.article-1 .articleTitle") 292 .height(featureMaxHeight); 293 294 $(".featuredGrid .article .PDS_Poll").height( 295 $(".featuredGrid .article-2").height() - 40 296 ); 297 });
298 } 299 300 function resizeGalleries() { 301 if ($(".galleryGrid .galleryContainer .gallery img").length <= 0) 302 return false; 303 logg("resizing galleries"); 304 $(".galleryGrid .galleryContainer .gallery img").imgpreload(function () { 305 $(".galleryGrid .galleryContainer .gallery .galleryInner").height("auto"); 306 307 var featureMaxHeight = 0; 308 var currentElementHeight = 0; 309 310 $(".galleryGrid .galleryContainer .gallery .galleryInner").each( 311 function () { 312 currentElementHeight = $(this).height(); 313 if (currentElementHeight > featureMaxHeight) 314 featureMaxHeight = currentElementHeight; 315 } 316 ); 317 $(".galleryGrid .galleryContainer .gallery .galleryInner").height( 318 featureMaxHeight 319 ); 320 }); 321 } 322 323 // function resizeVideoPlaylist() { 324 // // if ($(".home").length < 1 && $(".custom-homex").length < 1) return false; 325 // if ($(".videoFeature").length == 0) return false; 326 // $(".videoFeature .featuredVideoLink").height("auto"); 327 // $(".videoFeature .otherVideos").height("auto"); 328 // $(".videoFeature .otherVideos .cvContainer").height("auto"); 329 330 // var videoHeight = $(".videoFeature .featuredVideoLink").height(); 331 // var playlistHeight = $(".videoFeature .otherVideos").height(); 332 333 // if ($(window).width() < 768) { 334 // $(".videoFeature .otherVideos").height("auto"); 335 // } else { 336 // $(".videoFeature .otherVideos").height(videoHeight); 337 // $(".videoFeature .otherVideos .cvContainer").height(videoHeight - 50); 338 // } 339 // } 340 341 function repositionText() { 342 if ($(".customCategoryStories .story").length <= 0) return false; 343 if ($("body.sport").length > 0) return false; 344 345 logg("text repo, customcatstory"); 346 if ($(window).width() < 768) { 347 $(".customCategoryStories .story") 348 .not(".customCategoryStories .story.fourth") 349 .each(function () { 350 $(this) 351 .find("img") 352 .imgpreload(function () { 353 innerHeight = $(this).parent().parent().height(); 354 textHeight = $(this).parent().parent().find(".title").height(); 355 paddingTop = (innerHeight - textHeight) / 2; 356 if (paddingTop > 0) { 357 paddingTop -= 5; 358 $(this) 359 .parent() 360 .parent() 361 .find(".title") 362 .css("padding-top", paddingTop + "px"); 363 } 364 }); 365 }); 366 } else { 367 $(".customCategoryStories .story .title") 368 .not(".customCategoryStories .story.fourth .title") 369 .css("padding-top", "0px"); 370 } 371 } 372 373 //Shows 374 375 if ($(".showSlider").length > 0) { 376 $(".showSlider").slick({ 377 centerMode: true, 378 centerPadding: "0px", 379 slidesToShow: 3, 380 arrows: true, 381 dots: false, 382 autoplay: true, 383 autoplaySpeed: 4000, 384 nextArrow: 385 '<a href="#" class="showNav showRight slick-next"><i class="fa fa-angle-double-right" aria-hidden="true"></i></a>', 386 prevArrow: 387 '<a href="#" class="showNav showLeft slick-prev"><i class="fa fa-angle-double-left" aria-hidden="true"></i></a>', 388 responsive: [ 389 { 390 breakpoint: 1200, 391 settings: { 392 arrows: true, 393 centerMode: true, 394 centerPadding: "0px", 395 slidesToShow: 1, 396 }, 397 }, 398 ], 399 }); 400 401 $(".showSlider .show").not(".show.slick-current").fadeTo("fast", 0.5); 402 403 $(".showSlider").on( 404 "afterChange", 405 function (event, slick, currentSlide, nextSlide) { 406 $(".showSlider .show.slick-current").fadeTo("normal", 1); 407 $(".showSlider .show") 408 .not(".showSlider .show.slick-current") 409 .fadeTo("fast", 0.5); 410 } 411 ); 412 } 413 414 function resizeSlider() { 415 if ($(".showSlider").length <= 0) return false; 416 logg("resizing slider"); 417 if ($(window).width() > 1200) { 418 $showSliderWidth = $(".showSlider").width() * 2; 419 $(".showSlider").width($showSliderWidth);
420 $(".showSlider").css("margin-left", (-1 * $showSliderWidth) / 4); 421 } 422 } 423 424 function equalizeShowBoxes() { 425 if ($(".showGrid .show .desc").length <= 0) return false; 426 logg("eq show boxes"); 427 428 var maxShowHeight = 0; 429 $(".showGrid .show .desc").height("auto"); 430 $(".showGrid .show .desc").each(function () { 431 if ($(this).outerHeight() > maxShowHeight) 432 maxShowHeight = $(this).outerHeight(); 433 }); 434 $(".showGrid .show .desc").height(maxShowHeight); 435 $(".showGrid .show .desc .link").width( 436 $(".showGrid .show .desc").innerWidth() - 32 437 ); 438 } 439 440 function addSportsMenuItem() { 441 if ($(".sport").length == 0 && $(".sports-home").length == 0) return false; 442 $(".topContainer .topInnerContainer").append( 443 '<div class="bigMenu visible-xs hidden-sm"><a href="/sport" class="mobileMenuItem visible-xs hidden-sm">SPORT</a></div>' 444 ); 445 } 446 447 addSportsMenuItem(); 448 449}); 450
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.