-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_blog.html
61 lines (56 loc) · 1.62 KB
/
create_blog.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{% import 'macros.html' as m %}
{{ m.stylesheet() }}
<style>
#main_form { text-align: center; }
.unfilled::-webkit-input-placeholder { color: rgba(256,0,0,0.8); }
</style>
<script>
var DRIVE_PREFIX = "https://drive.google.com/#folders/";
</script>
<div id="main_form">
<h3>Create blog</h3>
<div><select id='title_selector'>
<script>var options = {}; var currentOption = "";</script>
{% for i in posts %}
<script>
currentOption = currentOption || '{{i.title}}';
options['{{i.title}}'] = '{{i.id}}';
</script>
<option>{{ i.title }}</option>
{% endfor %}
</select>
<a id="view" href="#">view</a>
</div>
<form id='form' action='{{host}}/create' method='post' onsubmit='return checkOk()'>
<input placeholder="Title" type='text' id='title' name='title' /><br>
<input placeholder="Subdomain" type='text' id='subdomain' name='subdomain' /><br/>
<textarea placeholder="Blog snippet" id='snippet' name='snippet'></textarea><br/>
<input placeholder="Image URL" type='text' id='image' name='image' /><br/>
<input type='hidden' id='folder' name='folder' />
<input type='submit'/>
</div>
</form>
<script>
function setViewUrl() {
$("#view").attr('href', DRIVE_PREFIX + options[currentOption]);
$("#folder").attr('value', options[currentOption]);
}
$('#title_selector').change(function(){
currentOption = this.value;
setViewUrl();
});
function checkOk() {
var ok = true;
$('#form').children().each(function(){
if (this.value === '' && this.type !== 'submit') {
$(this).addClass('unfilled');
ok = false;
}
});
console.log(ok);
return ok;
}
$(document).ready(function(){
setViewUrl();
});
</script>