<docbook><section><title>ODSWebIDIdPJScriptEx1</title><bridgehead class="http://www.w3.org/1999/xhtml:h2">Using Virtuoso&#39;s <ulink url="WebID">WebID</ulink> Verify Proxy Service with an X.509 certificate <ulink url="WebID">WebID</ulink>: <ulink url="JavaScript">JavaScript</ulink> Example</bridgehead>
<programlisting>&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;WebID Verification Demo - HTML, JS&lt;/title&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
      function check() {
        if (document.location.protocol != &#39;https:&#39;) {
          alert(&#39;Please use https protocol&#39;);
          return;
        }

        var callback = document.location.protocol + &#39;//&#39; + document.location.host + document.location.pathname;
        document.location = &#39;https://id.myopenlink.net/ods/webid_verify.vsp?callback=&#39; + encodeURIComponent(callback);
      }
      function getObject(id) {
        return document.getElementById(id)
      }
      function hide(id) {
        var obj = getObject(id);
        obj.style.display = &quot;none&quot;;
      }
      function show(id) {
        var obj = getObject(id);
        obj.style.display = &quot;&quot;;
      }
      function getParam(name)
      {
        name = name.replace(/[\[]/,&quot;\\\[&quot;).replace(/[\]]/,&quot;\\\]&quot;);
        var regexS = &quot;[\\?&amp;]&quot;+name+&quot;=([^&amp;#]*)&quot;;
        var regex = new RegExp( regexS );
        var results = regex.exec( window.location.href );
        if( results == null )
          return &quot;&quot;;
        else
          return decodeURIComponent(results[1]);
      }
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;WebID Verification Demo&lt;/h1&gt;
    &lt;div&gt;
      This will check your X.509 Certificate&#39;s WebID  watermark. &lt;br/&gt;Also note this service supports ldap, http, mailto, acct scheme based WebIDs.
    &lt;/div&gt;
    &lt;br/&gt;
    &lt;br/&gt;
    &lt;div&gt;
      &lt;input type=&quot;button&quot; name=&quot;go&quot; value=&quot;Check&quot; id=&quot;go&quot; onclick=&quot;javascript: return check();&quot; /&gt;
    &lt;/div&gt;
    &lt;div id=&quot;result&quot; style=&quot;display: none;&quot;&gt;
    	The return values are:
	    &lt;ul id=&quot;result_webid&quot; style=&quot;display: none;&quot;&gt;
	      &lt;li&gt;WebID -  &lt;span id=&quot;webid&quot;&gt;&lt;/span&gt;&lt;/li&gt;
	      &lt;li&gt;Timestamp in ISO 8601 format - &lt;span id=&quot;ts&quot;&gt;&lt;/span&gt;&lt;/li&gt;
	    &lt;/ul&gt;
	    &lt;ul id=&quot;result_error&quot; style=&quot;display: none;&quot;&gt;
	      &lt;li&gt;Error - &lt;span id=&quot;error&quot;&gt;&lt;/span&gt;&lt;/li&gt;
	    &lt;/ul&gt;
    &lt;/div&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
      var webid = getParam(&#39;webid&#39;);
      var error = getParam(&#39;error&#39;);
      if ((webid != &#39;&#39;) || (error != &#39;&#39;)) {
        show(&#39;result&#39;);
        if (webid != &#39;&#39;) {
          show(&#39;result_webid&#39;);
          getObject(&#39;webid&#39;).innerHTML = getParam(&#39;webid&#39;);;
          getObject(&#39;ts&#39;).innerHTML = getParam(&#39;ts&#39;);;
        } else {
          hide(&#39;result_webid&#39;);
        }
        if (error != &#39;&#39;) {
          show(&#39;result_error&#39;);
          getObject(&#39;error&#39;).innerHTML = getParam(&#39;error&#39;);;
        } else {
          hide(&#39;result_error&#39;);
        }
      } else {
        hide(&#39;result&#39;);
      }
    &lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;

</programlisting></section></docbook>