blob: 174e56f0b10593bd8bae152474fae8c123ced933 (
plain)
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
|
/* CSRFToken management */
$.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).ready(function(){
$("#main_menu ul ul").hide();
$("#main_menu ul ul .selected").parent().show();
var items = new Array('file', 'operation');
$("#current_file").change(function(){
$.post('/' + url_path + 'update-current-item/',
{item:'file', value:$("#current_file").val()}
);
});
$("#current_operation").change(function(){
$.post('/' + url_path + 'update-current-item/',
{item:'operation', value:$("#current_operation").val()}
);
});
});
$("#main_menu ul li").live('click', function(){
$("#main_menu ul ul").hide('slow');
$(this).find('ul').show('slow');
});
|