Commit 098fb047 authored by Andreas Heimann's avatar Andreas Heimann Committed by GitHub

Merge pull request #2 from jy1263/master

Drag and drop install implemented
parents 69fcd2b8 878d6712
const DOMLibrarySongsList = document.querySelector(".song-row-library .song-list");
//The Extraction Process
function ExtractionProcess(filePath){
//Basic .zip detection so the console doesnt throw a flurry of errors complaining it can't unzip.
if (filePath.endsWith('.zip')){
let fileName = path.basename(filePath)
srxdControl.extractBackup(filePath, fileName).then(function(extractResults) {
if(extractResults) {
installBackup(extractResults);
setTimeout(function() {
RefreshLibrary();
}, 200);
}
else {
console.error("Backup could not be loaded!");
}
});
}
else {console.error('Not a zip!');}
}
//Upload Manually
function InstallBackupManually() {
dialog.showOpenDialog({ title: "Open Backup", properties: ['openFile'], filters: [{"name": "Backup Archive", "extensions": ["zip"]}] }).then(result => {
if(!result.canceled) {
let filePath = result.filePaths[0];
let fileName = path.basename(filePath);
srxdControl.extractBackup(filePath, fileName).then(function(extractResults) {
if(extractResults) {
installBackup(extractResults);
setTimeout(function() {
RefreshLibrary();
}, 200);
} else {
console.error("Backup could not be loaded!");
}
});
ExtractionProcess(filePath);
}
});
}
//Drag and Drop
document.ondragover = document.ondrop = (dragndrop) => {
dragndrop.preventDefault();
}
document.body.ondrop = (ev) => {
let filePath = (ev.dataTransfer.files[0].path)
ev.preventDefault()
ExtractionProcess(filePath);
}
function RefreshLibrary() {
// Clear current songs
let installElement = DOMLibrarySongsList.firstElementChild;
......
......@@ -163,4 +163,5 @@ function BuildSongDOM(songItem) {
});
return songContainer;
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment