{% load staticfiles %}
<!-- Yawol client -->
<script src="{% static 'js/yawol.js' %}"></script>
<!-- Yawol template -->
<script type="text/template" id="synsetbox_template">
     <div class="synsetbox container-fluid well">
     <div class="row">
     <div class="col-xs-12">
      <button type="button" class="close" aria-label="Close">
        <span aria-hidden="true">&times;</span>
      </button>
     </div>
     </div>
     <div class="row">
     <div class="col-xs-12 col-sm-2 col-md-2">
      <label>SynsetID</label>
     </div>
     <div class="col-xs-12 col-sm-2 col-md-2">
      <span class="synsetid"><%= synset.synsetid %></span>                
     </div>
     <div class="col-xs-12 col-sm-2 col-md-2">
      <label>Lemmas</label> <span class="lemma"></span>
     </div>
     <div class="col-xs-12 col-sm-6 col-md-6">
      <span class="lemmas"><%= _.join(synset.lemmas, ', ') %></span>
     </div>
     </div>
     <div class="row">
     <div class="col-xs-12 col-md-2">
      <label>Definition</label>
     </div>
     <div class="col-xs-12 col-md-10">
      <span class="definition"><%= synset.definition %></span>
     </div>
     </div>
     <div class="row">
     <div class="col-xs-12 col-md-2">
      <label>Examples</label>
     </div>
     <div class="col-xs-12 col-md-10">
       <span class="examples">
         <% if(synset.examples.length > 0) {  %>
         <ul>
           <% _.each(synset.examples, function(ex){ %>
           <li><%= ex %></li>
           <% }); %>
         </ul>
         <% } %>    
       </span>
     </div>
     </div>
     </div>
</script>
<script>
 var yawol;
 var yawol_root = '{% url "yawol:index" %}';
 
 function get_yawol() {
   var yawol = undefined;
   if (yawol == undefined) {
     yawol = new Yawol("synsets", yawol_root, $("#synsetbox_template").html());
   }
   return yawol;
 }
 
 function find_synset(synsetid) {
   return function(){
     $("#message_box").empty();
     get_yawol().search_synset(synsetid, undefined, undefined, find_synset_error);
   };
 }

 function find_synset_error(jqxhr, query) {
   $("#message_box").empty();
   get_yawol().clear();
   show_alert("Could not find synset " + query);
 }
</script>
