1
|
$(document).ready(function() {
|
2
|
|
3
|
// Prevent crash if bereiche is not defined elsewhere
|
4
|
var bereiche = $("div[id^='bereich']");
|
5
|
var xcontent_position = Array();
|
6
|
for (var i = 0; i < bereiche.length; i++) {
|
7
|
xcontent_position["xcontent" + parseInt(i)] = 0;
|
8
|
}
|
9
|
|
10
|
var current_xcontent = $("div[xcontent='xcontent']").attr("class");
|
11
|
|
12
|
/** Init-Funktion **/
|
13
|
xcontent_position[current_xcontent] = 0;
|
14
|
|
15
|
button_next_deaktiviert = false;
|
16
|
fading = false;
|
17
|
|
18
|
var first = true;
|
19
|
$("body").find("div[xcontent='xcontent']").each(function(index){
|
20
|
if (!first) {
|
21
|
$(this).hide();
|
22
|
}
|
23
|
first = false;
|
24
|
});
|
25
|
|
26
|
// Aktuelle Position im Inhalt holen
|
27
|
moodle_course_id = getGETParameter("id");
|
28
|
if (moodle_course_id != -1) {
|
29
|
xcontent_position[current_xcontent] = parseInt(retrieve(moodle_course_id + "_" + current_xcontent));
|
30
|
}
|
31
|
|
32
|
if (isNaN(xcontent_position[current_xcontent])) {
|
33
|
xcontent_position[current_xcontent] = 0;
|
34
|
}
|
35
|
|
36
|
// Probleme beim Laden vermeiden
|
37
|
if (xcontent_position[current_xcontent] > get_current_max_subposition()) {
|
38
|
xcontent_position[current_xcontent] = get_current_max_subposition();
|
39
|
} else if (xcontent_position[current_xcontent] < 0) {
|
40
|
xcontent_position[current_xcontent] = 0;
|
41
|
}
|
42
|
|
43
|
// Geöffnete Abschnitte wieder laden
|
44
|
var tmp_position = xcontent_position[current_xcontent];
|
45
|
for (var i = 0; i < tmp_position; i++) {
|
46
|
append_next_to_content();
|
47
|
}
|
48
|
xcontent_position[current_xcontent] = tmp_position;
|
49
|
|
50
|
$("#step_current").html(xcontent_position[current_xcontent] + 1);
|
51
|
$("#steps_total").html(get_current_max_subposition() + 1);
|
52
|
|
53
|
if (get_current_max_subposition() <= 0) {
|
54
|
$(".seitenanzeige").hide();
|
55
|
}
|
56
|
|
57
|
control_next_prev_buttons();
|
58
|
|
59
|
// Buttons
|
60
|
$(document).on('click', "#example_exercise", function(e) {
|
61
|
load_example_exercise();
|
62
|
});
|
63
|
|
64
|
$(document).on('click', "#button_next", function(e) {
|
65
|
if ($(this).hasClass("grey")) return;
|
66
|
if (button_next_deaktiviert) return;
|
67
|
button_next_deaktiviert = true;
|
68
|
append_next_to_content();
|
69
|
button_next_deaktiviert = false;
|
70
|
});
|
71
|
|
72
|
// Zurück button has been removed to avoid navigation errors
|
73
|
|
74
|
$(".tooltip-icon").hover(function() {
|
75
|
$(this).next().fadeIn();
|
76
|
}, function() {
|
77
|
$(this).next().fadeOut();
|
78
|
});
|
79
|
|
80
|
activate_input_tooltips();
|
81
|
init_hover_feedback();
|
82
|
|
83
|
// Scroll to Ausblick when the "Zusammenfassung" button is clicked
|
84
|
$(document).on("click", "button:contains('Zusammenfassung')", function () {
|
85
|
const target = document.getElementById("ausblick");
|
86
|
if (target) {
|
87
|
target.scrollIntoView({ behavior: "smooth" });
|
88
|
}
|
89
|
});
|
90
|
|
91
|
|
92
|
});
|