|
|
|
|
@ -9,7 +9,6 @@ const VIDEO_PREFIX = '/video/';
|
|
|
|
|
|
|
|
|
|
// NOTE: create links for folder contents
|
|
|
|
|
function addContents(node, json) { |
|
|
|
|
let li = document.createElement('li'); |
|
|
|
|
let a = document.createElement('a'); |
|
|
|
|
a.href = window.location; |
|
|
|
|
a.dataset.base_name = json.base_name; |
|
|
|
|
@ -17,18 +16,16 @@ function addContents(node, json) {
|
|
|
|
|
a.dataset.is_dir = json.is_dir; |
|
|
|
|
a.dataset.rel_path = json.rel_path; |
|
|
|
|
|
|
|
|
|
if (json.is_dir) |
|
|
|
|
if (json.is_dir) { |
|
|
|
|
a.classList.add('folder'); |
|
|
|
|
else |
|
|
|
|
} else { |
|
|
|
|
if (json.in_db) |
|
|
|
|
a.classList.add('file_stored'); |
|
|
|
|
else |
|
|
|
|
a.classList.add('file'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
a.appendChild(document.createTextNode(json.base_name)); |
|
|
|
|
li.appendChild(a); |
|
|
|
|
node.appendChild(li); |
|
|
|
|
|
|
|
|
|
a.addEventListener('click', function(e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
let element = e.target.parentNode; // NOTE: the parent 'li' element
|
|
|
|
|
@ -50,6 +47,10 @@ function addContents(node, json) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
let li = document.createElement('li'); |
|
|
|
|
li.appendChild(a); |
|
|
|
|
node.appendChild(li); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// NOTE: display an 'info card' for a path that has already been stored
|
|
|
|
|
@ -83,19 +84,17 @@ function openQueryDialog(dataset, element) {
|
|
|
|
|
query_str = QUERY_PATH |
|
|
|
|
+ '?query=' + dataset.base_name |
|
|
|
|
+ '&rel_path=' + dataset.rel_path; |
|
|
|
|
fetchJSON(query_str, function(json) { |
|
|
|
|
|
|
|
|
|
console.log('openQueryDialog(), ' + query_str); |
|
|
|
|
console.log(json); |
|
|
|
|
|
|
|
|
|
fetchJSON(query_str, function(json) { |
|
|
|
|
if (json.errors) { |
|
|
|
|
for (let e of json.errors) |
|
|
|
|
logError(e) |
|
|
|
|
} else { |
|
|
|
|
let tcontainer = document.querySelector('#query_results'); |
|
|
|
|
let tclone = document.importNode(tcontainer.content, true); |
|
|
|
|
let close = tclone.querySelector('#query_close'); |
|
|
|
|
close.addEventListener('click', function(e) { |
|
|
|
|
let tclone = document.importNode( |
|
|
|
|
document.querySelector('#query_results').content, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
tclone.querySelector('#query_close').addEventListener('click', function(e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
document.querySelector('body').removeChild(e.target.parentNode); |
|
|
|
|
}); |
|
|
|
|
@ -114,8 +113,7 @@ function openQueryDialog(dataset, element) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function createBlurb(details) { |
|
|
|
|
let qt = document.querySelector('#query_result'); |
|
|
|
|
let qtclone = document.importNode(qt.content, true); |
|
|
|
|
let qtclone = document.importNode(document.querySelector('#query_result').content, true); |
|
|
|
|
|
|
|
|
|
let title_link = qtclone.querySelector('h3 > a'); |
|
|
|
|
title_link.href = details.tmdb_link; |
|
|
|
|
@ -185,8 +183,7 @@ function parseResponse(json, node) {
|
|
|
|
|
|
|
|
|
|
window.onload = function() { |
|
|
|
|
document.querySelector('#noscript').style.display = 'none'; |
|
|
|
|
let error_box = document.querySelector('#js_errors'); |
|
|
|
|
error_box.style.display = 'none'; |
|
|
|
|
document.querySelector('#js_errors').style.display = 'none'; |
|
|
|
|
|
|
|
|
|
if (!('fetch' in window)) { |
|
|
|
|
logError('Unsupported Browser, No fetch API'); |
|
|
|
|
|