frontend sketch on pure web
This commit is contained in:
commit
7d0c459b77
13 changed files with 1054 additions and 0 deletions
46
www/js/functions.js
Normal file
46
www/js/functions.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
function makeid(length) {
|
||||
var result = '';
|
||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
var charactersLength = characters.length;
|
||||
for ( var i = 0; i < length; i++ ) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const imageTypes = {
|
||||
types: [
|
||||
{
|
||||
description: "Images",
|
||||
accept: {
|
||||
"image/*": [".png", ".gif", ".jpeg", ".jpg"],
|
||||
},
|
||||
},
|
||||
],
|
||||
excludeAcceptAllOption: true,
|
||||
multiple: false,
|
||||
};
|
||||
|
||||
let fileHandle;
|
||||
async function loadImage() {
|
||||
[fileHandle] = await window.showOpenFilePicker(imageTypes);
|
||||
return fileHandle;
|
||||
}
|
||||
|
||||
function addImage(initiator, target) {
|
||||
loadImage().then(async (result) => {
|
||||
let img = document.createElement("img");
|
||||
img.src = URL.createObjectURL(await result.getFile());
|
||||
document.getElementById(target).appendChild(img);
|
||||
initiator = document.getElementById(initiator);
|
||||
if (initiator) initiator.remove();
|
||||
//document.getElementById(target).addEventListener("click", addImage("", target));
|
||||
});
|
||||
}
|
||||
|
||||
function json_filter(key,value)
|
||||
{
|
||||
if (key=="html") return undefined;
|
||||
//else if (key=="id") return undefined;
|
||||
else return value;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue