Advertisement
SimeonSheytanov

HomeController showGuestPage()

Jun 26th, 2016
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. showGuestPage() {
  2.         let _that = this;
  3.  
  4.         let recentPosts = [];
  5.  
  6.         let requestUrl = this._baseServiceUrl + "/appdata/" + this._appId + "/posts";
  7.  
  8.         this._requester.get(requestUrl,
  9.             function success(data) {
  10.                 let currentId = 1;
  11.                
  12.                 data.sort(function (elem1, elem2) {
  13.                     let date1 = new Date(elem1._kmd.ect);
  14.                     let date2 = new Date(elem2._kmd.ect);
  15.                     return date2 - date1;
  16.                 });
  17.  
  18.                 for (let i = 0; i < data.length && i < 5; i++) {
  19.                     data[i].postId = currentId;
  20.                     currentId++;
  21.                     recentPosts.push(data[i]);
  22.                 }
  23.  
  24.                 _that._homeView.showGuestPage(recentPosts, data);
  25.             },
  26.             function error(data) {
  27.                 showPopup('error', "Error loading posts!");
  28.             }
  29.         );
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement