aboutsummaryrefslogtreecommitdiff
path: root/web/poc_jsonrpc/movies.html
blob: 3e41a62042bfdccb6d272703c9ead6350f9d36c3 (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
<html>
<head>
<title>XBMC - Movies</title>
<link type="text/css" rel="stylesheet" href="basic.css">
<script type="text/javascript" src="json.js"> // FOR browsers which doesn't have it included
</script>
<script type="text/javascript">
function PlayMovie(movieid)
{
  alert("Not implemented");
}
</script>
</head>
<body>
<h1>Movies</h1>

<script type="text/javascript">
var http_request = new XMLHttpRequest();
http_request.open( "POST", "jsonrpc", false );
var send = { "jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "id": 1 }
http_request.send("{\"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.GetMovies\", \"params\": { \"fields\": [\"title\", \"plot\"] }, \"id\": 1}");

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

document.write("<table class=\"Movies\"><thead><tr><th>Thumbnail</th><th>Info</th></tr></thead><tbody>");
var odd = false;
for (var property in array) {
  var item = array[property];
  var row = "even";
  if (odd)
    row = "odd";

  document.write("<tr class=\"" + row + "\"><td class=\"cover\">");
  if (item["thumbnail"])
    document.write("<img src=thumb/" + item["thumbnail"] + ".jpg alt=\"" + item["title"] + "\" height=200 onclick=\"PlayMovie(" + item["movieid"] + ")\"></img>");
  document.write("</td><td>");

  document.write("<table class\"Info\"><tr><td class=\"Title\">");
    document.write("<h1>" + item["title"] + "</h1>");
  document.write("</td></tr><tr><td class=\"Plot\">");
  if (item["plot"])
    document.write(item["plot"]);
  document.write("</td></tr></table>");


  document.write("</td></tr>");
  odd = !odd;
}
document.write("</tbody></table>");
</script>
</body>
</html>