Skip to content

Commit

Permalink
Session. Load tracks functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
turner committed Jan 25, 2024
1 parent df9d5d5 commit 317cf44
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
5 changes: 0 additions & 5 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,6 @@ async function initializationHelper(browser, container, options) {

const trackLoader = async configurations => {
try {
// Add "searchable" attribute to non-indexed annotation tracks
for(let c of configurations) {


}
await browser.loadTrackList(configurations)
} catch (e) {
console.error(e)
Expand Down
25 changes: 20 additions & 5 deletions js/sessionUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,20 @@ function createLocalTrackFileCard(parentElement, id, browser){
fileInput.click()
})

cardElement.querySelector(`#${ id }-load-tracks`).addEventListener('click', e => {
console.log('Load Files')
cardElement.querySelector(`#${ id }-load-tracks`).addEventListener('click', async e => {

const configurations = []
for (const config of Object.values(sessionLocalTrackFilesDictionary)) {
if (config.url) {
configurations.push(config)
}
}
if (configurations.length > 0) {
await browser.loadTrackList(configurations)
}
cardElement.style.left = '-1000px'
cardElement.style.top = '-1000px'

})

makeDraggable(cardElement, cardElement.querySelector('.card-header'), undefined)
Expand All @@ -182,15 +192,20 @@ function createLocalTrackFileCard(parentElement, id, browser){
fileInputElement.addEventListener('change', async e => {

const names = Array.from(fileInputElement.files).map(({ name }) => name)
const files = Array.from(fileInputElement.files)

if (names.length > 0) {
for (const name of names) {
const listItemElement = document.querySelector(`[data-filename="${ name }"]`)
if (files.length > 0) {
for (const file of files) {
const listItemElement = document.querySelector(`[data-filename="${ file.name }"]`)
if (null !== listItemElement) {
const inputElement = listItemElement.querySelector('input')
inputElement.disabled = false
inputElement.checked = true
listItemElement.style.backgroundColor = '#007bff1c'

sessionLocalTrackFilesDictionary[ file.name ].url = file

cardElement.querySelector(`#${ id }-load-tracks`).disabled = false
} else {
console.log(`Retrieved file ${ name } is NOT a local session file`)
}
Expand Down

0 comments on commit 317cf44

Please sign in to comment.