mirror of
https://codeberg.org/fediverse/fediparty.git
synced 2024-11-01 06:37:21 +00:00
29 lines
815 B
JavaScript
29 lines
815 B
JavaScript
|
|
const list = require('./reasons'); /* add more reasons there */
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
'use strict';
|
|
const reason = document.getElementById('reason');
|
|
const reasonFinder = document.getElementById('getReason');
|
|
const reasonsList = list.reasons;
|
|
const max = reasonsList.length - 1;
|
|
|
|
function getRandomNum(min, max) {
|
|
min = Math.ceil(min);
|
|
max = Math.floor(max);
|
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
}
|
|
|
|
const showReason = function() {
|
|
const num = getRandomNum(0, max);
|
|
const theReason = reasonsList[num];
|
|
reason.innerHTML = theReason;
|
|
reason.classList.add('fadeIn');
|
|
setTimeout(() => {
|
|
reason.classList.remove('fadeIn');
|
|
}, 300);
|
|
};
|
|
|
|
reasonFinder.addEventListener('click', showReason, false);
|
|
});
|