Advertisement
reggi

Untitled

Apr 26th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   $('#scan-form').submit(function(event){
  2.     event.preventDefault();
  3.     $.ajax({
  4.       type: 'POST',
  5.       url: 'post',
  6.       dataType: 'json',
  7.       data: {'scan':true},
  8.       success: function(){
  9.         $.ajax({
  10.           url: 'api/periods.json',
  11.           dataType: 'json',
  12.           success: function(d1){
  13.             var start = function(){
  14.               var dtd = $.Deferred();
  15.               $('#scan-interactive').removeClass('disabled');
  16.               for(var key in d1.periods){
  17.                 var html = "";
  18.                 html += '<tr id="'+d1.periods[key].id+'">';
  19.                 html += '<td class="month">'+d1.periods[key].month+'</td>';
  20.                 html += '<td class="week">'+d1.periods[key].week+'</td>';
  21.                 html += '<td class="days">'+d1.periods[key].days+'</td>';
  22.                 html += '<td class="dates">'+d1.periods[key].dates+'</td>';
  23.                 html += '<td class="open"></td>';
  24.                 html += '<td class="refunded"></td>';
  25.                 html += '<td class="closed"></td>';
  26.                 html += '<td class="status"></td>';
  27.                 html += "</tr>";
  28.                 $('#scan-interactive table tbody').append(html);
  29.                 (function(key){
  30.                   $.ajax({
  31.                     type: 'POST',
  32.                     url: 'api/count.json',
  33.                     dataType: 'json',
  34.                     data:{'created_at_min':d1.periods[key].created_at_min,'created_at_max':d1.periods[key].created_at_max},
  35.                     success: function(d2){
  36.                       $('#'+d1.periods[key].id+" .open").html(d2.open).effect("highlight", {color:'#FBEED5'},  1000);
  37.                       $('#'+d1.periods[key].id+" .closed").html(d2.closed).effect("highlight", {color:'#FBEED5'},  1000);
  38.                       $('#'+d1.periods[key].id+" .refunded").html(d2.refunded).effect("highlight", {color:'#FBEED5'},  1000);
  39.                       request[key] = new Object();
  40.                       request[key].id = d1.periods[key].id;
  41.                       request[key].status = d2.open == 0;
  42.                       request[key].retrieve = d2.closed !== 0;
  43.                       request[key].pages = Math.ceil(d2.closed / 250);
  44.                       request[key].created_at_min = d1.periods[key].created_at_min;
  45.                       request[key].created_at_max = d1.periods[key].created_at_max;
  46.                       dtd.resolve();
  47.                     },//success: function(d2){
  48.                   });//$.ajax({
  49.                 })(key);//(function(key){
  50.               }//for(var key in d1.periods){
  51.               return dtd.promise();
  52.             };//var start = function(){
  53.            
  54.             start.apply(this).pipe(function(){
  55.               console.log('success has been completed');
  56.             });//start.apply(this).pipe(function(){
  57.            
  58.           },//success: function(d1){
  59.         });//$.ajax({
  60.       },//success: function(){
  61.     });//$.ajax({
  62.   });//$('#scan-form').submit(function(event){
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement