more file upload options
This commit is contained in:
parent
fb26f77366
commit
d739dc0a3b
7 changed files with 142 additions and 45 deletions
|
@ -852,6 +852,7 @@ class Channel extends SnowFlake{
|
||||||
await this.buildmessages();
|
await this.buildmessages();
|
||||||
//loading.classList.remove("loading");
|
//loading.classList.remove("loading");
|
||||||
(document.getElementById("typebox") as HTMLDivElement).contentEditable =""+this.canMessage;
|
(document.getElementById("typebox") as HTMLDivElement).contentEditable =""+this.canMessage;
|
||||||
|
(document.getElementById("upload") as HTMLElement).style.visibility=this.canMessage?"visible":"hidden";
|
||||||
(document.getElementById("typebox") as HTMLDivElement).focus();
|
(document.getElementById("typebox") as HTMLDivElement).focus();
|
||||||
}
|
}
|
||||||
typingmap: Map<Member, number> = new Map();
|
typingmap: Map<Member, number> = new Map();
|
||||||
|
|
|
@ -199,6 +199,7 @@ class Group extends Channel{
|
||||||
}
|
}
|
||||||
this.buildmessages();
|
this.buildmessages();
|
||||||
(document.getElementById("typebox") as HTMLDivElement).contentEditable ="" + true;
|
(document.getElementById("typebox") as HTMLDivElement).contentEditable ="" + true;
|
||||||
|
(document.getElementById("upload") as HTMLElement).style.visibility="visible";
|
||||||
(document.getElementById("typebox") as HTMLDivElement).focus();
|
(document.getElementById("typebox") as HTMLDivElement).focus();
|
||||||
}
|
}
|
||||||
messageCreate(messagep: { d: messagejson }){
|
messageCreate(messagep: { d: messagejson }){
|
||||||
|
|
1
src/webpage/icons/upload.svg
Normal file
1
src/webpage/icons/upload.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120"><path fill="red" d="M60 0A60 60 0 0 0 0 60a60 60 0 0 0 60 60 60 60 0 0 0 60-60A60 60 0 0 0 60 0Zm-7.7 20H68l-.1 31.2H100V67l-32.2-.1V100H52l.1-33.2H20V51l32.2.1Z"/></svg>
|
After Width: | Height: | Size: 232 B |
|
@ -81,7 +81,10 @@
|
||||||
<div id="replybox" class="hideReplyBox"></div>
|
<div id="replybox" class="hideReplyBox"></div>
|
||||||
<div id="typediv">
|
<div id="typediv">
|
||||||
<div id="realbox">
|
<div id="realbox">
|
||||||
<div id="typebox" contentEditable="true"></div>
|
<div class="outerTypeBox">
|
||||||
|
<span class="svg-upload svgicon" id="upload"></span>
|
||||||
|
<div id="typebox" contentEditable="true"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="typing" class="hidden flexltr">
|
<div id="typing" class="hidden flexltr">
|
||||||
<p id="typingtext">typing</p>
|
<p id="typingtext">typing</p>
|
||||||
|
@ -97,6 +100,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div hidden id="gimmefile">
|
||||||
|
<div id="filedroptext" class="centeritem nonimagecenter">Upload your files here!</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<script src="/index.js" type="module"></script>
|
<script src="/index.js" type="module"></script>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import{ Contextmenu }from"./contextmenu.js";
|
||||||
import{ mobile, getBulkUsers, setTheme, Specialuser }from"./login.js";
|
import{ mobile, getBulkUsers, setTheme, Specialuser }from"./login.js";
|
||||||
import{ MarkDown }from"./markdown.js";
|
import{ MarkDown }from"./markdown.js";
|
||||||
import{ Message }from"./message.js";
|
import{ Message }from"./message.js";
|
||||||
import{ File }from"./file.js";
|
import{File}from"./file.js";
|
||||||
import { I18n } from "./i18n.js";
|
import { I18n } from "./i18n.js";
|
||||||
|
|
||||||
(async ()=>{
|
(async ()=>{
|
||||||
|
@ -17,10 +17,12 @@ import { I18n } from "./i18n.js";
|
||||||
const loadingText=document.getElementById("loadingText");
|
const loadingText=document.getElementById("loadingText");
|
||||||
const loaddesc=document.getElementById("load-desc");
|
const loaddesc=document.getElementById("load-desc");
|
||||||
const switchaccounts=document.getElementById("switchaccounts");
|
const switchaccounts=document.getElementById("switchaccounts");
|
||||||
if(loadingText&&loaddesc&&switchaccounts){
|
const filedroptext=document.getElementById("filedroptext");
|
||||||
|
if(loadingText&&loaddesc&&switchaccounts&&filedroptext){
|
||||||
loadingText.textContent=I18n.getTranslation("htmlPages.loadingText");
|
loadingText.textContent=I18n.getTranslation("htmlPages.loadingText");
|
||||||
loaddesc.textContent=I18n.getTranslation("htmlPages.loaddesc");
|
loaddesc.textContent=I18n.getTranslation("htmlPages.loaddesc");
|
||||||
switchaccounts.textContent=I18n.getTranslation("htmlPages.switchaccounts");
|
switchaccounts.textContent=I18n.getTranslation("htmlPages.switchaccounts");
|
||||||
|
filedroptext.textContent=I18n.getTranslation("uploadFilesText");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
I18n
|
I18n
|
||||||
|
@ -191,50 +193,115 @@ import { I18n } from "./i18n.js";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CustomHTMLDivElement extends HTMLDivElement {markdown: MarkDown;}
|
interface CustomHTMLDivElement extends HTMLDivElement {markdown: MarkDown;}
|
||||||
|
|
||||||
const typebox = document.getElementById("typebox") as CustomHTMLDivElement;
|
const typebox = document.getElementById("typebox") as CustomHTMLDivElement;
|
||||||
const markdown = new MarkDown("", thisUser);
|
const markdown = new MarkDown("", thisUser);
|
||||||
typebox.markdown = markdown;
|
typebox.markdown = markdown;
|
||||||
typebox.addEventListener("keyup", handleEnter);
|
typebox.addEventListener("keyup", handleEnter);
|
||||||
typebox.addEventListener("keydown", event=>{
|
typebox.addEventListener("keydown", event=>{
|
||||||
thisUser.keydown(event)
|
thisUser.keydown(event)
|
||||||
if(event.key === "Enter" && !event.shiftKey) event.preventDefault();
|
if(event.key === "Enter" && !event.shiftKey) event.preventDefault();
|
||||||
});
|
});
|
||||||
markdown.giveBox(typebox);
|
markdown.giveBox(typebox);
|
||||||
|
|
||||||
const images: Blob[] = [];
|
const images: Blob[] = [];
|
||||||
const imagesHtml: HTMLElement[] = [];
|
const imagesHtml: HTMLElement[] = [];
|
||||||
|
|
||||||
document.addEventListener("paste", async (e: ClipboardEvent)=>{
|
document.addEventListener("paste", async (e: ClipboardEvent)=>{
|
||||||
if(!e.clipboardData)return;
|
if(!e.clipboardData)return;
|
||||||
|
|
||||||
for(const file of Array.from(e.clipboardData.files)){
|
for(const file of Array.from(e.clipboardData.files)){
|
||||||
const fileInstance = File.initFromBlob(file);
|
const fileInstance = File.initFromBlob(file);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const html = fileInstance.upHTML(images, file);
|
const html = fileInstance.upHTML(images, file);
|
||||||
pasteImageElement.appendChild(html);
|
pasteImageElement.appendChild(html);
|
||||||
images.push(file);
|
images.push(file);
|
||||||
imagesHtml.push(html);
|
imagesHtml.push(html);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setTheme();
|
||||||
|
|
||||||
|
function userSettings(): void{
|
||||||
|
thisUser.showusersettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
(document.getElementById("settings") as HTMLImageElement).onclick =
|
||||||
|
userSettings;
|
||||||
|
|
||||||
|
if(mobile){
|
||||||
|
const channelWrapper = document.getElementById("channelw") as HTMLDivElement;
|
||||||
|
channelWrapper.onclick = ()=>{
|
||||||
|
const toggle = document.getElementById("maintoggle") as HTMLInputElement;
|
||||||
|
toggle.checked = true;
|
||||||
|
};
|
||||||
|
const memberListToggle = document.getElementById("memberlisttoggle") as HTMLInputElement;
|
||||||
|
memberListToggle.checked = false;
|
||||||
|
}
|
||||||
|
let dragendtimeout=setTimeout(()=>{})
|
||||||
|
document.addEventListener("dragover",(e)=>{
|
||||||
|
clearTimeout(dragendtimeout);
|
||||||
|
const data = e.dataTransfer;
|
||||||
|
const bg=document.getElementById("gimmefile") as HTMLDivElement;
|
||||||
|
|
||||||
|
if(data){
|
||||||
|
const isfile=data.types.includes("Files")||data.types.includes("application/x-moz-file");
|
||||||
|
if(!isfile){
|
||||||
|
bg.hidden=true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
e.preventDefault();
|
||||||
|
bg.hidden=false;
|
||||||
setTheme();
|
//console.log(data.types,data)
|
||||||
|
}else{
|
||||||
function userSettings(): void{
|
bg.hidden=true;
|
||||||
thisUser.showusersettings();
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
(document.getElementById("settings") as HTMLImageElement).onclick =
|
document.addEventListener("dragleave",(_)=>{
|
||||||
userSettings;
|
dragendtimeout=setTimeout(()=>{
|
||||||
|
const bg=document.getElementById("gimmefile") as HTMLDivElement;
|
||||||
if(mobile){
|
bg.hidden=true;
|
||||||
const channelWrapper = document.getElementById("channelw") as HTMLDivElement;
|
},1000)
|
||||||
channelWrapper.onclick = ()=>{
|
});
|
||||||
const toggle = document.getElementById("maintoggle") as HTMLInputElement;
|
document.addEventListener("dragenter",(e)=>{
|
||||||
toggle.checked = true;
|
e.preventDefault();
|
||||||
};
|
})
|
||||||
const memberListToggle = document.getElementById("memberlisttoggle") as HTMLInputElement;
|
document.addEventListener("drop",e=>{
|
||||||
memberListToggle.checked = false;
|
const data = e.dataTransfer;
|
||||||
|
const bg=document.getElementById("gimmefile") as HTMLDivElement;
|
||||||
|
bg.hidden=true;
|
||||||
|
if(data){
|
||||||
|
const isfile=data.types.includes("Files")||data.types.includes("application/x-moz-file");
|
||||||
|
if(isfile){
|
||||||
|
e.preventDefault();
|
||||||
|
console.log(data.files);
|
||||||
|
for(const file of Array.from(data.files)){
|
||||||
|
const fileInstance = File.initFromBlob(file);
|
||||||
|
const html = fileInstance.upHTML(images, file);
|
||||||
|
pasteImageElement.appendChild(html);
|
||||||
|
images.push(file);
|
||||||
|
imagesHtml.push(html);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
(document.getElementById("upload") as HTMLElement).onclick=()=>{
|
||||||
|
const input=document.createElement("input");
|
||||||
|
input.type="file";
|
||||||
|
input.click();
|
||||||
|
console.log("clicked")
|
||||||
|
input.onchange=(() => {
|
||||||
|
if(input.files){
|
||||||
|
for(const file of Array.from(input.files)){
|
||||||
|
const fileInstance = File.initFromBlob(file);
|
||||||
|
const html = fileInstance.upHTML(images, file);
|
||||||
|
pasteImageElement.appendChild(html);
|
||||||
|
images.push(file);
|
||||||
|
imagesHtml.push(html);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -246,6 +246,11 @@ textarea {
|
||||||
.svg-plus {
|
.svg-plus {
|
||||||
mask: url(/icons/plus.svg);
|
mask: url(/icons/plus.svg);
|
||||||
}
|
}
|
||||||
|
.svg-upload {
|
||||||
|
mask: url(/icons/upload.svg);
|
||||||
|
width: .2in !important;!i;!;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
.svg-x {
|
.svg-x {
|
||||||
mask: url(/icons/x.svg);
|
mask: url(/icons/x.svg);
|
||||||
}
|
}
|
||||||
|
@ -278,6 +283,13 @@ textarea {
|
||||||
padding: .05in;
|
padding: .05in;
|
||||||
border-radius: .04in;
|
border-radius: .04in;
|
||||||
}
|
}
|
||||||
|
#gimmefile{
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: #00000070;
|
||||||
|
top:0px;
|
||||||
|
}
|
||||||
/* Animations */
|
/* Animations */
|
||||||
@keyframes fade {
|
@keyframes fade {
|
||||||
0%, 100% {
|
0%, 100% {
|
||||||
|
@ -832,6 +844,7 @@ span.instanceStatus {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
#pasteimage:empty {
|
#pasteimage:empty {
|
||||||
height: 0;
|
height: 0;
|
||||||
|
@ -885,14 +898,21 @@ span.instanceStatus {
|
||||||
#realbox {
|
#realbox {
|
||||||
padding: 0 16px 28px 16px;
|
padding: 0 16px 28px 16px;
|
||||||
}
|
}
|
||||||
#typebox {
|
#typebox{
|
||||||
|
flex-grow:1;
|
||||||
|
width:100%;
|
||||||
|
margin-left: .06in;
|
||||||
|
}
|
||||||
|
.outerTypeBox {
|
||||||
max-height: 50svh;
|
max-height: 50svh;
|
||||||
padding: 10px 14px;
|
padding: 10px 10px;
|
||||||
background: var(--typebox-bg);
|
background: var(--typebox-bg);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
display:flex;
|
||||||
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
#typebox > span::before {
|
.outerTypeBox > span::before {
|
||||||
content: "\feff";
|
content: "\feff";
|
||||||
}
|
}
|
||||||
#typebox[contenteditable=false] {
|
#typebox[contenteditable=false] {
|
||||||
|
|
|
@ -375,6 +375,7 @@
|
||||||
"reason:":"Reason:",
|
"reason:":"Reason:",
|
||||||
"ban":"Ban $1 from $2"
|
"ban":"Ban $1 from $2"
|
||||||
},
|
},
|
||||||
|
"uploadFilesText":"Upload your files here!",
|
||||||
"errorReconnect":"Unable to connect to the server, retrying in **$1** seconds...",
|
"errorReconnect":"Unable to connect to the server, retrying in **$1** seconds...",
|
||||||
"retrying":"Retrying...",
|
"retrying":"Retrying...",
|
||||||
"unableToConnect":"Unable to connect to the Spacebar server. Please try logging out and back in."
|
"unableToConnect":"Unable to connect to the Spacebar server. Please try logging out and back in."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue