HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //proc/1526/task/1530/cwd/zaklada/html/node_modules/jsdom/lib/jsdom/browser/history.js
"use strict";
const whatwgURL = require("whatwg-url-compat");
const resolveHref = require("../utils").resolveHref;

function StateEntry(data, title, url) {
  this.data = data;
  this.title = title;
  this.url = url;
}

module.exports = History;

function History(window) {
  this._states = [new StateEntry(null, "", window._document._URL)];
  this._index = 0;
  this._window = window;
  this._location = window._document._location;
}

History.prototype = {
  constructor: History,

  get length() {
    return this._states.length;
  },

  get state() {
    const state = this._states[this._index];
    return state ? state.data : null;
  },

  back() {
    this.go(-1);
  },

  forward() {
    this.go(1);
  },

  go(delta) {
    if (typeof delta === "undefined" || delta === 0) {
      this._location.reload();
      return;
    }

    const newIndex = this._index + delta;

    if (newIndex < 0 || newIndex >= this.length) {
      return;
    }

    this._index = newIndex;

    const state = this._states[newIndex];

    this._applyState(state);
    this._signalPopstate(state);
  },

  pushState(data, title, url) {
    const state = new StateEntry(data, title, url);
    if (this._index + 1 !== this._states.length) {
      this._states = this._states.slice(0, this._index + 1);
    }
    this._states.push(state);
    this._applyState(state);
    this._index++;
  },

  replaceState(data, title, url) {
    const state = new StateEntry(data, title, url);
    this._states[this._index] = state;
    this._applyState(state);
  },

  _applyState(state) {
    whatwgURL.setTheInput(this._location, resolveHref(this._location.href, state.url));
  },

  _signalPopstate(state) {
    if (this._window.document) {
      const ev = this._window.document.createEvent("HTMLEvents");
      ev.initEvent("popstate", false, false);
      ev.state = state.data;
      process.nextTick(() => this._window.dispatchEvent(ev));
    }
  },

  toString() {
    return "[object History]";
  }
};