aboutsummaryrefslogtreecommitdiff
path: root/web/poc_jsonrpc/videofiles.html
blob: 256c42bd69af36d9db34576503adf2fffc01a416 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<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": { "media": "video", "directory": "' + unescape(directory) + '" }, "id": 1}');
else
  http_request.send('{"jsonrpc": "2.0", "method": "Files.GetSources", "params": { "media": "video" }, "id": 1}');


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

  if (directory) {
    directories = result["directories"];
    files = result["files"];
  } else {
    directories = result["shares"];
  }

  document.write('<table class="Files">');

  var even = 0;

  for (var i in directories) {
    var item = directories[i];

    document.write('<tr class="' + (even % 2 == 0 ? "even" : "odd") + '"><td class="cover">');
    even += 1;

    document.write('<a href="videofiles.html?directory=' + escape(item["file"]) + '">');
    var imgSrc = item["thumbnail"] ? ('vfs/' + escape(item["thumbnail"])) : "images/DefaultFolder.png";
    document.write('<img src="' + imgSrc + '" class="smallcover" alt="' + item["label"] + '"></img></a>');

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

    document.write('<a href="videofiles.html?directory=' + Url.encode(item["file"]) + '">');
    document.write(item["label"] + "</a>");

    document.write('</td></tr>');
  }

  for (var i in files) {
    var item = files[i];

    document.write('<tr class="' + (even % 2 == 0 ? "even" : "odd") + '"><td class="cover">');
    even += 1;

    var imgSrc = item["thumbnail"] ? ('vfs/' + escape(item["thumbnail"])) : "images/DefaultVideo.png";
    document.write('<img src="' + imgSrc + '" class="smallcover" alt="' + item["label"] + '"></img>');

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

    document.write(item["label"]);

    document.write('</td></tr>');
  }

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