add page creation to quest_homepage

This commit is contained in:
iou1name 2018-10-05 11:31:19 -04:00
parent e7d73023eb
commit 518ea259cd
2 changed files with 26 additions and 3 deletions

View File

@ -2,6 +2,9 @@
{% block title %}{{ quest.title }}{% endblock %} {% block title %}{{ quest.title }}{% endblock %}
{% block head %} {% block head %}
<link rel="stylesheet" type="text/css" href="{{ static('quest.css') }}"> <link rel="stylesheet" type="text/css" href="{{ static('quest.css') }}">
{% if request.user == quest.owner %}
<link rel="stylesheet" type="text/css" href="{{ static('questQM.css') }}">
{% endif %}
<script> <script>
const quest_id = {{ quest.id }}; const quest_id = {{ quest.id }};
const page_num = '{{ page_num }}'; const page_num = '{{ page_num }}';
@ -9,8 +12,12 @@
const anon_name = '{{ quest.anon_name }}'; const anon_name = '{{ quest.anon_name }}';
</script> </script>
<script type="text/javascript" src="{{ static('quest.js') }}"></script> <script type="text/javascript" src="{{ static('quest.js') }}"></script>
{% if request.user == quest.owner %}
<script type="text/javascript" src="{{ static('questQM.js') }}"></script>
{% endif %}
<script>events = [socket.events['message'], socket.events['new_page']]; socket.events = {'message': events[0], 'new_page': events[1]}; delete events;</script>
<!-- We only want the message and new_page events on this page, others will error. Hacky solution, but it will do for now. -->
<script>window.onload = load;</script> <script>window.onload = load;</script>
<!-- We only want the message event on this page, others will error. Hacky solution, but it will do for now. -->
{% endblock %} {% endblock %}
{% block header %} {% block header %}
{% if request.user == quest.owner %} {% if request.user == quest.owner %}
@ -72,6 +79,22 @@
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
{% if quest.owner == request.user %}
<div id="QMPostPane">
<div>
<ul id="QMPostTabs">
<li><a class="QMPostTab" href="javascript:void(0);" onclick="openPostTab(event, 'QMPage')">Page</a></li>
</ul>
</div>
<div id="QMPage" class="QMPostTabContent" style="display:initial;">
<form id="QMPageForm" action="javascript:void(0);" onsubmit="form_post('QMPageForm', 'new_page');">
New Page: <input type="text" name="page_title" maxlength="200" value="Page {{ pages.last().page_num|int + 1 }}"><br>
Appendix: <input type="checkbox" name="appendix"><br>
<input type="submit" name="submit" value="Submit">
</form>
</div>
</div>
{% endif %}
{% if vars['next_page'] %} {% if vars['next_page'] %}
<div id="nextPageContainer"> <div id="nextPageContainer">
<input type="button" id="nextPage" value="Next Page: {{ vars['next_page'].title }}" onclick="window.location.href='{{ url('quest:quest', args=[quest_id, vars['next_page'].page_num]) }}'"> <input type="button" id="nextPage" value="Next Page: {{ vars['next_page'].title }}" onclick="window.location.href='{{ url('quest:quest', args=[quest_id, vars['next_page'].page_num]) }}'">

View File

@ -157,7 +157,7 @@ socket.events['set_option_box'] = function(data) {
} }
socket.events['new_page'] = function(data) { socket.events['new_page'] = function(data) {
if (page_num != data.page_num-1) { return; } if (page_num != data.page_num-1) { return; }
let html_str = '<div id="nextPageContainer"><input type="button" id="nextPage" value="Next Page: ' + data.title + '" onclick="window.location.href=\'' + data.url + '\'"></div>'; let html_str = '<div id="nextPageContainer"><input type="button" id="nextPage" value="Next Page: ' + data.title + '" onclick="window.location.href=\'' + SCRIPT_NAME + data.url + '\'"></div>';
document.getElementById('questPane').innerHTML = document.getElementById('questPane').innerHTML + html_str; document.getElementById('questPane').innerHTML = document.getElementById('questPane').innerHTML + html_str;
} }