Svenskt Kvinnobiografisktlexikon

Fills a select box with all women connected to SKBL

by Magnus Sälgö

HTML

<script src="https://cdn.rawgit.com/wikimedia/wikidata-query-gui/master/wikibase/queryService/api/Sparql.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/animate.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/wow/1.1.2/wow.min.js"></script>
<table width="100%" border="0">
<tr><td align=top><br /><div id="explain">
<h3>Integration with Wikipedia: Svenskt kvinnobiografiskt lexikon <a href="https://www.wikidata.org/wiki/Property_talk:P4963" target=_blank>P4963</a></h3>
Prototype to test searching in Wikipedia about people presented in "Svenskt kvinnobiografiskt lexikon" <span class="explain2">(1000 Swedish women from the Middle Ages to the present day)</span>
<br>What knows Swedish Wikipedia about those women? Below all women at "Svenskt kvinnobiografiskt lexikon" that Wikidata knows about are presented in the listbox. When selecting one a Wikipedia search is done and the result is displayed as "snippets" ==> the search engine explains why this Wikipedia article is of interest...if you have questions dont hesitate to contact Magnus Sälgö +46-70-5937579</div> <br />See also<br /><br />
<ll class="list">
  <li><a target=_blank href="https://minancestry.blogspot.com/2018/03/svenskt-kvinnobiografiskt-lexikon.html">Blogpost about SKBL/Wikidata</a></li>
  <li><a href="https://tools.wmflabs.org/massviews/?platform=all-access&agent=user&source=category&target=https%3A%2F%2Fsv.wikipedia.org%2Fwiki%2FKategori%3AWikipediaartiklar_med_identifierare_fr%25C3%25A5n_SKBL&range=this-year&subjectpage=0&subcategories=0&sort=views&direction=1&view=list">Pageviews of "SKBL women" in Swedish Wikipedia </a> abt. 11 000/day</li>
  <li>Same for <a target=_blank href="https://jsfiddle.net/salgo60/2qut3yxj/embedded/result/">Swedish Church parishes in Wikidata</a>, <a target=_blank href="https://jsfiddle.net/salgo60/0pdaymko/embedded/result/">National museum</a>, <a target=_blank...

CSS

body {
   color: #444;
   background: #BBFFC5;
   /* fallback for old browsers */
   background: -webkit-linear-gradient(to left, #006976, #BBFFC5);
   /* Chrome 10-25, Safari 5.1-6 */
   background: linear-gradient(to left, #006976, #BBFFC5);
   /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
   font-family: 'Dosis', sans-serif;
   background-repeat: no-repeat;
   background-size: cover;
   min-height: 100vh;
   font-size: 16px;
 }

 a {
   color: #444;
   cursor: pointer;
 }

 a:hover {
   color: #555;
   text-decoration: none;
 }

#Hits {
   margin-top: 10px;
   padding: 0 5%;
   color: white;
   font-size: 34px;
}


#output {
   margin-top: 40px;
   padding: 0 5%;
 }

 
.list a {
  text-decoration: none;
}
 
li a:hover {
  background: lightgreen;
}



 #text {
   padding: 10px 20px;
   border-top-left-radius: 30px;
   border-bottom-left-radius: 30px;
   border: 0px solid;
   width: 50%;
 }

 #text:focus {
   box-shadow: 1px 3px 40px 5px #536970;
   outline: none;
 }
 #not-found p {
   font-size: 20px;
  }

.result {
  padding: 0.5% 2%;
  background: #fff;
  margin: 1.5%;
  border-left: 7px solid #536976;
}

.result h2 {
  color: #536976;
}
  

 button {
   background: #536976;
   color: #fff;
   padding: 10px 20px;
   border: 1px solid #536976;
   border-radius: 30px;
   margin-left: -55px;
 }


 .currParish {
    background-color: aliceblue;
    margin: 8px;
    size: 12px;
    border-radius: 25px;
    border: 2px solid darkBlue;
    padding: 20px; 
    width: 500px;
    height:150px;    
 }

.searchmatch{
      color: darkblue;
}
#explain
{
     color: darkgreen;
     font-family: "Times New Roman", Times, serif;     
}

#title a:hover {
  background: lightgreen;
}

.explain2
{
     color: darkgreen;
     font-size: 16px;
     font-family: "Times New Roman", Times, serif;     
}
.more {
   color: darkgreen;
}

JavaScript

$(function() {
	new WOW().init();


	var query = 'SELECT ?itemLabel WHERE {    ?item wdt:P31 wd:Q5.   ?item wdt:P4963 ?SKBL.   SERVICE wikibase:label { bd:serviceParam wikibase:language "sv" } } ORDER BY ?itemLabel '; // finds SKBL related people

	var api = new wikibase.queryService.api.Sparql();
	api.query(query).done(function() {
	  	var nrHits = api.getResultRawData().results.bindings.length;

  		$("#Hits").html("Women in the listbox = " + nrHits + " <div data-wow-duration='6s' data-wow-offset='10' class='wow bounceInUp more'>Select a women</div>");   
 			$.each(api.getResultRawData().results.bindings, function(key, value) {
  		$('.SKBLList').append($('<option/>').text(value.itemLabel.value));
  	});
	});
});

	$( '.searchOptionList' ).change(function() {       
    var srcopt = '&srqiprofile=' + $('.searchOptionList').val();
    $("#URL").html(srcopt);

  });
	$( '.SKBLList' ).change(function() {       
    var input = $('.SKBLList').val();
    var srcopt = '&srqiprofile=classic';
    
//		srcopt = '&srqiprofile=' + $('.searchOptionList').val();
//    $("#URL").html(srcopt);
		var searchLimit = 400 // number of results in search 
    var url = `https://sv.wikipedia.org/w/api.php?action=query&list=search&srsearch=` + input + `&srlimit=` + searchLimit + `&format=json&prop=info&inprop=url` + srcopt;

    $.ajax({
      type: "GET",
      url: url,
      dataType: "jsonp",
      success: function(data) {
        let info = data.query.search;
        console.log(info);

        if (info.length === 0) {
          let notFound = "";
          notFound += `
            <div id="not-found" class="wow fadeIn text-center" data-wow-duration="0.5s">
              <p> No result for parameter </p>
            </div>
          `
          $("#output").html(notFound);
          $("#not-found").delay(5000).fadeOut(500);
        } else {
          let output = "";
          let numberofHits = "Number of hits in Swedish Wikipedia = " + info.length + " <div...