Significant writing.jinja2 cleanup.

This commit is contained in:
Sage Vaillancourt 2022-09-22 16:23:01 -04:00
parent 17ab611e9c
commit ddba4b103b
1 changed files with 37 additions and 23 deletions

View File

@ -5,30 +5,37 @@
<title>UnderCover</title> <title>UnderCover</title>
<link rel="stylesheet" type="text/css" href=" <link rel="stylesheet" type="text/css" href="
{{ url_for('static', filename='styles_min.css') }}"> {{ url_for('static', filename='styles_min.css') }}">
<meta name="viewport" content="user-scalable=no;width=device-width"> <meta name="viewport" content="user-scalable=no; width=device-width">
<script type="text/javascript"> <script type="text/javascript">
function init() { window.onload = () => {
{% if errors %} {% if errors %}
window.scrollTo(0, document.body.scrollHeight); window.scrollTo(0, document.body.scrollHeight);
{% endif %} {% endif %}
if (window.location.search.includes("reset=true")) { if (window.location.search.includes("reset=true")) {
window.history.pushState({},document.title,window.location.pathname); window.history.pushState({}, document.title, window.location.pathname);
return; return;
} }
decodeURIComponent(document.cookie).split(';').forEach(s => { decodeURIComponent(document.cookie).split(';').forEach(cookie => {
[id, v] = s.trim().split('=') [id, value] = cookie.trim().split('=')
document.getElementById(id).value = v document.getElementById(id).value = value
}) })
} }
window.onload = init;
const clearErrors = () => {
const e = document.getElementById('errors')
e.parentNode.removeChild(e)
}
</script> </script>
</head> </head>
<body> <body>
<a href="/" style="text-decoration: none;"> <a href="/" style="text-decoration: none;">
<h1><span class="logo left">Under</span><span class="logo right">Cover</span></h1> <h1><span class="logo left">Under</span><span class="logo right">Cover</span></h1>
<a> </a>
<h2>The secret cover letter generator</h2> <h2>The secret cover letter generator</h2>
{% from "_formhelpers.jinja2" import render_field %} {% from "_formhelpers.jinja2" import render_field %}
<form method=post> <form method=post>
<dl> <dl>
@ -40,24 +47,31 @@
{{ render_field(form.body, 'class=bigtext') }} {{ render_field(form.body, 'class=bigtext') }}
{{ render_field(form.closingtext) }} {{ render_field(form.closingtext) }}
</dl> </dl>
{% if errors %} {% if errors %}
<div id=errors> <div id=errors>
<h3>Your letter has errors.</h3> <h3>Your letter has errors.</h3>
<p>There is likely a typo in one of your variables (the {\blabla} bits). <p>
<br>Make sure each is spelled correctly, and has the correct brackets on either There is likely a typo in one of your variables (the {\blabla} bits).<br>
side</p> Make sure each is spelled correctly, and has the correct brackets on either side
<p class=errors> </p>
{% for error in errors %} <p class=errors>
{{ error }}<br> {% for error in errors %}
{% endfor %} {{ error }}<br>
</p> {% endfor %}
</div> </p>
{% endif %} </div>
<input class=submit type=submit value="Generate PDF"
{% if errors %}
onclick="const e = document.getElementById('errors'); e.parentNode.removeChild(e);"
{% endif %} {% endif %}
<input
class=submit
type=submit
value="Generate PDF"
{% if errors %}
onclick="clearErrors()"
{% endif %}
> >
</form> </form>
</body> </body>
</html> </html>