Less naive cookie processing
Remove some unnecessary whitespace
This commit is contained in:
parent
7cb9591acf
commit
e52a0e9d28
|
@ -1,12 +1,12 @@
|
||||||
{% macro render_field(field, extra="") %}
|
{% macro render_field(field, extra="") %}
|
||||||
<dt>{{ field.label }}
|
<dt>{{ field.label }}
|
||||||
<dd {{extra}}>{{ field(**kwargs)|safe }}
|
<dd {{extra}}>{{ field(**kwargs)|safe }}
|
||||||
{% if field.errors %}
|
{% if field.errors %}
|
||||||
<ul class=errors>
|
<ul class=errors>
|
||||||
{% for error in field.errors %}
|
{% for error in field.errors %}
|
||||||
<li>{{ error }}</li>
|
<li>{{ error }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dd>
|
</dd>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
|
@ -5,46 +5,18 @@
|
||||||
{{ url_for('static', filename='styles_min.css') }}">
|
{{ url_for('static', filename='styles_min.css') }}">
|
||||||
<meta name="viewport" content="user-scalable=no">
|
<meta name="viewport" content="user-scalable=no">
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function getCookie(cname) {
|
|
||||||
let name = cname + "=";
|
|
||||||
let decodedCookie = decodeURIComponent(document.cookie);
|
|
||||||
let ca = decodedCookie.split(';');
|
|
||||||
for(let i = 0; i <ca.length; i++) {
|
|
||||||
let c = ca[i];
|
|
||||||
while (c.charAt(0) == ' ') {
|
|
||||||
c = c.substring(1);
|
|
||||||
}
|
|
||||||
if (c.indexOf(name) == 0) {
|
|
||||||
return c.substring(name.length, c.length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
function init() {
|
function init() {
|
||||||
{% 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 => {
|
||||||
cookies = [
|
[id, v] = s.trim().split('=')
|
||||||
'username',
|
document.getElementById(id).value = v
|
||||||
'company',
|
})
|
||||||
'jobandpronoun',
|
|
||||||
'skilltypes',
|
|
||||||
'myskills',
|
|
||||||
'closingtext',
|
|
||||||
'body',
|
|
||||||
]
|
|
||||||
for(let i = 0; i < cookies.length; i++) {
|
|
||||||
c = getCookie(cookies[i]);
|
|
||||||
if (c) {
|
|
||||||
document.getElementById(cookies[i]).value=c
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
window.onload = init;
|
window.onload = init;
|
||||||
</script>
|
</script>
|
||||||
|
@ -52,7 +24,6 @@
|
||||||
<body>
|
<body>
|
||||||
<h1>UnderCover</h1>
|
<h1>UnderCover</h1>
|
||||||
<h2>The secret cover letter generator</h2>
|
<h2>The secret cover letter generator</h2>
|
||||||
|
|
||||||
{% from "_formhelpers.html" import render_field %}
|
{% from "_formhelpers.html" import render_field %}
|
||||||
<form method=post>
|
<form method=post>
|
||||||
<dl>
|
<dl>
|
||||||
|
@ -64,15 +35,12 @@
|
||||||
{{ 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>There is likely a typo in one of your variables (the {\blabla} bits).
|
||||||
<br>Make sure each is spelled correctly, and has the correct brackets on either
|
<br>Make sure each is spelled correctly, and has the correct brackets on either
|
||||||
side</p>
|
side</p>
|
||||||
|
|
||||||
<p class=errors>
|
<p class=errors>
|
||||||
{% for error in errors %}
|
{% for error in errors %}
|
||||||
{{ error }}<br>
|
{{ error }}<br>
|
||||||
|
@ -80,7 +48,6 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<input class=submit type=submit value="Submit"
|
<input class=submit type=submit value="Submit"
|
||||||
{% if errors %}
|
{% if errors %}
|
||||||
onclick="var e = document.getElementById('errors'); e.parentNode.removeChild(e);"
|
onclick="var e = document.getElementById('errors'); e.parentNode.removeChild(e);"
|
||||||
|
@ -88,5 +55,4 @@
|
||||||
>
|
>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue