123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- function setActiveStyleSheet(title) {
- var i, a, main;
- for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
- if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
- a.disabled = true;
- if(a.getAttribute("title") == title) a.disabled = false;
- }
- }
- }
- function getActiveStyleSheet() {
- var i, a;
- for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
- if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
- }
- return null;
- }
- function getPreferredStyleSheet() {
- var i, a;
- for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
- if(a.getAttribute("rel").indexOf("style") != -1
- && a.getAttribute("rel").indexOf("alt") == -1
- && a.getAttribute("title")
- ) return a.getAttribute("title");
- }
- return null;
- }
- function createCookie(name,value,days) {
- if (days) {
- var date = new Date();
- date.setTime(date.getTime()+(days*24*60*60*1000));
- var expires = "; expires="+date.toGMTString();
- }
- else expires = "";
- document.cookie = name+"="+value+expires+"; path=/";
- }
- function readCookie(name) {
- var nameEQ = name + "=";
- var ca = document.cookie.split(';');
- for(var i=0;i < ca.length;i++) {
- var c = ca[i];
- while (c.charAt(0)==' ') c = c.substring(1,c.length);
- if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
- }
- return null;
- }
- window.onload = function(e) {
- var cookie = readCookie("style");
- var title = cookie ? cookie : getPreferredStyleSheet();
- setActiveStyleSheet(title);
- }
- window.onunload = function(e) {
- var title = getActiveStyleSheet();
- createCookie("style", title, 365);
- }
- var cookie = readCookie("style");
- var title = cookie ? cookie : getPreferredStyleSheet();
- setActiveStyleSheet(title);
- function addText(elId,text) {
- text = ">>" + text + " \n";
- document.getElementById(elId).value += text;
- document.getElementById(elId).focus();
- }
- "use strict";
- function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}
- r(function(){
- if(!document.getElementsByClassName) {
- // IE8 support
- var getElementsByClassName = function(node, classname) {
- var a = [];
- var re = new RegExp('(^| )'+classname+'( |$)');
- var els = node.getElementsByTagName("*");
- for(var i=0,j=els.length; i<j; i++)
- if(re.test(els[i].className))a.push(els[i]);
- return a;
- }
- var videos = getElementsByClassName(document.body,"youtube");
- }
- else {
- var videos = document.getElementsByClassName("youtube");
- }
- var nb_videos = videos.length;
- for (var i=0; i<nb_videos; i++) {
- // Based on the YouTube ID, we can easily find the thumbnail image
- videos[i].style.backgroundImage = 'url(http://i.ytimg.com/vi/' + videos[i].id + '/mqdefault.jpg)';
- // Overlay the Play icon to make it look like a video player
- var play = document.createElement("div");
- play.setAttribute("class","play");
- videos[i].appendChild(play);
- videos[i].onclick = function() {
- // Create an iFrame with autoplay set to true
- var iframe = document.createElement("iframe");
- var iframe_url = "https://www.youtube.com/embed/" + this.id + "?autoplay=1&autohide=1";
- if (this.getAttribute("data-params")) iframe_url+='&'+this.getAttribute("data-params");
- iframe.setAttribute("src",iframe_url);
- iframe.setAttribute("frameborder",'0');
- // The height and width of the iFrame should be the same as parent
- iframe.style.width = this.style.width;
- iframe.style.height = this.style.height;
- // Replace the YouTube thumbnail with YouTube Player
- this.parentNode.replaceChild(iframe, this);
- }
- }
- });
|