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/testbed", function() {
38 oTable.load("/list/resource", {}, function(data) {
40 "bScrollInfinite": true,
41 "bScrollCollapse": true,
45 "bLengthChange": false,
54 function drawTable(data) {
58 //http://stackoverflow.com/questions/5100539/django-csrf-check-failing-with-an-ajax-post-request
59 //make sure to expose csrf in our outcoming ajax/post requests
61 beforeSend: function(xhr, settings) {
62 function getCookie(name) {
63 var cookieValue = null;
64 if (document.cookie && document.cookie != '') {
65 var cookies = document.cookie.split(';');
66 for (var i = 0; i < cookies.length; i++) {
67 var cookie = jQuery.trim(cookies[i]);
68 // Does this cookie string begin with the name we want?
69 if (cookie.substring(0, name.length + 1) == (name + '=')) {
70 cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
77 if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
78 // Only send the token to relative URLs i.e. locally.
79 xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));