1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-09-04 10:06:24 -07:00

Add filter to postbox file upload

This commit is contained in:
Eggbertx 2022-08-17 13:46:28 -07:00
parent 5ba270cb3f
commit 692befd8c3
5 changed files with 15 additions and 12 deletions

View file

@ -17,7 +17,7 @@ import { getBooleanStorageVal, getJsonStorageVal, setStorageVal } from "../stora
import { updateThread } from "../postutil";
import { currentBoard, currentThread, getPageThread } from "../postinfo";
import { getReplyCooldown, getThreadCooldown } from "../api/cooldowns";
import { updateUploadImage } from "./getuploadimage";
import { getUploadFilename, updateUploadImage } from "./uploaddata";
/**
* @type {JQuery<HTMLElement>}
@ -27,7 +27,7 @@ let threadCooldown = 0;
let replyCooldown = 0;
const qrButtonHTML =
`<input type="file" id="imagefile" name="imagefile"/>` +
`<input type="file" id="imagefile" name="imagefile" accept="image/jpeg,image/png,image/gif,video/webm,video/mp4"/>` +
`<input type="submit" value="Post" style="float:right;min-width:50px"/>`;
const qrTitleBar =
@ -58,13 +58,6 @@ function setSubmitButtonEnabled(enabled = true) {
}
}
function getUploadFilename() {
let elem = document.getElementById("imagefile");
if(elem === null) return "";
if(elem.files === undefined || elem.files.length < 1) return "";
return elem.files[0].name;
}
function unsetQrUpload() {
$("#imagefile").val("");
let $uploadContainer = $qr.find("div#upload-container");

View file

@ -10,4 +10,14 @@ export function updateUploadImage($elem, onLoad = noop) {
img.src = URL.createObjectURL(this.files[0]);
img.onload = onLoad;
};
}
/**
* @returns {string}
*/
export function getUploadFilename() {
let elem = document.getElementById("imagefile");
if(elem === null) return "";
if(elem.files === undefined || elem.files.length < 1) return "";
return elem.files[0].name;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -15,7 +15,7 @@
<input type="text" name="username" style="display:none"/>
<input type="submit" value="{{with .op}}Reply{{else}}Post{{end}}"/></td></tr>
<tr><th class="postblock">Message</th><td><textarea rows="4" cols="48" name="postmsg" id="postmsg"></textarea></td></tr>
<tr><th class="postblock">File</th><td><input name="imagefile" type="file"><input type="checkbox" id="spoiler" name="spoiler"/><label for="spoiler">Spoiler</label></td></tr>
<tr><th class="postblock">File</th><td><input name="imagefile" type="file" accept="image/jpeg,image/png,image/gif,video/webm,video/mp4"><input type="checkbox" id="spoiler" name="spoiler"/><label for="spoiler">Spoiler</label></td></tr>
<tr><th class="postblock">Password</th><td><input type="password" id="postpassword" name="postpassword" size="14" /> (for post/file deletion)</td></tr>
</table><input type="password" name="dummy2" style="display:none"/>
</form>