new.html 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {% extends "layout.html" %}
  2. {% import 'utils.html' as utils %}
  3. {% block title %}New - {{ config.NAME }}{% endblock %}
  4. {% block headers %}
  5. {% endblock %}
  6. {% block content %}
  7. {% include "header.html" %}
  8. {% if thread %}
  9. <div class="content" style="margin-left:10%;margin-right:10%;width:100%">
  10. <div id="notes">
  11. <div class="posts">
  12. <h1 class="content-subhead">Replying to {{ content }}</h1>
  13. {{ utils.display_thread(thread) }}
  14. </div>
  15. </div>
  16. </div>
  17. {% endif %}
  18. <aside style="margin-top:3%;width:80%;margin-bottom:2%">
  19. {% if thread %}
  20. <h3>New reply</h3>
  21. {% else %}
  22. {% if request.args.get("question") == "1" %}
  23. <h3>New question <small><a href="/admin/new" style="color:#FFFFFF">make it a note?</a></small></h3>
  24. {% else %}
  25. <h3>New note <small><a href="/admin/new?question=1" style="color:#FFFFFF">make it a question?</a></small></h3>
  26. {% endif %}
  27. {% endif %}
  28. <form action="/api/new_{% if request.args.get("question") == "1" %}question{%else%}note{%endif%}" method="POST" enctype="multipart/form-data">
  29. <input type="hidden" name="redirect" value="/">
  30. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
  31. {% if reply %}<input type="hidden" name="reply" value="{{reply}}">{% endif %}
  32. <p>
  33. {% for emoji in emojis %}
  34. <span class="ji">{{ emoji }}</span>
  35. {% endfor %}
  36. </p>
  37. <textarea name="content" autofocus="autofocus" designMode="on" style="width:100%;height:500px;resize:none">{{ content }}</textarea><br/><br/>
  38. <input type="file" name="file" style="color:#FFFFFF">
  39. {% if request.args.get("question") == "1" %}
  40. <center style="margin-top:20px;">
  41. <p>Open for: <select name="open_for" style="color:#000000">
  42. <option value="30">30 minutes</option>
  43. <option value="60">1 hour</option>
  44. <option value="360">6 hour</option>
  45. <option value="1440" selected>1 day</option>
  46. <option value="4320">3 days</option>
  47. <option value="10080">7 days</option>
  48. </select></p>
  49. <input type="hidden" name="of" value="oneOf" />
  50. <p><select name="of" style="color:#000000">
  51. <option value="oneOf">Single choice</option>
  52. <option value="anyOf">Multiple choices</option>
  53. </select></p>
  54. {% for i in range(4) %}
  55. <p><input type="text" name="answer{{i}}" placeholder="Answer #{{i+1}}"></p>
  56. {% endfor %}
  57. </center>
  58. {% endif %}
  59. <input type="submit" value="Post" class="pure-button pure-button-success" style="float:right">
  60. </div>
  61. </form>
  62. </aside>
  63. <script>
  64. var ta = document.getElementsByTagName("textarea")[0];
  65. function insertAtCursor (textToInsert) {
  66. ta.focus();
  67. const isSuccess = document.execCommand("insertText", false, textToInsert);
  68. if (!isSuccess) {
  69. const value = ta.value;
  70. const start = ta.selectionStart;
  71. const end = ta.selectionEnd;
  72. ta.value = value.slice(0, start) + textToInsert + value.slice(end);
  73. ta.selectionStart = ta.selectionEnd = start + textToInsert.length;
  74. }
  75. }
  76. var ji = function (ev) {
  77. insertAtCursor(ev.target.attributes.alt.value + " ");
  78. ta.focus()
  79. }
  80. var items = document.getElementsByClassName("ji")
  81. for (var i = 0; i < items.length; i++) {
  82. items[i].addEventListener('click', ji);
  83. }
  84. </script>{% endblock %}