aboutsummaryrefslogtreecommitdiff
path: root/web/poc_jsonrpc/artists.html
blob: 1a59e933f447bb9d078adfc0b1f4bc050648d769 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<html>
<head>
<title>XBMC - Artists</title> 
<link type="text/css" rel="stylesheet" href="basic.css">
<script type="text/javascript" src="json.js"></script>
<script type="text/javascript">
function CallPlay(album) {
  var http_request = new XMLHttpRequest();
  http_request.open( "POST", "jsonrpc", false );
  http_request.send('{"jsonrpc": "2.0", "method": "XBMC.Play", "params": { "albumid": ' + album + ' }, "id": 1}');
}

function writeArtist(artist) {
  document.write('<h2>' + artist["label"] + '</h2>');

  var http_request = new XMLHttpRequest();
  http_request.open( "POST", "jsonrpc", false );
  http_request.send('{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "artistid": ' + artist["artistid"] + ' }, "id": 1}');

  var the_object = JSON.parse(http_request.responseText);
  var result = the_object["result"];
  var array = result["albums"];

  for (var property in array) {
    var item = array[property];
    document.write('<a href="nowplaying.html" onclick=CallPlay(' + item["albumid"] + ')>');
    var imgSrc = item["thumbnail"] ? ('vfs/' + escape(item["thumbnail"])) : "images/DefaultAlbumCover.png";
    document.write('<img src="' + imgSrc + '" class="cover" alt="' + item["label"] + '"></img>');
    document.write('</a>');
  }
}
</script>
</head>
<body>
<table class="Navigation">
<tr class="primary">
  <td class="unselected"><a href="nowplaying.html">Now playing</a></td>
  <td class="unselected"><a href="movies.html">Videos</a></td>
  <td class="selected">Music</td>
  <td class="unselected"><a href="development.html">Development</a></td>
</tr>
<tr>
  <td></td><td></td><td>
  <table>
  <tr class="secondary">
    <td><a href="musicfiles.html">Music files</a></td>
    <td>Artists</td>
    <td><a href="albums.html">Albums</a></td>
  </tr>
  </table></td>
</tr>
</table>
<br>

<script type="text/javascript">
var http_request = new XMLHttpRequest();
http_request.open( "POST", "jsonrpc", false );
http_request.send('{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists", "id": 1}');

var the_object = JSON.parse(http_request.responseText);
var result = the_object["result"];
var array = result["artists"];

document.write('<table>');
for (var property in array) {
  document.write('<tr class="' + (property % 2 == 0 ? "even" : "odd") + '"><td>');

  var item = array[property];

  writeArtist(item);

  document.write('</td></tr>');
}
document.write('</table>');
</script>
</body>
</html>