MediaWiki:Common.js

From Wiki PeiP systèmes embarqués
Revision as of 07:01, 3 July 2023 by Rex (talk | contribs)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */

function cursormove(e){
  var slider = document.getElementById('demoslider');
  var cursor = document.getElementById('democursor');
  var bounds = slider.getBoundingClientRect();
  var x = e.clientX - bounds.left;
console.log(bounds.left,bounds.right,e.clientX);
  var max = bounds.width - cursor.offsetWidth;
  if ( x > max ) x = max;
  if (e.buttons != 0) {
    cursor.style.left = Math.floor(x)+'px';
console.log(Math.floor(x));
    }
  }

function demoslider(){
  var slider = document.getElementById('demoslider');
  if(slider != null){
    slider.onmousemove = cursormove;
    }
  }

function httpanim(){
  var http = document.getElementById('demoHTTP');
  http.innerHTML = 'POST';
  http.style.top = 0;
  http.style.left = 0;
  http.style.display = 'flex';
  var max =	document.getElementById('demoHTTP').offsetWidth;
  var cur =	document.getElementById('demoHTTP').style.top;
  if ( cur < max ) {
    http.style.top = cur + 10;
    setTimeout(httpanim,200);
    }
  else {
    http.style.top = 0;
    http.style.display = 'none';
    }
}

function initanim(val){
  var http = document.getElementById('demoHTTP');
  var uart = document.getElementById('demoUART');
  http.style.top = 0;
  http.style.left = 0;
  http.innerHTML = 'POST';
  http.style.display = 'flex';
  uart.style.top = 0;
  uart.style.left = 0;
  uart.innerHTML = val;
  httpanim();
  }

demoslider();