2 /* Table initialisation */
3 $(document).ready(function() {
5 var platformParameters = {};
8 $.get("/rest/platform", function(data) {
9 var list = '<div class="list-group-item sl-platfrom"><span class="list-group-item-heading">Testbeds</span></div>';
10 for(i=0; i<data.length;i++) {
11 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>';
13 $('#select-platform').html(list);
19 $("div#testbed-list").ready(function() {
20 $("table#testbedList").load("/table/network/", { "fields" : ["network_hrn","description"], "options": ["checkbox"] }, function() {
25 $("#objectList").load("/table/resource/", {"fields" : ["hostname","hrn","country","type"], "options": ["checkbox"] }, function(data) {
27 "sScrollY": window.innerHeight - 275,
29 "bScrollCollapse": true,
32 "bLengthChange": false,
38 "fnInitComplete": function(oSettings, json) {
39 for(var i = 0; i < myslice.pending.length; i++) {
40 $('*[data-key="'+myslice.pending[i]+'"]').addClass("active");
46 $("input[type=checkbox]").click(function() {
48 var id = $(this).val();
49 var row = $(this).parent().parent()
50 if (row.hasClass("active")) {
51 row.removeClass("active");
53 cnt = myslice.count();
54 $('#badge-pending').text(cnt);
56 $('#badge-pending').hide();
59 row.addClass("active");
61 cnt = myslice.count();
62 $('#badge-pending').text(cnt);
64 $('#badge-pending').show();
73 //http://stackoverflow.com/questions/5100539/django-csrf-check-failing-with-an-ajax-post-request
74 //make sure to expose csrf in our outcoming ajax/post requests
76 beforeSend: function(xhr, settings) {
77 function getCookie(name) {
78 var cookieValue = null;
79 if (document.cookie && document.cookie != '') {
80 var cookies = document.cookie.split(';');
81 for (var i = 0; i < cookies.length; i++) {
82 var cookie = jQuery.trim(cookies[i]);
83 // Does this cookie string begin with the name we want?
84 if (cookie.substring(0, name.length + 1) == (name + '=')) {
85 cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
92 if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
93 // Only send the token to relative URLs i.e. locally.
94 xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));