|
|
|
@ -61,10 +61,13 @@ function updateMediaType(node, media_type) |
|
|
|
|
|
|
|
|
|
|
|
function updateRadioButtons(node, media_type) |
|
|
|
function updateRadioButtons(node, media_type) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (media_type == 'movie') |
|
|
|
if (media_type == 'movie') { |
|
|
|
|
|
|
|
node.querySelector('input[value^="tv_show"]').setAttribute('checked', false); |
|
|
|
node.querySelector('input[value^="movie"]').setAttribute('checked', true); |
|
|
|
node.querySelector('input[value^="movie"]').setAttribute('checked', true); |
|
|
|
else if (media_type == 'tv_show') |
|
|
|
} else if (media_type == 'tv_show') { |
|
|
|
|
|
|
|
node.querySelector('input[value^="movie"]').setAttribute('checked', false); |
|
|
|
node.querySelector('input[value^="tv_show"]').setAttribute('checked', true); |
|
|
|
node.querySelector('input[value^="tv_show"]').setAttribute('checked', true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NOTE: recursively build DOM tree with attached data attributes and callbacks
|
|
|
|
// NOTE: recursively build DOM tree with attached data attributes and callbacks
|
|
|
|
@ -94,22 +97,42 @@ function buildDirectoryTreeWithData(path_info) |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: hide nested folders by default and add listener to open/close children
|
|
|
|
|
|
|
|
if (path_info.depth > 1) |
|
|
|
|
|
|
|
sub_list.classList.add('hidden'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (path_info.depth > 0) { |
|
|
|
|
|
|
|
sub_list.addEventListener('click', function(e) { |
|
|
|
|
|
|
|
e.stopPropagation(); |
|
|
|
|
|
|
|
for (let div of sub_list.querySelectorAll('div')) |
|
|
|
|
|
|
|
div.classList.toggle('hidden'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (let node of path_info.contents) |
|
|
|
for (let node of path_info.contents) |
|
|
|
sub_list.appendChild(buildDirectoryTreeWithData(node)); |
|
|
|
sub_list.appendChild(buildDirectoryTreeWithData(node)); |
|
|
|
|
|
|
|
|
|
|
|
return clone; |
|
|
|
return clone; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onScanSubmit(e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// TODO: need to walk the dom tree and build a json object out of the data attributes
|
|
|
|
|
|
|
|
// TODO: verify there are no 'unkown' media types, or fail with warning
|
|
|
|
|
|
|
|
// TODO: send json back to admin.php for tmdb_queries
|
|
|
|
|
|
|
|
console.log(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function scanFolderResponse(data) |
|
|
|
function scanFolderResponse(data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
let error_container = document.querySelector('#error_container'); |
|
|
|
let errors = document.querySelector('#errors'); |
|
|
|
let info_container = document.querySelector('#info pre'); |
|
|
|
let info_container = document.querySelector('#info pre'); |
|
|
|
let main_container = document.querySelector('#main_container'); |
|
|
|
let main_container = document.querySelector('#main_container'); |
|
|
|
resetContainers(error_container, info_container, main_container); |
|
|
|
resetContainers(errors, info_container, main_container); |
|
|
|
|
|
|
|
|
|
|
|
if (data.errors) { |
|
|
|
if (data.errors) { |
|
|
|
for (let err of data.errors) { |
|
|
|
for (let err of data.errors) { |
|
|
|
error_container.appendChild(document.createTextNode(err)); |
|
|
|
errors.appendChild(document.createTextNode(err)); |
|
|
|
console.log(err); |
|
|
|
console.log(err); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -121,7 +144,12 @@ function scanFolderResponse(data) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (data.path_info) { |
|
|
|
if (data.path_info) { |
|
|
|
console.log(data.path_info); |
|
|
|
//console.log(data.path_info);
|
|
|
|
|
|
|
|
let b = document.createElement('button'); |
|
|
|
|
|
|
|
b.textContent = 'Upload'; |
|
|
|
|
|
|
|
b.addEventListener('click', onScanSubmit); |
|
|
|
|
|
|
|
main_container.appendChild(b); |
|
|
|
|
|
|
|
|
|
|
|
main_container.appendChild(buildDirectoryTreeWithData(data.path_info)); |
|
|
|
main_container.appendChild(buildDirectoryTreeWithData(data.path_info)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|