-
Notifications
You must be signed in to change notification settings - Fork 0
/
moodle-mootyper-script.html
53 lines (45 loc) · 2.21 KB
/
moodle-mootyper-script.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!-- Moodle-Mootyper-Modified v.0.2 (moodle-mootyper-script.html) - Copyright (C) 2021, TRMSC - https://trmsc1.wordpress.com/ -->
<!-- GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html -->
<!-- Thanks to catdad for the canvas-confetti on https://github.com/catdad/canvas-confetti -->
<!-- Use the code in a block or in the description of the activity. -->
<script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.4.0/dist/confetti.browser.min.js"></script>
<script>
window.onload = function() {
jquery_load_check_interval = setInterval(function() {
if (window.jQuery) {
makePrecautions();
startConfettiSmall();
console.log("jquery successfully loaded...");
console.log($.fn.jquery); // <== version of jQuery
clearInterval(jquery_load_check_interval);
} else {
console.log("new try to load jquery...");
}
}, 150);
/* PART FOR FUNCTIONS */
function makePrecautions () {
$("#infoDiv").find('br').replaceWith(' ');
var str = $("#infoDiv").text();
str = str.replace('von', 'von ').replace('Vorgegeben', 'Vorgegebene');
$("#infoDiv").text(str);
str = $("#infoDiv").html();
str = str.replaceAll(' ', ' | ');
$("#infoDiv").html(str);
$('#mainDiv').css('visibility', 'inherit');
$('#region-main').css('cursor', 'auto');
}
function startConfettiSmall () {
var elementNow = document.getElementsByClassName("txtBlue");
$(elementNow).addClass('lastPressed');
document.getElementById("keyboard").onkeypress = function(){
if ($('.lastPressed').hasClass('txtGreen')) {
confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 } });
}
$(".txtGreen, .txtRed").removeClass("lastPressed");
var elementNow = document.getElementsByClassName("txtBlue");
$(elementNow).addClass('lastPressed');
}
}
/* END OF THE FUNCTIONS PART */
};
</script>