diff service/environment/index.html @ 136:2200d6530a5d

testing rdfs:comment display on enironment's graph viewer Ignore-this: d25c57b80a1dc4180b348d64f1546cd6
author drewp@bigasterisk.com
date Sun, 13 Oct 2013 12:03:26 -0700
parents 88e7dd767550
children 1952788e5299
line wrap: on
line diff
--- a/service/environment/index.html	Sun Oct 13 00:25:03 2013 -0700
+++ b/service/environment/index.html	Sun Oct 13 12:03:26 2013 -0700
@@ -15,12 +15,13 @@
       .literalType { vertical-align: super; font-size: 80%; }
       .literal { display: inline-block; border: 1px solid gray; background: white; }
       .resource { display: inline-block; background: lightblue; border-radius: 6px; padding: 1px 6px; margin: 2px; }
-      
+      .comment { color: green; }
     </style>
     
     <script type="text/html" id="node">
       <!-- ko if: typeof($data) == 'string' -->
-      <span class="node resource" data-bind="html: $root.createCurie($data)"></span> <span data-bind="html: $root.docLink($data)"></span>
+      <span class="node resource" data-bind="html: $root.createCurie($data)"></span>
+      <span class="comment" data-bind="html: $root.docLink($data)"></span>
       <!-- /ko -->
       <!-- ko if: typeof($data) != 'string' -->
          <!-- ko if: type == 'literal' -->
@@ -28,7 +29,8 @@
            <span class="literalType" data-bind="html: $root.createCurie($data['datatype'] || '')"></span>
          <!-- /ko -->
          <!-- ko if: type == 'uri' -->
-           <span class="resource" data-bind="html: $root.createCurie(value)"></span> <span data-bind="html: $root.docLink($data)"></span>
+           <span class="resource" data-bind="html: $root.createCurie(value)"></span>
+           <span class="comment" data-bind="html: $root.docLink($data)"></span>
          <!-- /ko -->
          <!-- ko if: type == 'bnode' -->
            <span class="resource bnode" data-bind="text: value"></span>
@@ -93,10 +95,18 @@
             var short = tryCurie(uri);
             return '<a href="' + _.escape(uri)  + '">' + _.escape(short) + '</a>';
           };
+          var docs = {}; // uri : observable(doc)
           model.docLink = function(uri) {
-            var result = ko.observable("...");
-            setTimeout(function() { result('hey'); }, 1000);
-            return result;
+            if (uri.type == 'uri') {
+              uri = uri.value;
+            }
+            if (_.isUndefined(docs[uri])) {
+              docs[uri] = ko.observable("...");
+              $.getJSON("doc", {uri: uri}, function(data) {
+                docs[uri](data.comment); // might be undefined
+              });
+            }
+            return docs[uri];
           };
 
           model.refresh = function() {