-
Notifications
You must be signed in to change notification settings - Fork 65
/
paella-debug.js
70 lines (58 loc) · 2.01 KB
/
paella-debug.js
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
function loadPaellaDebug(playerContainer,params) {
let fs = require("fs");
let path = require("path");
function importFile(file) {
let script = document.createElement("script");
if (file.split(".").pop()=='js') {
script.src = file;
//script.type = "text/javascript";
script.async = false;
document.head.appendChild(script);
}
}
function importFolder(src) {
let sortFn = (a,b) => {
if (a<b) return -1;
else return 1;
};
let stat = fs.statSync(src);
if (stat.isDirectory()) {
let dirContents = fs.readdirSync(src);
dirContents.sort(sortFn);
dirContents.forEach((fileName) => importFolder(path.join(src,fileName)));
}
else {
importFile(src);
}
}
let corePath = __dirname;
let coreSources = path.join(corePath,"src");
let pluginSources = path.join(corePath,"plugins");
window.paella_debug_baseUrl = path.join(corePath,'build/player/');
importFolder(coreSources);
importFolder(pluginSources);
function doLoad() {
// Fill in the video selector field
let currentVideoId = paella.utils.parameters.get('id');
let selectField = document.getElementById('videoSelector');
fs.readdirSync(__dirname + '/repository_test/repository').forEach((videoId) => {
let option = document.createElement('option');
option.id = videoId;
option.innerHTML = videoId;
if (videoId==currentVideoId) {
option.selected = true;
}
selectField.appendChild(option);
});
selectField.addEventListener('change',function(event) {
location.href = location.pathname + '?id=' + event.target.value;
});
if (!window.paella) {
setTimeout(() => doLoad(),100);
}
else {
paella.load(playerContainer,params);
}
}
doLoad();
}