HEX
Server: LiteSpeed
System: Linux cde2.duelhost.dk 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64
User: dtptviut (1121)
PHP: 8.0.30
Disabled: exec,system,passthru,shell_exec,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/dtptviut/domains/teleweb.dk/private_html/wp-content/plugins/w3-total-cache/pub/js/wizard.js
/**
 * File: wizard.js
 *
 * JavaScript for the wizard.
 *
 * @since 2.0.0
 */

jQuery(function () {
  var $container = jQuery("#w3tc-wizard-container"),
    $skipLink = $container.find("#w3tc-wizard-skip-link "),
    $skipButton = $container.find("#w3tc-wizard-skip "),
    $nextButton = $container.find("#w3tc-wizard-next "),
    $previousButton = $container.find("#w3tc-wizard-previous "),
    stepToSlideMap = {
      welcome: "welcome",
      pgcache: "pc1",
      dbcache: "dbc1",
      objectcache: "oc1",
      browsercache: "bc1",
      imageservice: "io1",
      lazyload: "ll1",
      more: "complete",
    };

  $skipLink.on("click", skipFunction);
  $skipButton.on("click", skipFunction);

  jQuery(window).on("beforeunload", function () {
    var $previousSlide = $container
      .find(".w3tc-wizard-slides:visible")
      .prev(".w3tc-wizard-slides");
    if ($previousSlide.length) {
      return W3TC_Wizard.beforeunloadText;
    }
  });

  // Listen for clicks to go to the W3TC Dashboard.
  $container.find("#w3tc-wizard-dashboard").on("click", function () {
    jQuery(window).off("beforeunload");
    document.location = W3TC_SetupGuide.dashboardUrl;
  });

  /**
   * Show the requested slide and adjust navigation state.
   *
   * @since 2.9.0
   *
   * @param object $targetSlide Slide to display.
   */
  function showSlide($targetSlide) {
    if (!$targetSlide.length) {
      return;
    }

    var $currentSlide = $container.find(".w3tc-wizard-slides:visible");

    if (
      $currentSlide.length &&
      "function" === typeof w3tc_mark_step_complete_on_leave
    ) {
      w3tc_mark_step_complete_on_leave($currentSlide.prop("id"));
    }

    $currentSlide.hide();
    $targetSlide.show();

    var hasPrevious = !!$targetSlide.prev(".w3tc-wizard-slides").length,
      hasNext = !!$targetSlide.next(".w3tc-wizard-slides").length;

    $previousButton.closest("span").toggle(hasPrevious);
    $skipButton.closest("span").toggle(!hasPrevious);

    $container.find("#w3tc-wizard-dashboard-span").toggle(!hasNext);
    $nextButton.closest("span").toggle(hasNext);

    if ("function" === typeof w3tc_wizard_actions) {
      w3tc_wizard_actions($targetSlide, $currentSlide);
    }
  }

  /**
   * Process the skip action.
   *
   * Saves and option to mark the wizard completed.
   *
   * @since 2.0.0
   */
  function skipFunction() {
    var $this = jQuery(this),
      nodeName = $this.prop("nodeName"),
      page = location.href.replace(/^.+page=/, "");

    jQuery(window).off("beforeunload");

    if ("BUTTON" === nodeName) {
      $this.prop("disabled", true).css("color", "#000").text("Skipping...");
    }

    // GA.
    if (window.w3tc_ga) {
      w3tc_ga("event", "button", {
        eventCategory: page,
        eventLabel: "skip",
      });
    }

    jQuery
      .ajax({
        method: "POST",
        url: ajaxurl,
        data: {
          _wpnonce:
            "function" === typeof w3tcGetWizardNonce
              ? w3tcGetWizardNonce("w3tc_wizard_skip")
              : $container.find('[name="_wpnonce"]').val(),
          action: "w3tc_wizard_skip",
        },
      })
      .done(function (response) {
        if ("BUTTON" === nodeName) {
          $this.text("Redirecting...");
        }

        window.location.replace(
          location.href.replace(/page=.+$/, "page=w3tc_dashboard"),
        );
      })
      .fail(function () {
        if ("BUTTON" === nodeName) {
          $this.text("Error with Ajax; reloading page...");
        }

        location.reload();
      });
  }

  $previousButton.on("click", function () {
    var $currentSlide = $container.find(".w3tc-wizard-slides:visible"),
      $previousSlide = $currentSlide.prev(".w3tc-wizard-slides");

    showSlide($previousSlide);
  });

  $nextButton.on("click", function () {
    var $currentSlide = $container.find(".w3tc-wizard-slides:visible"),
      $nextSlide = $currentSlide.next(".w3tc-wizard-slides");

    showSlide($nextSlide);
  });

  $container.find("#w3tc-options-menu").on("click", "li", function () {
    var rawId = jQuery(this).attr("id");
    var stepId = rawId.replace(/^w3tc-wizard-step-/, "").replace(/-text$/, "");
    var slideId = stepToSlideMap[stepId];
    var $targetSlide = slideId
      ? $container.find("#w3tc-wizard-slide-" + slideId)
      : jQuery();

    showSlide($targetSlide);
  });
});