135 lines
3.9 KiB
JavaScript
135 lines
3.9 KiB
JavaScript
|
|
||
|
|
||
|
|
||
|
|
||
|
function changeSpeed(value){
|
||
|
speed = value;
|
||
|
console.log("speed is now: " + speed);
|
||
|
if(running == true){
|
||
|
clearTimeout(timer);
|
||
|
timer = setTimeout(next_instruction, speed);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
function next_instruction(){
|
||
|
if(step == (steps.length)){
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
show_instruction();
|
||
|
|
||
|
step = step + 1;
|
||
|
if(step < (steps.length )){
|
||
|
clearTimeout(timer);
|
||
|
timer = setTimeout(next_instruction, speed);
|
||
|
}
|
||
|
else{ //end
|
||
|
step = step - 1;
|
||
|
// console.log("last step");
|
||
|
// show_instruction();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
function show_instruction(){
|
||
|
|
||
|
// document.getElementById("next").disabled = true;
|
||
|
// $("#next").disabled = true;
|
||
|
|
||
|
var active_line;
|
||
|
var shown_step;
|
||
|
$("#init_box_content").hide();
|
||
|
$(".step_boxes").hide();
|
||
|
|
||
|
if(step < steps.length){
|
||
|
active_line = steps[step];
|
||
|
shown_step = step + 1;
|
||
|
}
|
||
|
else{ //end
|
||
|
active_line = 0;
|
||
|
shown_step = step;
|
||
|
}
|
||
|
|
||
|
$("#step_" + (step + 1) + "_box").show();
|
||
|
|
||
|
if(shown_step == 1){
|
||
|
document.getElementById("previous").disabled = true;
|
||
|
}
|
||
|
else if(shown_step == steps.length){
|
||
|
document.getElementById("next").disabled = true;
|
||
|
console.log("last step (" + shown_step + "/" + steps.length + ": \"" + steps[step] + "\"), disable 'next' button");
|
||
|
}
|
||
|
else{
|
||
|
document.getElementById("previous").disabled = false;
|
||
|
document.getElementById("next").disabled = false;
|
||
|
}
|
||
|
|
||
|
hrmv.setActiveLine(active_line);
|
||
|
console.log("current step: " + shown_step + "/" + steps.length + ": \"" + steps[step] + "\" => Set active line to " + active_line + " and show step " + shown_step + " => " + "#step_" + (shown_step) + "_box");
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
function init_cpu(summary, program_quality){
|
||
|
var init_box_content = $("#init_box_content").html();
|
||
|
var style ="<div class=\"hrmcode\">";
|
||
|
|
||
|
// if(init_step == 0){
|
||
|
// init_box_content = init_box_content + "<br>Initializing CPU...<br>";
|
||
|
// }
|
||
|
if(init_step == 1){
|
||
|
init_box_content = init_box_content + style + "Überprüfe Hand...<br>";
|
||
|
}
|
||
|
else if(init_step == 2){
|
||
|
init_box_content = init_box_content + style + "Überprüfe Daten-Register...<br>";
|
||
|
}
|
||
|
// else if(init_step == 2){
|
||
|
// init_box_content = init_box_content + "1... ";
|
||
|
// }
|
||
|
// else if(init_step == 3){
|
||
|
// init_box_content = init_box_content + "2... ";
|
||
|
// }
|
||
|
// else if(init_step == 4){
|
||
|
// init_box_content = init_box_content + "3... </br>";
|
||
|
// }
|
||
|
else if(init_step == 3){
|
||
|
init_box_content = init_box_content + style + "Überprüfe Inbox...<br>";
|
||
|
}
|
||
|
else if(init_step == 4){
|
||
|
init_box_content = init_box_content + style + "Überprüfe Outbox...<br>";
|
||
|
}
|
||
|
else if(init_step == 5){
|
||
|
init_box_content = init_box_content + style + "Lade Programm...<br>";
|
||
|
}
|
||
|
else if(init_step == 6){
|
||
|
init_box_content = init_box_content + style + summary + "<br>";
|
||
|
if(program_quality == 0){
|
||
|
$("#init_box_content").html(init_box_content);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
else{ //last step
|
||
|
init_box_content = init_box_content + style + "Drücke Play um das Programm zu starten";
|
||
|
$("#init_box_content").html(init_box_content);
|
||
|
$("#play").show();
|
||
|
// $("#pause").show();
|
||
|
$("#reset").show();
|
||
|
$("#previous").show();
|
||
|
$("#next").show();
|
||
|
$("#slider_control").show();
|
||
|
document.getElementById("previous").disabled = true;
|
||
|
document.getElementById("next").disabled = false;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
$("#init_box_content").html(init_box_content);
|
||
|
|
||
|
init_step = init_step + 1;
|
||
|
timer = setTimeout(init_cpu, 500, summary, program_quality);
|
||
|
}
|
||
|
|