<commit_before>$(window).bind( 'hashchange', _updateFocusFromIri);

$( document ).ready( function() {
    $( "#labelOfOwner" ).on( 'click', function() {
        var iri = $( "#labelOfOwner" ).data( 'iri');
        if (iri) {
            jQuery.bbq.pushState({'iri' : iri});  
        };
    });
});

function _updateFocusFromIri(event) {
    var iri = event.getState( 'iri' );
    $( '.optionalField' ).hide();
    sparql_predefined(
        "/sparql-queries/focus.sparql.txt", 
        {'focus' : iri}, 
        _updateFocusFromJson);    
}

var _predicate_to_action = {
  "http://dot.rural/sepake/ownedBy" :
    _updateOwnerFromIri,
  "http://www.w3.org/2000/01/rdf-schema#label" : 
    function( y ){ $( ".labelOfFocus" ).text(y) },
  "http://dot.rural/sepake/htmlDescription" : 
    function( y ){ $( "#descriptionOfFocus" ).html(y || "(No summary)") },
  "http://xmlns.com/foaf/0.1/homepage" : 
    function( y ){ 
      if (y) {
          $( "#homepageOfFocus .dataGoesHere" ).text(y);
          $( "#homepageOfFocus .dataGoesHere" ).attr("href", y);
          $( "#homepageOfFocus" ).show();
      }
  },
  "http://www.w3.org/ns/prov#startedAtTime" : 
    function( y ){ 
      if (y) {
          $( "#startedAtTime .dataGoesHere" ).text(y);
          $( "#startedAtTime" ).show();          
      };
  },
  "http://www.w3.org/ns/prov#endedAtTime" : 
    function( y ){ 
      if (y) {
          $( "#endedAtTime .dataGoesHere" ).text(y) 
          $( "#endedAtTime" ).show()          
      };
  },
};

function _docReady_updateFocusFromJson(response) {
  $( document ).ready( function() {
    _updateFocusFromJson(response)
  }
}

function _updateFocusFromJson(response) {
    try {
        var values = sparqlListToObject(response, "p", "y");
        $.each(_predicate_to_action, function( p, action ){
          action(values[p]);
        });
        if (!values["http://dot.rural/sepake/htmlDescription"]) {
          _set_html_from_dbpedia_description( "#descriptionOfFocus", values["http://www.w3.org/2000/01/rdf-schema#label"] );
        }
    } catch (err) {
      console.log( err );
    }
}

function _updateOwnerFromIri(iri) {
  if (!iri) {
    return;
  };
  $( "#labelOfOwner" ).data( 'iri', iri);
  sparql("owner",
          [
           "SELECT ?y WHERE {",
           "    BIND (<--IRI--> AS ?owner) .",
           "    { ?owner rdfs:label ?y } .",
           "}",
          ],<commit_msg>Fixed JS bug For #30-query-parameters<commit_after>$(window).bind( 'hashchange', _updateFocusFromIri);

$( document ).ready( function() {
    $( "#labelOfOwner" ).on( 'click', function() {
        var iri = $( "#labelOfOwner" ).data( 'iri');
        if (iri) {
            jQuery.bbq.pushState({'iri' : iri});  
        };
    });
});

function _updateFocusFromIri(event) {
    var iri = event.getState( 'iri' );
    $( '.optionalField' ).hide();
    sparql_predefined(
        "/sparql-queries/focus.sparql.txt", 
        {'focus' : iri}, 
        _updateFocusFromJson);    
}

var _predicate_to_action = {
  "http://dot.rural/sepake/ownedBy" :
    _updateOwnerFromIri,
  "http://www.w3.org/2000/01/rdf-schema#label" : 
    function( y ){ $( ".labelOfFocus" ).text(y) },
  "http://dot.rural/sepake/htmlDescription" : 
    function( y ){ $( "#descriptionOfFocus" ).html(y || "(No summary)") },
  "http://xmlns.com/foaf/0.1/homepage" : 
    function( y ){ 
      if (y) {
          $( "#homepageOfFocus .dataGoesHere" ).text(y);
          $( "#homepageOfFocus .dataGoesHere" ).attr("href", y);
          $( "#homepageOfFocus" ).show();
      }
  },
  "http://www.w3.org/ns/prov#startedAtTime" : 
    function( y ){ 
      if (y) {
          $( "#startedAtTime .dataGoesHere" ).text(y);
          $( "#startedAtTime" ).show();          
      };
  },
  "http://www.w3.org/ns/prov#endedAtTime" : 
    function( y ){ 
      if (y) {
          $( "#endedAtTime .dataGoesHere" ).text(y) 
          $( "#endedAtTime" ).show()          
      };
  },
};

function _docReady_updateFocusFromJson(response) {
  $( document ).ready( function() {
    _updateFocusFromJson(response)
  });
}

function _updateFocusFromJson(response) {
    try {
        var values = sparqlListToObject(response, "p", "y");
        $.each(_predicate_to_action, function( p, action ){
          action(values[p]);
        });
        if (!values["http://dot.rural/sepake/htmlDescription"]) {
          _set_html_from_dbpedia_description( "#descriptionOfFocus", values["http://www.w3.org/2000/01/rdf-schema#label"] );
        }
    } catch (err) {
      console.log( err );
    }
}

function _updateOwnerFromIri(iri) {
  if (!iri) {
    return;
  };
  $( "#labelOfOwner" ).data( 'iri', iri);
  sparql("owner",
          [
           "SELECT ?y WHERE {",
           "    BIND (<--IRI--> AS ?owner) .",
           "    { ?owner rdfs:label ?y } .",
           "}",
          ],
{'fraction_non_alphanumeric': 0.19311624072547404, 'fraction_numerical': 0.007831821929101401, 'mean_word_length': 2.2636180228648284, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1652930', 'n_tokens_mistral': 1733, 'n_tokens_neox': 1683, 'n_words': 264}