-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.php
More file actions
429 lines (429 loc) · 23.1 KB
/
demo.php
File metadata and controls
429 lines (429 loc) · 23.1 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>dlvhex</title>
<link rel="stylesheet" type="text/css" media="all" href="css/reset.css"></link>
<link rel="stylesheet" type="text/css" media="all" href="css/text.css"></link>
<link rel="stylesheet" type="text/css" media="all" href="css/960.css"></link>
<link rel="stylesheet" type="text/css" media="all" href="css/style.css"></link>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<!-- Title -->
<!--
<div class="container_12">
<div class="grid_12" id="title">
<h1>dlvhex</h1>
</div>
</div>
-->
<!-- Menu -->
<div class="container_12">
<div class="grid_12" id="menu">
<a href="index.html">About</a>
<a href="people.html">People</a>
<a href="news.html">News</a>
<a href="downloadb.html">Download Binaries</a>
<a href="downloads.html">Download Source</a>
<a href="support.html">Support</a>
<a href="documentation.html">Documentation</a>
<a href="demo.php">Online Demo</a>
<a href="http://asptut.gibbi.com/">ASP Tutorial</a>
<a href="related.html">Related Work</a>
<a href="applications.html">Applications</a>
<a href="literature.html">Literature</a>
</div>
</div>
<!-- Information -->
<div class="container_12">
<div class="grid_9">
<noscript><style> .jsonly { display: none } </style></noscript>
<script language="Javascript" type="text/javascript" src="demo/edit_area/edit_area_full.js"></script>
<script type="text/javascript">
<!--
function clearHexprogramAndExtsource(){
if(confirm('Do you really want to clear the HEX-program and the external source definition?')){
if (document.getElementById("useeditarea").checked){
editAreaLoader.setValue("hexprogram", "");
editAreaLoader.setValue("extsource", "");
}else{
document.getElementById("hexprogram").value = "";
document.getElementById("extsource").value = "";
}
}
}
function evaluateHEX(){
var outputdiv=document.getElementById("outputdiv");
// display loading animation
var img=document.createElement('img');
img.src = "demo/dlvhexlogoanimated.gif";
img.width = 80;
img.height = 80;
var centerimg=document.createElement('center');
centerimg.appendChild(img);
outputdiv.innerHTML = "<div align=\"center\"><p style=\"font-size:20px\">Reasoning ...</p></div></br>";
outputdiv.appendChild(centerimg);
window.setTimeout(scrollToResults, 0);
// call reasoner
window.setTimeout(callReasoner, 0);
}
function callReasoner(){
// assemble command-line arguments
var commandlineoptions = "";
if (document.getElementById("optFilter").value != "") commandlineoptions = commandlineoptions + " --filter=" + document.getElementById("optFilter").value;
if (document.getElementById("optNumAS").value != "") commandlineoptions = commandlineoptions + " -n=" + document.getElementById("optNumAS").value;
if (document.getElementById("optStrongNegation").checked) commandlineoptions = commandlineoptions + " --strongnegation-enable=true"; else commandlineoptions = commandlineoptions + " --strongnegation-enable=false";
if (document.getElementById("optLiberalSafety").checked) commandlineoptions = commandlineoptions + " --liberalsafety"; else commandlineoptions = commandlineoptions + " --strongsafety";
if (document.getElementById("optCustom").value != "") commandlineoptions = commandlineoptions + " " + document.getElementById("optCustom").value;
// assemble query
var args = "?mode=evalhex";
args = args + "&commandlineoptions=" + encodeURIComponent(commandlineoptions);
if (document.getElementById("useeditarea").checked){
args = args + "&hexprogram=" + encodeURIComponent(editAreaLoader.getValue("hexprogram"));
args = args + "&extsource=" + encodeURIComponent(editAreaLoader.getValue("extsource"));
}else{
args = args + "&hexprogram=" + encodeURIComponent(document.getElementById("hexprogram").value);
args = args + "&extsource=" + encodeURIComponent(document.getElementById("extsource").value);
}
// send query
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "demo/evalandformaturl.txt", false);
xmlHttp.send(null);
evalandformaturl = xmlHttp.responseText;
xmlHttp.open("GET", evalandformaturl + args, true);
xmlHttp.send(null);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
// content is loaded...hide the gif and display the content...
if (xmlHttp.responseText) {
document.getElementById('outputdiv').innerHTML = xmlHttp.responseText;
window.setTimeout(scrollToResults, 0);
}
}
};
}
function scrollToResults(){
document.getElementById("outputdiv").scrollIntoView();
}
function loadExample(){
example = document.getElementById("cmbExample").value;
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "demo/examples/" + example + "/program.hex", false);
xmlHttp.send(null);
if (document.getElementById("useeditarea").checked){
editAreaLoader.setValue("hexprogram", xmlHttp.responseText);
}else{
document.getElementById("hexprogram").value = xmlHttp.responseText;
}
xmlHttp.open("GET", "demo/examples/" + example + "/plugin.py", false);
xmlHttp.send(null);
if (document.getElementById("useeditarea").checked){
editAreaLoader.setValue("extsource", xmlHttp.responseText);
}else{
document.getElementById("extsource").value = xmlHttp.responseText;
}
document.getElementById("cmbExample").value = "";
}
// HEX-program loading
var load_hexprogram = document.createElement('input');
load_hexprogram.setAttribute('type', 'file');
load_hexprogram.addEventListener('change', loadHexprogram, false);
function loadHexprogram(evt) {
var files = evt.target.files;
if (files) {
var r = new FileReader();
f = files[0];
r.onload = (function (f) {
return function (e) {
editAreaLoader.setValue("hexprogram", e.target.result);
};
})(f);
r.readAsText(f);
load_hexprogram.value = "";
}
}
function saveHexprogram(id, content){
a = document.createElement('a');
document.body.appendChild(a);
a.download = name;
a.href = "data:application/octet-stream," + encodeURIComponent(editAreaLoader.getValue("hexprogram"));
a.download = "program.hex";
a.click();
}
// external source loading
var load_extsource = document.createElement('input');
load_extsource.setAttribute('type', 'file');
load_extsource.addEventListener('change', loadExtsource, false);
function loadExtsource(evt) {
var files = evt.target.files;
if (files) {
var r = new FileReader();
f = files[0];
r.onload = (function (f) {
return function (e) {
editAreaLoader.setValue("extsource", e.target.result);
};
})(f);
r.readAsText(f);
load_extsource.value = "";
}
}
function saveExtsource(id, content){
a = document.createElement('a');
document.body.appendChild(a);
a.download = name;
a.href = "data:application/octet-stream," + encodeURIComponent(editAreaLoader.getValue("extsource"));
a.download = "extsource.py";
a.click();
}
function updateEditAreas(){
updateEditArea('hexprogram');
updateEditArea('extsource');
}
function updateEditArea(id){
if (document.getElementById("useeditarea").checked){
if (id == "hexprogram"){
editAreaLoader.init({
id: "hexprogram" // id of the textarea to transform
,start_highlight: true // if start with highlight
,allow_resize: "no"
,word_wrap: true
,language: "en"
,syntax: "hex"
,allow_toggle: false
,toolbar: "load, save, select_font"
,load_callback: "load_hexprogram.click"
,save_callback: "saveHexprogram"
});
}
if (id == "extsource"){
editAreaLoader.init({
id: "extsource" // id of the textarea to transform
,start_highlight: true // if start with highlight
,allow_resize: "no"
,word_wrap: true
,language: "en"
,syntax: "python"
,toolbar: "save, load, select_font"
,load_callback: "loadExtsource"
,save_callback: "saveExtsource"
,allow_toggle: false
,toolbar: "load, save, select_font"
,load_callback: "load_extsource.click"
,save_callback: "saveExtsource"
});
}
}else{
if (id == "hexprogram"){
editAreaLoader.delete_instance("hexprogram");
}
if (id == "extsource"){
editAreaLoader.delete_instance("extsource");
}
}
}
function toggle_visibility(id) {
var checkbox = document.getElementById("visible_" + id);
checkbox.checked = !checkbox.checked;
update_visibility(id);
}
function update_visibility(id) {
var checkbox = document.getElementById("visible_" + id);
var hidebutton = document.getElementById("hide_" + id);
var element = document.getElementById(id);
if(checkbox.checked){
hidebutton.innerHTML = "Hide";
element.style.display = 'block';
}else{
hidebutton.innerHTML = "Show";
element.style.display = 'none';
}
}
-->
</script>
<h2>Online Demo</h2>
<?php
if (!isset($_POST['btnClear'])){
$hexprogram = $_POST['hexprogram'];
$extsource = $_POST['extsource'];
}
if (isset($_POST['btnLoad'])){
$example = trim($_POST['example']);
}else{
$example = "";
}
if (!isset($_POST['reloaded'])){
$example = "001_intro";
}
?>
<p>This <b>online demo of the dlvhex system</b> allows for
evaluating programs without local installation.
This is intended mainly for testing and learning purposes.
External sources for the program at the top may be directly implemented in a Python script below.</p>
<p>Please check out the predefined <b>examples at the upper right corner</b> for a quick overview or consider the <b>links to the system documentation in the right-hand menu</b> for a more detailed description.</p>
<?php
$reasonerversion = trim(file_get_contents(trim(file_get_contents('demo/evalurl.txt')) . "?mode=getversion"));
if ($reasonerversion != "") {
print '<div style="text-align:right;">(The online demo currently runs <i>' . $reasonerversion . '</i>)</div>';
}else{
print '<div style="text-align:right;">(The online demo is <font color="red">currently offline</font>)</div>';
}
?>
</p>
<br>
<div style="width:100%;">
<h3>Input</h3>
<form method="post" action="demo.php">
<input type="text" style="display:none" name="reloaded">
<div style="text-align:right;">
Load example:
<?php
$exampleList = "<option name=\"\" value=\"\"></option>";
$dirhandle=opendir('demo/examples');
while($file=readdir($dirhandle)){
if ($file != "" && $file != "." && $file != ".."){
$file_array[] = $file;
}
}
closedir($dirhandle);
sort($file_array);
foreach ($file_array as $file){
$exname = file_get_contents("demo/examples/" . $file . "/name.txt");
$exampleList = $exampleList . "<option name=\"example\" value=\"$file\">$exname</option>";
}
?>
<noscript>
<select name="example">
<?php print $exampleList; ?>
</select>
<input type="submit" name="btnLoad" value="Load">
</noscript>
<select class="jsonly" id="cmbExample" onchange="loadExample();">
<?php print $exampleList; ?>
</select><br>
<noscript><b>Your browser does not support JavaScript.</b><br>Please enable it to make use of advanced features.</a></noscript>
<p class="jsonly"><input type="checkbox" id="useeditarea" name="useeditarea" onclick="updateEditAreas();" <?php echo (!isset($_POST['reloaded']) || isset($_POST['useeditarea'])) ? 'checked' : ''; ?>>Use advanced editor (powered by <a href='http://www.cdolivet.com/editarea' target='_blank'>EditArea</a>)</input></p>
</div>
<input type="checkbox" style="display:none" id="visible_hexprogramdiv" name="visible_hexprogramdiv" <?php echo (!isset($_POST['reloaded']) || isset($_POST['visible_hexprogramdiv'])) ? 'checked' : ''; ?> />
<input type="checkbox" style="display:none" id="visible_extsourcediv" name="visible_extsourcediv" <?php echo isset($_POST['visible_extsourcediv']) ? 'checked' : ''; ?> />
<input type="checkbox" style="display:none" id="visible_commandlineoptionsdiv" name="visible_commandlineoptionsdiv" <?php echo isset($_POST['visible_commandlineoptionsdiv']) ? 'checked' : ''; ?> />
<!-- <div style="width:49%;float:left;">-->
<b>HEX-Program:</b><br><p class="jsonly">[<a id="hide_hexprogramdiv" href="javascript:void(0)" onclick="toggle_visibility('hexprogramdiv'); updateEditArea('hexprogram');">Hide</a>]</p>
<div id="hexprogramdiv" style="width:100%">
<textarea id="hexprogram" name="hexprogram" style="width:100%; resize:none;" rows="30"><?php if ($example != ""){print file_get_contents("demo/examples/" . $example . "/program.hex");}else{print $hexprogram;}?></textarea>
</div>
<!-- </div>-->
<!-- <div style="width:2%;float:left;"> </div>-->
<!-- <div style="width:49%;float:left;">-->
<br><br>
<b>External Source Definition (Python):</b><br><p class="jsonly">[<a id="hide_extsourcediv" href="javascript:void(0)" onclick="toggle_visibility('extsourcediv'); updateEditArea('extsource');">Hide</a>]</p>
<div id="extsourcediv" style="width:100%">
<textarea id="extsource" name="extsource" style="width:100%; resize:none;" rows="30"><?php if ($example != ""){print file_get_contents("demo/examples/" . $example . "/plugin.py");}else{print $extsource;}?></textarea>
</div>
<br><br>
<b>Command-line Options:</b><br><p class="jsonly">[<a id="hide_commandlineoptionsdiv" href="javascript:void(0)" onclick="toggle_visibility('commandlineoptionsdiv');">Hide</a>]</p>
<div id="commandlineoptionsdiv" style="width:100%">
<table id="commandlineoptions" summary="">
<tr><td style="white-space: nowrap">Filter predicates (comma-separated):</td><td style="width:1000%"><input type="text" id="optFilter" name="optFilter" style="width:100%" value="<?php echo isset($_POST['optFilter']) ? $_POST['optFilter'] : ''; ?>"></td></tr>
<tr><td style="white-space: nowrap">Number of answer sets to compute<br>(empty or 0 means all):</td><td><input type="text" id="optNumAS" name="optNumAS" style="width:100%" value="<?php echo isset($_POST['optNumAS']) ? $_POST['optNumAS'] : ''; ?>"></td></tr>
<tr><td style="white-space: nowrap">Allow strong negation:</td><td><input type="checkbox" id="optStrongNegation" name="optStrongNegation" <?php echo !isset($_POST['reloaded']) || isset($_POST['optStrongNegation']) ? 'checked' : ''; ?> /></td></tr>
<tr><td style="white-space: nowrap">Liberal safety:</td><td><input type="checkbox" id="optLiberalSafety" name="optLiberalSafety" <?php echo !isset($_POST['reloaded']) || isset($_POST['optLiberalSafety']) ? 'checked' : ''; ?> /></td></tr>
<tr><td style="white-space: nowrap">Custom options:</td><td><span><input type="text" id="optCustom" name="optCustom" style="display:table-cell; width:100%" value="<?php echo isset($_POST['optCustom']) ? $_POST['optCustom'] : ''; ?>"></span></td></tr>
</table>
</div>
<div style="width:100%;text-align:right;">
<noscript><input type="submit" name="btnClear" value="Clear"> <input type="submit" name="btnEvaluate" value="Evaluate"></noscript>
<input class="jsonly" type="button" onclick="clearHexprogramAndExtsource();" value="Clear"> <input class="jsonly" type="button" onclick="evaluateHEX();" value="Evaluate">
</div>
<!-- </div>-->
</form>
</div>
<h3>Output</h3>
<div id="outputdiv" style="width:100%;float:right;">
<?php
if (isset($_POST['btnEvaluate'])){
function endsWith($haystack, $needle) {
return $needle === "" || substr($haystack, -strlen($needle)) === $needle;
}
$commandlineoptions = "";
if ($_POST['optFilter'] != "") { $commandlineoptions = $commandlineoptions . " --filter=" . $_POST['optFilter']; };
if ($_POST['optNumAS'] != "") { $commandlineoptions = $commandlineoptions . " -n=" . $_POST['optNumAS']; };
if ($_POST['optLiberalSafety']) { $commandlineoptions = $commandlineoptions . " --liberalsafety"; } else { $commandlineoptions = $commandlineoptions . " --strongsafety"; }
if ($_POST['optStrongNegation']) { $commandlineoptions = $commandlineoptions . " --strongnegation-enable=true"; } else { $commandlineoptions = $commandlineoptions . " --strongnegation-enable=false"; }
if ($_POST['optCustom'] != "") { $commandlineoptions = $commandlineoptions . " " . $_POST['optCustom']; };
$args = "?mode=evalhex" .
"&commandlineoptions=" . urlencode($commandlineoptions) .
"&hexprogram=" . urlencode($hexprogram) .
"&extsource=" . urlencode($extsource);
$contents = trim(file_get_contents(trim(file_get_contents('demo/evalandformaturl.txt')) . $args));
print $contents;
}else{
print "Please prepare your input and click 'Evaluate' to run the reasoner";
}
?>
</div>
<script language="Javascript" type="text/javascript">
<!--
update_visibility('hexprogramdiv');
update_visibility('extsourcediv');
update_visibility('commandlineoptionsdiv');
updateEditAreas();
-->
</script>
</div>
<div class="grid_3">
<p> </p>
<p>
<img width="200" height="44" src="images/logo_whitebg.png" alt="dlvhex" id="logo">
</p>
<p>
<div style="font-size: 14pt"><label for="q">Search this Website</label></div>
<form action="http://www.google.com/cse" id="cse-search-box">
<div>
<input name="cx" id="cx" value="010363983165505105153:4bhl-l5ixd4" type="hidden" alt="Search this website">
<input name="ie" id="ie" value="UTF-8" type="hidden" alt="Search this website">
<input style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" name="q" id="q" size="19" type="text">
<input name="sa" id="sa" value="Go" type="submit">
</div>
</form>
</p>
<p>
<span style="font-size: 14pt">General</span><br>
<a href="https://github.com/hexhex/">dlvhex source code @ github.com</a><br>
<!-- a href="https://sourceforge.net/projects/dlvhex/">dlvhex: Sourceforge project</a><br/ -->
<a href="doap.rdf">Description-Of-A-Project</a>
</p>
<p>
<span style="font-size: 14pt">Popular Plugins</span><br>
<!-- <a href="http://www.polleres.net/dlvhex-sparql">SPARQL Plugin</a><br> -->
<a href="actionplugin.html">Action Plugin</a><br>
<a href="decisiondiagramsplugin.html">DecisionDiagrams Plugin</a><br>
<a href="dlplugin.html">Description Logics Plugin</a><br>
<a href="dlliteplugin.html">Description Logics Lite Plugin</a><br>
<a href="mergingplugin.html">MELD: Belief Merging Plugin</a><br>
<a href="nestedhexplugin.html">Nested HEX Plugin</a><br>
<a href="http://www.kr.tuwien.ac.at/research/systems/mcsie">MCSIE Plugin</a><br>
<a href="stringplugin.html">String Plugin</a><br>
<a href="https://sourceforge.net/projects/dlvhex-semweb/">dlvhex-semweb Project</a><br>
</p>
<p>
<span style="font-size: 14pt">Documentation</span><br>
<a href="docs/userguide.pdf">User Guide</a><br>
<a href="https://github.com/hexhex/core/blob/master/README">README</a><br>
<a href="doc2x">doxygen</a><br>
<a href="doc2x/group__pluginframework.html">Writing Plugins in C++</a><br>
<a href="doc2x/group__pythonpluginframework.html">Writing Plugins in Python</a>
<!--
<a href="doc1x">doxygen version 1.X</a><br>
<a href="doc1x/group__pluginframework.html">Writing Plugins 1.X</a><br>
-->
</p>
</div> <!-- grid_3 -->
</div> <!-- container_12 -->
</body>
</html>
<!--
Local Variables:
mode: xml
End:
-->