1
0
mirror of https://github.com/JustKato/FreePad.git synced 2026-02-23 15:50:46 +02:00

Started working on V2 rework

This commit is contained in:
2022-05-18 22:54:07 +03:00
parent 2d7d6a2f8b
commit 89eaceddcc
57 changed files with 22 additions and 680 deletions

0
static/css/.keep Normal file
View File

3
static/css/main.css Normal file
View File

@@ -0,0 +1,3 @@
#post_content {
height: calc(100vh - 35rem);
}

0
static/img/.keep Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
static/img/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

BIN
static/img/gopher.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
static/img/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

0
static/js/.keep Normal file
View File

106
static/js/main.js Normal file
View File

@@ -0,0 +1,106 @@
function setStatus(text, className ) {
// Show loading
const statusIndicator = document.getElementById(`status-indicator`);
if ( !!statusIndicator ) {
// Clear all previous status-es
for ( let [x, k] of statusIndicator.classList.entries() ) {
statusIndicator.classList.remove(k);
}
// Mark as loading
statusIndicator.textContent = text;
statusIndicator.classList.add(className);
}
}
function updatePost(postName) {
const postContentElement = document.getElementById(`post_content`);
if ( !!postContentElement && !!postContentElement.value ) {
const postContent = String(postContentElement.value);
if ( !!postContent && postContent.length > 0 ) {
setStatus(`Loading...`, `has-text-warning`);
// Generate the form data
let formData = new FormData();
formData.append('name', postName);
formData.append('content', postContent);
// Send out a fetch request
fetch("/api/post", {
method: "post",
body: formData,
})
.then( result => {
if ( result.status < 200 || result.status > 299 ) {
if ( result.status == 429) {
setStatus(`Too many requests, please wait`, `has-text-danger`);
} else {
setStatus(`Failed to Save`, `has-text-danger`);
}
} else {
setStatus(`Saved`, `has-text-success`);
}
console.log(result);
})
.catch( error => {
console.error(error);
alert(error);
setStatus(`Failed to Save`, `has-text-danger`);
})
}
}
}
/**
* @location /
* @role Searching
*/
function goToPost() {
// Get the post name element
const postNameElement = document.getElementById(`postName`);
// Check if the element exists
if ( !!postNameElement ) {
// Get the post name string
const postName = String(postNameElement.value);
// Check if the post name is valid
if ( !!postName && postName.length > 0 && postName.length <= 256 ) {
// Change the location
window.location.href = `/${postName}`;
}
}
}
function getQr(link = `https://justkato.me/`) {
return new Promise((_r, _e) => {
let formData = new FormData();
formData.append('link', link);
// Send out a fetch request
fetch("/api/qr", {
method: "post",
body: formData,
})
.then( result => {
result.json()
.then( rez => {
return _r(rez);
})
})
.catch( error => {
console.error(error);
alert(error);
return _e(error);
})
})
}

0
static/vendor/.keep vendored Normal file
View File