1// requestAnimationFrame polyfill 2(function() { 3 var lastTime = 0; 4 var vendors = ["ms", "moz", "webkit", "o"]; 5 for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { 6 window.requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"]; 7 window.cancelAnimationFrame = 8 window[vendors[x] + "CancelAnimationFrame"] || 9 window[vendors[x] + "CancelRequestAnimationFrame"]; 10 } 11 12 if (!window.requestAnimationFrame) 13 window.requestAnimationFrame = function(callback, element) { 14 var currTime = new Date().getTime(); 15 var timeToCall = Math.max(0, 16 - (currTime - lastTime)); 16 var id = window.setTimeout(function() { 17 callback(currTime + timeToCall); 18 }, timeToCall); 19 lastTime = currTime + timeToCall; 20 return id; 21 }; 22 23 if (!window.cancelAnimationFrame) 24 window.cancelAnimationFrame = function(id) { 25 clearTimeout(id); 26 }; 27})(); 28 29/** 30 * Window resizer 31 * 32 * @author Jari Pennanen 33 */ 34jQuery.winResizer = function(fn, t) { 35 var ct = null, 36 t = typeof t == "undefined" ? 10 : t; 37 38 var win = jQuery(window), 39 update = function() { 40 fn(win.width(), win.height()); 41 clearTimeout(ct); 42 ct = null; 43 }; 44 45 setTimeout(update, 0); 46 setTimeout(update, t); 47 win.resize(function() { 48 if (!ct) { 49 ct = setTimeout(update, t); 50 } 51 }); 52}; 53 54/** 55 * Format datetime like php.net/date 56 */ 57function formatDatetime(format, dt) { 58 for (var i = format.length - 1; i >= 0; i--) { 59 var p = (i > 0 && format[i - 1]) || false, 60 c = format[i], 61 f = datePlaceholders[c]; 62 if (p === "\\") { 63 format = format.substring(0, i - 1) + c + format.substring(i + 1); 64 i--; 65 continue; 66 } else if (!f) { 67 continue; 68 } 69 format = 70 format.substring(0, i) + 71 (typeof f == "string" ? dt[f]() : f(dt)) + 72 format.substring(i + 1); 73 } 74 return format; 75} 76 77/** 78 * Parse ISO datetime 79 * 80 * 2014-10-18 15:30:30 81 * 2014-10-18T15:30:30 82 * 2014-10-18 83 * @author Jari Pennanen 84 */ 85function parseIsoDatetime(dtstr) { 86 var dt = dtstr.split(/[: T-]/).map(parseFloat); 87 return new Date(dt[0], dt[1] - 1, dt[2], dt[3] || 0, dt[4] || 0, dt[5] || 0, 0); 88} 89 90/** 91 * jQuery since 92 * 93 * @version 0.0.1 94 * @author Jari Pennanen 95 * @license FreeBSD 96 **/ 97(function($) { 98 /** 99 * Since function 100 * 101 * @param Date oldDate 102 * @returns string 103 */ 104 function since(oldDate) { 105 var msSince = new Date().getTime() - oldDate; 106 107 var ago = [ 108 [OWNSKIT.fmt_years_ago, msSince / (1000 * 60 * 60 * 24 * 365)], 109 [OWNSKIT.fmt_weeks_ago, msSince / (1000 * 60 * 60 * 24 * 7)], 110 [OWNSKIT.fmt_days_ago, msSince / (1000 * 60 * 60 * 24)], 111 [OWNSKIT.fmt_hours_ago, msSince / (1000 * 60 * 60)], 112 [OWNSKIT.fmt_minutes_ago, msSince / (1000 * 60)], 113 [OWNSKIT.fmt_right_now, 1] 114 ]; 115 116 for (var i = 0; i <= ago.length; i++) { 117 var txt = ago[i][0], 118 time = ago[i][1]; 119 120 if (Math.floor(time)) { 121 return txt.replace("§", Math.floor(time)); 122 } 123 } 124 } 125 126 $.fn.since = function(d) { 127 $.each(this, function() { 128 var self = $(this), 129 date = d || ($(this).data("date") && parseIsoDatetime($(this).data("date"))), 130 count = function() { 131 self.text(since(date)); 132 setTimeout(count, 60000); 133 }; 134 135 if (!date) { 136 return this; 137 } 138 139 count(); 140 }); 141 return this; 142 }; 143})(jQuery); 144 145/** 146 * jQuery Dialog 147 * 148 * @version 0.1.0 149 * @author Jari Pennanen 150 * @license FreeBSD 151 **/ 152(function($) { 153 var template = 154 "" + 155 '<div class="dialog-container"><div class="dialog">' + 156 '<a href="#" class="dialog-close"></a>' + 157 '<div class="dialog-content"></div>' + 158 "</div></div>"; 159 160 /** 161 * Geneerinen dialogi 162 * 163 * @param _settings object 164 */ 165 function Dialog(_settings) { 166 var self = this; 167 168 /** 169 * Elementti 170 */ 171 var body = $("body"), 172 ui = $(template) 173 .addClass("hidden") 174 .appendTo(body), 175 keypress = function(e) { 176 if (e.keyCode == 27) { 177 self.hide(); 178 e.preventDefault(); 179 } 180 }; 181 182 this.ui = ui; 183 this.contentEl = ui.find(".dialog-content"); 184 this.titleEl = ui.find(".dialog-header"); 185 186 ui.on("click", function(e) { 187 if ($(e.target).is(".dialog-container,.dialog-close")) { 188 self.hide(); 189 e.preventDefault(); 190 } 191 }); 192 193 /** 194 * Show dialog 195 */ 196 this.show = function() { 197 ui.addClass("show") 198 .removeClass("hide hidden") 199 .trigger("dialog-show", [self]); 200 body.on("keydown", keypress); 201 setTimeout(function() { 202 body.addClass("dialog-shown"); 203 }, 0); 204 return self; 205 }; 206 207 /** 208 * Hide dialog 209 */ 210 this.hide = function() { 211 var self = this; 212 ui.addClass("hide") 213 .removeClass("show") 214 .trigger("dialog-hide", [self]); 215 body.off("keydown", keypress); 216 setTimeout(function() { 217 ui.removeClass("hide") 218 .addClass("hidden") 219 .trigger("dialog-hidden", [self]); 220 body.removeClass("dialog-shown"); 221 setTimeout(function() { 222 self.destroy(); 223 }, 500); 224 }, 0); 225 }; 226 227 /** 228 * Remove dialog ui 229 */ 230 this.destroy = function() { 231 ui.remove(); 232 }; 233 } 234 235 /** 236 * Show dialog 237 */ 238 $.dialog = function(_settings) { 239 var d = new Dialog(); 240 setTimeout(function() { 241 d.show(); 242 }, 0); 243 d.ui.on("dialog-hidden", function() { 244 d.destroy(); 245 }); 246 return d; 247 }; 248})(jQuery); 249 250/** 251 * jQuery Slidefy 252 * 253 * @version 0.2.6 254 * @author Jari Pennanen 255 * @license FreeBSD 256 * 257 * Requires requestAnimationFrame polyfill for timing 258 * 259 * @changed 260 * 2014-12-03 - sliderEl.children() -> sliderEl.find() 261 * 2015-01-26 - Slide properties data-time-wait="", data-time-animation="" 262 * in milliseconds 263 * 2015-05-26 - Progress bar global, or individually for each navigation bullet 264 * 2015-06-15 - slideSelector and jumpSelector was hard coded, 265 * jumpSelector works automatically without data-jump-to if it's inside e.g. li>a.jump 266 * 2016-03-03 - Modified touchSwipe parameters 267 * 2016-06-10 - Change of slide changes the url hash (hashChange) property 268 **/ 269(function($) { 270 $.slidefy = { 271 defaultSettings: {
272 startPlay: false, 273 waitTime: 7000, 274 first: 0, // Start slide index 275 delaySelectedRemove: 0, // Delay selected removal 276 hashChange: false, 277 slideSelector: ".slide", 278 nextSelector: "a.next", 279 prevSelector: "a.prev", 280 jumpSelector: "a.jump", 281 // Slider bar: inside each navigation bullet, OR single element in slider 282 slideBarSelector: ".slide-bar > i", 283 touchSwipe: false, 284 keyboard: false 285 } 286 }; 287 288 function cyclic(i, count) { 289 var n = i % count; 290 if (n < 0) return n + count; 291 return n; 292 } 293 294 function Slidefy(ui, _settings) { 295 var self = this, 296 win = $(window), 297 opts = $.extend({}, $.slidefy.defaultSettings, _settings), 298 sliderEl = ui, 299 jumpEls = sliderEl.find(opts.jumpSelector), 300 slideEls = sliderEl.find(opts.slideSelector), 301 slideBarEl = sliderEl.find(opts.slideBarSelector), 302 slideBarElItem = slideBarEl.get(0), 303 count = slideEls.length, 304 current = slideEls.filter(".init").index(), 305 zIndexContinuos = 11, 306 autoPlayAnimationLoop = null; 307 308 if (count <= 1) { 309 ui.find(opts.jumpSelector).hide(0); 310 ui.find(opts.nextSelector).hide(0); 311 ui.find(opts.prevSelector).hide(0); 312 return; 313 } 314 315 this.ui = ui; 316 this.settings = opts; 317 318 function _beginPlayTimeout() { 319 var wait = slideEls.eq(current).data("time-wait") || opts.waitTime, 320 start = 0; 321 if (autoPlayAnimationLoop) { 322 cancelAnimationFrame(autoPlayAnimationLoop); 323 } 324 if (slideBarElItem) { 325 slideBarElItem.style.width = "0%"; 326 } 327 var barAnimationCb = function(t) { 328 if (start === 0) { 329 start = t; 330 } 331 var distance = t - start; 332 if (slideBarElItem) { 333 var progress = Math.round((distance / wait) * 100 * 100) / 100; 334 slideBarElItem.style.width = progress + "%"; 335 } 336 if (distance >= wait) { 337 self.autoPlay(); 338 } else { 339 autoPlayAnimationLoop = requestAnimationFrame(barAnimationCb); 340 } 341 }; 342 autoPlayAnimationLoop = requestAnimationFrame(barAnimationCb); 343 } 344 345 function _endPlayTimeout() { 346 if (slideBarElItem) { 347 slideBarElItem.style.width = "0%"; 348 } 349 if (autoPlayAnimationLoop) { 350 cancelAnimationFrame(autoPlayAnimationLoop); 351 } 352 } 353 354 slideEls.each(function() { 355 var slide = $(this), 356 animTime = slide.data("time-animation"); 357 if (animTime) { 358 slide.css("transition-duration", animTime + "ms"); 359 } 360 }); 361 362 /** 363 * Jump to slide 364 */ 365 this.jumpTo = function(i) { 366 var next = cyclic(i, count); 367 if (next !== current) { 368 (function(c) { 369 setTimeout(function() { 370 if (c == current) { 371 slideEls.eq(c).removeClass("removing gt lt"); 372 return; 373 } 374 slideEls.eq(c).removeClass("selected removing gt lt"); 375 }, opts.delaySelectedRemove); 376 })(current); 377 slideEls 378 .eq(current) 379 .removeClass("gt lt init") 380 .addClass("removing " + (i < current ? "gt" : "lt")); 381 } 382 jumpEls.eq(current).removeClass("selected"); 383 jumpEls.eq(next).addClass("selected"); 384 if (slideBarEl.length > 1) { 385 slideBarElItem = slideBarEl.eq(next).get(0); 386 } 387 if (opts.hashChange) { 388 if (window.history) { 389 history.pushState(null, null, "#" + slideEls.eq(next).attr("id")); 390 } 391 } 392 slideEls 393 .eq(next) 394 .css("z-index", zIndexContinuos++) 395 .addClass("selected " + (i > current ? "gt" : "lt")); 396 current = next; 397 return self; 398 }; 399 400 this.resetPlaying = function() { 401 if (sliderEl.is(".playing")) { 402 _beginPlayTimeout(); 403 } 404 }; 405 406 this.startPlay = function() { 407 sliderEl.addClass("playing").removeClass("paused"); 408 _beginPlayTimeout(); 409 return self; 410 }; 411 412 this.stopPlay = function() { 413 sliderEl.removeClass("playing").addClass("paused"); 414 _endPlayTimeout(); 415 return self; 416 }; 417 418 this.autoPlay = function() { 419 sliderEl.addClass("playing").removeClass("paused"); 420 self.jumpTo(current + 1); 421 _beginPlayTimeout(); 422 return self; 423 }; 424 425 $(function() { 426 if (opts.startPlay) { 427 self.startPlay(); 428 } 429 if (opts.touchSwipe && jQuery.fn.swipe) { 430 ui.swipe({ 431 swipeLeft: function() { 432 self.jumpTo(current + 1); 433 self.resetPlaying(); 434 }, 435 swipeRight: function() { 436 self.jumpTo(current - 1); 437 self.resetPlaying(); 438 } 439 }); 440 } 441 if (opts.keyboard) { 442 win.on("keydown", function(e) { 443 if (e.keyCode == 39) { 444 self.jumpTo(current + 1); 445 self.resetPlaying(); 446 } else if (e.keyCode == 37) { 447 self.jumpTo(current - 1); 448 self.resetPlaying(); 449 } 450 }); 451 } 452 if (opts.hashChange) { 453 var id = location.hash, 454 index = slideEls.filter(id).index(); 455 if (index !== -1) { 456 self.jumpTo(index); 457 setTimeout(function() { 458 $("html,body").animate({ scrollTop: slideEls.eq(current).offset().top }, 0); 459 }, 10); 460 } 461 } 462 ui.on("click", opts.jumpSelector, function(e) { 463 var j = $(this).data("jump-to"); 464 if (typeof j === "undefined") { 465 j = $(this) 466 .parent() 467 .index(); 468 } 469 self.jumpTo(0 + j); 470 self.resetPlaying(); 471 e.preventDefault(); 472 }); 473 ui.on("click", opts.nextSelector, function(e) { 474 self.jumpTo(current + 1); 475 self.resetPlaying(); 476 e.preventDefault(); 477 }); 478 ui.on("click", opts.prevSelector, function(e) { 479 self.jumpTo(current - 1); 480 self.resetPlaying(); 481 e.preventDefault(); 482 }); 483 }); 484 } 485 486 $.fn.slidefy = function(_settings) { 487 $(this).each(function() { 488 if (!$(this).data("slidefy")) $(this).data("slidefy", new Slidefy($(this), _settings)); 489 }); 490 return this; 491 }; 492})(jQuery); 493 494/** 495 * Window Scroller 496 * 497 * @author Jari Pennanen 498 */ 499jQuery.winScroller = function(fn, t) { 500 var ct = null, 501 t = typeof t == "undefined" ? 10 : t; 502 503 var win = jQuery(window), 504 update = function() { 505 fn(win.scrollTop(), win.scrollLeft(), win.width(), win.height()); 506 clearTimeout(ct); 507 ct = null; 508 }, 509 fnt = function() { 510 if (!ct) { 511 ct = setTimeout(update, t); 512 } 513 }; 514 515 setTimeout(update, 0); 516 setTimeout(update, t); 517 win.resize(fnt).scroll(fnt); 518}; 519 520function slugify(text) { 521 return text 522 .toString() 523 .toLowerCase() 524 .replace(/\s+/g, "-") // Replace spaces with - 525 .replace(/[^\w\-]+/g, "") // Remove all non-word chars 526 .replace(/\-\-+/g, "-") // Replace multiple - with single - 527 .replace(/^-+/, "") // Trim - from start of text 528 .replace(/-+$/, ""); // Trim - from end of text 529} 530 531jQuery(function($) { 532 var win = $(window), 533 html = $("html") 534 .removeClass("no-js") 535 .addClass("js"), 536 body = $("body"); 537 538 body.toggleClass("ios", /(iPad|iPhone|iPod)/g.test(navigator.userAgent)); 539 540 $("#go-top").click(function(e) { 541 $("html,body").animate({ scrollTop: 0 }, "fast"); 542 e.preventDefault(); 543 }); 544 545 $("table").each(function() { 546 var titles = $(this) 547 .find("thead th") 548 .map(function() { 549 return $(this).text(); 550 }); 551 $(this) 552 .find("tbody tr") 553 .each(function() { 554 $(this) 555 .find("td") 556 .each(function(i) { 557 $(this).attr("data-label", titles[i]); 558 }); 559 }); 560 }); 561 562 body.on("click", "a[href*='#']", function(e) { 563 var currentUrl = location.protocol + "//" + location.host + location.pathname; 564 var href = $(this).attr("href") || "", 565 hash = ""; 566 567 if (href[0] === "#") { 568 hash = href.slice(1); 569 } else if (href.startsWith && href.startsWith(currentUrl)) { 570 hash = href.split("#")[1]; 571 } else { 572 return; 573 } 574 575 var items = $("#" + hash); 576 if (items.length) { 577 var o = items.offset(); 578 $("html, body") 579 .stop() 580 .animate({ scrollTop: o.top + "px" }, "fast"); 581 e.preventDefault(); 582 } 583 }); 584 585 $(".slider").slidefy({ 586 startPlay: true 587 }); 588 589 if ($.magnificPopup && $.magnificPopup.defaults) { 590 $.magnificPopup.defaults.closeMarkup = 591 '<a title="%title%" type="button" class="mfp-close">×</a>'; 592 } 593 594 $(".gallery a").magnificPopup({ 595 type: "image", 596 gallery: { 597 enabled: true 598 } 599 }); 600 601 $(".since").since(); 602 603 // Iframe resizing 604 (function() { 605 // Iframe resizing 606 var resizeIframeEls, fitIframeEls; 607 608 function findResizeIframes() { 609 resizeIframeEls = $("iframe") 610 .not(".not-resize") 611 .not(".fit") 612 .each(function() { 613 var iframe = $(this); 614 if (!iframe.attr("width") || !iframe.attr("height")) return; 615 iframe.addClass("auto-resize"); 616 }) 617 .filter(".auto-resize"); 618 619 fitIframeEls = $("iframe.fit"); 620 resizeIframes(); 621 } 622 623 function fitIframes() { 624 var winWidth = win.width() - 16 - 5, 625 winHeight = win.height() - 47 - 5, 626 winAr = winHeight / winWidth; 627 628 fitIframeEls.each(function() { 629 var iframe = $(this), 630 w = iframe.attr("width"), 631 h = iframe.attr("height"), 632 ar = h / w; 633 634 if (ar < winAr) { 635 iframe.css("width", "100%"); 636 iframe.css("height", Math.ceil(iframe.outerWidth() * ar) + "px"); 637 } else { 638 var newH = winHeight; 639 iframe.css("width", Math.ceil(newH / ar) + "px"); 640 iframe.css("height", Math.ceil(newH) + "px"); 641 } 642 }); 643 } 644 645 function resizeIframes() { 646 fitIframes(); 647 648 resizeIframeEls.each(function() { 649 var iframe = $(this), 650 ar = iframe.attr("height") / iframe.attr("width"); 651 iframe.css("width", "100%"); 652 iframe.css("height", Math.ceil(iframe.outerWidth() * ar) + "px"); 653 }); 654 } 655 findResizeIframes(); 656 $.winResizer(resizeIframes, 30); 657 658 $(".play-embed-popup").magnificPopup({ 659 preloader: false, 660 callbacks: { 661 open: function() { 662 $(".mfp-content iframe") 663 .addClass("not-resize") 664 .addClass("fit"); 665 findResizeIframes(); 666 } 667 } 668 }); 669 })(); 670 671 // Mobile menu 672 (function() { 673 var navMobile = $("#navigation-mobile") 674 .find("a") 675 .click(function() { 676 body.removeClass("show-mobile-menu"); 677 }), 678 navMobileContainer = navMobile.children(); 679 // $("#navigation-top").find('ul.menu').eq(0).clone().find('li').removeAttr('id').end().appendTo(navMobileContainer); 680 // $("#header").find('.socmed-follow').eq(0).clone().find('li').removeAttr('id').end().appendTo(navMobileContainer); 681 $("#more-mobile-menu2").click(function(e) { 682 body.toggleClass("show-mobile-menu"); 683 e.preventDefault(); 684 }); 685 })(); 686 687 // Scrolled 688 (function() { 689 var scrollT = null, 690 checkScroll = function() { 691 var top = win.scrollTop(); 692 body.toggleClass("scrolled", top > 1); 693 scrollT = null; 694 }, 695 handleScroll = function() { 696 if (scrollT) { 697 return; 698 } 699 if (!scrollT) { 700 checkScroll(); 701 } 702 scrollT = setTimeout(checkScroll, 30); 703 }; 704 win.scroll(handleScroll).resize(handleScroll); 705 setTimeout(checkScroll, 500); 706 })(); 707 // Scrolled 708 (function() { 709 var scrollT = null, 710 checkScroll = function() { 711 var top = win.scrollTop(); 712 body.toggleClass("scrolled2", top > 500); 713 scrollT = null; 714 }, 715 handleScroll = function() { 716 if (scrollT) { 717 return; 718 } 719 if (!scrollT) { 720 checkScroll(); 721 } 722 scrollT = setTimeout(checkScroll, 30); 723 }; 724 win.scroll(handleScroll).resize(handleScroll); 725 setTimeout(checkScroll, 500); 726 })(); 727});
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.