/*********************************************************************** paceDelay.js ************************************************************************ Do not change this file unless it should change for all users. This file defines functions that deal with Pace and Delays ************************************************************************/ Content.prototype.Pace = function(){ } Content.prototype.SetPace = function(pace){ var curr = Number(getCookie("thepace")); var thepace = curr; if(typeof pace == "undefined"){ if(curr == paces[0]){ thepace = paces[paces.length-1]; }else{ thepace = Number(thepace) - speedstep; thepace = Math.round(thepace*100)/100; }; }else{ thepace = paces[paces.length-1]; } setCookie("thepace",thepace,360); window.location.reload(); } Content.prototype.EnablePace = function(){ var c = this; //$("#speedBtn").unbind("click"); $("#speedBtn").click(function(e){ c.SetPace(); }); $("#speedImage").mouseenter(function(e){ var src = c.Pace(); var nsrc = src.split("."); $(this).attr("src",nsrc[0]+"_down."+nsrc[1]); }); $("#speedImage").mouseleave(function(e){ $(this).attr("src",c.Pace()); }); } Content.prototype.DisablePace = function(){ $("#speedBtn").unbind("click"); $("#speedImage").unbind("mouseenter"); $("#speedImage").unbind("mouseleave"); } Content.prototype.makeDelay = function(){ var c = this; //Spara undan delay-värden i array pageDelays $("."+elements.delay).each(function(i,v){ if(parseInt($(this).text()) >= 0){ c.pageDelays.push(parseInt($(this).text())); }; }); var index = 0; //Läs in samtliga divs på sidan var divsTotal = $("div"); $(divsTotal).each(function(i,v){ //Hitta samtliga element mellan delay a och delay b if($(this).hasClass(elements.delay)){ //Om delay == -1, avbryt if(parseInt($(this).text()) >= 0){ //Addera variabeln totalTime med innehållet i pageDelays totalTime += c.pageDelays[index]; //Dimma ner objekten var nexts = $(this).nextUntil("."+elements.delay); var nexts2 = $(this).nextUntil("."+elements.delay).filter(":first"); var hasCharacter = /[a-z]/i.test($(nexts2).text().toLowerCase()); if(!hasCharacter){ nexts2 = $(this).nextUntil("."+elements.delay).filter(":first").next(); } hasCharacter = /[a-z]/i.test($(nexts2).text().toLowerCase()); $(nexts).each(function(ii,vv){ if($(this).hasClass("overlay")){ $(this).addClass("hideImage"); $(this).addClass("dimmed_"+index); }else if($(this).hasClass("list")){ }else{ if($(this).attr("class") != undefined){ $(this).addClass("textdim"); $(this).addClass("dimmed_"+index); } } }); //Sätt timeout för att highlighta objekten var tempCount = 0; $(nexts).each(function(ii,vv){ tempCount++; var dimmedObj = $(this); var tempIndex = index; timer = setTimeout(function(){ highlight(dimmedObj,tempIndex); },totalTime*globalTime); }); $(nexts2).each(function(ii,vv){ var soundObj = $(this); var tempIndex = index; soundtimer = setTimeout(function(){ startSound(soundObj); },totalTime*globalTime); }); index++; }; }; }); function setDivsToSkip(){ var skips = $(".p, .item"); $(skips).each(function(ii,vv){ if(!$(this).hasClass("rs_skip")){ $(this).addClass("rs_skip"); } }); } var rsTriggered = 0; function highlight(dimmedObj,intIndex){ $(dimmedObj).removeClass("textdim"); $(".dimmed_"+intIndex).removeClass("textdim"); $(".overlay.dimmed_"+(intIndex-1)).hide(); $(".dimmed_"+intIndex).removeClass("hideImage").show(); if($(".textdim").length < 1){ $("a").removeClass("block"); $("area").removeClass("block"); } }; function startSound(soundObj){ if(getCookie("speakerState") == "on"){ //Kopiera över texten till rs_hiddenLayer och starta readspeaker $("#rs_hiddenLayer").html($(soundObj).text()); } if(document.getElementById('readspeaker_button1')){ var a = $("#readspeaker_button1").find("a"); rsTriggered++; //if(rsTriggered == 2){ $(a).trigger("click"); //} if(rsTriggered > 2){ rsTriggered = 1; } } }; //Strippa bort delay-elementet så att det inte visas på sidan - Ändras till att endast dölja delays $(divsTotal).each(function(i,v){ //Hitta samtliga element mellan delay a och delay b if($(this).hasClass(elements.delay)){ $(this).hide(); //Prevent readspeaker from reading delay-element $(this).addClass("rs_skip"); }; }); };