jumpserver/apps/templates/_foot_js.html

89 lines
2.5 KiB
HTML
Raw Normal View History

2016-09-14 07:19:27 +00:00
{% load i18n %}
{% load static %}
<!-- Mainly scripts -->
<script src="{% static "js/plugins/metisMenu/jquery.metisMenu.js" %}"></script>
<!-- Custom and plugin javascript -->
<script src="{% static "js/plugins/toastr/toastr.min.js" %}"></script>
<script src="{% static "js/inspinia.js" %}"></script>
<script>
// active menu
var url_array = document.location.pathname.split("/");
app = url_array[1];
resource = url_array[2];
if (app == ''){
$('#index').addClass('active')
} else {
$("#"+app).addClass('active');
$('#'+app+' #'+resource).addClass('active');
}
2016-08-25 11:29:59 +00:00
// ajax set cookie
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;
2016-08-25 11:29:59 +00:00
}
}
}
return cookieValue;
}
2016-08-25 11:29:59 +00:00
var csrftoken = getCookie('csrftoken');
var sessionid = getCookie('sessionid');
2016-08-25 11:29:59 +00:00
function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
2016-08-25 11:29:59 +00:00
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
2016-08-25 11:29:59 +00:00
}
}
});
2016-09-05 15:12:01 +00:00
// textarea rows
$('textarea').attr('rows', 5)
2016-09-14 07:19:27 +00:00
//Sweet Alert for Delete
function obj_del(obj,name,url){
swal({
title: "{% trans 'Are you sure delete ??' %}",
//text: "You will not be able to recover this imaginary file!",
text: "【"+name+"】",
type: "warning",
showCancelButton: true,
cancelButtonText: "{% trans 'Cancel' %}",
confirmButtonColor: "#DD6B55",
confirmButtonText: "{% trans 'Yes, delete it!' %}",
closeOnConfirm: false
}, function () {
$.ajax({
type : "post",
url : url,
data : {
// idc_id : idc_id
},
success : function(data) {
swal("{% trans 'Deleted!' %}", "【"+name+"】"+"{% trans 'has been deleted.' %}", "success");
$(obj).parent().parent().remove();
},
dataType : "text"
});
});
}
2016-09-06 08:40:44 +00:00
</script>
<script src="{% static "js/jumpserver.js" %}"></script>