-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
84 lines (73 loc) · 2.78 KB
/
index.html
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
82
83
84
<!DOCTYPE html>
<html lang="en">
<head>
<title>dReal: JSON Visualizer</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/dropzone.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<meta charset="UTF-8">
</head>
<body>
<div class="container">
<div class="page-header">
<h1>JSON Visualization for the dReal Solver</h1>
</div>
<div id="drop_zone"> Drop your JSON file here</div>
<script src="js/d3.v3.js"></script>
<script src="js/underscore-min.js"></script>
<div id="chart-container" style="text-align:center">
</div>
</div>
<script>
var config;
function handleDrop(e){
e.stopPropagation();
e.preventDefault();
var file = e.dataTransfer.files[0];
if (!file.name.match('\.json')) {
alert("Only .json files are accepted");
}
else{
var reader = new FileReader();
reader.onload = function(f){
document.getElementById('drop_zone').className = "hidden";
json = reader.result;
$.ajax({
url: 'http://gauss.modck.cs.cmu.edu:8081',
data: json,
type: 'POST',
beforeSend: function (){
$("#chart-container").html("<h3> Generating... </h3>");
},
success: function (data){
$("#chart-container").html("");
config = { jsonfile:data, animation_delay:800, width:950, height:1000, inter_chart_margin:25, contextHeight:100, margin:{top:50, right:40, bottom:50, left:60}};
var s2 = document.createElement('script');
s2.setAttribute('type','text/javascript');
s2.setAttribute('src', 'js/vis.js');
$('#chart-container').append(s2);
},
error: function(xhr, status, error){
document.getElementById("chart-container").innerHTML = "Error: " + error.message;
}
});
}
reader.readAsText(file);
}
}
function handleDragOver(e){
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
}
var dropZone = document.getElementById("drop_zone");
dropZone.addEventListener('dragover', handleDragOver, false);
dropZone.addEventListener('drop', handleDrop, false);
</script>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>