mediaserverindex.html
· 1.1 KiB · HTML
Raw
<html>
<head>
<script src="jquery.js"></script>
</head>
<body>
<span id="VideoList"></span>
<script>
var videosPath = "/Videos/";
var curdir = "";
function updateList(data) {
var directoryListing = $(data);
$("#VideoList").html(directoryListing);
$("#VideoList a").on("click", function(ev) {
ev.preventDefault();
if ($(this).attr("href") == "/") return false;
curdir = $("#VideoList").find('h1').text().slice(9) + "/";
document.location.hash = (curdir + $(this).attr("href")).replace(/.+\/\//g, "/");
if ($(this).attr("href").slice(-1) == "/") {
$.get((curdir + $(this).attr("href")).replace(/.+\/\//g, "/"), updateList);
document.location.hash = (curdir + $(this).attr("href")).replace(/.+\/\//g, "/");
} else {
video.setAttribute('src', curdir + $(this).attr("href"));
video.load();
video.play();
}
return false;
});
}
$(function() {
var video = document.createElement('video');
video.setAttribute('src', '');
video.setAttribute('controls', 'controls');
video.setAttribute('id', 'video');
$('body').prepend(video);
$.get(videosPath, updateList);
});
</script>
</body>
</html>
| 1 | <html> |
| 2 | <head> |
| 3 | <script src="jquery.js"></script> |
| 4 | </head> |
| 5 | <body> |
| 6 | <span id="VideoList"></span> |
| 7 | <script> |
| 8 | var videosPath = "/Videos/"; |
| 9 | var curdir = ""; |
| 10 | function updateList(data) { |
| 11 | var directoryListing = $(data); |
| 12 | |
| 13 | $("#VideoList").html(directoryListing); |
| 14 | $("#VideoList a").on("click", function(ev) { |
| 15 | ev.preventDefault(); |
| 16 | if ($(this).attr("href") == "/") return false; |
| 17 | curdir = $("#VideoList").find('h1').text().slice(9) + "/"; |
| 18 | document.location.hash = (curdir + $(this).attr("href")).replace(/.+\/\//g, "/"); |
| 19 | if ($(this).attr("href").slice(-1) == "/") { |
| 20 | $.get((curdir + $(this).attr("href")).replace(/.+\/\//g, "/"), updateList); |
| 21 | document.location.hash = (curdir + $(this).attr("href")).replace(/.+\/\//g, "/"); |
| 22 | } else { |
| 23 | video.setAttribute('src', curdir + $(this).attr("href")); |
| 24 | video.load(); |
| 25 | video.play(); |
| 26 | } |
| 27 | return false; |
| 28 | }); |
| 29 | } |
| 30 | |
| 31 | $(function() { |
| 32 | |
| 33 | var video = document.createElement('video'); |
| 34 | video.setAttribute('src', ''); |
| 35 | video.setAttribute('controls', 'controls'); |
| 36 | video.setAttribute('id', 'video'); |
| 37 | $('body').prepend(video); |
| 38 | |
| 39 | $.get(videosPath, updateList); |
| 40 | }); |
| 41 | </script> |
| 42 | </body> |
| 43 | </html> |