mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 11:04:20 +00:00
core: move centralized custom scripts on top of base.jinja and move getCookie inside
This commit is contained in:
parent
97b06b160b
commit
8111ae107a
@ -43,3 +43,22 @@ $( function() {
|
|||||||
function display_notif() {
|
function display_notif() {
|
||||||
$('#header_notif').toggle().parent().toggleClass("white");
|
$('#header_notif').toggle().parent().toggleClass("white");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// You can't get the csrf token from the template in a widget
|
||||||
|
// We get it from a cookie as a workaround, see this link
|
||||||
|
// https://docs.djangoproject.com/en/2.0/ref/csrf/#ajax
|
||||||
|
function getCookie(cname) {
|
||||||
|
var name = cname + "=";
|
||||||
|
var decodedCookie = decodeURIComponent(document.cookie);
|
||||||
|
var ca = decodedCookie.split(';');
|
||||||
|
for(var i = 0; i <ca.length; i++) {
|
||||||
|
var c = ca[i];
|
||||||
|
while (c.charAt(0) == ' ') {
|
||||||
|
c = c.substring(1);
|
||||||
|
}
|
||||||
|
if (c.indexOf(name) == 0) {
|
||||||
|
return c.substring(name.length, c.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
<!-- Jquery declared here to be accessible in every django widgets -->
|
<!-- Jquery declared here to be accessible in every django widgets -->
|
||||||
<script src="{{ static('core/js/jquery-3.1.0.min.js') }}"></script>
|
<script src="{{ static('core/js/jquery-3.1.0.min.js') }}"></script>
|
||||||
|
<!-- Put here to always have acces to those functions on django widgets -->
|
||||||
|
<script src="{{ static('core/js/script.js') }}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -257,7 +259,6 @@
|
|||||||
<script src="{{ static('core/js/multiple-select.js') }}"></script>
|
<script src="{{ static('core/js/multiple-select.js') }}"></script>
|
||||||
<script src="{{ static('ajax_select/js/ajax_select.js') }}"></script>
|
<script src="{{ static('ajax_select/js/ajax_select.js') }}"></script>
|
||||||
<script src="{{ url('javascript-catalog') }}"></script>
|
<script src="{{ url('javascript-catalog') }}"></script>
|
||||||
<script src="{{ static('core/js/script.js') }}"></script>
|
|
||||||
<script>
|
<script>
|
||||||
$('.select_single').multipleSelect({
|
$('.select_single').multipleSelect({
|
||||||
single: true,
|
single: true,
|
||||||
|
@ -13,25 +13,6 @@
|
|||||||
document.head.innerHTML += '<link rel="stylesheet" href="' + css + '">';
|
document.head.innerHTML += '<link rel="stylesheet" href="' + css + '">';
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can't get the csrf token from the template in a widget
|
|
||||||
// We get it from a cookie as a workaround, see this link
|
|
||||||
// https://docs.djangoproject.com/en/2.0/ref/csrf/#ajax
|
|
||||||
function getCookie(cname) {
|
|
||||||
var name = cname + "=";
|
|
||||||
var decodedCookie = decodeURIComponent(document.cookie);
|
|
||||||
var ca = decodedCookie.split(';');
|
|
||||||
for(var i = 0; i <ca.length; i++) {
|
|
||||||
var c = ca[i];
|
|
||||||
while (c.charAt(0) == ' ') {
|
|
||||||
c = c.substring(1);
|
|
||||||
}
|
|
||||||
if (c.indexOf(name) == 0) {
|
|
||||||
return c.substring(name.length, c.length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom markdown parser
|
// Custom markdown parser
|
||||||
function customMarkdownParser(plainText, preview) {
|
function customMarkdownParser(plainText, preview) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
Loading…
Reference in New Issue
Block a user