cement/templates/index.html

50 lines
1.8 KiB
HTML

{% extends "base.html" %}
{% block title %}Create Paste{% endblock title %}
{% block body %}
<form class="grow" method="POST" action="/">
<input type="hidden" name="token" value="{{ token }}">
<textarea
class="w-full h-full resize-none bg-transparent font-mono outline-none"
name="content"
autofocus
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
placeholder="Paste something :)"></textarea>
<div class="absolute bottom-4 right-4 flex flex-row items-stretch gap-2">
<select
class="block p-2.5 pr-8 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg
focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
name="highlight">
<option value="">No syntax highlighting</option>
{% include "highlight/languages.html" %}
</select>
<button
class="px-5 py-2.5 text-white bg-blue-700 hover:bg-blue-800 focus:ring-4
focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none
dark:focus:ring_blue-800 font-medium rounded-lg text-sm transition-colors"
type="submit"
title="Create paste &#x2318;+&#x23ce;">&#10003; Create paste</button>
</div>
</form>
<script>
const form = document.querySelector("form");
const textarea = document.querySelector("textarea");
const button = document.querySelector("button[type='submit']");
textarea.addEventListener("input", () => {
button.disabled = !textarea.value;
});
document.body.addEventListener("keydown", (event) => {
if (event.key === "Enter" && (event.metaKey || event.ctrlKey || event.altKey)) {
form.submit();
}
});
</script>
{% endblock body %}