1var youtubeThumbs = []; 2var customYoutubeThumbs = []; 3var youtubeTitles = []; 4var youtubeVideos = []; 5var youtubeFsk = []; 6 7var youtubePlayer; 8var youtubePlayerPaused = false; 9var currentYoutubeVideo = 0; 10 11var isFullscreen = false; 12 13 14$(document).ready(function(){ 15 16 17 function loadScript() { 18 if (typeof(YT) == 'undefined' || typeof(YT.Player) == 'undefined') { 19 var tag = document.createElement('script'); 20 tag.src = "js/libs/yt-iframe-api.js"; 21 var firstScriptTag = document.getElementsByTagName('script')[0]; 22 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 23 } 24 } 25 26 function loadPlayer() { 27 window.onYouTubePlayerAPIReady = function() { 28 onYouTubePlayer(); 29 }; 30 } 31 32 $(function () { 33 loadScript(); 34 }); 35 36}); 37 38function imageExists(image_url){ 39/* 40 var http = new XMLHttpRequest(); 41 42 http.open('HEAD', image_url, false); 43 try { 44 http.send(); 45 } 46 catch(e) {} 47 48 return http.status != 404; 49*/ 50return false; 51} 52function getTitleFromDbase(){ 53 $.each(youtubeVideos, function(i, item) { 54 console.log('YoutubeID: ' + item); 55 ytId = item; 56 if (ytId) { 57 $.getJSON(API_URL + "/corp/nr/" + i + "/yt/" + ytId, function (json) { 58 59 if (json.message !== 'error') { 60 // console.log(json.title); 61 var title_output = json.title; 62 $('.videos-item .video-title').eq(parseInt(json.nr)).html(title_output); 63 } 64 }); 65 66 } 67 else { 68 return false; 69 } 70 }); 71} 72 73function setupVideosPage(items) { 74 75 $.each(items, function(i, item) { 76 77 customYoutubeThumbs.push(media_url + "tl_files/content/thumb/" + item.contentDetails.videoId + ".jpg"); 78 79 try { 80 if(imageExists(media_url + "tl_files/content/fsk/" + item.contentDetails.videoId + ".png")) 81 { 82 youtubeFsk.push(media_url + "tl_files/content/fsk/" + item.contentDetails.videoId + ".png"); 83 } 84 } 85 catch(e) {} 86 87 88 try { 89 youtubeThumbs.push(item.snippet.thumbnails.maxres.url); 90 } 91 catch(e) { 92 93 try { 94 youtubeThumbs.push(item.snippet.thumbnails.high.url); 95 } 96 catch(e) {} 97 } 98 99 youtubeTitles.push(item.snippet.title); 100 youtubeVideos.push(item.contentDetails.videoId); 101 102 var playStyle = "big" 103 var style = ""; 104 if(i == 0) 105 style = "big3"; 106 else if(i == 1) 107 style = "big2"; 108 else { 109 style = ""; 110 playStyle = ""; 111 } 112 113 var text = youtubeTitles[i]; 114 var videoId = youtubeVideos[i]; 115 if(i > 1 && i != 14) 116 text = text.split(" - ")[0]; 117 118 console.log(typeof youtubeFsk[i]); 119 if(typeof youtubeFsk[i] == 'undefined') 120 { 121 $("#videos-content").append('<div class="videos-item ' + style + '">' + 122 "<img onError='loadYoutubeThumb(this)' src='" + customYoutubeThumbs[i] + "'/>" + 123 "<div class='videos-item-play " + playStyle + "'></div>" + 124 "<a onclick='videoItemClicked(this)'></a>" + 125 "<a class='video-title' target='_blank' href='https://youtube.com/watch?v=" + videoId + "' style='z-index:0;'>" + text + "</a>" + 126 '</div>'); 127 } 128 else 129 { 130 $("#videos-content").append('<div class="videos-item ' + style + '">' + 131 "<img onError='loadYoutubeThumb(this)' src='" + customYoutubeThumbs[i] + "'/>" + 132 "<div class='videos-item-play " + playStyle + "'></div>" + 133 "<a onclick='videoItemClicked(this)'></a>" + 134 "<a class='video-title' target='_blank' href='https://youtube.com/watch?v=" + videoId + "' style='z-index:0;'>" + text + "</a>" + 135 "<img class='fsk' onError='loadYoutubeFSK(this)' src='" + youtubeFsk[i] + "'/>" + 136 '</div>'); 137 } 138 139 }); 140 141 // Setup Videos Content 142 setupLayout(); 143 144 // Setup Header 145 setupHeader(); 146 getTitleFromDbase(); 147} 148 149function loadYoutubeThumb(img) { 150 151 var newUrl = youtubeThumbs[$(img).parent().index() - 1]; 152 $(img).attr("src", newUrl); 153} 154function loadYoutubeFSK(img) { 155 156 var newUrl = youtubeFsk[$(img).parent().index() - 1]; 157 $(img).attr("src", newUrl); 158} 159function setupLayout() { 160 161 $("#videos-content").isotope({ 162 layoutMode: "packery", 163 itemSelector: ".videos-item", 164 percentPosition: true, 165 transitionDuration: "0s", 166 packery: { 167 gutter: ".gutter-sizer" 168 } 169 }); 170} 171 172function setupHeader() { 173 174 initYoutubePlayer(); 175 176 resizeHeader(); 177 178 $("#header-progress-click").click(function(e) { 179 180 var clickPos = 100/$("#header-progress-click").width() * e.pageX; 181 182 var newPos = youtubePlayer.getDuration()/100 * clickPos; 183 youtubePlayer.seekTo(newPos); 184 }); 185 186 $(document).keypress(function(event) { 187 188 if(youtubePaused && event.charCode == 32) { 189 190 playClicked(); 191 } 192 else if(event.charCode == 32) { 193 194 playClicked(); 195 } 196
197 var $focusElem = $(":focus"); 198 if(!youtubePaused && event.charCode == 102 && !$focusElem.is("input")) 199 fullscreenClicked(); 200 201 if(event.which == 32 && !($focusElem.is("input") || $focusElem.attr("contenteditable") == "true")) 202 event.preventDefault(); 203 }); 204 205 if (document.addEventListener) 206 { 207 document.addEventListener('webkitfullscreenchange', exitHandler, false); 208 document.addEventListener('mozfullscreenchange', exitHandler, false); 209 document.addEventListener('fullscreenchange', exitHandler, false); 210 document.addEventListener('MSFullscreenChange', exitHandler, false); 211 } 212 213 // Sound Slider 214 $("#header-video-sound").mouseover(function() { 215 216 TweenMax.to([this, "#header-video-playPause"], 0.5, {x:-75, ease:Back.easeOut}); 217 TweenMax.to(".video-sound-slider", 0.5, {delay:0.2, autoAlpha:1}); 218 }); 219 220 $(".video-sound-slider-handle").each(function() { 221 222 Draggable.create(this, {type:"x", bounds:{maxX:0, minX:-$(this).parent().outerWidth() + $(this).width()}})[0].addEventListener("drag", function() { 223 224 var offset = $(this).offset().left - $(this).parent().offset().left; 225 226 $(this).parent().find(".video-sound-slider-fill").css("width", offset); 227 228 youtubePlayer.setVolume(Math.round(100/$(this).parent().width() * offset)); 229 }); 230 }); 231 232 $(".video-sound-slider").mousedown(function(e) { 233 234 var clickOffset = e.pageX - $(this).offset().left; 235 var percent = 100/$(this).width() * clickOffset; 236 237 $(this).find(".video-sound-slider-fill").css("width", percent + "%"); 238 TweenMax.set($(this).find(".video-sound-slider-handle"), {x:clickOffset-$(this).width()}); 239 Draggable.get($(this).find(".video-sound-slider-handle")).update(); 240 241 youtubePlayer.setVolume(percent); 242 243 Draggable.get($(this).find(".video-sound-slider-handle")).startDrag(e); 244 }); 245 246 $(".video-sound-slider").click(function(e) { 247 248 var clickOffset = e.pageX - $(this).offset().left; 249 var percent = 100/$(this).width() * clickOffset; 250 251 $(this).find(".video-sound-slider-fill").css("width", percent + "%"); 252 TweenMax.set($(this).find(".video-sound-slider-handle"), {x:clickOffset-$(this).width()}); 253 Draggable.get($(this).find(".video-sound-slider-handle")).update(); 254 255 youtubePlayer.setVolume(percent); 256 }); 257 258 259 startVideo(currentYoutubeVideo); 260} 261 262function initYoutubePlayer() { 263 264 function loadScript() { 265 if (typeof(YT) == 'undefined' || typeof(YT.Player) == 'undefined') { 266 var tag = document.createElement('script'); 267 tag.src = "https://www.youtube.com/iframe_api"; 268 var firstScriptTag = document.getElementsByTagName('script')[0]; 269 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 270 } 271 } 272 273 function loadPlayer() { 274 window.onYouTubePlayerAPIReady = function() { 275 onYouTubePlayer(); 276 }; 277 } 278 279 $(function () { 280 loadScript(); 281 }) 282 283 youtubePlayer = new YT.Player('youtube-video', { 284 videoId: youtubeVideos[currentYoutubeVideo], 285 host: 'https://www.youtube-nocookie.com', 286 playerVars: { 287 'autoplay': 1, 288 'controls': 1, 289 'showinfo': 0, 290 'playsinline': 0, 291 'modestbranding': 1, 292 'iv_load_policy': 3, 293 'disablekb': 1, 294 'cc_load_policy': 0, 295 'rel': 0, 296 'enablejsapi': 1 297 }, 298 events: { 299 'onReady': onPlayerReady, 300 'onStateChange': onPlayerStateChange 301 } 302 }); 303} 304 305function hideSoundSlider() { 306 307 TweenMax.to(["#header-video-sound", "#header-video-playPause"], 0.3, {delay:0.2, x:0}); 308 TweenMax.to(".video-sound-slider", 0.5, {autoAlpha:0}); 309} 310 311function exitHandler() { 312 if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) 313 { 314 //console.log("Exit Fullscreen"); 315 316 /* Run code on exit */ 317 if(!isFullscreen) { 318 319 var video = $("#header"); 320 $(video).removeClass("fullscreen"); 321 $("#header-content").removeClass("fullscreen"); 322 $("#nav").removeClass("fullscreen"); 323 } 324 325 isFullscreen = false;
326 } 327} 328 329function onPlayerReady(e) { 330 331 if(isMobile()) 332 $("#header iframe").css("pointer-events", "all"); 333 334 // Autoplay Video If Not Mobile 335 if(!isMobile()) 336 youtubePlayer.playVideo(); 337 338 headerUpdate(); 339} 340 341function headerUpdate() { 342 343 //console.log("Duration -> " + youtubePlayer.getDuration()); 344 //console.log("CurrentTime -> " + youtubePlayer.getCurrentTime()); 345 346 TweenMax.delayedCall(0.1, headerUpdate); 347 348 var currentPos = 100/youtubePlayer.getDuration() * youtubePlayer.getCurrentTime(); 349 $("#header-progress").css("width", currentPos + "%"); 350 351 //TweenMax.to("#header-progress", 0.3, {width:currentPos + "%"}); 352} 353 354function onPlayerStateChange(e) { 355 356 //console.log("-> " + e.data); 357 358 if(e.data == YT.PlayerState.ENDED) { 359 360 if(currentYoutubeVideo < youtubeVideos.length - 1) 361 currentYoutubeVideo++; 362 else 363 currentYoutubeVideo = 0; 364 365 startVideo(currentYoutubeVideo); 366 } 367 368 if(e.data == YT.PlayerState.PAUSED) 369 youtubePlayerPaused = true; 370 else 371 youtubePlayerPaused = false; 372} 373 374function videoItemClicked(item) { 375 376 $("html, body").animate({ 377 scrollTop: 0 378 }, 500); 379 380 currentYoutubeVideo = $(item).parent().index() - 1; 381 382 startVideo(currentYoutubeVideo); 383} 384 385function startVideo(nr) { 386 387 var text = youtubeTitles[nr].split(" - "); 388 389 $("#header-video-title").html(text[0]); 390 $("#header-video-subtitle").html(text[1]); 391 392 // Remove Old Iframe And Init New 393 $("#youtube-video").replaceWith("<div id='youtube-video'></div>"); 394 initYoutubePlayer(); 395 396 // Play animation 397 infosTimeline = new TimelineMax({paused:true, onComplete:hideSoundSlider}); 398 infosTimeline.from("#header-infos", 2, {alpha:0}); 399 infosTimeline.from("#header-progress-container", 2, {alpha:0}, "=-2"); 400 infosTimeline.to("#header-infos", 2, {delay:1, alpha:1}, "=+4"); 401 infosTimeline.to("#header-progress-container", 2, {alpha:1}, "=-2"); 402 infosTimeline.seek(0); 403 infosTimeline.play(); 404 405 playPauseIcon(true); 406} 407 408function playClicked() { 409 410 youtubePlayer.pauseVideo(); 411 playPauseIcon(false); 412 413 if(youtubePlayerPaused) { 414 415 youtubePlayer.playVideo(); 416 playPauseIcon(true); 417 } 418} 419 420function playPauseIcon(playing) { 421 422 var positions = ["-34px -2px", "-52px -1px"]; 423 424 if(playing) 425 $("#header-video-playPause").css("background-position", positions[1]); 426 else 427 $("#header-video-playPause").css("background-position", positions[0]); 428} 429 430function soundClicked() { 431 432 if(youtubePlayer.isMuted()) { 433 434 youtubePlayer.unMute(); 435 soundIcon(true); 436 } 437 else { 438 439 youtubePlayer.mute(); 440 soundIcon(false); 441 } 442} 443 444function soundIcon(active) { 445 446 var positions = ["-68px -25px", "-68px -48px"]; 447 448 if(!active) 449 $("#header-video-sound").css("background-position", positions[0]); 450 else 451 $("#header-video-sound").css("background-position", positions[1]); 452} 453 454function fullscreenClicked() { 455 456 var video = $("#header"); 457 //$(video).addClass("fullscreen"); 458 //video = video[0]; 459 460 if (!document.fullscreenElement && // alternative standard method 461 !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { // current working methods 462 463 isFullscreen = true; 464 $(video).addClass("fullscreen"); 465 $("#header-content").addClass("fullscreen"); 466 $("#nav").addClass("fullscreen"); 467 468 if (video[0].requestFullscreen) { 469 video[0].requestFullscreen(); 470 } else if (video[0].msRequestFullscreen) { 471 video[0].msRequestFullscreen(); 472 } else if (video[0].mozRequestFullScreen) { 473 video[0].mozRequestFullScreen(); 474 } else if (video[0].webkitRequestFullscreen) { 475 video[0].webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); 476 } 477 } else { 478 479 isFullscreen = false; 480 $(video).removeClass("fullscreen"); 481 $("#header-content").removeClass("fullscreen"); 482 $("#nav").removeClass("fullscreen"); 483 484 if (document.exitFullscreen) { 485 document.exitFullscreen(); 486 } else if (document.msExitFullscreen) { 487 document.msExitFullscreen(); 488 } else if (document.mozCancelFullScreen) { 489 document.mozCancelFullScreen(); 490 } else if (document.webkitExitFullscreen) { 491 document.webkitExitFullscreen(); 492 } 493 } 494}
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.