aboutsummaryrefslogtreecommitdiff
path: root/web/poc_jsonrpc/tvshowepisodes.html
blob: 9c0d0d8da5e5ebeced58167bc73f33241d8b232c (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
<html>
<head>
<link type="text/css" rel="stylesheet" href="basic.css" />
<script type="text/javascript" src="json.js" />
<script type="text/javascript" src="help.js" />
<script type="text/javascript">
function CallPlay(episodeid) {
  var http_request = new XMLHttpRequest();
  http_request.open( "POST", "jsonrpc", false );
  http_request.send('{"jsonrpc": "2.0", "method": "XBMC.Play", "params": { "episodeid": ' + episodeid + ' }, "id": 1}');
}
</script>
</head>
<body>
<table class="Navigation">
<tr class="primary">
  <td class="unselected"><a href="nowplaying.html">Now playing</a></td>
  <td class="selected">Videos</td>
  <td class="unselected"><a href="artists.html">Music</a></td>
  <td class="unselected"><a href="development.html">Development</a></td>
</tr>
<tr>
  <td></td><td>
  <table>
  <tr class="secondary">
    <td><a href="videofiles.html">Video files</a></td>
    <td><a href="movies.html">Movies</a></td>
    <td>TV Shows</td>
  </tr>
  </table></td>
</tr>
</table>
<br />

<script type="text/javascript">
var tvshowid = gup("tvshowid");
var season   = gup("season");

var http_request = new XMLHttpRequest();
http_request.open( "POST", "jsonrpc", false );
http_request.send('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": { "tvshowid": ' + tvshowid + ', "season": ' + season + ', "fields": ["plot"] }, "id": 1}');

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

  document.write('<table class="Episodes"><thead><tr><th>Thumbnail</th><th>Info</th></tr></thead><tbody>');
  for (var i in array) {
    var item = array[i];
    document.write('<tr class="" + (i % 2 == 0 ? "even" : "odd") + ""><td class="cover">');

    document.write('<a href="nowplaying.html" onclick=CallPlay(' + item["episodeid"] + ')>');
    var imgSrc = item["thumbnail"] ? ('vfs/' + escape(item["thumbnail"])) : "images/DefaultVideo.png";
    document.write('<img src="' + imgSrc + '" class="cover"></img>');
    document.write('</td><td class="info">');
    document.write('</a>');

    document.write('<h1>' + item["label"] + '</h1>');
    if (item["plot"])
      document.write(item["plot"]);

    document.write('</td></tr>');
  }
  document('</tbody></table>');
} else {
  document.write("Error");
}
</script>
</body>
</html>