Compare commits
4 Commits
Containerf
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13870d48a1 | ||
|
|
8b3c78cb84 | ||
|
|
049a1b0125 | ||
| f5aac579ff |
@@ -6,23 +6,22 @@
|
|||||||
export let language: string | undefined;
|
export let language: string | undefined;
|
||||||
|
|
||||||
let displayCode: string | undefined;
|
let displayCode: string | undefined;
|
||||||
|
let displayLanguage: string | undefined;
|
||||||
let showAlert = false;
|
let showAlert = false;
|
||||||
let initial = true;
|
|
||||||
|
|
||||||
$: if(code) {
|
$: if(code) {
|
||||||
highlight();
|
highlight();
|
||||||
initial = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$: if(language) {
|
$: if(language !== displayLanguage) {
|
||||||
if(initial || !code) {
|
highlight();
|
||||||
highlight();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlight() {
|
function highlight() {
|
||||||
if(language) {
|
if(language) {
|
||||||
const res = hljs.highlight(language!, code!);
|
const res = hljs.highlight(code!, {
|
||||||
|
language
|
||||||
|
});
|
||||||
if(!res.errorRaised) {
|
if(!res.errorRaised) {
|
||||||
displayCode = res.value;
|
displayCode = res.value;
|
||||||
}
|
}
|
||||||
@@ -33,6 +32,7 @@
|
|||||||
language = res.language;
|
language = res.language;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
displayLanguage = language;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function copy() {
|
async function copy() {
|
||||||
|
|||||||
@@ -45,7 +45,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if(res.ok) {
|
if(res.ok) {
|
||||||
const id = await res.text();
|
let id = await res.text();
|
||||||
|
if(id.includes('/')) {
|
||||||
|
id = id.substring(id.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
push(`/${id}`);
|
push(`/${id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +78,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if(res.status === 200) {
|
if(res.status === 200) {
|
||||||
const id = await res.text();
|
let id = await res.text();
|
||||||
|
if(id.includes('/')) {
|
||||||
|
id = id.substring(id.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
createdUrl = `${location.origin}/to/${id}`;
|
createdUrl = `${location.origin}/to/${id}`;
|
||||||
enteredUrl = '';
|
enteredUrl = '';
|
||||||
showAlert = true;
|
showAlert = true;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ mod paste;
|
|||||||
|
|
||||||
// Generate random key function
|
// Generate random key function
|
||||||
fn random_string() -> String {
|
fn random_string() -> String {
|
||||||
|
// hallo
|
||||||
rand::thread_rng()
|
rand::thread_rng()
|
||||||
.sample_iter(&Alphanumeric)
|
.sample_iter(&Alphanumeric)
|
||||||
.take(5)
|
.take(5)
|
||||||
|
|||||||
Reference in New Issue
Block a user