Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
108 lines (89 sloc) 2.87 KB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My First App</title>
<link rel="stylesheet" href="sp://import/css/adam.css">
<link rel="stylesheet" href="tutorial.css">
<script src="jquery.js"></script>
<style>
.displayed {
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
}
</style>
</head>
<body onload="sp = getSpotifyApi(1); tutorial = sp.require('tutorial'); tutorial.init(); initTrack();">
<h1 id="header">Hello, world!</h1>
<span class="displayed">
<a id="linx" href="">
<img id="rijks" width="500" class="displayed" src="http://www.rijksmuseum.nl/assetimage2.jsp?id=SK-A-4878&200x200"/>
<span id="title" class="displayed"/>
</a>
</span>
<a href="javascript:startSlide();">Slide</a>
<script>
function startSlide(token) {
var url = "http://www.rijksmuseum.nl/api/oai/ceda5165-6087-4455-aa15-2c1642b1f481/?verb=listrecords&metadataPrefix=oai_dc";
if(token) url = url +"&resumptiontoken="+ token;
$.get(url,function(data) {
//alert(data);
//alert($(data).find("dc").first().find("format").first().text());
var records = $(data).find("metadata");
var i = 0;
var record = records[i];
$("#rijks")[0].src = $(record).find("format").first().text();
$("#title")[0].innerHTML = $(record).find("title").first().text();
var token = $(data).find("resumptionToken").text();
//alert(token);
getNext(0,records,token);
//alert($("#rijks")[0].src);
});
}
//startSlide();
var sp = getSpotifyApi(1);
var models = sp.require('sp://import/scripts/api/models');
var player = models.player;
function search(querystr) {
var url = "http://www.rijksmuseum.nl/zoeken/search.jsp?lang=nl&query="+ querystr +"&x=0&y=0&focus=all";
$.get(url,function(data) {
var uri = $(data).find("div.zoekimg").first()[0].style.background;
var pat1=new RegExp("&resize100square.*");
var pat2=new RegExp(".*url\\(");
console.log(uri.replace(pat1,"").replace(pat2,""));
$("#rijks")[0].src = uri.replace(pat1,"").replace(pat2,"");
});
}
//search("song");
//search("junk");
//search(getTerm());
function getTerm() {
var trackname = player.track.data.name.split(" ");
return trackname[trackname.length-1];
}
function initTrack() {
search(getTerm());
player.observe(models.EVENT.CHANGE, function (e) {
// Only update the page if the track changed
if (e.data.curtrack == true) {
search(getTerm());
}
});
}
function getNext(index, records,token) {
index++;
var record = records[index];
$("#rijks")[0].src = $(record).find("format").first().text();// +"&200x200";
$("#title")[0].innerHTML = $(record).find("title").first().text();
//alert($(record).find("format").next().first().text());
$("#linx")[0].href = $(record).find("format").next().first().text();
if( index < 100)
$("#rijks").ready( function(){ setTimeout(function() { getNext(index,records,token); }, 10000);});
else
startSlide(token);
}
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.