-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
42 lines (28 loc) · 898 Bytes
/
main.js
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
/*
* An example main program that calls and uses clingon functions
*
* Uses jQuery
*/
/* Callback function to pass to loadASP that gets called when it has finished
*/
function useASP (code) {
displayASP (code);
// Enable "run" button
$("#run").attr("disabled", false);
$("#run").click( function() { clingon.groundAndSolve (code, useResults); });
}
function displayASP (code) {
$("#asp").append('<pre>'+code+'</pre>');
}
/* Callback function to pass to groundAndSolve that gets called when it has finished,
* recieving the solutions as a parameter
*/
function useResults (results) {
var model = results.Witnesses[0].Value;
$("#output").append('<pre>'+model+'</pre>');
}
/* Wait for jQuery to load before starting */
$(document).ready(function() {
// Load the ASP code from graph.lp and call useASP function when it's done
clingon.loadASP ("graph.lp", useASP);
});