MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
const animdelay=200; | |||
const animdelta=10; | |||
function httpanim(){ | function httpanim(){ | ||
var http = document.getElementById('demoHTTP'); | var http = document.getElementById('demoHTTP'); | ||
var max = document.http.offsetWidth; | |||
var cur = document.http.style.top; | |||
var max = document. | |||
var cur = document. | |||
if ( cur < max ) { | if ( cur < max ) { | ||
http.style.top = cur + | cur += animdelta; | ||
setTimeout(httpanim, | http.style.top = cur + 'px'; | ||
setTimeout(httpanim,animdelay); | |||
} | } | ||
else { | else { | ||
Line 49: | Line 29: | ||
uart.style.left = 0; | uart.style.left = 0; | ||
uart.innerHTML = val; | uart.innerHTML = val; | ||
httpanim(); | setTimeout(httpanim,animdelay); | ||
} | |||
function launchanim(){ | |||
var cursor = document.getElementById('democursor'); | |||
var bounds = slider.getBoundingClientRect(); | |||
var x = cursor.style.left - bounds.left; | |||
initanim(2*val); | |||
} | |||
function cursormove(e){ | |||
var slider = document.getElementById('demoslider'); | |||
var cursor = document.getElementById('democursor'); | |||
var bounds = slider.getBoundingClientRect(); | |||
var x = e.pageX - bounds.left; | |||
var max = bounds.width - cursor.offsetWidth; | |||
if ( x > max ) x = max; | |||
if ( x < 0 ) x = 0; | |||
if (e.buttons != 0) { | |||
cursor.style.left = Math.floor(x)+'px'; | |||
} | |||
} | |||
function demoslider(){ | |||
var slider = document.getElementById('demoslider'); | |||
if(slider != null){ | |||
slider.onmousemove = cursormove; | |||
slider.onmouseup = launchanim; | |||
} | |||
} | } | ||
demoslider(); | demoslider(); |
Revision as of 07:45, 3 July 2023
/* Any JavaScript here will be loaded for all users on every page load. */
const animdelay=200;
const animdelta=10;
function httpanim(){
var http = document.getElementById('demoHTTP');
var max = document.http.offsetWidth;
var cur = document.http.style.top;
if ( cur < max ) {
cur += animdelta;
http.style.top = cur + 'px';
setTimeout(httpanim,animdelay);
}
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;
setTimeout(httpanim,animdelay);
}
function launchanim(){
var cursor = document.getElementById('democursor');
var bounds = slider.getBoundingClientRect();
var x = cursor.style.left - bounds.left;
initanim(2*val);
}
function cursormove(e){
var slider = document.getElementById('demoslider');
var cursor = document.getElementById('democursor');
var bounds = slider.getBoundingClientRect();
var x = e.pageX - bounds.left;
var max = bounds.width - cursor.offsetWidth;
if ( x > max ) x = max;
if ( x < 0 ) x = 0;
if (e.buttons != 0) {
cursor.style.left = Math.floor(x)+'px';
}
}
function demoslider(){
var slider = document.getElementById('demoslider');
if(slider != null){
slider.onmousemove = cursormove;
slider.onmouseup = launchanim;
}
}
demoslider();