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 $('*[data-key="'+myslice.pending[i]+'"]').addClass("active");
38 $("input[type=checkbox]").click(function() {
40 var id = $(this).val();
41 var row = $(this).parent().parent()
42 if (row.hasClass("active")) {
43 row.removeClass("active");
45 cnt = myslice.count();
46 $('#badge-pending').text(cnt);
48 $('#badge-pending').hide();
51 row.addClass("active");
53 cnt = myslice.count();
54 $('#badge-pending').text(cnt);
56 $('#badge-pending').show();
65 //http://stackoverflow.com/questions/5100539/django-csrf-check-failing-with-an-ajax-post-request
66 //make sure to expose csrf in our outcoming ajax/post requests
68 beforeSend: function(xhr, settings) {
69 function getCookie(name) {
70 var cookieValue = null;
71 if (document.cookie && document.cookie != '') {
72 var cookies = document.cookie.split(';');
73 for (var i = 0; i < cookies.length; i++) {
74 var cookie = jQuery.trim(cookies[i]);
75 // Does this cookie string begin with the name we want?
76 if (cookie.substring(0, name.length + 1) == (name + '=')) {
77 cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
84 if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
85 // Only send the token to relative URLs i.e. locally.
86 xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));