6jarjar6

iFunny Ajax

Jan 11th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         //    debugger;
  2.         isShowNewAfterAdd = isShowNewAfterAdd || false;
  3.         var reqData = {'type': type, 'count': 0, 'excludeIds': [], firstImg: firstImg};
  4.  
  5.         app.serverGetImagesProccessing = true;
  6.         var lengthBefore = app.imagesIds.length;
  7.         $.ajax({
  8.             url: '/server/get-content/',
  9.             type: "POST",
  10.             data: reqData,
  11.             success: function (data) {
  12.                 app.serverGetImagesProccessing = false;
  13.  
  14.                 if (data.error) {
  15.                     app.msg.showError(data.error.text);
  16.                     return;
  17.                 }
  18.  
  19.                 app.utils.unshiftAndTrim(data);
  20.  
  21.                 if (isShowNewAfterAdd) {
  22.                     app.currentImgIndex = null;
  23.                     app.showImage(0);
  24.                 }
  25.  
  26.                 app.msg.console('******* imagesIds.len: ' +app.imagesIds.length);
  27.             },
  28.             error: function(jqXHR, textStatus, errorThrown) {
  29.                 app.msg.showError(errorThrown);
  30.             },
  31.             dataType: 'json'
  32.         });
  33.     },
  34.  
  35.     /**
  36.      * @param cid
  37.      * @param isLike
  38.      * @param unVote
  39.      * @param isReverce
  40.      */
  41.     vote: function(cid, isLike, unVote, isReverce) {
  42.         $.ajax({
  43.             url: '/server/vote/',
  44.             type: "POST",
  45.             data: {cid: cid, isLike: isLike, unVote: unVote, isReverce: isReverce},
  46.             success: function (data) {
  47.                 //app.content.find('div.likes-tooltip div.vc').html(data);
  48.             },
  49.             error: function(jqXHR, textStatus, errorThrown) {
  50.                 app.msg.showError(errorThrown);
  51.             },
  52.             cache: false,
  53.             async: false
  54.         });
  55.  
  56.         var inc = unVote ? -1 : 1;
  57.  
  58.         var vc = app.content.find('div.likes-tooltip div.vc');
  59.         vc.html(parseInt(vc.text()) + inc);
  60.     }
  61. };
Add Comment
Please, Sign In to add comment