Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 52.15.173.197
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : 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,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/self/root/usr/share/doc/python3-resolvelib/examples/visualization/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/self/root/usr/share/doc/python3-resolvelib/examples/visualization/main.js
var dotSourceList = {{ dot_source_list|tojson }};

var state = {
  transitionDelay: 0,
  index: 0,
  playing: false,
}
var controls = {
  index: null,
  buttons: {
    next: null,
    prev: null,
    toggle: null,
  },
  slider: null,
}
var graph = null;

/////////////
// Helpers //
/////////////
// From https://stackoverflow.com/a/37623959/1931274
function onRangeChange(r, f) {
  var n, c, m;
  r.addEventListener("input", function (e) {
    n = 1; c = e.target.value; if (c != m) { f(e); }; m = c;
  });
  r.addEventListener("change", function (e) { if (!n) { f(e); }});
}

//////////////
// UI Logic //
//////////////
function setupControls() {
  controls.index = document.getElementById("index");

  controls.buttons.next = document.getElementById("next");
  controls.buttons.next.onclick = showNext;

  controls.buttons.prev = document.getElementById("prev");
  controls.buttons.prev.onclick = showPrevious;

  controls.buttons.toggle = document.getElementById("toggle");
  controls.buttons.toggle.onclick = toggle;

  controls.slider = document.getElementById("slider");
  controls.slider.setAttribute("max", dotSourceList.length - 1);
  onRangeChange(controls.slider, showSliderState);

}

function updateControls() {
  controls.slider.value = state.index;
  controls.index.innerHTML = state.index;

  if (state.playing) {
    controls.buttons.toggle.innerHTML = "Pause";
  } else {
    controls.buttons.toggle.innerHTML = "Play";
  }
}

//////////////////
// UI callbacks //
//////////////////
function toggle() {
  console.log("toggle");
  state.playing = !state.playing;
  showThisGraph();
}

function showNext() {
  console.log("next");
  state.playing = false;
  if (state.index < dotSourceList.length - 1) {
    state.index = state.index + 1;
  }
  showThisGraph();
}

function showPrevious() {
  console.log("previous");
  state.playing = false;
  if (state.index != 0) {
    state.index = state.index - 1;
  }
  showThisGraph();
}

function showSliderState() {
  console.log("slider");
  var value = Number(controls.slider.value);
  state.index = value;
  state.playing = false;

  showThisGraph();
}

///////////////
// Rendering //
///////////////
function prepareGraph() {
  graph = d3.select("#graph").graphviz();
  graph
    .zoom(false)
    .transition(function () {
      return d3.transition("main")
        .ease(d3.easeExpOut)
        .duration(500)
        // .delay(state.transitionDelay);
    })
    .on("initEnd", showThisGraph);

}

function showThisGraph() {
  updateControls();

  var dotSource = dotSourceList[state.index];
  return graph
    .renderDot(dotSource)
    // The following sets up the "play" mode.
    .on("end", continueIfPlaying);
}


function continueIfPlaying() {
  if (!state.playing) {
    return
  }
  state.index = (state.index + 1) % dotSourceList.length;
  showThisGraph();
}

/////////////////
// Entry Point //
/////////////////
function main() {
  setupControls();
  prepareGraph();
}

document.addEventListener("DOMContentLoaded", main);

Anon7 - 2022
AnonSec Team