Gebruiker:Rots61/Gadget-TestGadget.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 2: | Regel 2: | ||
var titelnummerTS = 0; |
var titelnummerTS = 0; |
||
var secondenTS = 0; |
var secondenTS = 0; |
||
− | var |
+ | var timeoutTimer = 40; |
⚫ | |||
− | var printedvalues = 'secondenTS'; |
||
function TS () { |
function TS () { |
||
− | console.log( |
+ | console.log(secondenTS, timeoutTimer); |
if (document.visibilityState !== 'hidden' && timeoutTimer !== 0) { |
if (document.visibilityState !== 'hidden' && timeoutTimer !== 0) { |
||
secondenTS += 1; |
secondenTS += 1; |
||
Regel 14: | Regel 12: | ||
titelnummerTS += 1; |
titelnummerTS += 1; |
||
uploadTS(); |
uploadTS(); |
||
+ | } |
||
+ | } else if (document.visibilityState === 'hidden') { |
||
+ | if (timeoutTimer < 25) { |
||
⚫ | |||
} |
} |
||
} |
} |
||
Regel 23: | Regel 25: | ||
function resetTimeout() { |
function resetTimeout() { |
||
− | timeoutTimer = |
+ | timeoutTimer = 40; |
} |
} |
||
Versie van 16 jun 2023 21:22
// Test voor het maken van tijd-statistieken
var titelnummerTS = 0;
var secondenTS = 0;
var timeoutTimer = 40;
function TS () {
console.log(secondenTS, timeoutTimer);
if (document.visibilityState !== 'hidden' && timeoutTimer !== 0) {
secondenTS += 1;
timeoutTimer -= 1;
if ((secondenTS % 10) === 0) {
titelnummerTS += 1;
uploadTS();
}
} else if (document.visibilityState === 'hidden') {
if (timeoutTimer < 25) {
timeoutTimer = 25;
}
}
}
function uploadTS () {
document.title = titelnummerTS;
}
function resetTimeout() {
timeoutTimer = 40;
}
if (mw.config.get('wgTitle').toLowerCase().includes('testpagina')) {
$('body').on("click mousedown mouseup focus blur keydown change dblclick mousemove mouseover mousewheel keypress textInput touchstart touchmove touchend touchcancel resize scroll zoom select change submit reset",function(e){
console.log(e.type);
resetTimeout();
});
setInterval(TS, 1000);
}