-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.html
365 lines (332 loc) · 16.6 KB
/
base.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}Chemhacktica{% endblock %}</title>
<!-- Bootstrap -->
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet" type="text/css"/>
<link href="{% static 'css/fontawesome.min.css' %}" rel="stylesheet" type="text/css">
<script src="{% static 'js/jquery-3.5.1.min.js' %}"></script>
<script src="{% static 'js/bootstrap.bundle.min.js' %}"></script>
<!-- Our CSS (overrides) -->
<link href="{% static 'css/default.css' %}?v{{ static_version }}" rel="stylesheet" type="text/css"/>
<script src="{% static 'js/default.js' %}?v{{ static_version }}"></script>
<script src="{% static 'js/dayjs.min.js' %}"></script>
<!-- Javascript drawing -->
<script src="{% static 'jsme/jsme/jsme.nocache.js' %}"></script>
{% block extrahead %}{% endblock %}
</head>
<body>
{% csrf_token %}
<div id="document">
<nav class="navbar navbar-expand-lg navbar-dark nfixed-top" style="background-color: #222;">
<a class="navbar-brand" href="{% url 'index' %}">
<img class="org-logo" src="/static/images/4tv_logo.png"> Chemhacktica <span class="org-text">{{ organization }}</span>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="modulesDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="fas fa-th-large mr-1"></span>Modules
</a>
<div class="dropdown-menu" aria-labelledby="modulesDropdown">
<a class="dropdown-item" href="{% url 'modules' %}">Overview</a>
<div class="dropdown-divider"></div>
<h5 class="dropdown-header"><b>Modules</b></h5>
<a class="dropdown-item" href="{% url 'retro_network' %}">Interactive Path Planning</a>
<a class="dropdown-item" href="{% url 'retro_interactive_mcts' %}">Tree Builder (Path Planning)</a>
<a class="dropdown-item" href="/synth_interactive/">Synthesis Predictor</a>
<a class="dropdown-item" href="{% url 'site_prediction' %}">Site Selectivity</a>
<a class="dropdown-item" href="{% url 'scscoring' %}">SCScore Evaluator</a>
<a class="dropdown-item" href="{% url 'buyables' %}">Buyable Look-up</a>
<a class="dropdown-item" href="{% url 'atom_mapping' %}">Atom Mapping</a>
<a class="dropdown-item" href="{% url 'draw' %}">Drawing</a>
<!-- Keep these links around for now, to remove later -->
<div class="dropdown-divider"></div>
<h5 class="dropdown-header"><b>Legacy Modules</b></h5>
<a class="dropdown-item" href="/retro/">One-step Retrosynthesis</a>
<a class="dropdown-item" href="/synth_interactive/?mode=context">Context Recommendation</a>
<a class="dropdown-item" href="/synth_interactive/?mode=forward">Forward Prediction</a>
<a class="dropdown-item" href="/synth_interactive/?mode=impurity">Impurity Prediction</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="helpDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="fa fa-question-circle mr-1"></span>Help
</a>
<div class="dropdown-menu" aria-labelledby="helpDropdown">
<a class="dropdown-item" href="{% url 'faq' %}">FAQ</a>
<a class="dropdown-item" href="{% url 'tutorial' %}">Tutorial</a>
</div>
</li>
{% if user.is_authenticated %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="resultsDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="fa fa-cloud mr-1"></span>My Results
</a>
<div class="dropdown-menu" aria-labelledby="resultsDropdown">
<a class="dropdown-item" href="#" id="savepage">Save this page</a>
<a class="dropdown-item" href="/my-results/">View results</a>
</div>
</li>
<li class="nav-item"><a class="nav-link" href="{% url 'user_banlist' %}"><span class="fa fa-ban mr-1"></span>My Banlist</a></li>
{% endif %}
<li class="nav-item"><a class="nav-link" href="/status/"><span class="fa fa-server mr-1"></span>Glitter Computer Status</a></li>
<!-- <li class="nav-item"><a class="nav-link" href="#" data-toggle="modal" data-target="#supportModal"><span class="fa fa-comment mr-1"></span>Support</a></li> -->
</ul>
{% if user.is_authenticated %}
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="fa fa-cog mr-1"></span>Settings
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="userDropdown">
<!-- <a class="dropdown-item" href="{% url 'password_change' %}">Change password</a> -->
<a class="dropdown-item" href="{% url 'logout' %}">Logout</a>
</div>
</li>
</ul>
{% else %}
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link" href="{% url 'django_registration_register' %}"><span class="fa fa-user mr-1"></span>Register</a></li>
{% if request.path == "/registration/logout/" %}
<li class="nav-item"><a class="nav-link" href="{% url 'login' %}?next=/"><span class="fa fa-sign-in mr-1"></span>Login</a></li>
{% else %}
<li class="nav-item"><a class="nav-link" href="{% url 'login' %}?next={{ request.path }}"><span class="fa fa-sign-in mr-1"></span>Login</a></li>
{% endif %}
</ul>
{% endif %}
</div>
</nav>
<div class="container mb-5">
{% if err or warn %}
<div class="my-3">
{% if err %}
<div class="alert alert-danger">{{ err | safe}}</div>
{% endif %}
{% if warn %}
<div class="alert alert-warning">{{ warn | safe}}</div>
{% endif %}
</div>
{% endif %}
<div id="contents">
<div class="mt-5 mb-3 pb-3 border-bottom"><h1>{% block page_title %}Chemhacktica{% endblock %}</h1></div>
{% block page_body %}Looks like there is nothing here!{% endblock %}
</div>
</div>
<footer class="footer">
<div class="container">
{% block footer %}
Keep each other healthy. Keep each other safe.
{% endblock %}
</div>
</footer>
</div>
<div id="pageLoader" class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
<div class="modal fade" id="supportModal" role="dialog" aria-labelledby="supportModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="supportModalLabel">Send support email</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div id="support-form" class="form mb-3">
<div class="form-group">
<label for="support-module">Select Module: </label>
<select id="support-module" class="form-control">
<option value="onestep">One-step Retrosynthesis</option>
<option value="pathplanner">Interactive Path Planning</option>
<option value="treebuilder">Tree Builder</option>
<option value="context">Context Recommendation</option>
<option value="synthpred">Synthesis Predictor</option>
<option value="general">General</option>
</select>
</div>
<div class="form-group">
<label for="support-category">Select issue/problem category: </label>
<select id="support-category" class="form-control">
<option value="bug">Report a bug</option>
<option value="enhancement">Request an enhancement</option>
<option value="documentation">Documentation</option>
<option value="general">General Query</option>
</select>
</div>
<div class="form-group">
<label for="support-subject">Email subject line: </label>
<input id="support-subject" type="text" class="form-control" placeholder="Subject line (max length: 150 characters)" maxlength="150" autocomplete="off">
</div>
<div class="form-check">
<input class="form-check-input" id="support-shared" type="checkbox">
<label class="form-check-label" for="support-shared">I wish to share this information with other Consortium members.</label>
</div>
</div>
<div class="text-justify">
NOTE: Clicking "Submit" should launch your email client to send us an email. If this is blocked for some reason, please include the above information in an email you compose separately to {{ contact_email }}.
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-success" data-dismiss="modal" onclick="submitSupport()">Submit</button>
</div>
</div>
</div>
</div>
<script>
function submitSupport() {
var mailtoString = "mailto:{{ support_emails }}"
mailtoString += "?subject="+document.querySelector('#support-module').value
mailtoString += "|"+document.querySelector('#support-category').value
if (document.querySelector('#support-shared').checked) {
mailtoString += "|shared"
}
else {
mailtoString += "|"
}
mailtoString += "| "+document.querySelector('#support-subject').value
mailtoString += "&body=Please add your comments here. Please don't modify the beginning of the subject line; we use this for internal purposes"
window.open(mailtoString, '_blank')
}
</script>
<script type="text/javascript">
$.ajaxSetup({
beforeSend: function(xhr, settings) {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
// Only send the token to relative URLs i.e. locally.
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
}
}
});
$(document).ajaxStart(function() {
$(document.body).css({'cursor' : 'wait'});
}).ajaxStop(function() {
$(document.body).css({'cursor' : 'default'});
});
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
});
// Toggle navbar dropdowns on mouse hover
function toggleDropdown(e) {
const _d = $(e.target).closest('.dropdown');
const _m = $('.dropdown-menu', _d);
setTimeout(function() {
const shouldOpen = e.type !== 'click' && _d.is(':hover');
_m.toggleClass('show', shouldOpen);
_d.toggleClass('show', shouldOpen);
$('[data-toggle="dropdown"]', _d).attr('aria-expanded', shouldOpen);
}, e.type === 'mouseleave' ? 100 : 0);
}
$('body')
.on('mouseenter mouseleave', '.dropdown', toggleDropdown)
.on('click', '.dropdown-menu a', toggleDropdown);
// End of dropdown toggle on hover
// This JSFiddle is part of a tutorial written by Zach Alam (zachalam.com)
// You can view the complete tutorial and more background information
// by visiting the following URL:
// https://zachalam.com/using-ajax-and-jquery-to-load-images-asynchronously/
// verify the DOM is completely loaded.
$(document).ready(function() {
// check for images in view when page loads.
load_images_in_view();
// check for images in view when page scrolls.
$(window).scroll(load_images_in_view);
function load_images_in_view() {
// a scroll was detected - check all images in DOM
$("img").each(function() {
// calculate the halfway to the bottom of the object.
var object_bottom = $(this).offset().top + ($(this).outerHeight()/2);
// calculate the bottom of the window.
var window_bottom = $(window).scrollTop() + $(window).height();
if(window_bottom > object_bottom)
{
// check to see if a flag was set,
// so we don't constantly reload this image
if($(this).data("image-loaded") != true)
{
// obtain the image to replace
var image_source = $(this).data("async-load");
// set image loaded complete flag, and change image src.
$(this).data("image-loaded",true);
$(this).attr("src",image_source);
}
}
}); // end $("img").each()
}}); // end $(document).ready();
$("#savepage").click(function () {
console.log('saving this page...');
var desc = prompt("Please enter a description for this page", "no description");
if (desc) {
var datetime = dayjs().format('MMMM DD, YYYY, hh:mm:ss A');
$.ajax({
type: 'POST',
url: '/ajax/user_save_page/',
data: {
html: $("#contents").html(),
csrfmiddlewaretoken: '{{ csrf_token }}',
desc: desc,
datetime: datetime,
},
dataType: 'json',
success: function (data) {
if (data.err) {
alert(data.err);
} else {
alert('Saved "' + desc + '" at ' + datetime);
}
}
});
};
});
// For drawing
function jsmeOnLoad() {
jsmeApplet = new JSApplet.JSME("jsme_container", "565px", "400px");
};
// set the value of an ID with the current SMILES string
// note: assumes drawBoxID has been assigned as global var!
function setSmilesText() {
var data = jsmeApplet.smiles();
document.getElementById(drawBoxId).value = data;
$("#" + drawBoxId).trigger("change");
};
// set the drawing to match the SMILES string of a certain id's value
function setSmilesDrawing(id) {
var smi = $("#" + id).val();
if(smi) {
jsmeApplet.readGenericMolecularInput(smi);
} else {
jsmeApplet.reset();
};
};
// onclick action for drawing popup
function drawBox(id) {
setSmilesDrawing(id);
drawBoxId = id;
};
</script>
{% block javascript %}{% endblock %}
</body>
</html>