// var clockAdded = false;
// var digitalClockId;
// var date = new Date();

//Editor
// =====================================>>>
{
  // Uncomment the following code to test the "Timeout Loading Method".
  // CKEDITOR.loadFullCoreTimeout = 5;

  window.onload = function () {
    // Listen to the double click event.
    if (window.addEventListener)
      document.body.addEventListener("dblclick", onDoubleClick, false);
    else if (window.attachEvent)
      document.body.attachEvent("dblclick", onDoubleClick);
  };

  function onDoubleClick(ev) {
    // Get the element which fired the event. This is not necessarily the
    // element to which the event has been attached.
    var element = ev.target || ev.srcElement;

    // Find out the div that holds this element.
    var name;

    do {
      element = element.parentNode;
    } while (
      element &&
      (name = element.nodeName.toLowerCase()) &&
      (name != "div" || element.className.indexOf("editable") == -1) &&
      name != "body"
    );

    if (name == "div" && element.className.indexOf("editable") != -1)
      replaceDiv(element);
  }

  var editor;

  function replaceDiv(div) {
    if (editor) editor.destroy();

    editor = CKEDITOR.replace(div);
  }
}
// <<<=====================================

// submit subtitle Details
function submitSubTitleDetails() {
  if (activeLayerId.includes("subTitle")) {
    if (subTitleSourceInput !== "") {
      console.log("activeLayerId.includes subTitle");
      var subTitleSourceInput = document.querySelector("#subTitleSrc").value;
      console.log("activeLayerId.includes subTitle");
      let activesubTitle = document.getElementsById("activeLayerId");
      document.getElementById(activesubTitle).innerHTML = subTitleSourceInput;
    }
  }
}

// Fullscreen mode
// =====================================>>>
const screenToFullscreen = document.getElementById("screen");
document
  .getElementById("full-screen-btn")
  .addEventListener("click", function () {
    if (screenToFullscreen.requestFullscreen) {
      screenToFullscreen.requestFullscreen();
    } else if (screenToFullscreen.webkitRequestFullscreen) {
      /* Safari */
      screenToFullscreen.webkitRequestFullscreen();
    } else if (screenToFullscreen.msRequestFullscreen) {
      /* IE11 */
      screenToFullscreen.msRequestFullscreen();
    }
  });
// <<<=====================================

// Login simulator
