aboutsummaryrefslogtreecommitdiff
path: root/web/poc_jsonrpc/videofiles.html
blob: d5d4a37c7dcbc56b23b4c515f5577766e05c070c (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
78
79
80
81
82
83
84
85
86
87
88
<html>
<head>
<title>XBMC - Video files</title>
<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 PlayMovie(movieid)
{
  alert("Not implemented");
}
</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>Video files</td>
    <td><a href="movies.html">Movies</a></td>
    <td><a href="tvshows.html">TV Shows</a></td>
  </tr>
  </table></td>
</tr>
</table>
<br />

<script type="text/javascript">
String.prototype.endsWith = function(str) 
{return (this.match(str+"$")==str)}

var directory = gup("directory");

var http_request = new XMLHttpRequest();
http_request.open( "POST", "jsonrpc", false );

if (directory)
  http_request.send("{\"jsonrpc\": \"2.0\", \"method\": \"Files.GetDirectory\", \"params\": { \"type\": \"video\", \"directory\": \"" + Url.decode(directory) + "\" }, \"id\": 1}");
else
  http_request.send("{\"jsonrpc\": \"2.0\", \"method\": \"Files.GetSources\", \"params\": { \"type\": \"video\" }, \"id\": 1}");


var the_object = JSON.parse(http_request.responseText);
var result = the_object["result"];
if (result) {
  var array;
  if (directory)
    array = result["directories"];
  else
    array = result["shares"];

  document.write("<table class=\"Files\">");
  for (var i in array) {
    var item = array[i];

    document.write("<tr class=\"" + (i % 2 == 0 ? "even" : "odd") + "\"><td class=\"cover\">");
    if (item["file"].endsWith("/")) {
      document.write("<a href=\"videofiles.html?directory=" + Url.encode(item["file"]) + "\">");
      document.write("<img src=\"" + (item["thumbnail"] ? ("thumb/" + item["thumbnail"] + ".jpg"): "images/DefaultFolder.png") + "\" class=\"smallcover\" alt=\"" + item["label"] + "\"></img></a>");
    } else {
      document.write("<img src=\"images/DefaultVideo.png\" class=\"smallcover\" alt=\"" + item["label"] + "\"></img>");
    }

    document.write("<td class=\"info\">");

    if (item["file"].endsWith("/")) {
      document.write("<a href=\"videofiles.html?directory=" + Url.encode(item["file"]) + "\">");
      document.write(item["label"] + "</a>");
    } else {
      document.write(item["label"]);
    }

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