mirror of
https://github.com/acid-info/peripatos.free.technology.git
synced 2025-01-13 17:14:57 +00:00
feat: enable form
This commit is contained in:
parent
c2c476423a
commit
dc744cea8e
@ -14,6 +14,47 @@
|
|||||||
src={import.meta.env.VITE_TRACKING_URL}
|
src={import.meta.env.VITE_TRACKING_URL}
|
||||||
></script>
|
></script>
|
||||||
{/if}
|
{/if}
|
||||||
|
<script>
|
||||||
|
async function handleSubmit(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
const form = document.querySelector(".apply-form");
|
||||||
|
const name = form.querySelector("#form-name").value;
|
||||||
|
const email = form.querySelector("#form-email").value;
|
||||||
|
|
||||||
|
console.log(name, email);
|
||||||
|
|
||||||
|
const res = await fetch(
|
||||||
|
`https://odoo.logos.co/website_mass_mailing/subscribe2`,
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
jsonrpc: "2.0",
|
||||||
|
method: "call",
|
||||||
|
params: {
|
||||||
|
email: email,
|
||||||
|
name: name,
|
||||||
|
list_id: 12,
|
||||||
|
subscription_type: "email",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const data = await res.json();
|
||||||
|
|
||||||
|
if (data.error) {
|
||||||
|
console.error(data.error);
|
||||||
|
alert("There was an error submitting your application.");
|
||||||
|
} else {
|
||||||
|
console.log(data);
|
||||||
|
alert("Thank you for applying!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<main
|
<main
|
||||||
|
20
src/app.css
20
src/app.css
@ -63,3 +63,23 @@ main > div > div:first-child {
|
|||||||
::-webkit-scrollbar-thumb:hover {
|
::-webkit-scrollbar-thumb:hover {
|
||||||
background: none;
|
background: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.apply-form {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 24px;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.apply-input {
|
||||||
|
padding: 4px 12px;
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.apply-submit {
|
||||||
|
padding: 4px 12px;
|
||||||
|
background: transparent;
|
||||||
|
color: white;
|
||||||
|
border: 1px solid white;
|
||||||
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { afterUpdate, onMount } from 'svelte';
|
import { afterUpdate, onMount } from "svelte";
|
||||||
import { history } from '../stores/history';
|
import { history } from "../stores/history";
|
||||||
import { theme } from '../stores/theme';
|
import { theme } from "../stores/theme";
|
||||||
import { commands } from '../utils/commands';
|
import { commands } from "../utils/commands";
|
||||||
import { track } from '../utils/tracking';
|
import { track } from "../utils/tracking";
|
||||||
|
|
||||||
let command = '';
|
let command = "";
|
||||||
let historyIndex = -1;
|
let historyIndex = -1;
|
||||||
|
|
||||||
let input: HTMLInputElement;
|
let input: HTMLInputElement;
|
||||||
@ -14,28 +14,28 @@
|
|||||||
input.focus();
|
input.focus();
|
||||||
|
|
||||||
if ($history.length === 0) {
|
if ($history.length === 0) {
|
||||||
const command = commands['banner'] as () => string;
|
const command = commands["banner"] as () => string;
|
||||||
|
|
||||||
console.log('command',command);
|
console.log("command", command);
|
||||||
|
|
||||||
if (command) {
|
if (command) {
|
||||||
const output = command();
|
const output = command();
|
||||||
console.log('output',output);
|
console.log("output", output);
|
||||||
|
|
||||||
$history = [...$history, { command: 'banner', outputs: [output] }];
|
$history = [...$history, { command: "banner", outputs: [output] }];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
afterUpdate(() => {
|
afterUpdate(() => {
|
||||||
input.scrollIntoView({ behavior: 'smooth', block: 'end' });
|
input.scrollIntoView({ behavior: "smooth", block: "end" });
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleKeyDown = async (event: KeyboardEvent) => {
|
const handleKeyDown = async (event: KeyboardEvent) => {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === "Enter") {
|
||||||
const [commandName, ...args] = command.split(' ');
|
const [commandName, ...args] = command.split(" ");
|
||||||
|
|
||||||
if (import.meta.env.VITE_TRACKING_ENABLED === 'true') {
|
if (import.meta.env.VITE_TRACKING_ENABLED === "true") {
|
||||||
track(commandName, ...args);
|
track(commandName, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@
|
|||||||
if (commandFunction) {
|
if (commandFunction) {
|
||||||
const output = await commandFunction(args);
|
const output = await commandFunction(args);
|
||||||
|
|
||||||
if (commandName !== 'clear') {
|
if (commandName !== "clear") {
|
||||||
$history = [...$history, { command, outputs: [output] }];
|
$history = [...$history, { command, outputs: [output] }];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -53,8 +53,8 @@
|
|||||||
$history = [...$history, { command, outputs: [output] }];
|
$history = [...$history, { command, outputs: [output] }];
|
||||||
}
|
}
|
||||||
|
|
||||||
command = '';
|
command = "";
|
||||||
} else if (event.key === 'ArrowUp') {
|
} else if (event.key === "ArrowUp") {
|
||||||
if (historyIndex < $history.length - 1) {
|
if (historyIndex < $history.length - 1) {
|
||||||
historyIndex++;
|
historyIndex++;
|
||||||
|
|
||||||
@ -62,26 +62,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else if (event.key === 'ArrowDown') {
|
} else if (event.key === "ArrowDown") {
|
||||||
if (historyIndex > -1) {
|
if (historyIndex > -1) {
|
||||||
historyIndex--;
|
historyIndex--;
|
||||||
command =
|
command =
|
||||||
historyIndex >= 0
|
historyIndex >= 0
|
||||||
? $history[$history.length - 1 - historyIndex].command
|
? $history[$history.length - 1 - historyIndex].command
|
||||||
: '';
|
: "";
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else if (event.key === 'Tab') {
|
} else if (event.key === "Tab") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const autoCompleteCommand = Object.keys(commands).find((cmd) =>
|
const autoCompleteCommand = Object.keys(commands).find((cmd) =>
|
||||||
cmd.startsWith(command),
|
cmd.startsWith(command)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (autoCompleteCommand) {
|
if (autoCompleteCommand) {
|
||||||
command = autoCompleteCommand;
|
command = autoCompleteCommand;
|
||||||
}
|
}
|
||||||
} else if (event.ctrlKey && event.key === 'l') {
|
} else if (event.ctrlKey && event.key === "l") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
$history = [];
|
$history = [];
|
||||||
@ -91,7 +91,11 @@
|
|||||||
|
|
||||||
<svelte:window
|
<svelte:window
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
input.focus();
|
const form = document.querySelector(".apply-form");
|
||||||
|
|
||||||
|
if (!form) {
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
@ -10,10 +10,14 @@ export const commands: Record<
|
|||||||
(args: string[]) => Promise<string> | string
|
(args: string[]) => Promise<string> | string
|
||||||
> = {
|
> = {
|
||||||
apply: async () => {
|
apply: async () => {
|
||||||
// const htmlString =
|
const htmlString = `<template>
|
||||||
// '<template>Please email us at <a class="link" href="mailto:contact@free.technology">contact@free.technology</a></template>';
|
<form class="apply-form" onsubmit="handleSubmit(event)">
|
||||||
|
<input class="apply-input" id="form-name" placeholder="First name or pseudonym" />
|
||||||
|
<input class="apply-input" id="form-email" placeholder="Email address" type="email" />
|
||||||
|
<button class="apply-submit">Submit</button>
|
||||||
|
</form>
|
||||||
|
</template>`;
|
||||||
|
|
||||||
const htmlString = "Coming Soon.";
|
|
||||||
return htmlString;
|
return htmlString;
|
||||||
},
|
},
|
||||||
help: () => {
|
help: () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user