Advertisement
Guest User

Untitled

a guest
May 26th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.BBCImages.net = (function() {
  2.    
  3.     /**
  4.         @private
  5.         @name _constructUrl
  6.         @function
  7.         @param {BBCImages} An instance of the BBCImages core
  8.         @param {int} Optional page number
  9.         @description Examine an instance of bbcimages core and create an api url
  10.      */
  11.     var _constructUrl: function(imagesInstance, page) {
  12.         if(imagesInstance.url.indexOf('/page/') == -1)
  13.         {
  14.             return imagesInstance.url.replace(/\/+$/,"")+'/page/'+page;
  15.         }
  16.         return imagesInstance.url.replace(/\/page\/(\b[1-9][0-9]{0,4})/, '\/page\/'+page);
  17.     }
  18.    
  19.     return {
  20.         /**
  21.             @public
  22.             @name GET
  23.             @function
  24.             @param {BBCImages} An instance of the BBCImages core
  25.             @param {int} Optional page number
  26.             @description Make an net request to BBCImages api for resource and page specified
  27.          */
  28.         get: function(imagesInstance, page) {
  29.             var page = page || 1;
  30.             //We could just pass the glow request object back for events to get tied to, for ease?
  31.             return imagesInstance.glow.net.get(_constructUrl(imagesInstanc, page));
  32.         }
  33.     }
  34. }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement