view light9/rdfdb/web/index.xhtml @ 1212:95dfce5c12ce

rearrange /static. new bin/homepage Ignore-this: 2b17aa8e74a9c052a9a93704e85287b1
author drewp@bigasterisk.com
date Sun, 07 Jun 2015 22:42:33 +0000
parents a4632a7b2e17
children e703b3434dbd
line wrap: on
line source

<?xml version="1.0" encoding="utf8"?>
<!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>rdfdb</title>
    <link rel="stylesheet" type="text/css" href="/style.css"/>
  </head>
  <body>
    <h1>rdfdb</h1>
    <p>status: <span id="status">starting...</span></p>
    
    <section>
      <h2>Edits</h2>
      <div id="patches"></div>
    </section>

    <p>Clients: <span id="clients"/></p>

    <fieldset>
      <legend>Messages</legend>
      <div id="out"></div>
    </fieldset>

    <script type="text/javascript" src="/lib/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="/websocket.js"></script>
    <script type="text/javascript">
      // <![CDATA[
      $(function(){

          function collapseCuries(s) {
            // this is temporary. The correct thing is to parse the quad (or receive it as a tree) and then make links to the full URIs and display curies of them

              return s
                  .replace(/<http:\/\/www.w3.org\/2001\/XMLSchema#(.*?)>/g, function (match, short) { return "xsd:"+short; })
                  .replace(/<http:\/\/light9.bigasterisk.com\/(.*?)>/g, function (match, short) { return "light9:"+short; })
                  .replace(/<http:\/\/light9.bigasterisk.com\/show\/dance2012\/sessions\/(.*?)>/g, function (match, short) { return "kcsession:"+short });
          }

          function onMessage(d) {
              if (d.clients !== undefined) {
                  $("#clients").empty().text(JSON.stringify(d.clients));
              }
              if (d.patch !== undefined) {
                  $("#patches").prepend(
                      $("<fieldset>").addClass("patch")
                          .append($("<legend>").text("Patch"))
                          .append($("<div>").addClass("deletes").text(collapseCuries(d.patch.deletes)))
                          .append($("<div>").addClass("adds").text(collapseCuries(d.patch.adds)))
                  );
              }

              $('#out').append($('<div>').text(JSON.stringify(d)));
          }
          reconnectingWebSocket("ws://localhost:8051/live", onMessage);
      });
      // ]]>
    </script>

  </body>
</html>