"use strict";

if (typeof loaders === 'undefined' || typeof transitions === 'undefined' || typeof config === 'undefined') {
  throw new Error("Config is not loaded!");
}
var content;
var current = 0;

var cycles = 0;

function nextContent() {
  var oldContent = content[current];
  var transition;

  //Transition out the old content
  //noinspection JSJQueryEfficiency
  var oldElem = $("#content-" + current);
  current += 1;
  // Fetch new content
  if (current >= content.length) {
    current = 0;
    cycles += 1;
  }

  if (cycles >= config.checkCycles) {
    cycles = 0;
    getNewestData();
  }

  var newContent = content[current];
  //noinspection JSJQueryEfficiency
  var newElem = $("#content-" + current);
  var duration = newContent.duration ? newContent.duration : config.defaultDuration;
  duration *= 1000;

  if (newContent.transition)
    transition = transitions[newContent.transition];
  else
    transition = transitions[config.defaultTransition];
  if (loaders[newContent.type].transitionIn)
    loaders[newContent.type].transitionIn(newContent, newElem);

  if (oldContent && loaders[oldContent.type].transitionOut)
    loaders[oldContent.type].transitionOut(oldContent, oldElem);
  //Do the transition
  transition.transition(newElem, oldElem, duration, function () {
    if (oldContent && loaders[oldContent.type].onHidden)
      loaders[oldContent.type].onHidden(oldContent, oldElem);

    if (loaders[newContent.type].onShown)
      loaders[newContent.type].onShown(newContent, newElem);
    var delay = config.defaultDelay;
    if (newContent.delay) delay = newContent.delay;

    delay *= 1000;
    setTimeout(nextContent, delay);
  });
}
function getNewestData() {
  $.getJSON(config.contentURL, function (data) {
    var timeout = content === undefined;
    content = data;
    //Preload everything
    $(".container").empty();
    for (var i in content) {
      if (!content.hasOwnProperty(i)) continue;
      var c = content[i];
      var elem = loaders[c.type].preLoad(c);
      var slide = $('<div class="slide"></div>').append(elem);
      if (i != 0)
        slide.addClass("hidden");
      else {
        if (loaders[c.type].onShown)
          loaders[c.type].onShown(c, elem);
      }
      slide.attr("id", "content-" + i);
      slide.appendTo($(".container"));
    }
    if (timeout) setTimeout(nextContent, (content[current].delay ? content[current].delay : config.defaultDelay) * 1000);
  });
}

$(function () {
  $(document).idleTimer(3000);

  $(document).on("idle.idleTimer", function () {
    $("body").css("cursor", "none");
  });

  $(document).on("active.idleTimer", function () {
    $("body").css("cursor", "");
  });
  getNewestData();
});
@@ -2061,24 +2061,103 @@
 pend(elem);%0A
+      slide.attr(%22id%22, %22content-%22 + i);%0A      slide.appendTo($(%22.container%22));%0A
       if (i 
@@ -2302,87 +2302,8 @@
   %7D%0A
-      slide.attr(%22id%22, %22content-%22 + i);%0A      slide.appendTo($(%22.container%22));%0A
     

Fix error with videos