2 /* Table initialisation */
3 $(document).ready(function() {
5 var platformParameters = {};
7 var oTable = $("#objectList");
9 $.get("/rest/platform", function(data) {
10 var list = '<div class="list-group-item sl-platfrom"><span class="list-group-item-heading">Testbeds</span></div>';
11 for(i=0; i<data.length;i++) {
12 list += '<a href="#" class="list-group-item sl-platfrom" data-platform="'+data[i].platform+'"><span class="list-group-item-heading">'+data[i].platform_longname+'</span><p class="list-group-item-text">'+data[i].platform+'</p></a>';
14 $('#select-platform').html(list);
16 // $('a.sl-platfrom').click(function() {
17 // console.log($(this).data('platform'));
18 // platformParameters = { "platform" : $(this).data('platform') };
19 // $('a.sl-platfrom').removeClass('active');
20 // $(this).addClass('active');
22 // oTable.load("/list/resource", platformParameters, function(data) {
26 // $('body').data('filters',platformParameters);
31 $('div#testbed-list').ready(function() {
32 $('table#testbedList').load("/table/network/",{'fields' : ['platform'], 'options': ['checkbox']}, function() {
37 //{'columns' : ['hostname','country','type'], 'filters' : { 'country' : 'France' } }
38 oTable.load("/table/resource/", {'columns' : ['hostname','country','type'] }, function(data) {
40 "sScrollY": window.innerHeight - 275,
42 "bScrollCollapse": true,
45 "bLengthChange": false,
55 function drawTable(data) {
59 //http://stackoverflow.com/questions/5100539/django-csrf-check-failing-with-an-ajax-post-request
60 //make sure to expose csrf in our outcoming ajax/post requests
62 beforeSend: function(xhr, settings) {
63 function getCookie(name) {
64 var cookieValue = null;
65 if (document.cookie && document.cookie != '') {
66 var cookies = document.cookie.split(';');
67 for (var i = 0; i < cookies.length; i++) {
68 var cookie = jQuery.trim(cookies[i]);
69 // Does this cookie string begin with the name we want?
70 if (cookie.substring(0, name.length + 1) == (name + '=')) {
71 cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
78 if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
79 // Only send the token to relative URLs i.e. locally.
80 xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));