WhisperMaPhone/main/templates/whispermaphone/post.html

37 lines
1.1 KiB
HTML
Raw Normal View History

2020-09-06 03:12:54 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="{% url 'post'%}" method="post">
{% csrf_token %}
2020-09-06 03:38:15 +00:00
<textarea name="text" id="text"></textarea>
<textarea name="extended_text" id="extended_text"></textarea>
<input type="hidden" name="timezone_offset" id="timezone_offset">
<input type="submit">
2020-09-06 03:12:54 +00:00
</form>
2020-09-06 04:06:16 +00:00
<script>
const textEl = document.getElementById("text");
const textExtEl = document.getElementById("extended_text");
2020-09-06 04:12:14 +00:00
textEl.addEventListener("keydown", evt => {
2020-09-06 04:06:16 +00:00
// If the length is more than 120
const value = textEl.value;
2020-09-06 04:12:14 +00:00
if (value.length > 140) {
const splitAt = value.lastIndexOf(" ", 140) + 1; // Plus 1 keeps the space in the original text instead of moving it
const toMove = value.substring(splitAt);
2020-09-06 04:06:16 +00:00
textExtEl.value = toMove + textExtEl.value;
2020-09-06 04:12:14 +00:00
textEl.value = value.substring(0, splitAt);
2020-09-06 04:06:16 +00:00
}
});
2020-09-06 03:38:15 +00:00
2020-09-06 04:06:16 +00:00
const timezoneOffsetEl = document.getElementById("timezone_offset");
timezoneOffsetEl.value = (new Date()).getTimezoneOffset();
</script>
2020-09-06 03:38:15 +00:00
2020-09-06 03:12:54 +00:00
</body>
</html>