1// solomun 2 | functions.js 2 3// ------------ scroll to 0 ------------ / 4window.scrollTo(0,0); 5window.onbeforeunload = function(){ window.scrollTo(0,0); }; 6var cachecontrol = getCacheControl(); 7 8function doCtrl() { 9 // hi ;) 10} 11 12$(window).on("load", function() { 13 onPageLoaded(); 14 pageLoader(); 15}); 16 17var pageLoad = 0; 18function pageLoader() { 19 pageLoad++ 20 if (pageLoad === 2) { 21 initContents(); 22 setTimeout(function() { 23 hidePreloader(); 24 }, 900); 25 } 26} 27 28function onPageReady() { 29 doLog("onPageReady"); 30 getConf(); 31 initAnims(1); 32 initCarousels(); 33 initYouTube(); 34 doTruncate('.text_truncate', 7); 35 initSvg(); 36 initNav(); 37 initFancybox(); 38 initLazysizes(); 39 onResize(); 40 initResize(); 41 sRefresh(); 42 initSounds(); 43 initSettings(); 44 initTypeIt(); 45 doStats("PageReady: Done"); 46} 47 48function onPageLoaded() { 49 doLog("onPageLoaded"); 50 $("#audioplayer").attr("oncanplay", "canPlay();"); 51 $("#audioplayer").attr("onended", "playNext();"); 52 initAnims(2); 53 initImageCycle("body_id"); 54 sRefresh(); 55 setTimeout(function() { 56 sRefresh(); 57 // getContent(lang,"video","","","","",0); 58 }, 3000); 59 doStats("PageLoaded: Done"); 60 if (main != "index") { 61 setTimeout(function() { doStats("","clear"); }, 3000); 62 } 63} 64 65var isPreloaded = false; 66function hidePreloader() { 67 if (!isPreloaded) { 68 isPreloaded = true; 69 $('#preloader').slideUp(300); 70 // doStats('','clear'); 71 // hiliteNav("home","","",""); 72 setTimeout(function() { $("#body_id").addClass("stats_loaded"); }, 250); 73 setTimeout(function() { pageLoader(); }, 3000); 74 } 75} 76 77function skipIntro() { 78 doScroll('#news'); 79 volume_bg_video(0); 80} 81 82function onResize() { 83 sRefresh(); 84} 85 86// ------------ effects ------------ // 87 88function initTypeIt() { 89 // https://www.typeitjs.com 90 $(".ticker").each( function() { 91 var myId = "type-effect-" + myRandom(1000000, 9999999); 92 $(this).attr("id", myId); 93 new TypeIt('#' + myId, { speed: 100, waitUntilVisible: true, cursor: true, loop: true }).go(); 94 }); 95 96 $(".ticker-fast-once").each( function() { 97 var myId = "type-effect-" + myRandom(1000000, 9999999); 98 $(this).attr("id", myId); 99 new TypeIt('#' + myId, { speed: 1, waitUntilVisible: true, cursor: false, loop: false }).go(); 100 }); 101 102 $(".footer .version").each( function() { 103 var myId = "type-effect-" + myRandom(1000000, 9999999); 104 $(this).attr("id", myId); 105 new TypeIt('#' + myId, { speed: 100, waitUntilVisible: true, cursor: false, loop: false }).go(); 106 }); 107} 108 109function initAnims(phase) { 110 if (device == "") { 111 if (phase === 1) { 112 $('.animated').appear(); 113 /* init animations for on appear */ 114 $('.animated').on('appear', function() { 115 var elem = $(this); 116 var animation = elem.data('animation'); 117 if ( !elem.hasClass('visible') ) { 118 var animationDelay = elem.data('animation-delay'); 119 if ( animationDelay ) { 120 setTimeout(function(){ 121 elem.addClass( animation + " visible" ); 122 }, animationDelay); 123 } else { 124 elem.addClass( animation + " visible" ); 125 } 126 } 127 }); 128 } else { 129 /* start animations on load */ 130 $('.onstart').each( function() { 131 var elem = $(this); 132 if ( !elem.hasClass('visible') ) { 133 var animationDelay = elem.data('animation-delay'); 134 var animation = elem.data('animation'); 135 if ( animationDelay ) { 136 setTimeout(function(){ 137 elem.addClass( animation + " visible" ); 138 }, animationDelay); 139 } else { 140 elem.addClass( animation + " visible" ); 141 } 142 } 143 }); 144 } 145 } 146} 147 148function initAnimsManual(target) { 149 if (device == "") { 150 $(target).appear(); 151 // if( detectIE() ) { 152 if (false) { 153 $(target).css({ 154 'display':'block', 155 'visibility': 'visible' 156 }); 157 } else { 158 $(target).on('appear', function() { 159 var elem = $(this); 160 var animation = elem.data('animation'); 161 if ( !elem.hasClass('visible') ) { 162 var animationDelay = elem.data('animation-delay'); 163 if ( animationDelay ) { 164 setTimeout(function(){ 165 elem.addClass( animation + " visible" ); 166 }, animationDelay); 167 } else { 168 elem.addClass( animation + " visible" ); 169 } 170 } 171 }); 172 } 173 } 174} 175 176function doAnim(elem, effect) { 177 $(elem).addClass("animated_manual_animation " + effect).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function(){ 178 $(elem).removeClass("animated_manual_animation"); 179 $(elem).removeClass(effect); 180 });
181 $(elem).removeClass('animated_manual'); 182} 183 184function initImageCycle(target_id) { 185 var count = 0; 186 $("#" + target_id + " .imagecycle").each(function(index) { 187 var c = count++; 188 var self = this; 189 var self_max = $(self).data("imagecycle_max"); 190 if (self_max > 1) { 191 if (typeof myInterval != 'undefined') { 192 clearInterval(myInterval); 193 } 194 var myInterval; 195 setTimeout(function() { 196 var $elem = $(self); 197 var i = 0; 198 var imax = $(self).data("imagecycle_max"); 199 myInterval = setInterval(function() { 200 i++; 201 $elem.find(".display").css("opacity", 0); 202 $elem.find(".display" + i).css("opacity", 1); 203 if (i >= imax) { i = 0; } 204 }, 4000); 205 206 }, c * 1000); 207 } 208 }); 209} 210 211// ------------ inits ------------ / 212 213var bg_video_enabled = false; 214 215function getConf() { 216 doStats("User Agent: " + navigator.userAgent); doStats(" "); 217 if (device == "") { 218 // http://stackoverflow.com/questions/3514784/ 219 var ua = navigator.userAgent.toLowerCase(); 220 if (ua.match(/webos/i)) { device = "webos"; } 221 if (ua.match(/opera mini/i)) { device = "opera mini"; } 222 if (ua.match(/mobile/i)) { device = "mobile"; } 223 if (ua.match(/ipad/i)) { device = "ipad"; } 224 if (ua.match(/ipod|iphone/i)) { device = "iphone"; } 225 if (ua.match(/blackberry/i)) { device = "blackberry"; } 226 if (ua.match(/android/i)) { device = "android"; } 227 if (ua.match(/kindle/i)) { device = "kindle"; } 228 if (ua.match(/windows phone/i)) { device = "windows phone"; } 229 if (ua.match(/iemobile/i)) { device = "iemobile"; } 230 if (ua.match(/tablet/i)) { device = "tablet"; } 231 } 232 doLog("getConf() -> device: " + device); 233 if (device === "ipad" || device === "tablet") { $("#viewport_id").attr("content", "width=device-width, initial-scale=1"); } // set viewport 234 if (device !== "") { 235 $("#body_id").removeClass("desktop").addClass("device"); // set body-class, default: desktop 236 } 237 if (device === "" || device === "ipad" || device === "tablet") { 238 bg_video_enabled = true; 239 } 240} 241 242function sInit() { 243 // doLog("sInit"); 244} 245 246function sRefresh() { 247 // Waypoint.refreshAll(); 248 initCopyButtons(); 249} 250 251 252// ------------------------ history ------------------------ // 253 254var section = ""; 255 256function getContent(itemLang,itemSection,itemName,itemType,itemSubtype,itemId,itemStart) { 257 doStats("getContent(" + itemLang + "," + itemSection + "," + itemName + "," + itemType + "," + itemSubtype + "," + itemId + "," + itemStart + ")"); 258 doStop(); 259 var data = {lang:itemLang,section:itemSection,type:itemType,subtype:itemSubtype,id:itemId,start:itemStart}; 260 var theTitle = itemLang + "|" + itemSection + "|" + itemType + "|" + itemSubtype + "|" + itemId + "|" + itemStart; 261 // var theUrl = "/" + itemLang + "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "-" + itemStart + ".html"; 262 var theUrl = "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "-" + itemStart + ".html"; // special: itemLang always "en" 263 if (itemName == "" && itemType == "" && itemSubtype == "" && itemId == "" && itemStart == "") { 264 theUrl = "/" + itemSection + "/"; 265 } 266 if (itemSection == "misc") { 267 var theTitle = itemLang + "|" + itemSection + "|" + itemType + "|" + itemSubtype + "|" + itemId + "|" + itemStart; 268 var theUrl = "/" + itemType + "/"; 269 } 270 updateContent(data); 271 if (window.history && window.history.pushState) { 272 history.pushState(data, theTitle, theUrl); // add an item to the history log // http://stackoverflow.com/questions/11932869/ 273 } 274 setMenu("off"); 275 // tracking: var tmp_virtualpage = "/" + base + "/" + itemLang + "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "/"; var tmp_title = itemSection + ": " + itemName.replace(/-/g, " "); doTrackPage(tmp_virtualpage,tmp_title); 276} 277 278function setHistory(itemLang,itemSection,itemName,itemType,itemSubtype,itemId,itemStart) { 279 console.log("setHistory(" + itemLang + "," + itemSection + "," + itemName + "," + itemType + "," + itemSubtype + "," + itemId + "," + itemStart + ")"); 280 var data = {lang:itemLang,section:itemSection,type:itemType,subtype:itemSubtype,id:itemId,start:itemStart}; 281 var theTitle = itemLang + "|" + itemSection + "|" + itemType + "|" + itemSubtype + "|" + itemId + "|" + itemStart; 282 // var theUrl = "/" + itemLang + "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "-" + itemStart + ".html"; 283 var theUrl = "/" + itemSection + "/" + itemName + "-" + itemType + "-" + itemSubtype + "-" + itemId + "-" + itemStart + ".html"; // special: itemLang always "en" 284 if (itemName == "" && itemType == "" && itemSubtype == "" && itemId == "" && itemStart == "") { 285 theUrl = "/" + itemSection + "/"; 286 } 287 if (itemSection == "misc") { 288 var theTitle = itemLang + "|" + itemSection + "|" + itemType + "|" + itemSubtype + "|" + itemId + "|" + itemStart; 289 var theUrl = "/" + itemType + "/"; 290 } 291 if (window.history && window.history.pushState) { 292 history.pushState(data, theTitle, theUrl); // add an item to the history log // http://stackoverflow.com/questions/11932869/ 293 } 294} 295 296if (window.history && window.history.pushState) { 297 // revert to a previously saved state 298 window.addEventListener('popstate', function(event) { 299 // console.log('popstate fired!'); 300 updateContent(event.state); 301 }); 302} 303 304function updateContent(data) { 305 if (data == null) { return; } 306 doShow(data.section,data.type,data.subtype,data.id,data.start,1); 307} 308 309function doShow(section,type,subtype,id,start,autoplay) { 310 doStats("doShow(" + section + "," + type + "," + subtype + "," + id + "," + start + "," + autoplay + ")","clear"); 311 window.section = section; 312 doStats("window.section: " + window.section); 313 /* type = parseInt(type);subtype = parseInt(subtype);id = parseInt(id);autoplay = parseInt(autoplay); */ 314 var ausdruck = /^(\w*)?$/;
314 // \d = digit, \w = word, ? = egal wievielmal vorher (zb. egal wieviel buchstaben) 315 if (ausdruck.exec(id) && id != "" && id != 0 && id != undefined && id != null) { 316 // prio 1: id 317 var tmp_id = RegExp.$1; 318 doLog("id detected: " + tmp_id); 319 var tmp_type = ""; 320 if (ausdruck.exec(type) && type != "" && type != 0 && type != undefined && type != null) { 321 var tmp_type = RegExp.$1; 322 doLog("type detected: " + tmp_type); 323 } 324 // if onepager: 325 /* 326 if (section != "dates") { 327 if (hist[section]["type"] != tmp_type) { 328 getItems(section,tmp_type,subtype,start); // only reload items if type changes 329 } 330 getItem(section,tmp_type,subtype,tmp_id,autoplay); 331 } 332 */ 333 getItem(section,tmp_type,subtype,tmp_id,autoplay); 334 } else { 335 if (ausdruck.exec(subtype) && subtype != "" && subtype != 0 && subtype != undefined && subtype != null) { 336 // prio 2: subtype 337 var tmp_subtype = RegExp.$1; 338 doLog("subtype detected: " + tmp_subtype); 339 if (hist[section]["type"] != type) { 340 getItems(section,type,tmp_subtype,start); // only reload items if type changes 341 } 342 getItem(section,type,tmp_subtype,id,autoplay); 343 } else { 344 // prio 3: type 345 if (ausdruck.exec(type) && type != "" && type != 0 && type != undefined && type != null) { 346 var tmp_type = RegExp.$1; 347 doLog("type detected: " + tmp_type); 348 getItems(section,tmp_type,subtype,start); 349 } else { 350 // prio 4: no type, no subtype, no id -> clear section_holder 351 if (type == "" && subtype == "" && id == "") { 352 doLog("clear of section detected. vars: " + section + "," + type + "," + subtype + "," + id); 353 getItems(section,"","",start); 354 } 355 } 356 } 357 } 358 if (section == "misc" && type != "") { 359 console.log("misc: " + type); 360 $("#nav .nav_page").removeClass("on"); 361 $("#nav .nav_page").addClass("off"); 362 setTimeout(function() { 363 $("#nav .nav_" + type).removeClass("off"); 364 $("#nav .nav_" + type).addClass("on"); 365 }, 1100); 366 } 367} 368 369// keep tracking of sections content 370var hist = new Array(); 371hist["home"] = new Object(); hist["home"]["type"] = ""; hist["home"]["subtype"] = ""; hist["home"]["id"] = ""; hist["home"]["start"] = ""; 372hist["video"] = new Object(); hist["video"]["type"] = ""; hist["video"]["subtype"] = ""; hist["video"]["id"] = ""; hist["video"]["start"] = ""; 373hist["dates"] = new Object(); hist["dates"]["type"] = ""; hist["dates"]["subtype"] = ""; hist["dates"]["id"] = ""; hist["dates"]["start"] = ""; 374hist["photos"] = new Object(); hist["photos"]["type"] = ""; hist["photos"]["subtype"] = ""; hist["photos"]["id"] = ""; hist["photos"]["start"] = ""; 375hist["music"] = new Object(); hist["music"]["type"] = ""; hist["music"]["subtype"] = ""; hist["music"]["id"] = ""; hist["music"]["start"] = ""; 376hist["news"] = new Object(); hist["news"]["type"] = ""; hist["news"]["subtype"] = ""; hist["news"]["id"] = ""; hist["news"]["start"] = ""; 377hist["game"] = new Object(); hist["game"]["type"] = ""; hist["game"]["subtype"] = ""; hist["game"]["id"] = ""; hist["game"]["start"] = ""; 378hist["shop"] = new Object(); hist["shop"]["type"] = ""; hist["shop"]["subtype"] = ""; hist["shop"]["id"] = ""; hist["shop"]["start"] = ""; 379hist["products"] = new Object(); hist["products"]["type"] = ""; hist["products"]["subtype"] = ""; hist["products"]["id"] = ""; hist["products"]["start"] = ""; 380hist["tracks"] = new Object(); hist["tracks"]["type"] = ""; hist["tracks"]["subtype"] = ""; hist["tracks"]["id"] = ""; hist["tracks"]["start"] = ""; 381hist["blog"] = new Object(); hist["blog"]["type"] = ""; hist["blog"]["subtype"] = ""; hist["blog"]["id"] = ""; hist["blog"]["start"] = ""; 382hist["playlist"] = new Object(); hist["playlist"]["type"] = ""; hist["playlist"]["subtype"] = ""; hist["playlist"]["id"] = ""; hist["playlist"]["start"] = ""; 383hist["newsletter"] = new Object(); hist["newsletter"]["type"] = ""; hist["newsletter"]["subtype"] = ""; hist["newsletter"]["id"] = ""; hist["newsletter"]["start"] = ""; 384hist["misc"] = new Object(); hist["misc"]["type"] = ""; hist["misc"]["subtype"] = ""; hist["misc"]["id"] = ""; hist["misc"]["start"] = ""; 385 386function saveHistory(section,type,subtype,id,start) { 387 hist[section]["type"] = type; hist[section]["subtype"] = subtype; hist[section]["id"] = id; hist[section]["start"] = ""; 388} 389 390// ------------ load / set item(s) ------------ // 391 392function getItems(section,type,subtype,start) { 393 doStats("getItems('" + section + "," + type + "," + subtype + "," + start + "'): START"); 394 saveHistory(section,type,subtype,"",start); 395 var starttime = + new Date(); 396 $.ajax({
397 url: "/" + base + "/" + section + ".php", 398 data: "section=" + section + "&type=" + type + "&subtype=" + subtype + "&start=" + start + "&lang=" + lang + "&device=" + device + "&country=" + country, 399 method: "GET", 400 dataType: "html", 401 cache: false, 402 beforeSend: function() { 403 window.scrollTo(0,0); 404 hiliteNav("","","",""); 405 // $("#article section").addClass("blink_out"); 406 $("#article section").addClass("switch_out"); 407 setTimeout(function() { 408 showOverlay("on"); 409 stopBgAnim(); 410 $("#article section").removeClass("switch_out"); 411 }, 300); 412 }, 413 success: function(data) { 414 $("#article").empty().append(data); 415 doTruncate("#article .text_truncate", 7); 416 hiliteNav(section,type,subtype,""); 417 initSvg("#" + section); 418 sRefresh(); 419 initImageCycle(section); 420 doStats("getItems('" + section + "," + type + "," + subtype + "'): DONE"); 421 var endtime = + new Date(); 422 if ((endtime - starttime) < minOverlayDuration) { 423 setTimeout(function() { showOverlay("off"); }, 1000); 424 } else { 425 showOverlay("off"); 426 } 427 initBg(section); 428 if (section == "newsletter") { 429 setTimeout(function() { initNewsletter(); }, 500); 430 } 431 if (section == "home") { 432 playSound("startup"); 433 setTimeout(function() { initNewsletter(); }, 500); 434 } 435 }, 436 error: function(XMLHttpRequest, textStatus, errorThrown) { 437 doStats("Error:" + errorThrown + "(" + XMLHttpRequest.status + ")"); 438 }, 439 complete: function() { 440 setTimeout(function() { loadOverlay("random"); }, 2000); 441 } 442 }); 443} 444 445function getItem(section,type,subtype,id,autoplay) { 446 doStats("getItem('" + section + "," + type + "," + subtype + "," + id + "," + autoplay + "'): START"); 447 saveHistory(section,type,subtype,id); 448 var starttime = + new Date(); 449 var ausdruck = /^(\d*)?$/; // \d = digit, \w = word, ? = egal wievielmal vorher (zb. egal wieviel buchstaben) 450 if (ausdruck.exec(id)) { 451 // alert("valid request ->\n id:" + RegExp.$1); 452 var id = RegExp.$1; 453 var feedback_id = "#" + section + "_container"; 454 $.ajax({ 455 url: "/" + base + "/" + section + ".php", 456 data: "type=" + type + "&subtype=" + subtype + "&id=" + id + "&autoplay=" + autoplay + "&lang=" + lang + "&device=" + device + "&country=" + country, 457 method: "GET", 458 dataType: "html", 459 cache: false, 460 beforeSend: function() { 461 window.scrollTo(0,0); 462 hiliteNav("","","",""); 463 // $("#article section").addClass("blink_out"); 464 $("#article section").addClass("switch_out"); 465 setTimeout(function() { 466 showOverlay("on"); 467 stopBgAnim(); 468 $("#article section").removeClass("switch_out"); 469 }, 300); 470 }, 471 success: function(data) { 472 $("#article").empty().append(data); 473 doTruncate("#article .text_truncate", 7); 474 hiliteNav(section,type,subtype,""); 475 initSvg("#" + section); 476 sRefresh(); 477 initImageCycle(section); 478 doStats("getItem('" + section + "," + type + "," + subtype + "," + id + "," + autoplay + "'): DONE"); 479 var endtime = + new Date(); 480 if ((endtime - starttime) < minOverlayDuration) { 481 setTimeout(function() { showOverlay("off"); }, 1000); 482 } else { 483 showOverlay("off"); 484 } 485 initBg(section); 486 }, 487 error: function(XMLHttpRequest, textStatus, errorThrown) { 488 doStats("Error:" + errorThrown + "(" + XMLHttpRequest.status + ")"); 489 }, 490 complete: function() { 491 setTimeout(function() { loadOverlay("random"); }, 2000); 492 } 493 }); 494 } else { 495 alert("invalid request"); 496 } 497} 498 499 500// ------------ backgrounds ------------ // 501var bgAnimTimer; 502var bgAnimOn = 0; 503var bgAnimDefault = 101; 504var bgAnimCurrent = bgAnimDefault; 505 506function bgAnim(max_frames,max_random) { 507 // doStats("bgAnim(" + max_frames + "," + max_random + ")"); 508 var r = myRandom(1,max_random); 509 var bg = "none"; 510 if (r == 1) { bg = "url(/" + base + "/images/bg/" + bgAnimCurrent + "." + myRandom(1,max_frames) + ".gif)"; } 511 setBgImage("#bg_image",bg); 512 bgAnimTimer = setTimeout(function(){ bgAnim(max_frames,max_random) }, 100); 513} 514 515function startBgAnim(framesname,max_frames,max_random) { 516 doStats("startBgAnim(" + framesname + "," + max_frames + "," + max_random + ")"); 517 bgAnimCurrent = framesname; 518 if (!bgAnimOn) { 519 bgAnimOn = 1; 520 bgAnim(max_frames,max_random); 521 } 522 showBg(); 523} 524 525function setBgImage(target,bg,position) { 526 $(target).css('background-image',bg); 527 if (position != "" && position != 0 && position != undefined && position != null) { 528 $(target).css('background-position',position); 529 } 530} 531 532function stopBgAnim() { 533 bgAnimCurrent = bgAnimDefault; 534 setBgImage("#bg_image","none"); 535 clearTimeout(bgAnimTimer); 536 bgAnimOn = 0; 537} 538 539function clearBg() { 540 setBgImage("#bg_image","none"); 541 $("#bg_video_holder0").empty(); 542 $("#bg_image").css("display","none"); 543} 544 545function showBg() { 546 $("#bg_image").css("display","block"); 547} 548 549var backgroundEffects = true; 550
551function toggleBackground() { 552 if (backgroundEffects == true) { 553 setBackground("off"); 554 } else { 555 setBackground("on"); 556 } 557} 558 559function setBackground(modus) { 560 if (modus == "off") { 561 backgroundEffects = false; 562 $(".setting-background").removeClass("on"); 563 stopBgAnim(); 564 clearBg(); 565 setSetting("background","off"); 566 } else { 567 backgroundEffects = true; 568 $(".setting-background").addClass("on"); 569 if (section != "") { 570 initBg(section); 571 } 572 setSetting("background","on"); 573 } 574 playSound("klick"); 575} 576 577function initBg(section) { 578 if (backgroundEffects == true) { 579 doStats("initBg(" + section + ")"); 580 $("#body_id").removeClass (function (index, className) { 581 return (className.match (/(^|\s)body_index_\S+/g) || []).join(' '); 582 }); 583 $("#body_id").addClass("body_index_" + section); 584 clearBg(); 585 switch(section) { 586 case "home": 587 startBgAnim(101,8,15); 588 break; 589 case "news": 590 if (bg_video_enabled) { 591 // load_bg_video("/" + base + "/images/bg/name.mp4","0","Y"); 592 startBgAnim(102,8,5); 593 } else { 594 startBgAnim(102,8,5); 595 } 596 break; 597 case "music": 598 startBgAnim(104,8,20); 599 break; 600 case "dates": 601 if (bg_video_enabled) { 602 // load_bg_video("/" + base + "/images/bg/bg_dates.mp4","0","Y"); 603 } else { 604 // static jpg: setBgImage("#bg_image",'url(/' + base + '/images/bg/bg_dates.jpg)','right bottom'); 605 // animated gif: 606 // setBgImage("#bg_image","url(/" + base + "/images/bg/bg_dates.gif)","center center"); 607 // showBg(); 608 } 609 startBgAnim(105,5,10); 610 break; 611 case "shop": 612 startBgAnim(105,5,2); 613 break; 614 case "playlist": 615 if (bg_video_enabled) { 616 // load_bg_video("/" + base + "/images/bg/name.mp4","0","Y"); 617 startBgAnim(102,8,5); 618 } else { 619 startBgAnim(102,8,5); 620 } 621 break; 622 case "game": 623 // $("#game .section_content iframe").focus(); 624 break; 625 case "newsletter": 626 startBgAnim(107,7,30); 627 /* 628 if (bg_video_enabled) { 629 load_bg_video("/" + base + "/images/bg/tvnoise3.mp4","0","Y"); 630 } else { 631 startBgAnim(106,5,1); 632 } 633 */ 634 break; 635 default: 636 startBgAnim(bgAnimDefault,8,15); 637 break; 638 } 639 } 640} 641 642 643// ------------ bg-video ------------ // 644function load_bg_video(src,id,loop) { 645 console.log("load_bg_video(" + src + "," + id + "," + loop + ")"); 646 var loop_str = ""; 647 var onended_str = ""; 648 if (loop == "Y") { 649 loop_str = "loop"; 650 } else { 651 onended_str = "hide_bg_video('bg_video" + id + "');"; 652 } 653 var txt = ""; 654 if (bg_video_enabled) { 655 // bg_video_enabled set in getConf() 656 // set bg_video 657 txt += "<video id=\"bg_video" + id + "\" class=\"bg_video bg_video_off\" muted volume=\"0\" preload=\"auto\" autoplay " + loop_str + " onCanPlay=\"show_bg_video('bg_video" + id + "');\" onended=\"" + onended_str + "\">"; 658 txt += "<source src=\"" + src + "\" type=\"video/mp4\">"; 659 txt += "</video>"; 660 txt += "<div class='fg_video'></div>"; 661 $("#bg_video_holder" + id).html(txt); 662 } else { 663 txt += "<div class='fg_video'></div>"; 664 $("#bg_video_holder" + id).html(txt); 665 $("#bg_video_holder" + id).css("background","none"); 666 } 667} 668 669function show_bg_video(id) { 670 if ($("#" + id).hasClass("bg_video_off")) { 671 if (id == "bg_video0") { 672 var vid = document.getElementById("bg_video0"); 673 vid.playbackRate = 0.5; 674 } 675 doLog("show_bg_video(" + id + ")"); 676 $("#" + id).removeClass("bg_video_off"); 677 $("#" + id).addClass("bg_video_on"); 678 $("#" + id).attr("onCanPlay",""); 679 } 680} 681 682function hide_bg_video(id) { 683 $("#" + id).removeClass("bg_video_on"); 684 $("#" + id).addClass("bg_video_off"); 685} 686 687 688function volume_bg_video(vol) { 689 var vid = $(".slides .bg_video"); 690 vid.animate({volume: vol}, 1000, 'swing', function() { 691 // $(".slides .bg_video").each(this.pause()); // pause video 692 });
693} 694 695function toggle_bg_video() { 696 /* 697 var video = document.getElementById('bg_video_main'); 698 if (bgVideo) { 699 $(".bg_video_ctrl").removeClass("bg_video_ctrl_on"); 700 if (video) { video.pause(); } 701 $(".bg_video_holder").hide(); 702 bgVideo = false; 703 } else { 704 $(".bg_video_ctrl").addClass("bg_video_ctrl_on"); 705 if (video) { video.play(); } 706 $(".bg_video_holder").show(); 707 bgVideo = true; 708 } 709 */ 710} 711 712 713// ------------------------ overlays ------------------------ // 714 715var minOverlayDuration = 1000; 716 717function loadOverlay(id) { 718 var html = ""; 719 if (id === "random") { 720 id = myRandom(3,8); 721 } 722 if (id !== "") { 723 // doStats("Load Overlay(" + id + ")"); 724 switch(id) { 725 /* 726 // iframe, flat shading 727 html = "<iframe onload=\"doStats('Load Overlay(" + id + "): Done');\" class=\"clearfix\" title=\"\" src=\"/1/3d/index.php\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"no\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>"; 728 $("#overlay").html(html); 729 break; 730 731 // iframe, wireframe 732 html = "<iframe onload=\"doStats('Load Overlay(" + id + "): Done');\" class=\"clearfix\" title=\"\" src=\"/1/3d/index.php?wireframe=1\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"no\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>"; 733 $("#overlay").html(html); 734 break; 735 */ 736 case 1: 737 case 2: 738 case 3: 739 // glitch1 740 if (bg_video_enabled) { 741 html = "<div id=\"bg_video_holder1\" class=\"bg_video_holder\"></div>"; 742 $("#overlay").html(html); 743 load_bg_video("/" + base + "/images/bg/glitch1.mp4",1,"Y"); 744 } else { 745 html = "<div class=\"bg_image\" style=\"background-image:url(/" + base + "/images/bg/glitch1.gif);\"><div class=\"fg_image\"></div></div>"; 746 $("#overlay").html(html); 747 } 748 break; 749 case 4: 750 // glitch2 751 if (bg_video_enabled) { 752 html = "<div id=\"bg_video_holder1\" class=\"bg_video_holder\"></div>"; 753 $("#overlay").html(html); 754 load_bg_video("/" + base + "/images/bg/glitch2.mp4",1,"Y"); 755 } else { 756 html = "<div class=\"bg_image\" style=\"background-image:url(/" + base + "/images/bg/glitch2.gif);\"><div class=\"fg_image\"></div></div>"; 757 $("#overlay").html(html); 758 } 759 break; 760 case 5: 761 // glitch3 762 if (bg_video_enabled) { 763 html = "<div id=\"bg_video_holder1\" class=\"bg_video_holder\"></div>"; 764 $("#overlay").html(html); 765 load_bg_video("/" + base + "/images/bg/glitch3.mp4",1,"Y"); 766 } else { 767 html = "<div class=\"bg_image\" style=\"background-image:url(/" + base + "/images/bg/glitch3.gif);\"><div class=\"fg_image\"></div></div>"; 768 $("#overlay").html(html); 769 } 770 break; 771 case 6: 772 // tvnoise1 773 if (bg_video_enabled) { 774 html = "<div id=\"bg_video_holder1\" class=\"bg_video_holder\"></div>"; 775 $("#overlay").html(html); 776 load_bg_video("/" + base + "/images/bg/tvnoise1.mp4",1,"Y"); 777 } else { 778 html = "<div class=\"bg_image\" style=\"background-image:url(/" + base + "/images/bg/tvnoise1.gif);\"><div class=\"fg_image\"></div></div>"; 779 $("#overlay").html(html); 780 } 781 break; 782 case 7: 783 // tvnoise2 784 if (bg_video_enabled) { 785 html = "<div id=\"bg_video_holder1\" class=\"bg_video_holder\"></div>"; 786 $("#overlay").html(html); 787 load_bg_video("/" + base + "/images/bg/tvnoise2.mp4",1,"Y"); 788 } else { 789 html = "<div class=\"bg_image\" style=\"background-image:url(/" + base + "/images/bg/tvnoise2.gif);\"><div class=\"fg_image\"></div></div>"; 790 $("#overlay").html(html); 791 } 792 break; 793 case 8: 794 // tvnoise3 795 if (bg_video_enabled) { 796 html = "<div id=\"bg_video_holder1\" class=\"bg_video_holder\"></div>"; 797 $("#overlay").html(html); 798 load_bg_video("/" + base + "/images/bg/tvnoise3.mp4",1,"Y"); 799 } else { 800 html = "<div class=\"bg_image\" style=\"background-image:url(/" + base + "/images/bg/tvnoise3.gif);\"><div class=\"fg_image\"></div></div>"; 801 $("#overlay").html(html); 802 } 803 break; 804 default: 805 break; 806 } 807 } else { 808 $("#overlay").html(html); 809 } 810} 811 812function showOverlay(modus) { 813 if (modus === "on") { 814 $("#body_id").addClass("overlay_on"); 815 } else { 816 $("#body_id").removeClass("overlay_on"); 817 } 818} 819 820 821// ------------------------ youtube ------------------------ // 822function initYouTube() { 823 doStats("initYT: Start"); 824 var tag = document.createElement('script'); 825 tag.src = "https://www.youtube.com/iframe_api"; 826 var firstScriptTag = document.getElementsByTagName('script')[0]; 827 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 828} 829var ytApiKey = "AIzaSyBiYOXVYHnSaIHec43Ixj-GaIrF84UR9bQ"; 830function onYouTubeIframeAPIReady() { 831 if (ytReady == false) { 832 doStats("initYT: Done"); 833 ytReady = true; 834 } 835} 836function onYTPlayerRendered(iframe_id) { 837 if (typeof(YT) != "undefined") { 838 doLog("video: yt-api ready"); 839 if (iframe_id == "undefined" || iframe_id == ""|| iframe_id == null) { 840 iframe_id = "videoiframe"; 841 } 842 if (document.getElementById(iframe_id)) { 843 doLog("video: rendered"); 844 var tmp_player = new YT.Player(iframe_id, { events: { 'onReady': onYTPlayerReady, 'onStateChange': onYTPlayerStateChange } }); 845 } 846 } else { 847 doLog("video: yt-api not ready"); 848 } 849} 850function onYTPlayerReady(event) { 851 var tmp_id = ""; 852 var obj = event.target; 853 for (var key in obj) { 854 if (Object.prototype.hasOwnProperty.call(obj, key)) { // http://stackoverflow.com/questions/7306669/ 855 var val = obj[key]; 856 if (val.nodeName === "IFRAME") { 857 tmp_id = urldecode(val.id); // eg.: "video_playlist_PLpEG-NdxDo_uucxo-LKxaXbuZfCScOSlX"; 858 doLog("video: ready, id: " + tmp_id); 859 if (tmp_id.indexOf("playlist") !== -1) { 860 var reg = /video_playlist_(.*)/; 861 var res = reg.exec(tmp_id); 862 if (Array.isArray(res)) { 863 var ytPlaylist = res[1]; 864 doLog("video: playlist detected: " + ytPlaylist); 865 getYTPlaylist(ytPlaylist,tmp_id); 866 } 867 } 868 break; 869 } 870 } 871 } 872} 873var ytFirstStart = false; 874function onYTPlayerStateChange(event) { 875 var tmp_id = ""; 876 var tmp_title = ""; 877 var obj = event.target; 878 for (var key in obj) { 879 if (Object.prototype.hasOwnProperty.call(obj, key)) { 880 var val = obj[key]; 881 if (val.nodeName === "IFRAME") { 882 tmp_id = urldecode(val.id); 883 var tmp_obj = YT.get(tmp_id); 884 if (typeof tmp_obj.getVideoData === "function") { 885 tmp_title = tmp_obj.getVideoData().title; 886 } else { 887 var tmp_url = tmp_obj.getVideoUrl(); 888 var tmp_match = tmp_url.match(/[?&]v=([^&]+)/); 889 tmp_title = tmp_match[1]; // videoID 890 } 891 // doLog("onYTPlayerStateChange, " + tmp_id + ", " + tmp_title); 892 switch (event.data) { 893 case -1: 894 doLog("video: unstarted (" + tmp_title + ")"); 895 if (tmp_id.indexOf("playlist") !== -1) { 896 updateYTVideoNav(tmp_id); 897 } 898 break; 899 case 0: 900 doTrack('Video','VideoFinish',tmp_title); 901 break; 902 case 1: 903 if (ytFirstStart == false) { 904 ytFirstStart = true; 905 doTrack('Video','VideoStart',tmp_title); 906 } else { 907 doTrack('Video','VideoResume',tmp_title); 908 } 909 break; 910 case 2: 911 doTrack('Video','VideoPause',tmp_title); 912 break; 913 case 3: 914 doLog("video: buffering (" + tmp_title + ")"); 915 break; 916 case 5: 917 doLog("video: cued (" + tmp_title + ")"); 918 break; 919 default: 920 break; 921 } 922 break; 923 } 924 } 925 } 926} 927var ytPlaylistIDs, ytPlaylistTitles, ytPlaylistPos, ytPlaylistSize; 928function getYTPlaylist(list,iframe_id) { 929 var playListURL = "https://www.googleapis.com/youtube/v3/playlistItems?maxResults=30&part=snippet&playlistId=" + list
929+ "&key=" + ytApiKey; 930 ytPlaylistIDs = new Array(); 931 ytPlaylistTitles = new Array(); 932 ytPlaylistPos = 0; 933 ytPlaylistSize = 0; 934 $.get(playListURL,function(data) { 935 ytPlaylistSize = data.items.length; 936 $.each(data.items, function(i, item) { 937 ytPlaylistIDs.push(item.snippet.resourceId.videoId); 938 ytPlaylistTitles.push(item.snippet.title); 939 }); 940 // console.log(ytPlaylistIDs); // console.log(ytPlaylistTitles); 941 updateYTVideoNav(iframe_id); 942 if (ytPlaylistIDs.length > 1) { 943 $("#video .video_nav_holder").slideDown("slow",function() { sRefresh(); }); 944 } 945 }); 946} 947function updateYTVideoNav(iframe_id) { 948 ytPlaylistPos = YT.get(iframe_id).getPlaylistIndex(); 949 // doLog("updateYTVideoNav(" + iframe_id + ") -> ytPlaylistPos: " + ytPlaylistPos); 950 $("#video .video_nav_prev a").attr("onClick","previousYTVideo('" + iframe_id + "')"); 951 $("#video .video_nav_next a").attr("onClick","nextYTVideo('" + iframe_id + "')"); 952 $("#video .video_title").html(ytPlaylistTitles[ytPlaylistPos]); 953 var ytPlaylistPosDisplay = ytPlaylistPos + 1; 954 if (ytPlaylistPosDisplay < 10) { ytPlaylistPosDisplay = "0" + ytPlaylistPosDisplay; } 955 var ytPlaylistSizeDisplay = ytPlaylistSize; 956 if (ytPlaylistSizeDisplay < 10) { ytPlaylistSizeDisplay = "0" + ytPlaylistSizeDisplay; } 957 $("#video .video_nav .video_nav_counter").html(ytPlaylistPosDisplay + " / " + ytPlaylistSizeDisplay); 958} 959function playYTVideo(iframe_id) { 960 YT.get(iframe_id).playVideo(); 961} 962function pauseYTVideo(iframe_id) { 963 YT.get(iframe_id).pauseVideo(); 964} 965function stopYTVideo(iframe_id) { 966 YT.get(iframe_id).stopVideo(); 967} 968function previousYTVideo(iframe_id) { 969 YT.get(iframe_id).previousVideo(); 970} 971function nextYTVideo(iframe_id) { 972 YT.get(iframe_id).nextVideo(); 973} 974 975// ------------ carousels ------------ // 976function initCarousels() { 977 $('.carousel-holder-size-auto .carousel').flickity({ cellAlign:'left', contain:true, cellSelector:'.carousel-cell', setGallerySize:true }); 978 $('.carousel-holder-size-css .carousel').flickity({ cellAlign:'left', contain:true, cellSelector:'.carousel-cell', setGallerySize:false }); 979 $('.carousel').each( function() { 980 var elem = $(this); 981 elem.on('select.flickity', function() { 982 var flkty = elem.data('flickity'); 983 elem.find(".carousel-zoom").data("index", flkty.selectedIndex); 984 }); 985 }); 986 /* 987 $('.carousel-zoom').click(function(e) { 988 var sources = urldecode($(this).data("sources")); 989 var index = $(this).data("index"); 990 eval("$.fancybox.open([" + sources + "], { }, " + index + ")"); 991 return false; 992 }); 993 */ 994} 995 996// ------------------------ products ------------------------ // 997function showProduct(x) { 998 if (isNaN(x)) { 999 if (x == "next") { 1000 nr = product + 1; 1001 if (nr > productMax) { nr = 1; } 1002 } else { 1003 nr = product - 1; 1004 if (nr < 1) { nr = productMax; } 1005 } 1006 } else { 1007 nr = $("#product" + x).data("nr"); 1008 } 1009 $(".products .item").css("display", "none"); 1010 $(".products .item" + nr).fadeIn("slow"); // $(".shop .item" + nr).css("display", "block"); 1011 $(".products .thumb").removeClass("on"); 1012 $(".products .thumb").addClass("off"); 1013 $(".products .thumb" + nr).addClass("on"); 1014 product = nr; 1015 var id = $(".products .item" + nr).data("id"); 1016 var name = $(".products .item" + nr).data("name"); 1017 setHistory(lang,'products',name,'','',id,''); 1018} 1019 1020function toggleInfoBox(el) { 1021 if ($(el).parent().find(".text").css("display") == "none") { 1022 doLog("toogleInfoBox -> open"); 1023 $("#products .items .info").removeClass("info_off"); 1024 $("#products .items .info").addClass("info_on"); 1025 // $(el).parent().removeClass("info_off"); 1026 // $(el).parent().addClass("info_on"); 1027 $("#products .items .info .text").css("display","block"); 1028 } else { 1029 doLog("toogleInfoBox -> close"); 1030 $("#products .items .info").removeClass("info_on"); 1031 $("#products .items .info").addClass("info_off"); 1032 // $(el).parent().removeClass("info_on"); 1033 // $(el).parent().addClass("info_off"); 1034 $("#products .items .info .text").css("display","none"); 1035 } 1036} 1037 1038// ------------------------ dates ------------------------ // 1039function toggleDates(id) { 1040 var new_h, row_display; 1041 // get modus (compact, large) usually triggered via @media screen and (max-width:640px) { } 1042 if ($("#dates_block" + id + " .dateslist li").first().css("display") === "table") { 1043 row_display = "table"; 1044 } else { 1045 row_display = "block"; 1046 } 1047 if ($("#dates_block" + id + " .dateslist li.row-more").css("display") === "none") { 1048 // show more rows 1049 new_h = $("#dates_block" + id + " .dateslist").innerHeight(); 1050 $("#dates_block" + id + " .dateslist_holder").css("height", new_h + "px"); 1051 $("#dates_block" + id + " .dateslist li.row-more").css("display",row_display); 1052 new_h = $("#dates_block" + id + " .dateslist").innerHeight(); 1053 $("#dates_block" + id + " .dateslist_holder").animate({ height: new_h }, "slow", function() { 1054 $("#dates_block" + id + " .dateslist_holder").css("height", "auto"); 1055 $("#dates_block" + id + " .more_dates a.icon-down-open").css("display","none"); 1056 $("#dates_block" + id + " .more_dates a.icon-up-open").css("display","block"); 1057 sRefresh();
1058 }); 1059 } else { 1060 // show less rows 1061 $("#dates_block" + id + " .dateslist li.row-more").css("display","none"); 1062 new_h = $("#dates_block" + id + " .dateslist").innerHeight(); 1063 $("#dates_block" + id + " .dateslist li.row-more").css("display",row_display); 1064 $("#dates_block" + id + " .dateslist_holder").animate({ height: new_h }, "slow", function() { 1065 $("#dates_block" + id + " .dateslist li.row-more").css("display","none"); 1066 $("#dates_block" + id + " .dateslist_holder").css("height", "auto"); 1067 $("#dates_block" + id + " .more_dates a.icon-down-open").css("display","block"); 1068 $("#dates_block" + id + " .more_dates a.icon-up-open").css("display","none"); 1069 $.scrollTo("#dates_block" + id + " .more_dates", 1000, { 1070 axis: "y", 1071 offset: -220, 1072 onAfter: function () { 1073 } 1074 }); 1075 sRefresh(); 1076 }); 1077 } 1078} 1079 1080function toggleCalendar(id) { 1081 if ($(".calendar_links" + id).css("display") === "none") { 1082 $(".calendar_toggle" + id).text("-"); 1083 $(".calendar_links" + id).fadeIn("fast", function() { }); 1084 } else { 1085 $(".calendar_toggle" + id).text("+"); 1086 $(".calendar_links" + id).fadeOut("fast", function() { }); 1087 } 1088} 1089 1090// ------------ sounds ------------ // 1091/*! Tiny HTML5 audio library. * @author David VanDusen * @version 1.0, https://github.com/davidvandusen */ 1092var MIME_TYPES = { "ogg":"audio/ogg", "mp3":"audio/mpeg", "wav":"audio/wav", "*":"audio/*" }; 1093function getMimeType(src) { return MIME_TYPES[src.split(".").pop()] || MIME_TYPES["*"]; } 1094function Sound() { var i; this.el = document.createElement("audio"); if (arguments.length) { for (i = 0; i < arguments.length; i++) { this.loadSource(arguments[i]); } } } 1095Sound.prototype.loadSource = function (src) { 1096 if (typeof src !== "string") { throw new TypeError(); } 1097 var source = document.createElement("source"); source.setAttribute("src", src); source.setAttribute("type", getMimeType(src)); this.el.appendChild(source); 1098}; 1099Sound.prototype.play = function () { this.el.play(); }; 1100Sound.prototype.pause = function () { this.el.pause(); }; 1101var sounds; 1102function initSounds() { 1103 sounds = { 1104 klick : new Sound("/" + base + "/media/audio/klick.ogg", "/" + base + "/media/audio/klick.mp3", "/" + base + "/media/audio/klick.wav"), 1105 slide : new Sound("/" + base + "/media/audio/slide.ogg", "/" + base + "/media/audio/slide.mp3", "/" + base + "/media/audio/slide.wav"), 1106 error : new Sound("/" + base + "/media/audio/error.ogg", "/" + base + "/media/audio/error.mp3", "/" + base + "/media/audio/error.wav"), 1107 startup : new Sound("/" + base + "/media/audio/startup.ogg", "/" + base + "/media/audio/startup.mp3", "/" + base + "/media/audio/startup.wav") 1108 }; 1109 // sounds.klick.play(); 1110} 1111 1112function playSound(soundname) { 1113 if (soundsEffects == true) { 1114 switch (soundname) { 1115 case "klick": 1116 sounds.klick.play(); 1117 break; 1118 case "slide": 1119 sounds.slide.play(); 1120 break; 1121 case "error": 1122 sounds.error.play(); 1123 break; 1124 case "startup": 1125 sounds.startup.play(); 1126 break; 1127 default: 1128 break; 1129 } 1130 } 1131} 1132 1133var soundsEffects = true; 1134 1135function toggleSounds() { 1136 if (soundsEffects == true) { 1137 setSounds("off"); 1138 } else { 1139 setSounds("on"); 1140 } 1141} 1142 1143function setSounds(modus) { 1144 if (modus == "off") { 1145 soundsEffects = false; 1146 $(".setting-sounds").removeClass("on"); 1147 setSetting("sounds","off"); 1148 } else { 1149 soundsEffects = true; 1150 $(".setting-sounds").addClass("on"); 1151 playSound("klick"); 1152 setSetting("sounds","on"); 1153 } 1154} 1155 1156 1157// ------------ screen ------------ // 1158 1159var screenEffects = true; 1160 1161function toggleScreen() { 1162 if (screenEffects == true) { 1163 setScreen("off"); 1164 } else { 1165 setScreen("on"); 1166 } 1167} 1168 1169function setScreen(modus) { 1170 if (modus == "off") { 1171 screenEffects = false; 1172 $(".setting-screen").removeClass("on"); 1173 $("#body_id").addClass("screen_off"); 1174 setSetting("screen","off"); 1175 } else { 1176 screenEffects = true; 1177 $(".setting-screen").addClass("on"); 1178 $("#body_id").removeClass("screen_off"); 1179 setSetting("screen","on"); 1180 } 1181 playSound("klick"); 1182} 1183 1184 1185 1186// ------------ music ------------ // 1187 1188function toggleAlbumplayer(id) { 1189 if ($("#albumplayer" + id).css("display") === "none") { 1190 // close other players 1191 $(".albumplayer").empty(); 1192 $(".albumplayer").css("display","none"); 1193 $(".product li.albumplayer_trigger .title_off").css("display","block"); 1194 $(".product li.albumplayer_trigger .title_on").css("display","none"); 1195 // load specific player 1196 var txt = $("#albumplayer" + id).data("embedcode"); 1197 $("#albumplayer" + id).html(urldecode(txt)); 1198 $("#albumplayer" + id).css("display","block"); 1199 $("#albumplayer" + id).css("display","block"); 1200 $(".product" + id + " li.albumplayer_trigger .title_off").css("display","none"); 1201 $(".product" + id + " li.albumplayer_trigger .title_on").css("display","block"); 1202 } else { 1203 $("#albumplayer" + id).empty(); 1204 $("#albumplayer" + id).css("display","none"); 1205 $(".product" + id + " li.albumplayer_trigger .title_off").css("display","block"); 1206 $(".product" + id + " li.albumplayer_trigger .title_on").css("display","none"); 1207 } 1208} 1209 1210var playlist; 1211var playlist_pos = -1; 1212var play_modus = "manual"; 1213var oldTrack = null; 1214var audioFirstStart = false; 1215 1216function playTrack(id) { 1217 // alert("playTrack(" + id + "), oldTrack: " + oldTrack); 1218 var audio = document.querySelector("AUDIO"); // document.getElementById("audioplayer"); 1219 id = parseInt(id); 1220 playlist_pos = $.inArray(id, playlist); 1221 doLog("playTrack(" + id + "), my playlist_pos:" + playlist_pos); 1222 if (oldTrack == id) { 1223 if (audio.paused) { 1224 doPlay(); 1225 } else { 1226 doPause(); 1227 } 1228 } else { 1229 audio.addEventListener("timeupdate", progressBar, true); 1230 var trackname = $("#track"+ id).data("trackname"); 1231 $(".track").removeClass("track_on"); 1232 $(".track .playback_icon").html("<div class='icon icon-play'></div>"); 1233 $(".track .track_progress").css("width","0%"); 1234 $("#track"+ id).addClass("track_on"); 1235 $("#track"+ id + " .playback_icon").html("<div class='icon icon-spin5 animate-spin'></div>"); 1236 oldTrack = id; 1237 audioFirstStart = false; 1238 audio.src = $("#track"+ id).data("src"); 1239 audio.load(); 1240 } 1241} 1242 1243function canPlay() { 1244 if (play_modus == "auto" || play_modus == "manual") { 1245 doPlay(); 1246 } else { 1247 doPause(); 1248 } 1249} 1250 1251function doPlay() { 1252 var audio = document.querySelector("AUDIO"); 1253 audio.play(); 1254 $("#track"+ oldTrack + " .playback_icon").html("<div class='icon icon-pause'></div>"); 1255 if (audioFirstStart == false) { 1256 audioFirstStart = true; 1257 doTrack('Audio','AudioStart',$("#track"+ oldTrack).data("trackname"));
1258 } else { 1259 doTrack('Audio','AudioResume',$("#track"+ oldTrack).data("trackname")); 1260 } 1261} 1262 1263function doPause() { 1264 var audio = document.querySelector("AUDIO"); 1265 if (!audio.ended) { 1266 doTrack('Audio','AudioPause',$("#track"+ oldTrack).data("trackname")); 1267 } 1268 if (audio.ended) { 1269 $("#track"+ oldTrack + " .track_progress").css("width", "0%"); 1270 doTrack('Audio','AudioFinish',$("#track"+ oldTrack).data("trackname")); 1271 } 1272 audio.pause(); 1273 $("#track"+ oldTrack + " .playback_icon").html("<div class='icon icon-play'></div>"); 1274} 1275 1276function doStop() { 1277 var audio = document.querySelector("AUDIO"); 1278 if (audio) { 1279 doTrack('Audio','AudioStop',$("#track"+ oldTrack).data("trackname")); 1280 audio.pause(); 1281 $("#track"+ oldTrack + " .track_progress").css("width", "0%"); 1282 $("#track"+ oldTrack + " .playback_icon").html("<div class='icon icon-play'></div>"); 1283 } 1284} 1285 1286function playPause() { 1287 var audio = document.querySelector("AUDIO"); 1288 if (audio.paused) { 1289 doPlay(); 1290 } else { 1291 doPause(); 1292 } 1293} 1294 1295function playNext() { 1296 if (typeof(playlist) != "undefined") { 1297 doLog("playNext(), playlist.length:" + playlist.length + ", playlist_pos:" + playlist_pos) 1298 if (play_modus == "auto") { 1299 playlist_pos++; 1300 if (playlist_pos < playlist.length) { 1301 var next_id = playlist[playlist_pos]; 1302 doLog("next_id: " + next_id + ", playlist_pos:" + playlist_pos); 1303 doTrack('Audio','AudioGotoNextTrack',$("#track"+ next_id).data("trackname")); 1304 playTrack(next_id); 1305 } else { 1306 playlist_pos = -1; 1307 doLog("playlist end"); 1308 doPause(); 1309 } 1310 } else { 1311 doPause(); 1312 } 1313 } 1314} 1315 1316function progressBar() { 1317 var oAudio = document.getElementById('audioplayer'); 1318 var elapsedTime = Math.round(oAudio.currentTime); // get current time in seconds 1319 var w = (elapsedTime / oAudio.duration) * 100; // update the progress bar 1320 if (w >= 0 && w <= 100) { 1321 // doLog("audio-progress: " + w); 1322 $("#track"+ oldTrack + " .track_progress").css("width", w + "%"); 1323 } 1324} 1325 1326 1327// --------------- settings ----------------- // 1328 1329var settingsString = "SolomunSettingOff_"; 1330 1331function setSetting(kind,modus) { 1332 if (localStorageTest() === true) { 1333 var ausdruck = /^(\w*)?$/; 1334 if (ausdruck.exec(kind)) { 1335 kind = RegExp.$1; 1336 var item = settingsString + kind; 1337 if (modus == "on") { 1338 localStorage.removeItem(item); 1339 } 1340 if (modus == "off") { 1341 localStorage.setItem(item, "success"); 1342 } 1343 } else { 1344 alert("[ invalid request ]"); 1345 } 1346 } else { 1347 doStats("Your browser settings doesn't allow you to store settings. Possible reason: incognito / private mode."); 1348 } 1349} 1350 1351function initSettings() { 1352 doLog("initSettings"); 1353 if (localStorageTest() === true) { 1354 if (localStorage.getItem(settingsString + "sounds")) { 1355 setSounds("off"); 1356 } 1357 if (localStorage.getItem(settingsString + "background")) { 1358 setBackground("off"); 1359 } 1360 if (localStorage.getItem(settingsString + "screen")) { 1361 setScreen("off"); 1362 } 1363 } 1364} 1365 1366function localStorageTest(){ 1367 var test = 'test'; 1368 try { 1369 localStorage.setItem(test, test); 1370 localStorage.removeItem(test); 1371 return true; 1372 } catch(e) { 1373 return false; 1374 } 1375} 1376 1377 1378// ------------ forms ------------ // 1379 1380function validateEmail(email) { 1381 var exp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 1382 return exp.test(email); 1383} 1384 1385var warnTimeout; 1386 1387function doWarn(id,txt) { 1388 // alert("doWarn(" + id + "," + txt + ")"); 1389 playSound("error"); 1390 $("#"+id).addClass("warning"); 1391 $("label[for='"+ id +"']").html("<span class='icon icon-attention'></span> " + txt); 1392 $("label[for='"+ id +"']").addClass("warning"); 1393 /* 1394 // make it shake! 1395 $(elem).addClass("animated_manual_animation shake").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function(){ 1396 $(elem).removeClass("animated_manual_animation"); 1397 $(elem).removeClass("shake"); 1398 });
1399 */ 1400 $("#"+id).disabled = false; 1401 $("#"+id).trigger("focus"); 1402 1403 clearTimeout(warnTimeout); 1404 warnTimeout = setTimeout(function(){ 1405 resetFormWarnings(); 1406 }, 3000); 1407} 1408 1409function resetFormWarnings() { 1410 $("form .text").removeClass("warning"); 1411 $("form label").removeClass("warning"); 1412 $("form label").each(function(index) { 1413 var myText = $(this).attr('data-text'); 1414 if (myText !== undefined) { 1415 $(this).html(urldecode(myText)); 1416 } 1417 }); 1418} 1419 1420function checkInput(id, title, allow_empty) { 1421 title = urldecode(title); 1422 input = $("#" + id); 1423 if (allow_empty === undefined) { allow_empty = false; } 1424 if (allow_empty == false) { 1425 if (input.val() === "" || input.val().length < 2) { 1426 doWarn(id, title + " is missing."); 1427 return false; 1428 } 1429 } 1430 var zeichen ="<>"; 1431 var eingabe = input.val(); 1432 var laenge = eingabe.length; 1433 for(i=0; i<laenge; i++) { 1434 badchar = eingabe.charAt(i); 1435 if (zeichen.indexOf(badchar)>-1) { 1436 doWarn(id, title + " contains invalid letters."); 1437 return false; 1438 } 1439 } 1440 return true; 1441} 1442 1443function checkText(id, title, allow_empty) { 1444 input = $("#" + id); 1445 if (allow_empty === undefined) { allow_empty = false; } 1446 if (allow_empty == false) { 1447 if (input.val() === "" || input.val().length < 24) { 1448 doWarn(id, title + " is missing."); 1449 return false; 1450 } 1451 } 1452 return true; 1453} 1454 1455function checkCharCount(el) { 1456 var str = $("#" + el).val(); 1457 if ($("#" + el).val().length >= maxChars) { 1458 doWarn(el, "Too many chars."); 1459 } 1460} 1461 1462function checkUrl(id, title, allow_empty) { 1463 input = $("#" + id); 1464 if (allow_empty === undefined) { allow_empty = false; } 1465 if (allow_empty == false) { 1466 if (input.val() === "" || input.val().length < 2) { 1467 doWarn(id, title + " is missing."); 1468 return false; 1469 } 1470 } 1471 var zeichen =";<>"; 1472 var eingabe = input.val(); 1473 var laenge = eingabe.length; 1474 for(i=0; i<laenge; i++) { 1475 badchar = eingabe.charAt(i); 1476 if (zeichen.indexOf(badchar)>-1) { 1477 doWarn(id, title + " contains invalid letters."); 1478 return false; 1479 } 1480 } 1481 if (eingabe.indexOf("http") !== 0) { 1482 doWarn(id, title + " must start with http or https."); 1483 return false; 1484 } 1485 return true; 1486} 1487 1488function doFeedback(id,txt) { 1489 $("#"+ id + " .content").html(txt); 1490 $("#" + id).slideDown("slow"); 1491 setTimeout(function() { $("#" + id + " a.close").fadeIn("slow"); }, 3000); 1492} 1493 1494function closeFeedback(id) { 1495 $("#" + id + " a.close").fadeOut("fast"); 1496 $("#" + id).fadeOut("slow"); 1497} 1498 1499 1500// ------------ newsletter ------------ // 1501 1502function initTeaserNewsletter() { 1503 $('#teaser_nl_email_id').on("keyup", function(e) { 1504 if (e.key === 'Enter' || e.keyCode === 13) { 1505 // Disable textbox to prevent multiple submit 1506 $(this).attr("disabled", "disabled"); 1507 sendTeaserNewsletter(); 1508 // Enable the textbox again if needed. 1509 $(this).removeAttr("disabled"); 1510 } 1511 }); 1512} 1513 1514 1515function initNewsletter() { 1516 doStats("initNewsletter()"); 1517 1518 var newsletterKeyPress = false; 1519 /* 1520 $("#nl_sender_form input").keypress(function(event) { 1521 if (newsletterKeyPress == false) { 1522 newsletterKeyPress = true; 1523 window.dataLayer = window.dataLayer || []; 1524 window.dataLayer.push({ 1525 event: "Generic Event", 1526 event_name: "newsletter_soi_start", 1527 newsletter_soi_start: { 1528 newsletter_selection: nl_addressbooks, 1529 event_category: "Customer Relations", 1530 event_action: "Newsletter", 1531 event_label: "Single Opt-In - Start" 1532 } 1533 }); 1534 } 1535 }); 1536 */ 1537 /* 1538 // rewrite browser-history for urls like /newsletter/confirm/ 1539 var res = /newsletter\/([a-zA-Z]+)/.exec(window.location.href); 1540 if (Array.isArray(res)) { 1541 // doLog("newsletter_path found: " + res[1]); 1542 if (window.history && window.history.replaceState) { 1543 history.replaceState("", window.location.host, window.location.protocol + "//" + window.location.host); 1544 } 1545 } 1546 */ 1547 $("#nl_sender_form input").on("focus", function() { 1548 if (newsletterKeyPress == false) { 1549 newsletterKeyPress = true; 1550 $("#newsletter .step-2").slideDown("fast"); 1551 // setTimeout(function() { sRefresh(); }, 500); 1552 } 1553 });
1554 1555 $.getJSON("https://api4.ipify.org?format=json", function(data) { 1556 // console.log("ipify.org > data:"); console.log(JSON.stringify(data, null, 2)); 1557 if (data.ip !="" && data.ip.length > 1) { 1558 $("#nl_ip_id").val(data.ip); 1559 } 1560 }); 1561 1562 return; 1563 1564 /* 1565 // get geo-infos 1566 $.getJSON("https://pro.ip-api.com/json/?key=v5ctYr9wp1NIwiq", function(data) { 1567 // console.log("ip-api > data:"); console.log(JSON.stringify(data, null, 2)); 1568 var query = data.query; 1569 var country = data.countryCode.toUpperCase(); 1570 var city = data.city; 1571 console.log("ip-api > query: " + query + ", country: " + country + ", city: " + city); 1572 if (query !="" && query.length > 1) { 1573 $("#nl_ip_id").val(query); 1574 } 1575 if (country !="" && country.length == 2) { 1576 // $("#nl_country_id").val(country); 1577 } 1578 if (city !="" && city.length > 1) { 1579 // $("#nl_city_id").val(city); 1580 } 1581 }); 1582 */ 1583 1584 /* 1585 if (teaserEmail != "") { 1586 $("#nl_email_id").val(teaserEmail); 1587 $("#nl_firstname_id").focus(); 1588 } else { 1589 $("#nl_email_id").focus(); 1590 } 1591 */ 1592} 1593 1594function sendnewsletter() { 1595 doLog("sendnewsletter()"); 1596 1597 playSound("klick"); 1598 1599 // check email 1600 if (document.getElementById("nl_email_id")) { 1601 if (!checkInput("nl_email_id", "E-Mail")) { return false; } 1602 if (!validateEmail($("#nl_email_id").val())) { 1603 doWarn("nl_email_id", "The E-Mail is invalid."); 1604 return false; 1605 } 1606 } 1607 1608 // check firstname 1609 if (document.getElementById("nl_firstname_id")) { 1610 if (!checkInput("nl_firstname_id", "First Name", true)) { return false; } 1611 } 1612 1613 // check city 1614 if (document.getElementById("nl_city_id")) { 1615 if (!checkInput("nl_city_id", "City", true)) { return false; } 1616 } 1617 1618 // check nl_country 1619 if (document.getElementById("nl_country_id")) { 1620 if (!checkInput("nl_country_id", "Country")) { return false; } 1621 } 1622 1623 // send data 1624 var post_data = $("#nl_sender_form").serialize(); 1625 1626 // add pers_lytics_uid 1627 /* 1628 if (window.hasOwnProperty('lio')) { 1629 post_data += "&pers_lytics_uid=" + window.lio._uid; 1630 } else { 1631 post_data += "&pers_lytics_uid="; 1632 } 1633 */ 1634 // doLog("post_data:"); doLog(post_data); 1635 1636 $.ajax({ 1637 url: "/" + base + "/newsletter_sender.php", 1638 data: post_data, 1639 method: "GET", 1640 dataType: "html", 1641 cache: false, 1642 beforeSend: function() { 1643 $("#nl_btn_send").css("pointer-events","none"); 1644 $("#nl_btn_send .symbol").css("display","none"); 1645 $("#nl_btn_send .loading").css("display","block"); 1646 }, 1647 success: function(data) { 1648 // console.log("data:"); console.log(data); 1649 $("#nl_btn_send .symbol").css("display","none"); 1650 if (data.search(/error/i) == -1 && data.search(/fehler/i) == -1 && data.search(/erreur/i) == -1) { 1651 // feedback contains no errors: 1652 $("#nl_btn_send .ok").css("display","block"); 1653 setTimeout(function() { 1654 $("#nl_sender_form").slideUp("fast"); 1655 $("#newsletter .step-2").slideUp("fast"); 1656 playSound("error"); 1657 doMsg(data); 1658 }, 500); 1659 if ($("#body_id").hasClass("body_index_newsletter")) { 1660 setTimeout(function() { 1661 doGetContent('newsletter'); 1662 }, 4500); 1663 } 1664 } else { 1665 $("#nl_btn_send .error").css("display","block"); 1666 setTimeout(function() { 1667 $("#nl_btn_send").css("pointer-events","all"); 1668 $("#nl_btn_send .symbol").css("display","none"); 1669 $("#nl_btn_send .enter").css("display","block"); 1670 playSound("error"); 1671 doMsg(data); 1672 }, 500); 1673 } 1674 }, 1675 error: function(XMLHttpRequest, textStatus, errorThrown) { 1676 alert("Error: " + errorThrown + "(" + XMLHttpRequest.status + ")"); 1677 $("#nl_btn_send .symbol").css("display","none"); 1678 $("#nl_btn_send .error").css("display","block"); 1679 }, 1680 complete: function() { 1681 // 1682 } 1683 }); 1684 1685 return false; 1686} 1687 1688 1689 1690// ------------ standard functions ------------ // 1691 1692var resized; 1693 1694function initResize() { 1695 console.log("initResize"); 1696 $(window).on('resize orientationChanged', function(){ 1697 clearTimeout(resized); 1698 resized = setTimeout(onResize, 50); 1699 }); 1700} 1701 1702var copyActive = false; 1703 1704function initCopyButtons() { 1705 // doLog("initCopyButtons()"); // for clipboard.js v2.0.6 1706 var clipboard = new ClipboardJS(".copy-button"); 1707 clipboard.on('success', function(e) { 1708 if (copyActive == false) { 1709 // console.info('Action:', e.action); console.info('Text:', e.text); console.info('Trigger:', e.trigger); 1710 doTrack('Social', "LinkCopy", urldecode(e.text)); 1711 e.clearSelection(); 1712 if (lang == "de") { 1713 doMsg("<span class='icon icon-ok'></span> Link kopiert"); 1714 } else { 1715 doMsg("<span class='icon icon-ok'></span> Link copied"); 1716 } 1717 copyActive = true; 1718 setTimeout(function() { closeMsg(); copyActive = false; }, 3000); 1719 } 1720 }); 1721 var emailclipboard = new ClipboardJS('a.copy-email', { 1722 text: function(trigger) { 1723 return trigger.getAttribute('data-usr') + "@" + trigger.getAttribute('data-dom') + "." + trigger.getAttribute('data-tld'); 1724 } 1725 });
1726 emailclipboard.on('success', function(e) { 1727 if (copyActive == false) { 1728 // console.info('emailclipboard Action:', e.action); console.info('emailclipboard Text:', e.text); console.info('Trigger:', e.trigger); 1729 doTrack('Social', "EmailCopy", urldecode(e.text)); 1730 e.clearSelection(); 1731 if (lang == "de") { 1732 doMsg("<span class='icon icon-ok'></span> E-Mail kopiert"); 1733 } else { 1734 doMsg("<span class='icon icon-ok'></span> E-Mail copied"); 1735 } 1736 copyActive = true; 1737 setTimeout(function() { closeMsg(); copyActive = false; }, 3000); 1738 } 1739 }); 1740} 1741 1742function doMsg(txt) { 1743 // if ($("#msg .content").html() != "") { doAnim("#msg", "flash"); } 1744 // $("#msg .content").html(urldecode(txt)); 1745 // $("#msg").slideDown('fast', function() {}); 1746 showError(txt); 1747} 1748 1749function closeMsg() { 1750 if (window.jQuery) { 1751 $("#msg").slideUp("fast", function() { $("#msg .content").empty(); }); 1752 } else { 1753 document.getElementById('msg').children[0].innerHTML='';document.getElementById('msg').style.display='none'; 1754 } 1755} 1756 1757function showError(txt) { 1758 $("#system-overlay .content").html(urldecode(txt)); 1759 $("#system-overlay").css("display","block"); 1760 $("#system-overlay").removeClass("switch_out"); 1761 $("#system-overlay").addClass("blink_in"); 1762 setTimeout(function() { 1763 closeError(); 1764 }, 4000); 1765} 1766 1767function closeError() { 1768 $("#system-overlay .content").empty(); 1769 $("#system-overlay").removeClass("blink_in"); 1770 $("#system-overlay").addClass("switch_out"); 1771 setTimeout(function() { 1772 $("#system-overlay").css("display","none"); 1773 }, 160); 1774} 1775 1776function setShare(id, url, title) { 1777 var txt = ''; 1778 txt += '<div class="share_tools" data-url="' + url + '" data-title="' + title + '">'; 1779 txt += '<a class="button share_facebook" href="#" onclick="doShare(event,\'facebook\');return false;" title="Share on facebook"><span class="icon icon-facebook"></span></a>'; 1780 // txt += '<a class="button share_facebook_messenger" href="#" onclick="doShare(event,\'facebook_messenger\');" title="Share with Facebook Messenger"><span class="icon icon-facebook-messenger"></span></a>'; 1781 txt += '<a class="button share_whatsapp" href="#" onclick="doShare(event,\'whatsapp\');" title="Share with whatsapp"><span class="icon icon-whatsapp"></span></a>'; 1782 txt += '<a class="button share_twitter" href="#" onclick="doShare(event,\'twitter\');return false;" title="Tweet"><span class="icon icon-twitter"></span></a>'; 1783 txt += '<a class="button share_email" href="#" onclick="doShare(event,\'email\');" title="Share via email"><span class="icon icon icon-mail"></span></a>'; 1784 txt += '</div>'; 1785 $('#' + id).empty().append(txt); 1786} 1787 1788function toggleShare(event) { 1789 $(event.target).closest(".share_tools").toggleClass("on"); 1790} 1791 1792function doShare(event, network) { 1793 // doMsg("doShare(" + network + ")");console.log("event:");console.log(event); 1794 var share_el,share_container,url,title,share_window; 1795 // get data-url & data-title from parent div.share_tools 1796 if (event.target.parentNode.className == "share_tools") { 1797 // old safari 1798 share_el = event.target; 1799 share_container = event.target.parentNode; 1800 } else { 1801 share_el = event.target.parentNode; 1802 share_container = event.target.parentNode.parentNode; 1803 } 1804 // console.log("share_container:");console.log(share_container); 1805 url = share_container.dataset.url; 1806 title = share_container.dataset.title; 1807 // console.log("data:");console.log(url);console.log(urldecode(title));doMsg("url: " + urldecode(url) + "<br>title: " + urldecode(title)); 1808 switch(network) { 1809 case "facebook": 1810 doTrack('Social', "FacebookShare", urldecode(url)); 1811 share_window = window.open("https://www.facebook.com/sharer/sharer.php?u=" + url,"share_window","width=600,height=450,status=no,location=no,scrollbars=no,resizable=yes"); 1812 share_window.focus(); 1813 break; 1814 case "twitter": 1815 doTrack('Social', "TwitterShare", urldecode(url)); 1816 title = urldecode(title); 1817 title = encodeURIComponent(title); 1818 $(window).bind("message", function(event) { event = event.originalEvent; if (event.source == share_window && event.data != "__ready__") { doLog("tweet successful"); } }); 1819 share_window = window.open("https://twitter.com/intent/tweet?url=" + url + "&text=" + title + "&hashtags=","share_window","width=600,height=500,status=no,location=no,scrollbars=no,resizable=yes"); 1820 share_window.focus(); 1821 break; 1822 case "email": 1823 doTrack('Social', "EmailShare", urldecode(url)); 1824 title = urldecode(title); 1825 title = encodeURIComponent(title); 1826 share_el.href = "mailto:?subject=" + title + "&body=" + url; 1827 break; 1828 case "whatsapp": 1829 doTrack('Social', "WhatsappShare", urldecode(url)); 1830 share_el.href = "whatsapp://send?text=" + title + encodeURIComponent(": ") + url; 1831 break; 1832 case "facebook_messenger": 1833 doTrack('Social', "FacebookMessengerShare", urldecode(url)); 1834 share_el.href = "fb-messenger://share?link=" + url; 1835 default: 1836 break; 1837 } 1838} 1839 1840function toggleTab(nr) { 1841 $(".tabs .tabheader li").removeClass("on"); 1842 $(".tabs .tab").slideUp("fast"); 1843 setTimeout(function() { 1844 $(".tabs .tabheader li.tab" + nr + "toggle").addClass("on"); 1845 $(".tabs .tab" + nr).slideDown("slow", function() {}); 1846 }, 400); 1847} 1848 1849function toggleMenu() { 1850 playSound("klick"); 1851 if ($("#body_id").hasClass("menu_on")) { 1852 setMenu("off"); 1853 } else { 1854 setMenu("on"); 1855 } 1856} 1857 1858function setMenu(modus) { 1859 if (modus == "off") { 1860 $("#body_id").removeClass("menu_on"); 1861 $("#html_id").removeClass("menu_on"); 1862 $("#nav .nav_list").removeClass("blink_in"); 1863 $("#nav .nav_list").addClass("blink_out"); 1864 setTimeout(function() { $("#nav .nav_list").css("display","none"); }, 500); 1865 } else { 1866 $("#body_id").addClass("menu_on"); 1867 $("#html_id").addClass("menu_on"); 1868 $("#nav .nav_list").css("display","block"); 1869 $("#nav .nav_list").addClass("blink_in"); 1870 $("#nav .nav_list").removeClass("blink_out"); 1871 } 1872} 1873 1874function initFacebook(app_id,locale) { 1875 var s = "script"; 1876 var id = "facebook-jssdk"; 1877 var js, fjs = document.getElementsByTagName(s)[0]; 1878 if (document.getElementById(id)) return; 1879 js = document.createElement(s); js.id = id; 1880 js.src = "https://connect.facebook.net/" + locale + "/sdk.js#xfbml=1&version=v2.8&appId=" + app_id; 1881 fjs.parentNode.insertBefore(js, fjs); 1882} 1883 1884function doScroll(el) { 1885 doLog("doScroll(" + el + ")"); 1886 yOffset = -1 * $(".header_norm").outerHeight(); 1887 // yOffset -= 20;
1888 $.scrollTo(el, 800, { 1889 axis: "y", 1890 offset: yOffset, 1891 onAfter: function () { 1892 } 1893 }); 1894} 1895 1896function doScrollTop() { 1897 playSound('klick'); 1898 doScroll('#article'); 1899 return false; 1900} 1901 1902function doSlideToggle(el) { 1903 playSound('slide'); 1904 $(el + "-toggle").toggleClass("on"); 1905 $(el).slideToggle(); 1906 return false; 1907} 1908 1909function doGetContent(section) { 1910 playSound('klick'); 1911 getContent(lang,section,"","","","",0); 1912 return false; 1913} 1914 1915function initNav() { 1916 doLog("initNav()"); 1917 if (main == "index") { 1918 /* 1919 $('#nav .nav_page a').on("click", function() { 1920 var section = $(this).data('href'); 1921 doGetContent(section); 1922 return false; 1923 }); 1924 */ 1925 $('#nav a.settings_link').on("click", function() { 1926 playSound('klick'); 1927 }); 1928 } 1929 if (device == "") { 1930 initNavKeyboard(); 1931 } 1932 // setMenu("off"); 1933} 1934 1935function initNavKeyboard() { 1936 console.log("initNavKeyboard()"); 1937 $(document).on('keypress', function(event) { 1938 if(!$(event.target).is(':input')) { 1939 // console.log(event); 1940 switch(event.key) { 1941 case "h": 1942 getContent(lang,"home","","","","",0); 1943 break 1944 case "v": 1945 getContent(lang,"video","","","","",0); 1946 break; 1947 case "d": 1948 getContent(lang,"dates","","","","",0); 1949 break; 1950 case "m": 1951 getContent(lang,"music","","","","",0); 1952 break; 1953 case "s": 1954 getContent(lang,"shop","","","","",0); 1955 break; 1956 case "p": 1957 getContent(lang,"playlist","","","","",0); 1958 break; 1959 case "n": 1960 getContent(lang,"newsletter","","","","",0); 1961 break; 1962 case "c": 1963 // close 1964 setMenu('off'); 1965 break; 1966 default: 1967 break; 1968 } 1969 } 1970 }); 1971} 1972 1973function hiliteNav(section,type,subtype,id) { 1974 $("#nav .nav_page").removeClass("on"); 1975 if (section != "") { 1976 $("#nav .nav_" + section).addClass("on"); 1977 } 1978} 1979 1980function initFancybox() { 1981 Fancybox.bind("[data-fancybox]", { 1982 placeFocusBack: false, 1983 Hash: false, 1984 }); 1985} 1986 1987function doTruncate(identifier, limit) { 1988 if (lang === "de") { 1989 var showText = "Mehr anzeigen"; 1990 var hideText = "Weniger anzeigen"; 1991 } else { 1992 var showText = "Show more"; 1993 var hideText = "Show less"; 1994 } 1995 if (isNaN(limit)) { limit = 7; } 1996 $(identifier).truncate({ 1997 "maxLines": limit, 1998 "truncateString": " …", 1999 "showText": "<div class='more clearfix'><span class='border title'>" + showText + "</span> <span class='icon icon-down-open'></span></div>", 2000 "hideText": "<div class='more clearfix'><span class='border title'>" + hideText + "</span> <span class='icon icon-up-open'></span></div>", 2001 "animate": true, 2002 "animateOptions": { 'complete': function() { 2003 $(identifier).css("height","auto"); 2004 sRefresh(); 2005 if ($(this).data("status") === "open") { 2006 $(this).data("status","closed"); 2007 var yOffset = -1 * $(".header_compact").height(); 2008 yOffset -= 10; 2009 var myId = $(this).attr("id"); 2010 if (!myId) { 2011 myId = "trunc_" + myRandom(100000, 999999); 2012 $(this).attr("id",myId); 2013 } 2014 var target = $("#" + myId); 2015 $.scrollTo(target, 1000, { 2016 axis: "y", 2017 offset: yOffset, 2018 duration: 3000, 2019 onAfter: function () {} 2020 }); 2021 } else { 2022 $(this).data("status","open"); 2023 } 2024 } } 2025 }); 2026} 2027 2028function initLazysizes() { 2029 lazySizes.init(); 2030} 2031 2032function urldecode(str) { 2033 return decodeURIComponent((str+'').replace(/\+/g, ' ')); 2034} 2035 2036function doLog(txt) { 2037 node = document.getElementById("log"); 2038 if (node) { node.innerHTML = txt + "<br>" + node.innerHTML; } 2039 if (console) { console.log(txt); } 2040} 2041 2042function doStats(txt,modus) { 2043 doLog("doStats(" + txt + "," + modus + ")"); 2044 if (modus == "clear") { 2045 if (txt != "") { 2046 // doAnim("#stats", "flash"); 2047 $("#stats").empty(); 2048 $("#stats").append("<li>" + txt + "</li>"); 2049 } else { 2050 doAnim("#stats", "flash"); 2051 doAnim("#stats li:nth-child(n+2)", "shake"); 2052 setTimeout(function() { 2053 $("#stats").empty(); 2054 }, 500); 2055 } 2056 } else { 2057 $("#stats").append("<li>" + txt + "</li>"); 2058 // document.getElementById("stats").innerHTML += "<li>" + txt + "</li>"; 2059 } 2060} 2061 2062function doTrack(category, action, label) { 2063 if (category != "" && action != "") { 2064 // gtag.js 2065 /* 2066 try { 2067 dataLayer.push({'event':'GAEvent', 'attributes': {'eventCategory': '' + category + '', 'eventAction': '' + action +'', 'eventLabel': '' + label + '' }}); 2068 } catch(err) {} 2069 */ 2070 // analytics.js 2071 try { 2072 ga('send', 'event', category, action, label); 2073 ga('clientTracker.send', 'event', category, action, label); 2074 } catch(err) {} 2075 // ga.js: 2076 // _gaq.push(['_trackEvent', category, action, label]); 2077 } 2078 doLog("doTrack(" + category + " | " + action + " | " + label + ")"); 2079} 2080 2081function initSvg() { 2082 $('img.svg').each(function(){ 2083 var $img = $(this); var imgID = $img.attr('id'); var imgClass = $img.attr('class'); var imgURL = $img.attr('src'); 2084 $.get(imgURL, function(data) { 2085 var $svg = $(data).find('svg'); 2086 if (typeof imgID !== 'undefined') { $svg = $svg.attr('id', imgID); } 2087 if (typeof imgClass !== 'undefined') { $svg = $svg.attr('class', imgClass+' replaced-svg'); } 2088 $svg = $svg.removeAttr('xmlns:a'); $img.replaceWith($svg); 2089 }, 'xml'); 2090 }); 2091} 2092 2093// wca (facebook website custom audiences) 2094function wcaCtrl(modus) { 2095 var domain = location.hostname.replace('www.','').replace('m.',''); 2096 if (modus === "off") { 2097 document.cookie = "fb_umg_disabled=1; expires=Thu, 31 Dec 2099 23:59:59 UTC; domain=." + domain + "; path=/"; 2098 alert('Facebook WCA is now disabled for this site'); 2099 } else { 2100 document.cookie = "fb_umg_disabled=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC; domain=." + domain; 2101 alert('Facebook WCA is now enabled for this site'); 2102 } 2103} 2104 2105function getCacheControl() { 2106 var date = new Date(); 2107 var year = date.getUTCFullYear();
2108 var month = date.getUTCMonth(); 2109 month++; // (from 0-11) 2110 if (month < 10) { month = "0" + month; } 2111 var day = date.getUTCDate(); 2112 if (day < 10) { day = "0" + day; } 2113 var hour = date.getUTCHours(); 2114 if (hour < 10) { hour = "0" + hour; } 2115 var minutes = date.getUTCMinutes(); 2116 switch(true) { case minutes>45:minutes="45";break; case minutes>30:minutes="30";break; case minutes>15:minutes="15";break; default:minutes="00";break; } 2117 var c = year + month + day + "-" + hour + minutes; 2118 return c; 2119} 2120 2121function getDate() { 2122 var date = new Date(); 2123 var year = date.getUTCFullYear(); 2124 var month = date.getUTCMonth(); 2125 month++; // (from 0-11) 2126 if (month < 10) { month = "0" + month; } 2127 var day = date.getUTCDate(); 2128 if (day < 10) { day = "0" + day; } 2129 2130 var hour = date.getUTCHours(); 2131 if (hour < 10) { hour = "0" + hour; } 2132 var minutes = date.getUTCMinutes(); 2133 if (minutes < 10) { minutes = "0" + minutes; } 2134 var seconds = date.getUTCSeconds(); 2135 if (seconds < 10) { seconds = "0" + seconds; } 2136 var d = day + "/" + month + "/" + year + " " + hour + ":" + minutes + ":" + seconds; 2137 return d; 2138} 2139 2140function winopen(url,name,w,h) { 2141 var w_shift = Number((screen.width/2)-(w/2)); 2142 var h_shift = Number((screen.height/2)-(h/2)); 2143 var newWin = window.open(url, name, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+w+', height='+h+', left='+w_shift+', top='+h_shift); 2144 newWin.focus(); 2145} 2146 2147function capitalizeFirstLetter(string) { 2148 return string.charAt(0).toUpperCase() + string.slice(1); 2149} 2150 2151function getCookieValue(a) { // thx 2 mac: http://stackoverflow.com/questions/5639346/#answer-25490531 2152 var b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)'); 2153 return b ? b.pop() : ''; 2154} 2155 2156function getRequestVar(name){ 2157 if (name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search)) { return decodeURIComponent(name[1]); } 2158} 2159 2160function kill(id) { 2161 element = document.getElementById(id); 2162 if (element) { 2163 var parent = element.parentNode; 2164 if (parent) { 2165 parent.removeChild(element); 2166 } 2167 } 2168 return false; 2169} 2170 2171// thx Jonas Raoni Soares Silva, http://jsfromhell.com/array/shuffle [rev. #1] // usage: var a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; alert('shuffle(a): ' + shuffle(a)); 2172function shuffle(v) { 2173 for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x); 2174 return v; 2175}; 2176 2177function myRandom(a, b) { 2178 if (a > b) { return(-1); } 2179 if (a === b) { return(a); } 2180 return a + parseInt(Math.random() * ( b - a+1 )); 2181} 2182 2183// peace out
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.