Changeset - 6f984ce851e2
[Not reviewed]
default
2 0 6
drewp@bigasterisk.com - 12 years ago 2012-09-30 07:10:51
drewp@bigasterisk.com
refactor rdfdb web ui
Ignore-this: e94d7c4e2379ebae4d87d5cfa6f627c2
6 files changed with 129 insertions and 56 deletions:
0 comments (0 inline, 0 general)
light9/rdfdb/web/graphView.xhtml
Show inline comments
 
new file 100644
 
<?xml version="1.0" encoding="utf-8"?>
 
<!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>graphview</title>
 
    <link rel="stylesheet" type="text/css" href="style.css"/>
 

	
 
  </head>
 
  <body>
 
    <!--
 
        this page is another graph client who maintains the whole
 
        graph all the time
 
    -->
 

	
 
    <p>status: <span id="status">starting...</span></p>
 

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

	
 
    <p>URI substring: <input type="text" id="uriSubstring"/></p>
 

	
 
    <table>
 
      <thead>
 
        <tr>
 
          <th>subject</th> <th>predicate</th> <th>object</th> <th>context</th>
 
        </tr>
 
      </thead>
 
      <tbody>
 
      </tbody>
 
    </table>
 

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

	
 
      });
 
      // ]]>
 
    </script>
 
  </body>
 
</html>
 
\ No newline at end of file
light9/rdfdb/web/index.xhtml
Show inline comments
 
file renamed from light9/rdfdb.xhtml to light9/rdfdb/web/index.xhtml
 
@@ -4,42 +4,7 @@
 
<html xmlns="http://www.w3.org/1999/xhtml">
 
  <head>
 
    <title>rdfdb</title>
 
    <style type="text/css" media="all">
 
      /* <![CDATA[ */
 
body {
 
background: black;
 
color: white;
 
}
 
      #patches { /* wants flex box */
 
          max-height: 27em;
 
          overflow-y: scroll;
 
      }
 
      .patch {
 
          border: 1px solid gray;
 
          padding: 2px;
 
          margin: 4px;
 
      }
 
      .patch > div {
 
          font-family: monospace;
 
          font-size: 90%;
 
          white-space: pre-wrap;
 
      } 
 
      .patch .adds {
 
          color: #3AEA38;
 
      }
 
      .patch .deletes {
 
          color: #FF2828;
 
      }
 
      #out {
 
          white-space: pre-wrap;
 
      }
 
      .patch fieldset {
 
          color: gray;
 
          font-family: arial;
 
          font-size: 75%;
 
      }
 
      /* ]]> */
 
    </style>
 
    <link rel="stylesheet" type="text/css" href="style.css"/>
 
  </head>
 
  <body>
 
    <h1>rdfdb</h1>
 
@@ -57,7 +22,8 @@ color: white;
 
      <div id="out"></div>
 
    </fieldset>
 

	
 
    <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
 
    <script type="text/javascript" src="lib/jquery-1.7.2.min.js"></script>
 
    <script type="text/javascript" src="websocket.js"></script>
 
    <script type="text/javascript">
 
      // <![CDATA[
 
      $(function(){
 
@@ -77,25 +43,7 @@ color: white;
 

	
 
              $('#out').append($('<div>').text(JSON.stringify(d)));
 
          }
 
          
 
          var pong = 0;
 
          function connect() {
 
              var ws = new WebSocket("ws://localhost:8051/live");
 
              
 
              ws.onopen = function() {   $("#status").text("connected"); };
 
              ws.onerror = function(e) { $("#status").text("error: "+e); };
 
              ws.onclose = function() {  
 
                  pong = 1 - pong;
 
                  $("#status").text("disconnected (retrying "+(pong ? "😼":"😺")+")"); 
 
                  // this should be under a requestAnimationFrame to
 
                  // save resources
 
                  setTimeout(connect, 2000);
 
              };
 
              ws.onmessage = function (evt) {
 
                  onMessage(JSON.parse(evt.data));
 
              };
 
          }
 
          connect();
 
          reconnectingWebSocket("ws://localhost:8051/live", onMessage);
 
      });
 
      // ]]>
 
    </script>
light9/rdfdb/web/lib/jquery-1.7.2.min.js
Show inline comments
 
file renamed from lib/jquery-1.7.2.min.js to light9/rdfdb/web/lib/jquery-1.7.2.min.js
light9/rdfdb/web/style.css
Show inline comments
 
new file 100644
 
body {
 
    background: black;
 
    color: white;
 
}
 
#patches { /* wants flex box */
 
    max-height: 27em;
 
    overflow-y: scroll;
 
}
 
.patch {
 
    border: 1px solid gray;
 
    padding: 2px;
 
    margin: 4px;
 
}
 
.patch > div {
 
    font-family: monospace;
 
    font-size: 90%;
 
    white-space: pre-wrap;
 
} 
 
.patch .adds {
 
    color: #3AEA38;
 
}
 
.patch .deletes {
 
    color: #FF2828;
 
}
 
#out {
 
    white-space: pre-wrap;
 
}
 
.patch fieldset {
 
    color: gray;
 
    font-family: arial;
 
    font-size: 75%;
 
}
light9/rdfdb/web/syncedgraph.js
Show inline comments
 
new file 100644
 
function SyncedGraph(label) {
 
    /*
 
      like python SyncedGraph but talks over a websocket to
 
      rdfdb. This one has an API more conducive to reading and
 
      querying.
 
    */
 
    var self = this;
 

	
 
    
 

	
 
    self.patch = function (p) {
 
        throw;
 
    }
 
    self.nodesWithSubstring = function (subString) {
 

	
 
    }
 
    self.quads = function (s, p, o, c) {
 
        // any args can be null for wildcard
 
    }
 

	
 

	
 
    function onMessage(d) {
 
        $('#out').append($('<div>').text(JSON.stringify(d)));
 
    }
 
    
 
    reconnectingWebSocket("ws://localhost:8051/liveSyncedGraph", onMessage);
 
}
light9/rdfdb/web/websocket.js
Show inline comments
 
new file 100644
 
function reconnectingWebSocket(url, onMessage) {
 
    var pong = 0;
 
    function connect() {
 
        var ws = new WebSocket(url);
 
        
 
        ws.onopen = function() {   $("#status").text("connected"); };
 
        ws.onerror = function(e) { $("#status").text("error: "+e); };
 
        ws.onclose = function() {  
 
            pong = 1 - pong;
 
            $("#status").text("disconnected (retrying "+(pong ? "😼":"😺")+")"); 
 
            // this should be under a requestAnimationFrame to
 
            // save resources
 
            setTimeout(connect, 2000);
 
        };
 
        ws.onmessage = function (evt) {
 
            onMessage(JSON.parse(evt.data));
 
        };
 
    }
 
    connect();
 
}
 
\ No newline at end of file
0 comments (0 inline, 0 general)