2 /* Table initialisation */
3 $(document).ready(function() {
5 var platformParameters = {};
11 $("div#testbed-list").ready(function() {
12 $("table#testbedList").load("/table/network/", { "fields" : ["network_hrn","description"], "options": ["checkbox"] }, function() {
17 $("#objectList").load("/table/resource/", {"fields" : ["hostname","hrn","country","type"], "options": ["checkbox"] }, function(data) {
19 "sScrollY": window.innerHeight - 275,
21 "bScrollCollapse": true,
24 "bLengthChange": false,
30 "fnInitComplete": function(oSettings, json) {
31 for(var i = 0; i < myslice.pending.length; i++) {
32 var el = $('*[data-key="'+myslice.pending[i]+'"]');
33 el.addClass("active");
34 el.find('input[type=checkbox]').prop('checked', true);
40 $("input[type=checkbox]").click(function() {
42 var id = $(this).val();
43 var row = $(this).parent().parent()
44 if (row.hasClass("active")) {
45 row.removeClass("active");
47 cnt = myslice.count();
48 $('#badge-pending').text(cnt);
50 $('#badge-pending').hide();
53 row.addClass("active");
55 cnt = myslice.count();
56 $('#badge-pending').text(cnt);
58 $('#badge-pending').show();
67 //http://stackoverflow.com/questions/5100539/django-csrf-check-failing-with-an-ajax-post-request
68 //make sure to expose csrf in our outcoming ajax/post requests
70 beforeSend: function(xhr, settings) {
71 function getCookie(name) {
72 var cookieValue = null;
73 if (document.cookie && document.cookie != '') {
74 var cookies = document.cookie.split(';');
75 for (var i = 0; i < cookies.length; i++) {
76 var cookie = jQuery.trim(cookies[i]);
77 // Does this cookie string begin with the name we want?
78 if (cookie.substring(0, name.length + 1) == (name + '=')) {
79 cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
86 if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
87 // Only send the token to relative URLs i.e. locally.
88 xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));