Compare commits
2 Commits
d66b7300f8
...
1ebd2708e3
Author | SHA1 | Date | |
---|---|---|---|
1ebd2708e3 | |||
a2ca2065cd |
35
manage.js
35
manage.js
@ -49,7 +49,7 @@ function createAnimationStyleSelect() {
|
||||
|
||||
|
||||
addbtn.onclick = async () => {
|
||||
var fsfhs = await showOpenFilePicker({
|
||||
var fileHandles = await showOpenFilePicker({
|
||||
id: "add",
|
||||
multiple: true,
|
||||
types: [
|
||||
@ -61,12 +61,31 @@ addbtn.onclick = async () => {
|
||||
}
|
||||
]
|
||||
});
|
||||
if (!fsfhs.length) return;
|
||||
if (!fileHandles.length) return;
|
||||
var files = [];
|
||||
for (let fileHandle of fileHandles) {
|
||||
try {
|
||||
files.push(await fileHandle.getFile());
|
||||
} catch (error) {
|
||||
displayError(error);
|
||||
}
|
||||
}
|
||||
await addFiles(files);
|
||||
};
|
||||
|
||||
|
||||
document.body.onpaste = event => {
|
||||
if (event.clipboardData.files.length) {
|
||||
addFiles(event.clipboardData.files);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
async function addFiles(files) {
|
||||
var newEmojis = [];
|
||||
var errors = [];
|
||||
for (let fsfh of fsfhs) {
|
||||
for (let file of files) {
|
||||
try {
|
||||
let file = await fsfh.getFile();
|
||||
let image = await loadImage(URL.createObjectURL(file));
|
||||
let width = image.width;
|
||||
let height = image.height;
|
||||
@ -119,7 +138,10 @@ addbtn.onclick = async () => {
|
||||
emojis ||= [];
|
||||
emojis = emojis.concat(newEmojis);
|
||||
await chrome.storage.local.set({emojis});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deleteMode = false;
|
||||
@ -261,6 +283,7 @@ function createEmojiSquare(emoji, url) {
|
||||
if (this.dataset.state == "pending") return;
|
||||
var selectedState = this.dataset.state;
|
||||
this.dataset.state = "pending";
|
||||
div.querySelector("select").disabled = true;
|
||||
errorDiv.innerText = "";
|
||||
|
||||
if (deleteMode) {
|
||||
@ -286,6 +309,7 @@ function createEmojiSquare(emoji, url) {
|
||||
// disable
|
||||
callContentScript("deleteEmoji", this.dataset.currentId).then(() => {
|
||||
this.dataset.state = "disabled";
|
||||
div.querySelector("select").disabled = false;
|
||||
}).catch(error => {
|
||||
displayError(error);
|
||||
this.dataset.state = selectedState;
|
||||
@ -300,6 +324,7 @@ function createEmojiSquare(emoji, url) {
|
||||
chrome.storage.local.set({emojis});
|
||||
this.dataset.currentId = newEmoji.id;
|
||||
this.dataset.state = "enabled";
|
||||
div.querySelector("select").disabled = false;
|
||||
});
|
||||
}).catch(error => {
|
||||
this.dataset.state = selectedState;
|
||||
|
Loading…
Reference in New Issue
Block a user