arrange code
This commit is contained in:
parent
5f1b0db47c
commit
9f020332cc
72
manage.js
72
manage.js
@ -1,33 +1,6 @@
|
||||
import * as db from "../db.js";
|
||||
|
||||
const ANIMATION_STYLES = `default
|
||||
Aura
|
||||
Bats
|
||||
Bees
|
||||
Bounce
|
||||
Cloud
|
||||
Confetti
|
||||
Crying
|
||||
Dislike
|
||||
Fire
|
||||
Idea
|
||||
Lasers
|
||||
Like
|
||||
Magnet
|
||||
Mistletoe
|
||||
Money
|
||||
Noise
|
||||
Orbit
|
||||
Pizza
|
||||
Rain
|
||||
Rotate
|
||||
Shake
|
||||
Snow
|
||||
Snowball
|
||||
Spin
|
||||
Splash
|
||||
Stop
|
||||
ZZZ`.split('\n');
|
||||
const ANIMATION_STYLES = `default Aura Bats Bees Bounce Cloud Confetti Crying Dislike Fire Idea Lasers Like Magnet Mistletoe Money Noise Orbit Pizza Rain Rotate Shake Snow Snowball Spin Splash Stop ZZZ`.split(' ');
|
||||
const animationStyleRegex = new RegExp(`(${ANIMATION_STYLES.join('|')})`, 'i');
|
||||
|
||||
function createAnimationStyleSelect() {
|
||||
@ -46,8 +19,21 @@ function createAnimationStyleSelect() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
db.getSetting("defaultAnimationStyle").then(defaultAnimationStyle => {
|
||||
default_animation_style_select.value = defaultAnimationStyle || "aura";
|
||||
});
|
||||
default_animation_style_select.onchange = async function () {
|
||||
await db.setSetting("defaultAnimationStyle", this.value);
|
||||
var enabled = [...document.querySelectorAll("[data-state=enabled]")].filter(e => !e.querySelector("select").value);
|
||||
if (enabled.length) {
|
||||
default_animation_style_select.disabled = true;
|
||||
await Promise.all(enabled.map(div => (async ()=>{
|
||||
await div.disable();
|
||||
await div.enable();
|
||||
})()));
|
||||
default_animation_style_select.disabled = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -73,13 +59,11 @@ addbtn.onclick = async () => {
|
||||
await addFiles(files);
|
||||
};
|
||||
|
||||
|
||||
document.body.onpaste = event => {
|
||||
if (event.clipboardData.files.length) {
|
||||
addFiles(event.clipboardData.files);
|
||||
}
|
||||
};
|
||||
|
||||
document.body.ondragover = event => event.preventDefault();
|
||||
document.body.ondrop = event => {
|
||||
event.preventDefault();
|
||||
@ -88,7 +72,6 @@ document.body.ondrop = event => {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
async function addFiles(files) {
|
||||
var errors = [];
|
||||
for (let file of files) {
|
||||
@ -154,21 +137,6 @@ deletebtn.onclick = () => {
|
||||
deletebtn.innerText = "Stop Delete";
|
||||
};
|
||||
|
||||
db.getSetting("defaultAnimationStyle").then(defaultAnimationStyle => {
|
||||
default_animation_style_select.value = defaultAnimationStyle || "aura";
|
||||
});
|
||||
default_animation_style_select.onchange = async function () {
|
||||
await db.setSetting("defaultAnimationStyle", this.value);
|
||||
var enabled = [...document.querySelectorAll("[data-state=enabled]")].filter(e => !e.querySelector("select").value);
|
||||
if (enabled.length) {
|
||||
default_animation_style_select.disabled = true;
|
||||
await Promise.all(enabled.map(div => (async ()=>{
|
||||
await div.disable();
|
||||
await div.enable();
|
||||
})()));
|
||||
default_animation_style_select.disabled = false;
|
||||
}
|
||||
};
|
||||
|
||||
importbtn.onclick = async () => {
|
||||
try {
|
||||
@ -216,14 +184,12 @@ clearbtn.onclick = async () => {
|
||||
emojigrid.innerHTML = '';
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
onfocus = () => loadToggleState().catch(displayError);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
loadEmojis().catch(displayError);
|
||||
|
||||
async function loadEmojis() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user