Skip to content

Instantly share code, notes, and snippets.

@crssnky
Last active May 8, 2019 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crssnky/b61e1744c4f49727fc172f5f2c686e00 to your computer and use it in GitHub Desktop.
Save crssnky/b61e1744c4f49727fc172f5f2c686e00 to your computer and use it in GitHub Desktop.
im@sparql BirthDate
onload = function () {
var Query = ["PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>PREFIX schema: <http://schema.org/>SELECT (sample(?o) as ?date) (sample(?n) as ?name) WHERE { ?sub schema:birthDate ?o; rdfs:label ?n;FILTER(regex(str(?o), \"", "\" )).}group by(?n)order by(?name)"];
var date = new Date();
var month = date.getMonth() + 1;
var day = date.getDate();
var now = (month < 10 ? "0" + month : month) + "-" + (day < 10 ? "0" + day : day);
var url = 'https://sparql.crssnky.xyz/spql/imas/query?query=' + encodeURIComponent(Query[0] + now + Query[1]);
d3.json(url, function (error, data) {
var jsons = data["results"]["bindings"];
if (jsons.length == 0) {
return false;
}
var idolnames = "";
jsons.forEach(function (value) {
idolnames += value.name.value + "、";
});
document.getElementById("birthAlert").innerHTML = ("今日は" + idolnames.substr(0, idolnames.length - 1) + "の誕生日です!");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment