Add poster name saving via cookie

When a user makes a new post with a name set, it will get saved via a
cookie to the user's client and it will automatically get set the next
time a user makes a post.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-07-12 20:28:21 -07:00
parent b096f70751
commit 5df21ccb95
3 changed files with 60 additions and 2 deletions

View File

@@ -55,4 +55,15 @@ input[type=text] {
<tr><td>&nbsp;</td><td><input type="submit" value="Submit" /></td></tr>
</table>
</form>
<script>
$("#submit").on("click", (e) => {
let name = $("#{{form.name.auto_id}}");
setCookie(NAME_COOKIE, name.val(), 3600 * 24 * 28);
});
$(window).on("load", (e) => {
$("#{{form.name.auto_id}}").val(getCookie(NAME_COOKIE));
});
</script>
{% endblock content %}

View File

@@ -67,7 +67,18 @@ input[type=text] {
{{ max_upload_size|measure_bytes }}
</td>
</tr>
<tr><td>&nbsp;</td><td><input type="submit" value="Submit" /></td></tr>
<tr><td>&nbsp;</td><td><input id="submit" type="submit" value="Submit" /></td></tr>
</table>
</form>
<script>
$("#submit").on("click", (e) => {
let name = $("#{{form.name.auto_id}}");
setCookie(NAME_COOKIE, name.val(), 3600 * 24 * 28);
});
$(window).on("load", (e) => {
$("#{{form.name.auto_id}}").val(getCookie(NAME_COOKIE));
});
</script>
{% endblock content %}