-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
56 lines (52 loc) · 2.3 KB
/
Copy pathutils.js
File metadata and controls
56 lines (52 loc) · 2.3 KB
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
54
55
56
function getButton(buttonId) {
let id = "p" + buttonId + "Button";
return document.getElementById(id);
}
function addProccessor(id) {
let div = document.getElementById('procRow');
let state = Math.round(Math.random() * 100) % K;
let tooltipText = '';
if (id == 0) {
tooltipText = "IF 𝑥(0)=𝑥(" + (N - 1) + ")" + "\n THEN 𝑥(0)≔𝑥(0)+1" +
"\n\nLeft Click - Make a move (if priviliged)";
} else {
tooltipText = "IF 𝑥(" + id + ")!=𝑥(" + (id - 1) + ")" +
"\n THEN 𝑥(" + id + ")≔𝑥(" + (id - 1) + ")" +
"\n\nLeft Click - Make a move (if priviliged)";
}
let procHTML =
`<div class="col text-center">
<button id="p` + id + `Button" type="button " class="btn btn-success proccessor" data-toggle="tooltip" data-placement="top" title="` + tooltipText + `">` + state + `</button>
<h4>P` + id + `</h4>
</div>`
div.insertAdjacentHTML('afterbegin', procHTML);
}
function removeProccessors() {
let div = document.getElementById('procRow');
div.innerHTML = ``;
}
function updateGuiForScheduler(isSchedulerActive) {
document.getElementById("kInput").disabled = isSchedulerActive;
document.getElementById("nInput").disabled = isSchedulerActive;
document.getElementById("secondsInput").disabled = isSchedulerActive;
document.getElementById("kInputButton").disabled = isSchedulerActive;
document.getElementById("nInputButton").disabled = isSchedulerActive;
document.getElementById("randomButton").disabled = isSchedulerActive;
}
// Restricts input for the given textbox to the given inputFilter function.
function setInputFilter(textbox, inputFilter) {
["input", "keydown", "keyup", "mousedown", "mouseup", "select", "contextmenu", "drop"].forEach(function(event) {
textbox.addEventListener(event, function() {
if (inputFilter(this.value)) {
this.oldValue = this.value;
this.oldSelectionStart = this.selectionStart;
this.oldSelectionEnd = this.selectionEnd;
} else if (this.hasOwnProperty("oldValue")) {
this.value = this.oldValue;
this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd);
} else {
this.value = "";
}
});
});
}