/**
* Copyright (c) 2016 Luminarys <postmaster@gensok.io>
+ *
+ * Copyright (c) 2021 Eric Johansson (Nekunekus) <neku@pomf.se>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* SOFTWARE.
*/
-document.addEventListener('DOMContentLoaded', function() {
+ document.addEventListener('DOMContentLoaded', function() {
/**
* Sets up the elements inside file upload rows.
*
} else if (respStatus === 413) {
link.textContent = 'File too big!';
url.appendChild(link);
+ } else if (respStatus === 415) {
+ link.textContent = 'Filetype not allowed!';
+ url.appendChild(link);
} else {
- link.textContent = 'Filetype not allowed or server error!';
+ link.textContent = 'Server error!';
url.appendChild(link);
}
}
target.click();
}
+ /* Handles the pasting function */
+ window.addEventListener("paste", e =>{
+ var len = e.clipboardData.files.length;
+ for (var i = 0; i < len; i++) {
+ var file = e.clipboardData.files[i];
+ var row = addRow(file);
+ uploadFile(file, row);
+ }
+ });
+
+
/* Set-up the event handlers for the <button>, <input> and the window itself
and also set the "js" class on selector "#upload-form", presumably to
allow custom styles for clients running javascript. */
window.addEventListener('drop', handleDragAway.bind(this, state, uploadButton), false);
window.addEventListener('dragover', stopDefaultEvent, false);
+
var uploadInput = document.getElementById('upload-input');
uploadInput.addEventListener('change', uploadFiles);
uploadButton.addEventListener('click', selectFiles.bind(this, uploadInput));