Created
January 2, 2013 19:08
-
-
Save anonymous/4436981 to your computer and use it in GitHub Desktop.
Find Wikipedia font boxes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<style> | |
img { | |
width: 200px; | |
} | |
textarea { | |
width: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<textarea id="query" rows="10"> | |
SELECT ?item ?thumbnail WHERE { | |
?item <http://dbpedia.org/property/wikiPageUsesTemplate> <http://dbpedia.org/resource/Template:Infobox_typeface> . | |
?item <http://dbpedia.org/ontology/thumbnail> ?thumbnail | |
} | |
</textarea> | |
<button id="load">load</button> | |
<div id="box"></div> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> | |
<script> | |
function load() { | |
$('#box').empty(); | |
var url = "http://dbpedia.org/sparql?format=application%2Fsparql-results%2Bjson&save=display&query=" + escape($('#query').val()); | |
$.getJSON(url, {}, | |
function(data) { | |
var img, last; | |
var html = ''; | |
for (i in data.results.bindings) { | |
img = data.results.bindings[i].thumbnail.value; | |
if (img != last) { | |
html += '<img src="' + img + '"/>'; | |
} | |
last = img; | |
} | |
$('#box').append(html); | |
}); | |
} | |
$(function () { | |
$('#load').click(load); | |
load(); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment