Skip to content

Commit a99b0e1

Browse files
committed
Handles code for showing and hiding params appropriately
1 parent 9512a55 commit a99b0e1

File tree

1 file changed

+47
-6
lines changed

1 file changed

+47
-6
lines changed

static/js/main.js

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
$(document).ready(function() {
2+
$("#simulated_annealing_params").fadeOut();
3+
$("#genetic_algorithm_params").fadeOut();
24
$("#nb_machines").change(function() {
35
if ($("#algorithm").val() === "johnson") {
46
if ($("#nb_machines") !== 2) {
@@ -15,20 +17,59 @@ $(document).ready(function() {
1517
if ($(this).val() === "johnson") {
1618
$("#nb_machines").val(2);
1719
}
20+
if ($(this).val() === "simulated-annealing") {
21+
$("#simulated_annealing_params").fadeIn();
22+
} else {
23+
$("#simulated_annealing_params").fadeOut();
24+
}
25+
26+
if ($(this).val() === "genetic-algorithm") {
27+
$("#genetic_algorithm_params").fadeIn();
28+
} else {
29+
$("#genetic_algorithm_params").fadeOut();
30+
}
31+
32+
1833
});
1934

2035
$("#solve").on("click", function() {
36+
37+
if ($("#algorithm").val() === "simulated-annealing") {
38+
var data_tbs = JSON.stringify({
39+
algorithm: $("#algorithm").val(),
40+
data: $("#data").val(),
41+
nb_machines: $("#nb_machines").val(),
42+
nb_jobs: $("#nb_jobs").val(),
43+
ti: $("#init_temp").val(),
44+
tf: $("#f_temp").val(),
45+
alpha: $("#alpha").val()
46+
});
47+
} else if ($("#algorithm").val() === "genetic-algorithm") {
48+
var data_tbs = JSON.stringify({
49+
algorithm: $("#algorithm").val(),
50+
data: $("#data").val(),
51+
nb_machines: $("#nb_machines").val(),
52+
nb_jobs: $("#nb_jobs").val(),
53+
population_number: $("#pop_number").val(),
54+
it_number: $("#it_number").val(),
55+
p_crossover: $("#p_crossover").val(),
56+
p_mutation: $("#p_mutation").val()
57+
});
58+
} else {
59+
var data_tbs = JSON.stringify({
60+
algorithm: $("#algorithm").val(),
61+
data: $("#data").val(),
62+
nb_machines: $("#nb_machines").val(),
63+
nb_jobs: $("#nb_jobs").val()
64+
});
65+
}
66+
2167
$.ajax({
2268
url: "/solve",
2369
dataType: "json",
2470
type: "post",
2571
contentType: "application/json",
26-
data: JSON.stringify({
27-
algorithm: $("#algorithm").val(),
28-
data: $("#data").val(),
29-
nb_machines: $("#nb_machines").val(),
30-
nb_jobs: $("#nb_jobs").val()
31-
}),
72+
data: data_tbs,
3273
processData: false,
3374
success: function(data, textStatus, jQxhr) {
3475
Plotly.newPlot("gantt", JSON.parse(data["graph"]), {});

0 commit comments

Comments
 (0)