PageSourceSearch

https://greenkit4en.ru/wp-content/plugins/fortune-widget//js/fortune.js

js greenkit4en.ru collected 2026-10-06 12:13:17 UTC 1,736 bytes, 45 lines download raw bytes

1document.addEventListener('DOMContentLoaded', function () {
2    const buttons = document.querySelectorAll('.fortune-button');
3
4    buttons.forEach(button => {
5        button.addEventListener('click', function () {
6            const widget = button.closest('.fortune-widget');
7            const selects = widget.querySelectorAll('.fortune-select');
8            const diceElements = widget.querySelectorAll('.dice');
9            const messageElement = widget.querySelector('.fortune-message');
10            const userChoices = [];
11            const results = [];
12            let match = true;
13
14            messageElement.textContent = '';
15            messageElement.classList.remove('win', 'lose');
16            diceElements.forEach(dice => {
17                dice.classList.remove('win');
18                dice.classList.add('rolling');
19            });
20
21            selects.forEach(select => {
22                userChoices.push(parseInt(select.value));
23            });
24
25            setTimeout(() => {
26                diceElements.forEach((dice, index) => {
27                    const random = Math.floor(Math.random() * 6) + 1;
28                    results.push(random);
29                    dice.classList.remove('rolling');
30                    dice.textContent = random;
31
32                    if (random === userChoices[index]) {
33                        dice.classList.add('win');
34                    } else {
35                        match = false;
36                    }
37                });
38
39                const message = match ? widget.dataset.win : widget.dataset.lose;
40                messageElement.textContent = message;
41                messageElement.classList.add(match ? 'win' : 'lose');
42            }, 1000);
43        });
44    });
45});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.