2020-05-22 22:54:10 +02:00
|
|
|
function fileSelectedDefault() {
|
|
|
|
|
const input = document.getElementById("selectedFileDefaultIconType");
|
|
|
|
|
|
|
|
|
|
// if (input.files.length > 0) {
|
|
|
|
|
// console.debug("Selected file: " + input.files[0].name);
|
|
|
|
|
// console.debug("Selected file type: " + input.files[0].type);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
function storeFile() {
|
|
|
|
|
const buffer = new Uint8Array(fr.result);
|
|
|
|
|
|
|
|
|
|
let binary = "";
|
|
|
|
|
const len = buffer.byteLength;
|
|
|
|
|
for (let i = 0; i < len; i++) {
|
|
|
|
|
binary += String.fromCharCode(buffer[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const base64 = window.btoa(binary);
|
|
|
|
|
const iconDiv = document.getElementById("defaultIcon");
|
|
|
|
|
iconDiv.setAttribute("data-default-icon", base64);
|
|
|
|
|
iconDiv.setAttribute("data-default-icon-mime", input.files[0].type);
|
|
|
|
|
|
|
|
|
|
const image = document.getElementById("defaultCustomIconImage");
|
|
|
|
|
image.setAttribute("src", `data:${input.files[0].type};base64,${base64}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fr = new FileReader();
|
|
|
|
|
fr.onload = storeFile;
|
|
|
|
|
fr.readAsArrayBuffer(input.files[0]);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-22 23:14:46 +01:00
|
|
|
function fileSelected() {
|
2020-01-23 23:28:52 +01:00
|
|
|
const input = document.getElementById("selectedFileIconType");
|
2020-01-22 23:14:46 +01:00
|
|
|
|
2020-03-02 22:16:19 +01:00
|
|
|
// if (input.files.length > 0) {
|
|
|
|
|
// console.debug("Selected file: " + input.files[0].name);
|
|
|
|
|
// console.debug("Selected file type: " + input.files[0].type);
|
|
|
|
|
// }
|
2020-01-22 23:14:46 +01:00
|
|
|
|
|
|
|
|
function storeFile() {
|
2020-01-23 23:28:52 +01:00
|
|
|
const buffer = new Uint8Array(fr.result);
|
2020-01-22 23:14:46 +01:00
|
|
|
|
|
|
|
|
let binary = "";
|
2020-01-23 23:28:52 +01:00
|
|
|
const len = buffer.byteLength;
|
2020-01-22 23:14:46 +01:00
|
|
|
for (let i = 0; i < len; i++) {
|
|
|
|
|
binary += String.fromCharCode(buffer[i]);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-23 23:28:52 +01:00
|
|
|
const base64 = window.btoa(binary);
|
|
|
|
|
const iconDiv = document.getElementById("icon");
|
2020-01-22 23:14:46 +01:00
|
|
|
iconDiv.setAttribute("data-icon", base64);
|
|
|
|
|
iconDiv.setAttribute("data-icon-mime", input.files[0].type);
|
|
|
|
|
|
2020-01-23 23:28:52 +01:00
|
|
|
const image = document.getElementById("customIconImage");
|
2020-03-02 22:16:19 +01:00
|
|
|
image.setAttribute("src", `data:${input.files[0].type};base64,${base64}`);
|
2020-01-22 23:14:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fr = new FileReader();
|
|
|
|
|
fr.onload = storeFile;
|
|
|
|
|
fr.readAsArrayBuffer(input.files[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document
|
|
|
|
|
.getElementById("selectedFileIconType")
|
|
|
|
|
.addEventListener("change", fileSelected);
|
2020-05-22 22:54:10 +02:00
|
|
|
|
|
|
|
|
document
|
|
|
|
|
.getElementById("selectedFileDefaultIconType")
|
|
|
|
|
.addEventListener("change", fileSelectedDefault);
|