2018-05-18 18:41:41 +00:00
{% extends "layout.html" %}
{% import 'utils.html' as utils %}
2018-05-21 19:03:21 +00:00
{% block title %}New - {{ config.NAME }}{% endblock %}
2019-09-08 13:06:52 +00:00
{% block header %}
2019-04-10 20:50:36 +00:00
{% endblock %}
2018-05-18 18:41:41 +00:00
{% block content %}
< div id = "container" >
< div id = "new" >
2018-06-03 19:28:06 +00:00
{% if thread %}
< h3 style = "padding-bottom: 30px" > Replying to {{ content }}< / h3 >
{{ utils.display_thread(thread) }}
{% else %}
2019-09-03 20:54:01 +00:00
< div class = "tabbar" >
2019-04-14 17:17:54 +00:00
{% if request.args.get("question") == "1" %}
2019-09-03 20:54:01 +00:00
< a href = "{{ url_for('admin.admin_new') }}" class = "tab" > Note< / a > < a href = "{{ url_for('admin.admin_new') }}?question=1" class = "tab selected" > Question< / a >
2019-04-14 17:17:54 +00:00
{% else %}
2019-09-03 20:54:01 +00:00
< a href = "{{ url_for('admin.admin_new') }}" class = "tab selected" > Note< / a > < a href = "{{ url_for('admin.admin_new') }}?question=1" class = "tab" > Question< / a >
2019-04-14 17:17:54 +00:00
{% endif %}
2019-09-03 20:54:01 +00:00
< / div >
2018-06-03 19:28:06 +00:00
{% endif %}
2019-10-20 14:00:02 +00:00
< form id = "new-activity" action = "/api/new_{% if request.args.get(" question " ) = = " 1 " % } question { % else % } note { % endif % } " method = "POST" enctype = "multipart/form-data" >
2018-06-03 09:41:18 +00:00
< input type = "hidden" name = "redirect" value = "/" >
< input type = "hidden" name = "csrf_token" value = "{{ csrf_token() }}" >
2019-09-08 07:51:30 +00:00
< select name = "visibility" style = "padding:8px 10px;" >
2019-07-12 22:28:14 +00:00
{% for v in visibility %}
2019-09-08 09:34:00 +00:00
< option value = "{{v.name}}" { % if v = = default_visibility % } selected = "selected" { % endif % } > {{ v.value }}< / option >
2019-07-12 22:28:14 +00:00
{% endfor %}
< / select >
2018-05-18 18:41:41 +00:00
{% if reply %}< input type = "hidden" name = "reply" value = "{{reply}}" > {% endif %}
2019-04-10 20:50:36 +00:00
2019-09-08 07:51:30 +00:00
< p > < input type = "text" name = "summary" placeholder = "summary/CW (optional)" > < / p >
2019-04-10 20:50:36 +00:00
< p >
{% for emoji in emojis %}
2019-05-12 11:05:27 +00:00
< span class = "ji" > {{ emoji | emojify | safe }}< / span >
2019-04-10 20:50:36 +00:00
{% endfor %}
2019-10-01 21:14:04 +00:00
{% for emoji in custom_emojis %}
2019-08-20 20:16:47 +00:00
< span class = "ji" > < img src = "{{emoji.get_icon_url()}}" alt = "{{emoji.name}}" title = "{{emoji.name}}" class = "custom-emoji" > < / span >
{% endfor %}
2019-04-10 20:50:36 +00:00
< / p >
2019-09-08 07:51:30 +00:00
< textarea name = "content" rows = "10" cols = "50" autofocus = "autofocus" designMode = "on" style = "font-size:1.2em;width:95%;" > {{ content }}< / textarea >
2019-09-08 08:34:34 +00:00
< p >
2018-07-01 21:46:58 +00:00
< input type = "file" name = "file" >
2019-09-08 08:34:34 +00:00
< p >
< p >
< input type = "text" name = "file_description" placeholder = "attachment description (optional)" >
< / p >
2019-04-14 17:17:54 +00:00
{% if request.args.get("question") == "1" %}
2018-05-18 18:41:41 +00:00
< div style = "margin-top:20px;" >
2019-04-14 17:17:54 +00:00
< p > Open for: < select name = "open_for" >
2019-09-03 20:54:01 +00:00
< option value = "5" > 5 minutes< / option >
< option value = "10" > 10 minutes< / option >
< option value = "15" > 15 minutes< / option >
2019-04-14 17:17:54 +00:00
< option value = "30" > 30 minutes< / option >
< option value = "60" > 1 hour< / option >
< option value = "360" > 6 hour< / option >
< option value = "1440" selected > 1 day< / option >
< option value = "4320" > 3 days< / option >
< option value = "10080" > 7 days< / option >
< / select > < / p >
< p > < select name = "of" >
< option value = "oneOf" > Single choice< / option >
< option value = "anyOf" > Multiple choices< / option >
2019-08-15 12:47:41 +00:00
< / select > < / p >
2019-04-14 17:17:54 +00:00
{% for i in range(4) %}
< p > < input type = "text" name = "answer{{i}}" placeholder = "Answer #{{i+1}}" > < / p >
{% endfor %}
< / div >
{% endif %}
2018-05-18 18:41:41 +00:00
< input type = "submit" value = "post" >
< / div >
< / form >
< / div >
< / div >
2019-04-10 20:50:36 +00:00
< script >
2019-04-10 20:57:20 +00:00
// The new post textarea
2019-04-10 20:50:36 +00:00
var ta = document.getElementsByTagName("textarea")[0];
2019-04-10 20:57:20 +00:00
// Helper for inserting text (emojis) in the textarea
2019-04-10 20:50:36 +00:00
function insertAtCursor (textToInsert) {
2019-04-10 20:57:20 +00:00
ta.focus();
const isSuccess = document.execCommand("insertText", false, textToInsert);
// Firefox (non-standard method)
if (!isSuccess) {
// Credits to https://www.everythingfrontend.com/posts/insert-text-into-textarea-at-cursor-position.html
// get current text of the input
const value = ta.value;
// save selection start and end position
const start = ta.selectionStart;
const end = ta.selectionEnd;
// update the value with our text inserted
ta.value = value.slice(0, start) + textToInsert + value.slice(end);
// update cursor to be at the end of insertion
ta.selectionStart = ta.selectionEnd = start + textToInsert.length;
}
2019-04-10 20:50:36 +00:00
}
2019-04-10 20:57:20 +00:00
// Emoji click callback func
2019-04-10 20:50:36 +00:00
var ji = function (ev) {
2019-04-10 20:57:20 +00:00
insertAtCursor(ev.target.attributes.alt.value + " ");
2019-04-10 20:50:36 +00:00
ta.focus()
//console.log(document.execCommand('insertText', false /*no UI*/, ev.target.attributes.alt.value));
}
2019-04-10 20:57:20 +00:00
// Enable the click for each emojis
2019-04-10 20:50:36 +00:00
var items = document.getElementsByClassName("ji")
for (var i = 0; i < items.length ; i + + ) {
items[i].addEventListener('click', ji);
}
< / script > {% endblock %}