You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jumpserver/apps/templates/_foot_js.html

55 lines
1.8 KiB

{% load static %}
<!-- Mainly scripts -->
<script src="{% static "js/plugins/metisMenu/jquery.metisMenu.js" %}"></script>
<!-- Custom and plugin javascript -->
<script src="{% static "js/inspinia.js" %}"></script>
<script src="{% static "js/base.js" %}"></script>
<!-- active menu -->
<script>
var url_array = document.location.pathname.split("/");
s1 = url_array[1];
s2 = url_array[2];
if (s1 == ''){
$('#index').addClass('active')
} else {
$("#"+s1).addClass('active');
$('#'+s1+' .'+s2).addClass('active');
}
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;
}
var csrftoken = getCookie('csrftoken');
8 years ago
var sessionid = getCookie('sessionid');
console.log(csrftoken);
console.log(sessionid);
function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
8 years ago
{# xhr.setRequestHeader("sessionid", sessionid);#}
}
}
});
</script>