Compare commits
No commits in common. "bc0661374f8c57141c7605bb9fb9e537121bba82" and "477553a6002b3e36a134c7306514fa434927ac6c" have entirely different histories.
bc0661374f
...
477553a600
@ -12,8 +12,9 @@ const reservedMappings = ["u", "s"];
|
|||||||
* Load mappings, create a table showing them with a "remove" button each
|
* Load mappings, create a table showing them with a "remove" button each
|
||||||
*/
|
*/
|
||||||
function renderMappings() {
|
function renderMappings() {
|
||||||
// console.log(localStorage.getItem('mappings'));
|
console.log(localStorage.getItem('mappings'));
|
||||||
const mappings = new Map(JSON.parse(localStorage.getItem('mappings')) || []);
|
const mappings = new Map(JSON.parse(localStorage.getItem('mappings')) || []);
|
||||||
|
console.log(typeof mappings);
|
||||||
const tbody = document.querySelector('#mappingTable tbody');
|
const tbody = document.querySelector('#mappingTable tbody');
|
||||||
tbody.innerHTML = ''; // clear table body
|
tbody.innerHTML = ''; // clear table body
|
||||||
mappings.forEach((directory, key) => {
|
mappings.forEach((directory, key) => {
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
<!-- <div class="keydebug">Key: <span id="keydebug"></span></div> -->
|
<!-- <div class="keydebug">Key: <span id="keydebug"></span></div> -->
|
||||||
<div class="statusline">Status: <span id="status">Loading</span></div>
|
<div class="statusline">Status: <span id="status"></span></div>
|
||||||
<!-- Imgsort 2 by Matthias Quintern -->
|
<!-- Imgsort 2 by Matthias Quintern -->
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
24
src/index.js
24
src/index.js
@ -5,7 +5,7 @@ const audioExtensions =['mp3', 'ogg', 'wav', 'flac'];
|
|||||||
const mappings = new Map(JSON.parse(localStorage.getItem('mappings')) || []);
|
const mappings = new Map(JSON.parse(localStorage.getItem('mappings')) || []);
|
||||||
let statusLine = document.getElementById('status');
|
let statusLine = document.getElementById('status');
|
||||||
// store for when done with sorting TODO display
|
// store for when done with sorting TODO display
|
||||||
let splash = document.getElementById('current-file').innerHTML;
|
let initialContent = document.getElementById('current-file').innerHTML;
|
||||||
|
|
||||||
let history = [];
|
let history = [];
|
||||||
|
|
||||||
@ -19,10 +19,11 @@ let history = [];
|
|||||||
function showServerError(fname, status, text) {
|
function showServerError(fname, status, text) {
|
||||||
if (status == 500) {
|
if (status == 500) {
|
||||||
message = `in ${fname}: server returned ${status}: '${text}'`;
|
message = `in ${fname}: server returned ${status}: '${text}'`;
|
||||||
} else {
|
else {
|
||||||
message = `in ${fname}: server returned ${status}`;
|
message = `in ${fname}: server returned ${status}`;
|
||||||
|
|
||||||
}
|
}
|
||||||
statusLine.textContent = message;
|
statusLine.innerHTML = message
|
||||||
console.error(message);
|
console.error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,12 +143,8 @@ function renderCurrentFile() {
|
|||||||
// }
|
// }
|
||||||
const currentFileDiv = document.getElementById('current-file');
|
const currentFileDiv = document.getElementById('current-file');
|
||||||
currentFileDiv.innerHTML = "";
|
currentFileDiv.innerHTML = "";
|
||||||
if (currentFile) {
|
|
||||||
let element = createMediaFileElement(currentFile, true);
|
let element = createMediaFileElement(currentFile, true);
|
||||||
currentFileDiv.appendChild(element);
|
currentFileDiv.appendChild(element);
|
||||||
} else {
|
|
||||||
currentFileDiv.innerHTML = splash;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -171,12 +168,7 @@ function preloadNextFile() {
|
|||||||
|
|
||||||
// set the currentFile variable according to currentFileIdx
|
// set the currentFile variable according to currentFileIdx
|
||||||
function setCurrentFile() {
|
function setCurrentFile() {
|
||||||
// check configuration
|
// if none set and
|
||||||
if (mappings.size == 0) {
|
|
||||||
statusLine.textContent = "No mappings configured - Click 'Configure' first";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// if none set and there are files
|
|
||||||
if (currentFileIdx == null && fileList.length > 0) {
|
if (currentFileIdx == null && fileList.length > 0) {
|
||||||
currentFileIdx = 0;
|
currentFileIdx = 0;
|
||||||
}
|
}
|
||||||
@ -192,7 +184,6 @@ function setCurrentFile() {
|
|||||||
else {
|
else {
|
||||||
currentFileIdx = null;
|
currentFileIdx = null;
|
||||||
currentFile = "";
|
currentFile = "";
|
||||||
statusLine.textContent = "No more files to sort";
|
|
||||||
}
|
}
|
||||||
renderCurrentFile();
|
renderCurrentFile();
|
||||||
renderFileList();
|
renderFileList();
|
||||||
@ -209,7 +200,7 @@ async function moveFile(directory) {
|
|||||||
const text = await response.text();
|
const text = await response.text();
|
||||||
// console.log(text);
|
// console.log(text);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
statusLine.textContent = `Moved '${currentFile}' to '${directory}'`;
|
statusLine.innerHTML = `Moved '${currentFile}' to '${directory}'`;
|
||||||
history.push([currentFile, directory]);
|
history.push([currentFile, directory]);
|
||||||
// remove file from list
|
// remove file from list
|
||||||
fileList.splice(currentFileIdx, 1);
|
fileList.splice(currentFileIdx, 1);
|
||||||
@ -225,7 +216,7 @@ async function moveFile(directory) {
|
|||||||
|
|
||||||
async function undo() {
|
async function undo() {
|
||||||
if (!history.length > 0) {
|
if (!history.length > 0) {
|
||||||
statusLine.textContent = "Nothing to undo"
|
statusLine.innerHTML = "Nothing to undo"
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const [file, directory] = history.pop();
|
const [file, directory] = history.pop();
|
||||||
@ -257,7 +248,6 @@ async function initialize() {
|
|||||||
renderFileList();
|
renderFileList();
|
||||||
// setCurrentFile();
|
// setCurrentFile();
|
||||||
preloadNextFile();
|
preloadNextFile();
|
||||||
statusLine.textContent = "Loaded";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// load existing mappings on page load
|
// load existing mappings on page load
|
||||||
|
@ -183,7 +183,6 @@ button:hover {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 300px;
|
height: 300px;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: scroll;
|
|
||||||
}
|
}
|
||||||
.current-file .imgsort2 {
|
.current-file .imgsort2 {
|
||||||
font-size: 3rem;
|
font-size: 3rem;
|
||||||
|
Loading…
Reference in New Issue
Block a user