1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-27 15:26:25 -07:00

Update new/old browse element when settings are saved

This commit is contained in:
Eggbertx 2024-09-08 14:24:12 -07:00
parent 9eda27d38b
commit f03ea709f8
3 changed files with 23 additions and 9 deletions

View file

@ -1,6 +1,7 @@
import $ from "jquery";
import { alertLightbox } from "./lightbox";
import { getBooleanStorageVal } from "../storage";
export function updateUploadImage($elem: JQuery<HTMLElement>, onLoad?:()=>any) {
@ -76,9 +77,9 @@ function addFileUpload(file:File) {
uploadReader.readAsDataURL(file);
}
export function replaceBrowseButton() {
function replaceBrowseButton() {
const $browseBtn = $<HTMLInputElement>("input[name=imagefile]").hide();
if($browseBtn.length < 1) return;
if($browseBtn.length < 1 || $("div#upload-box").length > 0) return;
$browseBtn.on("change", e => addFileUpload(e.target.files[0]));
$("<div/>").attr("id", "upload-box").append(
@ -101,3 +102,13 @@ export function replaceBrowseButton() {
});
});
}
export function updateBrowseButton() {
const useNewUploader = getBooleanStorageVal("newuploader", true);
if(useNewUploader) {
replaceBrowseButton();
} else {
$("div#upload-box").remove();
$("input[name=imagefile]").show();
}
}