-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathui.js
More file actions
81 lines (67 loc) · 2.27 KB
/
ui.js
File metadata and controls
81 lines (67 loc) · 2.27 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
'use strict'
import { Scheduler } from './classes/scheduler.js';
import { TableExport } from './classes/tableExport.js'
$(function () {
const TXTSTOP = "STOPPEN"
let config = {
"iterations": 1000
, "size": 20
, "crossover": 0.1
, "mutation": 0.5
, "skip": 10
, "webWorkers": true
};
/* assert: numSlots * slotSize >= numExams */
let userData = {
"solution": []
, "conflicts": []
, "numSlots": 8
, "slotSize": 50
, "exams": []
, "done": false
};
let genetic
let scheduler
$('#run').on('click', function () {
if ($(this).text() == TXTSTOP) {
scheduler.finalize(genetic)
}
else {
if ($('#inschrijvingen').val() == '') {
alert('Geen examens gevonden. Kopieer eerst de lijst met examens')
return false;
}
config.size = Number($("input[name='populationSize']").val())
config.mutation = Number($("input[name='mutationProbability']").val()) / 100
config.iterations = Number($("input[name='generations']").val())
let days = Number($('input[name = days]').val())
let examsPerDay = Number($('input[name = examsPerDay]').val())
let maxSlots = days * examsPerDay
userData.numSlots = maxSlots
$(this).html(TXTSTOP)
$(this).toggleClass("active")
scheduler = new Scheduler(config, userData)
genetic = scheduler.schedule()
}
})
$('#showHelp').on('click', function () {
$('.intro').toggleClass('hide')
})
$('#showTechnical').on('click', function () {
$('.technical').toggleClass('hide')
})
$('#downloadSolution').on('click', function () {
let objExport = new TableExport('.solution table.exams')
objExport.toCSV().download('solution', true) // with timestamp, e.g. solution-1234.csv
})
$('#downloadStudentList').on('click', function () {
let objExport = new TableExport('#studentSchedule')
objExport.toCSV().download('studentSchedule', true) // with timestamp, e.g. studentSchedule-1234.csv
})
// Add an event listener.
$(document).on('Finished', function (e, opts) {
$('#run').html(Scheduler.TXTGO)
$('#run').toggleClass("active")
console.log("finished")
});
})