diff service/reasoning/index.html @ 20:3f0dd03112b5

move reasoning from /my/proj/room, new integration with magma Ignore-this: 5c5551d566324f5a6e87f6f7623f3c3
author drewp@bigasterisk.com
date Tue, 07 Feb 2012 02:45:22 -0800
parents
children 0448fbd96a31
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/service/reasoning/index.html	Tue Feb 07 02:45:22 2012 -0800
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <title>reasoning</title>
+    <style type="text/css" media="all">
+      /* <![CDATA[ */
+body {
+    font-family: sans-serif;
+    font-size: 12px;
+
+}
+pre {
+    font-family: sans-serif;
+} 
+pre div {
+    border-bottom: 1px solid #ccc;
+}
+.pred {
+    background: #e7e6f8;
+}
+.obj {
+    background: #ccf
+}
+/* ]]> */
+    </style>
+
+  </head>
+  <body>
+
+    <h2>Input</h2>
+    <pre id="input"/>
+
+    <h2>Rules</h2>
+    <pre id="rules"/>
+
+    <h2>Output</h2>
+    <pre id="output"/>
+
+    <input id="auto" type="checkbox"/> <label for="auto">auto refresh</label>
+
+    <script type="text/javascript" src="jquery.min.js"></script>
+ <script type="text/javascript">
+      // <![CDATA[
+      $(function () { 
+	  function abbrev(term) { // does rdfquery do this?
+	      var repl = [
+		  ["http://projects.bigasterisk.com/room/", "room:"],
+		  ["http://projects.bigasterisk.com/device/", "dev:"],
+		  ["http://purl.org/dc/terms/", "dcterms:"],
+		  ["http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:"]]; 
+	      for (i in repl) {
+		  var p=repl[i];
+		  if (term.match(new RegExp("^" + p[0]))) {
+		      return term.replace(p[0], p[1]);
+		  }
+	      }
+	      return term;
+	  }
+
+	  function update() {
+	      function makeAddStmts(elem) {
+		  return function (stmts) {
+		      elem.empty();
+		      $.each(stmts, function (i, s) {
+			  elem.append($("<div>").html(
+			      "<span>"+abbrev(s[0])+"</span> "+
+				  "<span class=\"pred\">"+abbrev(s[1])+"</span> "+
+				  "<span class=\"obj\">"+abbrev(s[2])+"</span>"));
+
+		      })
+		  }
+	      }
+
+	      $.get("lastInputGraph", makeAddStmts($("#input")));
+	      $.get("lastOutputGraph", makeAddStmts($("#output")));
+	      $.get("rules", function (txt) { 
+		  $("#rules").empty().text(txt);
+	      });
+	  }
+	  function loop() {
+	      update();
+	      if ($("input#auto").is(":checked")) {
+		  setTimeout(loop, 2000);
+	      }
+	  }
+	  loop();
+	  $("input#auto").click(loop);
+      });
+      // ]]>
+</script>
+  </body>
+</html>
\ No newline at end of file