Browse Source

Implemented base functionality of this using a hard coded base folder.

pull/6/head
jrtechs 5 years ago
parent
commit
42e5fa9480
2 changed files with 55 additions and 12 deletions
  1. +32
    -3
      html/videos.html
  2. +23
    -9
      server.js

+ 32
- 3
html/videos.html View File

@ -1,6 +1,6 @@
<h1 class="text-center">Videos</h1>
<input id="videoFilter" class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<table class="table table-striped">
<thead class="thead-dark">
<tr>
@ -11,7 +11,7 @@
</thead>
<tbody id="movieTable">
{for video in videos}
<tr>
<tr class="table_row">
<td>{video.name}</td>
<td>{video.length}</td>
<td>
@ -20,4 +20,33 @@
</tr>
{/for}
</tbody>
</table>
</table>
<script>
function filterTable()
{
var input = $("input#videoFilter").val().toLowerCase();
$(".table_row").css({"display": "none"});
$(".table_row").each(function(index)
{
if($(this).text().toLowerCase().includes(input))
{
$(this).toggle(true);
//$(this).css({"display": "none"});
}
});
if(input.toString().split(" ").join("") === "")
{
$(".satellite_row").toggle(true);
}
}
$(document).ready(function()
{
$("input#videoFilter").bind("keyup", filterTable);
});
</script>

+ 23
- 9
server.js View File

@ -8,9 +8,6 @@ const fileIO = require('./fileIO');
const userUtils = require('./user.js');
const url = require('url');
const fs = require('fs');
const app = express();
@ -28,7 +25,7 @@ app.use(session({ secret: config.sessionSecret, cookie: { maxAge: 6000000 }}));
/** Template engine */
const whiskers = require('whiskers');
const rootDir = '/home/jeff/public/Movies/';
function fetchInTemplate(templateContext, templateKey, filename)
@ -90,10 +87,30 @@ app.post('/login', function(request, result)
result.redirect('/');
});
var videos = null;
function getVideosTemplateInformation(templateContext, request)
{
templateContext.videos = [{name: "test1", length: 32},{name: "test2", length: 55}];
if(videos === null)
{
videos = [];
return new Promise(function(resolve, reject)
{
fs.readdir(rootDir, (err, files) =>
{
files.forEach(file =>
{
videos.push({name: file, length: "n/a"});
});
templateContext.videos = videos;
resolve();
});
})
}
else
{
templateContext.videos = videos;
}
}
function getVideoTemplateInfo(templateContext, request)
@ -110,10 +127,7 @@ app.get('/video/', function(request, result)
if(request.session.login === true)
{
var videoID = request.query.v;
const path = '/home/jeff/public/Movies' + videoID;
console.log(path);
const path = rootDir + videoID;
const stat = fs.statSync(path);
const fileSize = stat.size;

Loading…
Cancel
Save