Compare commits

..

No commits in common. "1ebd2708e3f1d55e1faad8d298f882755ace8294" and "d66b7300f860eeee2aa5795415a3716d7d74fbff" have entirely different histories.

View File

@ -49,7 +49,7 @@ function createAnimationStyleSelect() {
addbtn.onclick = async () => { addbtn.onclick = async () => {
var fileHandles = await showOpenFilePicker({ var fsfhs = await showOpenFilePicker({
id: "add", id: "add",
multiple: true, multiple: true,
types: [ types: [
@ -61,31 +61,12 @@ addbtn.onclick = async () => {
} }
] ]
}); });
if (!fileHandles.length) return; if (!fsfhs.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 newEmojis = [];
var errors = []; var errors = [];
for (let file of files) { for (let fsfh of fsfhs) {
try { try {
let file = await fsfh.getFile();
let image = await loadImage(URL.createObjectURL(file)); let image = await loadImage(URL.createObjectURL(file));
let width = image.width; let width = image.width;
let height = image.height; let height = image.height;
@ -138,10 +119,7 @@ async function addFiles(files) {
emojis ||= []; emojis ||= [];
emojis = emojis.concat(newEmojis); emojis = emojis.concat(newEmojis);
await chrome.storage.local.set({emojis}); await chrome.storage.local.set({emojis});
} };
var deleteMode = false; var deleteMode = false;
@ -283,7 +261,6 @@ function createEmojiSquare(emoji, url) {
if (this.dataset.state == "pending") return; if (this.dataset.state == "pending") return;
var selectedState = this.dataset.state; var selectedState = this.dataset.state;
this.dataset.state = "pending"; this.dataset.state = "pending";
div.querySelector("select").disabled = true;
errorDiv.innerText = ""; errorDiv.innerText = "";
if (deleteMode) { if (deleteMode) {
@ -309,7 +286,6 @@ function createEmojiSquare(emoji, url) {
// disable // disable
callContentScript("deleteEmoji", this.dataset.currentId).then(() => { callContentScript("deleteEmoji", this.dataset.currentId).then(() => {
this.dataset.state = "disabled"; this.dataset.state = "disabled";
div.querySelector("select").disabled = false;
}).catch(error => { }).catch(error => {
displayError(error); displayError(error);
this.dataset.state = selectedState; this.dataset.state = selectedState;
@ -324,7 +300,6 @@ function createEmojiSquare(emoji, url) {
chrome.storage.local.set({emojis}); chrome.storage.local.set({emojis});
this.dataset.currentId = newEmoji.id; this.dataset.currentId = newEmoji.id;
this.dataset.state = "enabled"; this.dataset.state = "enabled";
div.querySelector("select").disabled = false;
}); });
}).catch(error => { }).catch(error => {
this.dataset.state = selectedState; this.dataset.state = selectedState;