PageSourceSearch

https://www.dublinchristmasflea.ie/wp-content/plugins/wd-instagram-feed/js/wdi_instagram_ver-1.1.15.js

js dublinchristmasflea.ie collected 2026-10-04 19:12:51 UTC 49,828 bytes, 1,612 lines download raw bytes

1/**
2 * WDIInstagram is jQuery based plugin which handles communication
3 * with instagram API endpoints
4 *
5 * Plugin Version: 1.0.0
6 * Author: Melik Karapetyan
7 * License: GPLv2 or later
8 *
9 *
10 *
11 *
12 *
13 * Methods:
14 *    getSelfInfo = function( args ) : Get information about the owner of the access_token.
15 *    searchForUsersByName = function( username, args ) : Get a list of users matching the query.
16 *      searchForTagsByName = function(tagname, args) : Search for tags by name.
17 *      getTagRecentMedia = function(tagname, args) : Gets recent media based on tagname
18 *
19 */
20
21
22
23/**
24 * example of arg
25 * @type {Object}
26 */
27// var args = {
28//  access_tokens: ['227416602.145c5c2.302096fa9b3b4a8bbe0cee9341a6d7f5'],
29//  filters: [{
30//  where: 'getTagRecentMedia',
31//  what: function(r) {
32//    return r;
33//  },
34// }, {
35//  where: 'searchForUsersByName',
36//    what: 'bbb',
37//  }],
38// }
39
40
41/**
42 * WDIInstagram object constructor
43 * @param {Object} args
44 *
45 * @param {Array}           [args.access_tokens] [array of lavid instagram access tokens]
46 * @param {Array}           [args.filters] [array of object defining filters]
47 * @param {Object}          [args.filters[i] ] [ filter object which contain 'where' : 'what' pair ]
48 * @param {String}          [args.filters.filter[i].where] [name of function where filter must be applied]
49 * @param {String or Array} [args.filters.filter[i].what] [name of filtering function,
50 *                       if function is in global scope then it should be name of the funtion
51 *                         else if function in method of some object then it should be an array
52 *                                ['parent_object_name','filtering_function_name']]
53 */
54function WDIInstagram(args)
55{
56
57  this.access_tokens = [];
58  this.filters = [];
59  if (typeof args != 'undefined') {
60    if (typeof args.access_tokens != 'undefined') {
61      this.access_tokens = args.access_tokens;
62    }
63    if (typeof args.filters != 'undefined') {
64      this.filters = args.filters;
65    }
66  }
67
68
69  var _this = this;
70
71  /**
72   * Default object for handling status codes
73   * @type {Object}
74   */
75  this.statusCode = {
76    429: function ()
77    {
78      console.log(' 429: Too many requests. Try after one hour');
79    },
80  }
81
82  /**
83   * gets filter function defined for specific method
84   * this function is internal function and cannot be called outside of this object
85   *
86   * @param  {String} methodName   [name of WDIInstagram method]
87   * @return {Function}            [filtering function for {methodName}]
88   */
89  this.getFilter = function (methodName)
90  {
91    var filters = _this.filters;
92    if (typeof filters == "undefined") {
93      return false;
94    }
95
96    for (var i = 0; i < filters.length; i++) {
97      if (filters[i].where == methodName) {
98
99        if (typeof filters[i].what == 'object' && filters[i].what.length == 2) {
100          if (typeof window[filters[i].what[0]] != 'undefined') {
101            if (typeof window[filters[i].what[0]][filters[i].what[1]] == 'function') {
102              return window[filters[i].what[0]][filters[i].what[1]];
103            }
104          }
105        } else
106        if (typeof filters[i].what == 'string') {
107          if (typeof window[filters[i].what] == 'function') {
108            return window[filters[i].what];
109          }
110        } else
111        if (typeof filters[i].what == 'function') {
112          return filters[i].what;
113        } else {
114          return false;
115        }
116      }
117    }
118    return false;
119  }
120
121  function getAccessToken()
122  {
123    var access_tokens = _this.access_tokens,
124      index = parseInt(Math.random(0, 1) * access_tokens.length);
125    return access_tokens[index];
126  }
127
128  /**
129   * Adds access token to this.access_tokens array
130   * non string values are not allowed
131   * @param {String} token [Instagram API access token]
132   */
133  this.addToken = function (token)
134  {
135    if (typeof token == 'string') {
136      _this.access_tokens.push(token);
137    }
138  }
139
140  this.resetTokens = function ()
141  {
142      _this.access_tokens = [];
143  }
144
145  /**
146   * Gets recent media based on tagname
147   *
148   *
149   * @definition success_callback => which function to call in case of success
150   * @definition error_callback   => which function to call in case of error
151   * @definition media_count      => number of media to request
152   * @definition min_tag_id       => Return media before this min_tag_id.
153   * @definition max_tag_id       => Return media after this max_tag_id.
154   * @definition statusCode       => StatusCode object.
155   *
156   * @param tagname               =>  A valid tag name without a leading #. (eg. snowy, nofilter)
157   * @param args = {
158   *       success    :   'success_callback',
159   *       error    :   'error_callback',
160   *       statusCode : statusCode
161   *       count      :   'media_count',
162   *     min_tag_id :   'min_tag_id',
163   *     max_tag_id :   'max_tag_id',
164   *     args : arguments to be passed to filtering function
165   *  }
166   *
167   *
168   * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
169   * or you can pass as callback function an anonymous function
170   *
171   *
172   * @return object of founded media
173   */
174  this.getTagRecentMedia = function (tagname, args)
175  {
176    var instagram = this,
177      noArgument = false,
178      successFlag = false,
179      statusCode = this.statusCode,
180      errorFlag = false,
181      argFlag = false,
182      filter = this.getFilter('getTagRecentMedia'),
183
184      baseUrl = 'https://api.instagram.com/v1/tags/' + tagname + '/media/recent?access_token=' 
184+ getAccessToken();
185
186
187    if (typeof args == 'undefined' || args.length === 0) {
188      noArgument = true;
189    } else {
190
191      if ('success' in args) {
192        successFlag = true;
193      }
194      if ('statusCode' in args) {
195        statusCode = args['statusCode'];
196      }
197      if ('error' in args) {
198        errorFlag = true;
199      }
200//
201      if ('args' in args) {
202        argFlag = true;
203      } else {
204        args.args = {};
205      }
206//
207      if ('count' in args) {
208        args['count'] = parseInt(args['count']);
209        if (!Number.isInteger(args['count']) || args['count'] <= 0) {
210          args.count = 33;
211        }
212      } else {
213        args.count = 33;
214      }
215
216      baseUrl += '&count=' + args.count;
217
218      if ('min_tag_id' in args) {
219        baseUrl += '&min_tag_id=' + args.min_tag_id;
220      }
221
222      if ('max_tag_id' in args) {
223        baseUrl += '&max_tag_id=' + args.max_tag_id;
224      }
225    }
226    var wdi_callback = function (cache_data) {
227      if(cache_data === false) {
228        jQuery.ajax({
229          type: 'POST',
230          url: baseUrl,
231          dataType: 'jsonp',
232          success: function (response) {
233            _this.setDataToCache(baseUrl,response);
234            success(response)
235          },
236          error: function (response) {
237            if (errorFlag) {
238              if (typeof args['error'] == 'object' && args['error'].length == 2) {
239                if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
240                  window[args['error'][0]][args['error'][1]](response);
241                }
242              } else if (typeof args['error'] == 'string') {
243                if (typeof window[args['error']] == 'function') {
244                  window[args['error']](response);
245                }
246              } else if (typeof args['error'] == 'function') {
247                args['error'](response);
248              }
249            }
250          },
251          statusCode: statusCode
252        });
253      }
254      else{
255        success(cache_data)
256      }
257
258      function success(response) {
259        if (typeof response["data"] === "undefined") response["data"] = [];
260        if (successFlag) {
261          if (typeof args.success == 'object' && args.success.length == 2) {
262            if (typeof window[args.success[0]] != 'undefined') {
263              if (typeof window[args.success[0]][args.success[1]] == 'function') {
264                if (filter) {
265                  response = filter(response, instagram.filterArguments, args.args);
266                }
267                window[args.success[0]][args.success[1]](response);
268              }
269            }
270
271          } else if (typeof args.success == 'string') {
272            if (typeof window[args.success] == 'function') {
273              if (filter) {
274                response = filter(response, instagram.filterArguments, args.args);
275              }
276              window[args.success](response);
277            }
278          } else if (typeof args.success == 'function') {
279            if (filter) {
280              response = filter(response, instagram.filterArguments, args.args);
281            }
282            args.success(response);
283          }
284        }
285      }
286    }
287    _this.getDataFromCache(wdi_callback, baseUrl);
288
289
290
291  }
292
293
294  /**
295   * Search for tags by name.
296   *
297   *
298   * @definition success_callback => which function to call in case of success
299   * @definition error_callback   => which function to call in case of error
300   * @definition statusCode       => StatusCode object.
301   *
302   * @param tagname               =>  A valid tag name without a leading #. (eg. snowy, nofilter)
303   * @param args = {
304   *       success: 'success_callback',
305   *       error:   'error_callback',
306   *       statusCode : statusCode,
307   *  }
308   *
309   *
310   * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
311   * or you can pass as callback function an anonymous function
312   *
313   *
314   * @return object of founded media
315   */
316
317  this.searchForTagsByName = function (tagname, args)
318  {
319    var instagram = this,
320      noArgument = false,
321      successFlag = false,
322      statusCode = this.statusCode,
323      errorFlag = false;
324    filter = this.getFilter('searchForTagsByName');
325
326    if (typeof args == 'undefined' || args.length === 0) {
327      noArgument = true;
328    } else {
329      if ('success' in args) {
330        successFlag = true;
331      }
332      if ('error' in args) {
333        errorFlag = true;
334      }
335      if ('statusCode' in args) {
336        statusCode = args['statusCode'];
337      }
338    }
339
340
341    var req_url = 'https://api.instagram.com/v1/tags/search?q=' + tagname + '&access_token=' + getAccessToken();
342
343    var wdi_callback = function (cache_data) {
344      if(cache_data === false){
345        jQuery.ajax({
346          type: 'POST',
347          url: req_url,
348          dataType: 'jsonp',
349          success: function (response)
350          {
351            _this.setDataToCache(req_url,response);
352            success(response);
353          },
354          error: function (response)
355          {
356            if (errorFlag) {
357              if (typeof args['error'] == 'object' && args['error'].length == 2) {
358                if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
359                  window[args['error'][0]][args['error'][1]](response);
360                }
361              } else
362              if (typeof args['error'] == 'string') {
363                if (typeof window[args['error']] == 'function') {
364                  window[args['error']](response);
365                }
366              } else
367              if (typeof args['error'] == 'function') {
368                args['error'](response);
369              }
370            }
371          },
372          statusCode: statusCode
373        });
374      }else{
375        success(cache_data);
376      }
377
378      function success(response) {
379        if (successFlag) {
380          if (typeof args.success == 'object' && args.success.length == 2) {
381            if (typeof window[args.success[0]] != 'undefined') {
382              if (typeof window[args.success[0]][args.success[1]] == 'function') {
383                if (filter) {
384                  response = filter(response, instagram.filterArguments);
385                }
386                window[args.success[0]][args.success[1]](response);
387              }
388            }
389          } else
390          if (typeof args.success == 'string') {
391            if (typeof window[args.success] == 'function') {
392              if (filter) {
393                response = filter(response, instagram.filterArguments);
394              }
395              window[args.success](response);
396            }
397          } else
398          if (typeof args.success == 'function') {
399            if (filter) {
400              response = filter(response, instagram.filterArguments);
401            }
402            args.success(response);
403          }
404        }
405      }
406    }
407    _this.getDataFromCache(wdi_callback, req_url);
408
409
410  }
411
412  /*deprecated API*/
413  /**
414   * Get a list of users matching the query.
415   *
416   *
417   * @definition success_callback => which function to call in case of success
418   * @definition error_callback   => which function to call in case of error
419   * @definition statusCode       => StatusCode object.
420   *
421   * @param username
422   * @param args = {
423   *       success: 'success_callback',
424   *       error:   'error_callback',
425   *       statusCode : statusCode
426   *  }
427   *
428   *
429   * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
430   * or you can pass as callback function an anonymous function
431   *
432   *
433   * @return object of founded users
434   */
435  this.searchForUsersByName = function (username, args)
436  {
437    var instagram = this,
438      noArgument = false,
439      successFlag = false,
440      statusCode = this.statusCode,
441      errorFlag = false,
442      filter = this.getFilter('searchForUsersByName');
443
444    if (typeof args == 'undefined' || args.length === 0) {
445      noArgument = true;
446    } else {
447      if ('success' in args) {
448        successFlag = true;
449      }
450      if ('error' in args) {
451        errorFlag = true;
452      }
453      if ('statusCode' in args) {
454        statusCode = args['statusCode'];
455      }
456    }
457
458
459    jQuery.ajax({
460      type: 'POST',
461      dataType: 'jsonp',
462      url: 'https://api.instagram.com/v1/users/search?q=' + username + '&access_token=' 
462+ getAccessToken(),
463      success: function (response)
464      {
465        if (successFlag) {
466          if (typeof args.success == 'object' && args.success.length == 2) {
467            if (typeof window[args.success[0]] != 'undefined') {
468              if (typeof window[args.success[0]][args.success[1]] == 'function') {
469                if (filter) {
470                  response = filter(response, instagram.filterArguments);
471                }
472                response.args = args;
473                window[args.success[0]][args.success[1]](response);
474              }
475            }
476          } else
477          if (typeof args.success == 'string') {
478            if (typeof window[args.success] == 'function') {
479              if (filter) {
480                response = filter(response, instagram.filterArguments);
481              }
482              response.args = args;
483              window[args.success](response);
484            }
485          } else
486          if (typeof args.success == 'function') {
487            if (filter) {
488              response = filter(response, instagram.filterArguments);
489            }
490            response.args = args;
491            args.success(response);
492          }
493        }
494      },
495      error: function (response)
496      {
497        if (errorFlag) {
498          if (typeof args['error'] == 'object' && args['error'].length == 2) {
499            if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
500              window[args['error'][0]][args['error'][1]](response);
501            }
502          } else
503          if (typeof args['error'] == 'string') {
504            if (typeof window[args['error']] == 'function') {
505              window[args['error']](response);
506            }
507          } else
508          if (typeof args['error'] == 'function') {
509            args['error'](response);
510          }
511        }
512      },
513      statusCode: this.statusCode
514
515    });
516  }
517
518
519  /**
520   * Get the list of recent media liked by the owner of the access_token.
521   *
522   *
523   * @definition success_callback => which function to call in case of success
524   * @definition error_callback   => which function to call in case of error
525   * @definition statusCode       => StatusCode object.
526   * @param args = {
527   *       success: 'success_callback',
528   *       error:   'error_callback',
529   *       statusCode : statusCode
530   *  }
531   *
532   *
533   * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
534   * or you can pass as callback function an anonymous function
535   *
536   * @return object of founded media
537   */
538
539  this.getRecentLikedMedia = function (args)
540  {
541    var instagram = this,
542      noArgument = false,
543      successFlag = false,
544      statusCode = this.statusCode,
545      errorFlag = false,
546      filter = this.getFilter('getRecentLikedMedia'),
547      baseUrl = 'https://api.instagram.com/v1/users/self/media/liked?access_token=' 
547+ getAccessToken();
548
549    if (typeof args == 'undefined' || args.length === 0) {
550      noArgument = true;
551    } else {
552      if ('success' in args) {
553        successFlag = true;
554      }
555      if ('error' in args) {
556        errorFlag = true;
557      }
558      if ('statusCode' in args) {
559        statusCode = args['statusCode'];
560      }
561      if ('args' in args) {
562        argFlag = true;
563      } else {
564        args.args = {};
565      }
566
567      if ('count' in args) {
568        args['count'] = parseInt(args['count']);
569        if (!Number.isInteger(args['count']) || args['count'] <= 0) {
570          args.count = 20;
571        }
572      } else {
573        args.count = 20;
574      }
575
576      baseUrl += '&count=' + args.count;
577
578      if ('next_max_like_id' in args) {
579        baseUrl += '&next_max_like_id=' + args.next_max_like_id;
580      }
581
582
583    }
584
585
586    jQuery.ajax({
587      type: 'POST',
588      dataType: 'jsonp',
589      url: baseUrl,
590      success: function (response)
591      {
592        if (successFlag) {
593          if (typeof args.success == 'object' && args.success.length == 2) {
594            if (typeof window[args.success[0]] != 'undefined') {
595              if (typeof window[args.success[0]][args.success[1]] == 'function') {
596                if (filter) {
597                  response = filter(response, instagram.filterArguments, args.args);
598                }
599                window[args.success[0]][args.success[1]](response);
600              }
601            }
602          } else
603          if (typeof args.success == 'string') {
604            if (typeof window[args.success] == 'function') {
605              if (filter) {
606                response = filter(response, instagram.filterArguments, args.args);
607              }
608              window[args.success](response);
609            }
610          } else
611          if (typeof args.success == 'function') {
612            if (filter) {
613              response = filter(response, instagram.filterArguments, args.args);
614            }
615            args.success(response);
616          }
617        }
618      },
619      error: function (response)
620      {
621        if (errorFlag) {
622          if (typeof args['error'] == 'object' && args['error'].length == 2) {
623            if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
624              window[args['error'][0]][args['error'][1]](response);
625            }
626          } else
627          if (typeof args['error'] == 'string') {
628            if (typeof window[args['error']] == 'function') {
629              window[args['error']](response);
630            }
631          } else
632          if (typeof args['error'] == 'function') {
633            args['error'](response);
634          }
635        }
636      },
637      statusCode: statusCode
638
639    });
640  }
641
642  /* deprecated API */
643  /**
644   * Get the most recent media published by a user.
645   * This endpoint requires the public_content scope if the user-id is not the owner of the access_token.
646   *
647   *
648   * @definition success_callback => which function to call in case of success
649   * @definition error_callback   => which function to call in case of error
650   * @definition media_count      => number of media to request
651   * @definition min_id           => Return media before this min_id.
652   * @definition max_id           => Return media after this max_id.
653   * @definition statusCode       => StatusCode object.
654   *
655   * @param args = {
656   *       success : 'success_callback',
657   *       error   : 'error_callback',
658   *       statusCode : statusCode,
659   *       count   : 'media_count',
660   *       min_id  : 'min_id',
661   *     max_id  : 'max_id',
662   *     args: arguments to be passed to filtering function
663   *  }
664   *
665   *
666   * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
667   * or you can pass as callback function an anonymous function
668   *
669   *
670   * @return object of founded media
671   */
672  this.getUserRecentMedia = function (user_id, args)
673  {
674    var instagram = this,
675      noArgument = false,
676      successFlag = false,
677      argFlag = false,
678      //internal default object for statusCode handling
679      statusCode = this.statusCode,
680      errorFlag = false,
681      filter = this.getFilter('getUserRecentMedia'),
682      baseUrl = 'https://api.instagram.com/v1/users/' + user_id + '/media/recent/?access_token=' 
682+ getAccessToken();
683
684
685    if (typeof args == 'undefined' || args.length === 0) {
686      noArgument = true;
687    } else {
688      if ('success' in args) {
689        successFlag = true;
690      }
691
692      if ('statusCode' in args) {
693        statusCode = args['statusCode'];
694      }
695
696      if ('args' in args) {
697        argFlag = true;
698      } else {
699        args.args = {};
700      }
701
702      if ('error' in args) {
703        errorFlag = true;
704      }
705
706      if ('count' in args) {
707        args['count'] = parseInt(args['count']);
708        if (!Number.isInteger(args['count']) || args['count'] <= 0) {
709          args.count = 33;
710        }
711      } else {
712        args.count = 33;
713      }
714
715      baseUrl += '&count=' + args.count;
716
717      if ('min_id' in args) {
718        baseUrl += '&min_id=' + args.min_id;
719      }
720
721      if ('max_id' in args) {
722        baseUrl += '&max_id=' + args.max_id;
723      }
724    }
725
726
727    jQuery.ajax({
728      type: 'POST',
729      dataType: 'jsonp',
730      url: baseUrl,
731      success: function (response)
732      {
733        if (typeof response["data"] === "undefined") response["data"] = [];
734
735        if (successFlag) {
736          if (typeof args.success == 'object' && args.success.length == 2) {
737            if (typeof window[args.success[0]] != 'undefined') {
738              if (typeof window[args.success[0]][args.success[1]] == 'function') {
739                if (filter) {
740                  response = filter(response, instagram.filterArguments, args.args);
741                }
742                window[args.success[0]][args.success[1]](response);
743              }
744            }
745          } else
746          if (typeof args.success == 'string') {
747            if (typeof window[args.success] == 'function') {
748              if (filter) {
749                response = filter(response, instagram.filterArguments, args.args);
750              }
751              window[args.success](response);
752            }
753          } else
754          if (typeof args.success == 'function') {
755            if (filter) {
756              response = filter(response, instagram.filterArguments, args.args);
757            }
758            args.success(response);
759          }
760        }
761      },
762      error: function (response)
763      {
764        if (errorFlag) {
765          if (typeof args['error'] == 'object' && args['error'].length == 2) {
766            if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
767              window[args['error'][0]][args['error'][1]](response);
768            }
769          } else
770          if (typeof args['error'] == 'string') {
771            if (typeof window[args['error']] == 'function') {
772              window[args['error']](response);
773            }
774          } else
775          if (typeof args['error'] == 'function') {
776            args['error'](response);
777          }
778        }
779      },
780      statusCode: statusCode
781
782    });
783
784  }
785
786
787  /**
788   * Get the most recent media published by the owner of the access_token.
789   *
790   *
791   * @definition success_callback => which function to call in case of success
792   * @definition error_callback   => which function to call in case of error
793   * @definition media_count      => number of media to request
794   * @definition min_id           => Return media before this min_id.
795   * @definition max_id           => Return media after this max_id.
796   * @definition statusCode       => StatusCode object.
797   *
798   * @param args = {
799   *       success : 'success_callback',
800   *       error   : 'error_callback',
801   *       count   : 'media_count',
802   *       min_id  : 'min_id'
803   *     max_id  : 'max_id'
804   *     statusCode : statusCode
805   *
806   *  }
807   *
808   *
809   * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
810   * or you can pass as callback function an anonymous function
811   *
812   *
813   * @return object of founded media
814   */
815  this.getSelfRecentMedia = function (args)
816  {
817    var instagram = this,
818      noArgument = false,
819      successFlag = false,
820      statusCode = this.statusCode,
821      errorFlag = false,
822      argFlag = false,
823      filter = this.getFilter('getSelfRecentMedia'),
824      baseUrl = 'https://api.instagram.com/v1/users/self/media/recent/?access_token=' 
824+ getAccessToken();
825
826    if (typeof args == 'undefined' || args.length === 0) {
827      noArgument = true;
828    } else {
829      if ('success' in args) {
830        successFlag = true;
831      }
832
833      if ('error' in args) {
834        errorFlag = true;
835      }
836
837      if ('statusCode' in args) {
838        statusCode = args['statusCode'];
839      }
840      if ('args' in args) {
841        argFlag = true;
842      } else {
843        args.args = {};
844      }
845
846      if ('count' in args) {
847        args['count'] = parseInt(args['count']);
848        if (!Number.isInteger(args['count']) || args['count'] <= 0) {
849          args.count = 20;
850        }
851      } else {
852        args.count = 20;
853      }
854
855      baseUrl += '&count=' + args.count;
856
857      if ('min_id' in args) {
858        baseUrl += '&min_id=' + args.min_id;
859      }
860
861      if ('max_id' in args) {
862        baseUrl += '&max_id=' + args.max_id;
863      }
864    }
865
866    var wdi_callback = function (cache_data) {
867      if(cache_data === false){
868        jQuery.ajax({
869          type: 'POST',
870          dataType: 'jsonp',
871          url: baseUrl,
872          success: function (response)
873          {
874            _this.setDataToCache(baseUrl,response);
875            success(response);
876          },
877          error: function (response)
878          {
879            if (errorFlag) {
880              if (typeof args['error'] == 'object' && args['error'].length == 2) {
881                if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
882                  window[args['error'][0]][args['error'][1]](response);
883                }
884              } else
885              if (typeof args['error'] == 'string') {
886                if (typeof window[args['error']] == 'function') {
887                  window[args['error']](response);
888                }
889              } else
890              if (typeof args['error'] == 'function') {
891                args['error'](response);
892              }
893            }
894          },
895          statusCode: statusCode
896
897        });
898      }else{
899        success(cache_data);
900      }
901      function success(response) {
902        if (successFlag) {
903          if (typeof args.success == 'object' && args.success.length == 2) {
904            if (typeof window[args.success[0]] != 'undefined') {
905              if (typeof window[args.success[0]][args.success[1]] == 'function') {
906                if (filter) {
907                  response = filter(response, instagram.filterArguments,  args);
908                }
909                window[args.success[0]][args.success[1]](response);
910              }
911            }
912          } else
913          if (typeof args.success == 'string') {
914            if (typeof window[args.success] == 'function') {
915              if (filter) {
916                response = filter(response, instagram.filterArguments, args);
917              }
918              window[args.success](response);
919            }
920          } else
921          if (typeof args.success == 'function') {
922            if (filter) {
923              response = filter(response, instagram.filterArguments,  args);
924            }
925            args.success(response);
926          }
927        }
928      }
929    }
930    _this.getDataFromCache(wdi_callback, baseUrl);
931
932  }
933
934  /* deprecated API */
935  /**
936   * Get information about a user.
937   * This endpoint requires the public_content scope if the user-id is not the owner of the access_token.
938   *
939   *
940   * @definition success_callback => which function to call in case of success
941   * @definition error_callback   => which function to call in case of error
942   * @definition statusCode       => StatusCode object.
943   *
944   * @param args = {
945   *       success : 'success_callback',
946   *       error   : 'error_callback'
947   *       statusCode : statusCode
948   *  }
949   *
950   *
951   * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
952   * or you can pass as callback function an anonymous function
953   *
954   *
955   * @return object of founded info
956   */
957  this.getUserInfo = function (user_id, args)
958  {
959    var instagram = this,
960      noArgument = false,
961      successFlag = false,
962      statusCode = this.statusCode,
963      errorFlag = false,
964      filter = this.getFilter('getUserInfo');
965
966    if (typeof args == 'undefined' || args.length === 0) {
967      noArgument = true;
968    } else {
969      if ('success' in args) {
970        successFlag = true;
971      }
972
973      if ('error' in args) {
974        errorFlag = true;
975      }
976
977      if ('statusCode' in args) {
978        statusCode = args['statusCode'];
979      }
980    }
981    jQuery.ajax({
982      type: 'POST',
983      dataType: 'jsonp',
984      url: 'https://api.instagram.com/v1/users/' + user_id + '/?access_token=' 
984+ getAccessToken(),
985      success: function (response)
986      {
987        if (successFlag) {
988          if (typeof args.success == 'object' && args.success.length == 2) {
989            if (typeof window[args.success[0]] != 'undefined') {
990              if (typeof window[args.success[0]][args.success[1]] == 'function') {
991                if (filter) {
992                  response = filter(response, instagram.filterArguments);
993                }
994                window[args.success[0]][args.success[1]](response);
995              }
996            }
997          } else
998          if (typeof args.success == 'string') {
999            if (typeof window[args.success] == 'function') {
1000              if (filter) {
1001                response = filter(response, instagram.filterArguments);
1002              }
1003              window[args.success](response);
1004            }
1005          } else
1006          if (typeof args.success == 'function') {
1007            if (filter) {
1008              response = filter(response, instagram.filterArguments);
1009            }
1010            args.success(response);
1011          }
1012        }
1013      },
1014      error: function (response)
1015      {
1016        if (errorFlag) {
1017          if (typeof args['error'] == 'object' && args['error'].length == 2) {
1018            if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
1019              window[args['error'][0]][args['error'][1]](response);
1020            }
1021          } else
1022          if (typeof args['error'] == 'string') {
1023            if (typeof window[args['error']] == 'function') {
1024              window[args['error']](response);
1025            }
1026          } else
1027          if (typeof args['error'] == 'function') {
1028            args['error'](response);
1029          }
1030        }
1031      },
1032      statusCode: statusCode
1033
1034    });
1035  }
1036
1037
1038  /**
1039   * Get information about the owner of the access_token.
1040   *
1041   *
1042   * @definition success_callback => which function to call in case of success
1043   * @definition error_callback   => which function to call in case of error
1044   * @definition statusCode       => StatusCode object.
1045   *
1046   * @param args = {
1047   *       success : 'success_callback',
1048   *       error   : 'error_callback'
1049   *       statusCode : statusCode
1050   *  }
1051   *
1052   *
1053   * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
1054   * or you can pass as callback function an anonymous function
1055   *
1056   *
1057   * @return object of founded info
1058   */
1059  this.getSelfInfo = function (args)
1060  {
1061    var instagram = this,
1062      noArgument = false,
1063      successFlag = false,
1064      statusCode = this.statusCode,
1065      errorFlag = false,
1066      filter = this.getFilter('getSelfInfo');
1067    if (typeof args == 'undefined' || args.length === 0) {
1068      noArgument = true;
1069    } else {
1070      if ('success' in args) {
1071        successFlag = true;
1072      }
1073
1074      if ('error' in args) {
1075        errorFlag = true;
1076      }
1077
1078      if ('statusCode' in args) {
1079        statusCode = args['statusCode'];
1080      }
1081    }
1082    var req_url = 'https://api.instagram.com/v1/users/self/?access_token=' 
1082+ getAccessToken();
1083
1084    var wdi_callback = function (cache_data) {
1085      if(cache_data === false){
1086        jQuery.ajax({
1087          type: 'POST',
1088          dataType: 'jsonp',
1089          url:req_url,
1090          success: function (response)
1091          {
1092            _this.setDataToCache(req_url,response);
1093            if (successFlag) {
1094              if (typeof args.success == 'object' && args.success.length == 2) {
1095                if (typeof window[args.success[0]] != 'undefined') {
1096                  if (typeof window[args.success[0]][args.success[1]] == 'function') {
1097                    if (filter) {
1098                      response = filter(response, instagram.filterArguments);
1099                    }
1100                    window[args.success[0]][args.success[1]](response);
1101                  }
1102                }
1103              } else
1104              if (typeof args.success == 'string') {
1105                if (typeof window[args.success] == 'function') {
1106                  if (filter) {
1107                    response = filter(response, instagram.filterArguments);
1108                  }
1109                  window[args.success](response);
1110                }
1111              } else
1112              if (typeof args.success == 'function') {
1113                if (filter) {
1114                  response = filter(response, instagram.filterArguments);
1115                }
1116                args.success(response);
1117              }
1118            }
1119          },
1120          error: function (response)
1121          {
1122
1123            if (errorFlag) {
1124              if (typeof args['error'] == 'object' && args['error'].length == 2) {
1125                if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
1126                  window[args['error'][0]][args['error'][1]](response);
1127                }
1128              } else
1129              if (typeof args['error'] == 'string') {
1130                if (typeof window[args['error']] == 'function') {
1131                  window[args['error']](response);
1132                }
1133              } else
1134              if (typeof args['error'] == 'function') {
1135                args['error'](response);
1136              }
1137            }
1138          },
1139          statusCode: statusCode
1140
1141        });
1142      }
1143      else{
1144        success(cache_data);
1145      }
1146
1147      function success(response) {
1148        if (successFlag) {
1149          if (typeof args.success == 'object' && args.success.length == 2) {
1150            if (typeof window[args.success[0]] != 'undefined') {
1151              if (typeof window[args.success[0]][args.success[1]] == 'function') {
1152                if (filter) {
1153                  response = filter(response, instagram.filterArguments);
1154                }
1155                window[args.success[0]][args.success[1]](response);
1156              }
1157            }
1158          } else
1159          if (typeof args.success == 'string') {
1160            if (typeof window[args.success] == 'function') {
1161              if (filter) {
1162                response = filter(response, instagram.filterArguments);
1163              }
1164              window[args.success](response);
1165            }
1166          } else
1167          if (typeof args.success == 'function') {
1168            if (filter) {
1169              response = filter(response, instagram.filterArguments);
1170            }
1171            args.success(response);
1172          }
1173        }
1174      }
1175    }
1176    _this.getDataFromCache(wdi_callback, req_url);
1177
1178  }
1179
1180
1181  /**
1182   * Get a list of recent comments on a media object.
1183   * The public_content permission scope is required to get comments for a media
1184   * that does not belong to the owner of the access_token.
1185   *
1186   * @media_id                    => id of the media which comments must be getted
1187   * @definition success_callback => which function to call in case of success
1188   * @definition error_callback   => which function to call in case of error
1189   * @definition statusCode       => StatusCode object.
1190   *
1191   * @param args = {
1192   *       success : 'success_callback',
1193   *       error   : 'error_callback'
1194   *       statusCode : statusCode
1195   *  }
1196   *
1197   *
1198   * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
1199   * or you can pass as callback function an anonymous function
1200   *
1201   *
1202   * @return object of founded comments
1203   */
1204  this.getRecentMediaComments = function (media_id, args)
1205  {
1206    var instagram = this,
1207      noArgument = false,
1208      successFlag = false,
1209      statusCode = this.statusCode,
1210      errorFlag = false,
1211      filter = this.getFilter('getRecentMediaComments');
1212    if (typeof args == 'undefined' || args.length === 0) {
1213      noArgument = true;
1214    } else {
1215      if ('success' in args) {
1216        successFlag = true;
1217      }
1218
1219      if ('error' in args) {
1220        errorFlag = true;
1221      }
1222
1223      if ('statusCode' in args) {
1224        statusCode = args['statusCode'];
1225      }
1226    }
1227    var req_url = 'https://api.instagram.com/v1/media/' + media_id + '/comments?access_token=' 
1227+ getAccessToken();
1228
1229    var wdi_callback = function (cache_data) {
1230      if(cache_data === false){
1231        jQuery.ajax({
1232          type: 'POST',
1233          dataType: 'jsonp',
1234          url: req_url,
1235          success: function (response)
1236          {
1237            _this.setDataToCache(req_url,response);
1238            success(response);
1239          },
1240          error: function (response)
1241          {
1242            if (errorFlag) {
1243              if (typeof args['error'] == 'object' && args['error'].length == 2) {
1244                if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
1245                  window[args['error'][0]][args['error'][1]](response);
1246                }
1247              } else
1248              if (typeof args['error'] == 'string') {
1249                if (typeof window[args['error']] == 'function') {
1250                  window[args['error']](response);
1251                }
1252              } else
1253              if (typeof args['error'] == 'function') {
1254                args['error'](response);
1255              }
1256            }
1257          },
1258          statusCode: statusCode
1259
1260        });
1261      }else{
1262        success(cache_data);
1263      }
1264      function success(response) {
1265        if (successFlag) {
1266          if (typeof args.success == 'object' && args.success.length == 2) {
1267            if (typeof window[args.success[0]] != 'undefined') {
1268              if (typeof window[args.success[0]][args.success[1]] == 'function') {
1269                if (filter) {
1270                  response = filter(response, instagram.filterArguments);
1271                }
1272                window[args.success[0]][args.success[1]](response);
1273              }
1274            }
1275          } else
1276          if (typeof args.success == 'string') {
1277            if (typeof window[args.success] == 'function') {
1278              if (filter) {
1279                response = filter(response, instagram.filterArguments);
1280              }
1281              window[args.success](response);
1282            }
1283          } else
1284          if (typeof args.success == 'function') {
1285            if (filter) {
1286              response = filter(response, instagram.filterArguments);
1287            }
1288            args.success(response);
1289          }
1290        }
1291      }
1292    }
1293    _this.getDataFromCache(wdi_callback, req_url);
1294  }
1295
1296
1297  /**
1298   * Get a list of users who have liked this media.
1299   *
1300   * @media_id                    => id of the media which comments must be getted
1301   * @definition success_callback => which function to call in case of success
1302   * @definition error_callback   => which function to call in case of error
1303   * @definition statusCode       => StatusCode object.
1304   *
1305   * @param args = {
1306   *       success : 'success_callback',
1307   *       error   : 'error_callback'
1308   *       statusCode : statusCode
1309   *  }
1310   *
1311   *
1312   * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
1313   * or you can pass as callback function an anonymous function
1314   *
1315   *
1316   * @return object of founded comments
1317   */
1318  this.getRecentMediaLikes = function (media_id, args)
1319  {
1320    var instagram = this,
1321      noArgument = false,
1322      successFlag = false,
1323      statusCode = this.statusCode,
1324      errorFlag = false,
1325      filter = this.getFilter('getRecentMediaLikes');
1326
1327    if (typeof args == 'undefined' || args.length === 0) {
1328      noArgument = true;
1329    } else {
1330      if ('success' in args) {
1331        successFlag = true;
1332      }
1333
1334      if ('error' in args) {
1335        errorFlag = true;
1336      }
1337
1338      if ('statusCode' in args) {
1339        statusCode = args['statusCode'];
1340      }
1341    }
1342    jQuery.ajax({
1343      type: 'POST',
1344      dataType: 'jsonp',
1345      url: 'https://api.instagram.com/v1/media/' + media_id + '/likes?access_token=' 
1345+ getAccessToken(),
1346      success: function (response)
1347      {
1348        if (successFlag) {
1349          if (typeof args.success == 'object' && args.success.length == 2) {
1350            if (typeof window[args.success[0]] != 'undefined') {
1351              if (typeof window[args.success[0]][args.success[1]] == 'function') {
1352                if (filter) {
1353                  response = filter(response, instagram.filterArguments);
1354                }
1355                window[args.success[0]][args.success[1]](response);
1356              }
1357            }
1358          } else
1359          if (typeof args.success == 'string') {
1360            if (typeof window[args.success] == 'function') {
1361              if (filter) {
1362                response = filter(response, instagram.filterArguments);
1363              }
1364              window[args.success](response);
1365            }
1366          } else
1367          if (typeof args.success == 'function') {
1368            if (filter) {
1369              response = filter(response, instagram.filterArguments);
1370            }
1371            args.success(response);
1372          }
1373        }
1374      },
1375      error: function (response)
1376      {
1377        if (errorFlag) {
1378          if (typeof args['error'] == 'object' && args['error'].length == 2) {
1379            if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
1380              window[args['error'][0]][args['error'][1]](response);
1381            }
1382          } else
1383          if (typeof args['error'] == 'string') {
1384            if (typeof window[args['error']] == 'function') {
1385              window[args['error']](response);
1386            }
1387          } else
1388          if (typeof args['error'] == 'function') {
1389            args['error'](response);
1390          }
1391        }
1392      },
1393      statusCode: statusCode
1394
1395    });
1396  }
1397
1398
1399  /**
1400   * make an ajax request based on url
1401   *
1402   *
1403   * @definition success_callback => which function to call in case of success
1404   * @definition error_callback   => which function to call in case of error
1405   * @definition statusCode       => StatusCode object.
1406   *
1407   * @param args = {
1408   *       success : 'success_callback',
1409   *       error   : 'error_callback',
1410   *       statusCode : statusCode,
1411   *       args.args : arguments to be passed to filter function
1412   *  }
1413   *
1414   *
1415   * if callback function is property of any other object just give it as array [ 'parent_object', 'callback_function']
1416   * or you can pass as callback function an anonymous function
1417   *
1418   *
1419   * @return object of founded media
1420   */
1421  this.requestByUrl = function (requestUrl, args)
1422  {
1423    var instagram = this,
1424      noArgument = false,
1425      successFlag = false,
1426      errorFlag = false,
1427      argFlag = false,
1428      statusCode = this.statusCode,
1429      filter = this.getFilter('requestByUrl'),
1430      urlParts,
1431      urlPart;
1432
1433    //changing access token to random one
1434    urlParts = requestUrl.split('?')[1].split('&');
1435    for (var i = 0; i < urlParts.length; i++) {
1436      urlParts[i] = urlParts[i].split('=');
1437      if (urlParts[i][0] == 'access_token') {
1438        urlParts[i][1] = getAccessToken();
1439      }
1440      urlParts[i] = urlParts[i].join('=');
1441    }
1442    urlParts = urlParts.join('&');
1443    requestUrl = requestUrl.split('?')[0] + '?' + urlParts;
1444
1445
1446    if (typeof args == 'undefined' || args.length === 0) {
1447      noArgument = true;
1448    } else {
1449      if ('success' in args) {
1450        successFlag = true;
1451      }
1452
1453      if ('args' in args) {
1454        argFlag = true;
1455      } else {
1456        args.args = {};
1457      }
1458
1459
1460      if ('error' in args) {
1461        errorFlag = true;
1462      }
1463
1464      if ('statusCode' in args) {
1465        statusCode = args['statusCode'];
1466      }
1467    }
1468
1469    var wdi_callback = function (cache_data) {
1470      if(cache_data === false){
1471        jQuery.ajax({
1472          type: 'POST',
1473          dataType: 'jsonp',
1474          url: requestUrl,
1475          success: function (response)
1476          {
1477            _this.setDataToCache(requestUrl,response);
1478            if (successFlag) {
1479              if (typeof args.success == 'object' && args.success.length == 2) {
1480                if (typeof window[args.success[0]] != 'undefined') {
1481                  if (typeof window[args.success[0]][args.success[1]] == 'function') {
1482                    if (filter) {
1483                      response = filter(response, instagram.filterArguments, args.args);
1484                    }
1485                    window[args.success[0]][args.success[1]](response);
1486                  }
1487                }
1488              } else
1489              if (typeof args.success == 'string') {
1490                if (typeof window[args.success] == 'function') {
1491                  if (filter) {
1492                    response = filter(response, instagram.filterArguments, args.args);
1493                  }
1494                  window[args.success](response);
1495                }
1496              } else
1497              if (typeof args.success == 'function') {
1498                if (filter) {
1499                  response = filter(response, instagram.filterArguments, args.args);
1500                }
1501                args.success(response);
1502              }
1503            }
1504          },
1505          error: function (response)
1506          {
1507            if (errorFlag) {
1508              if (typeof args['error'] == 'object' && args['error'].length == 2) {
1509                if (typeof window[args['error'][0]][args['error'][1]] == 'function') {
1510                  window[args['error'][0]][args['error'][1]](response);
1511                }
1512              } else
1513              if (typeof args['error'] == 'string') {
1514                if (typeof window[args['error']] == 'function') {
1515                  window[args['error']](response);
1516                }
1517              } else
1518              if (typeof args['error'] == 'function') {
1519                args['error'](response);
1520              }
1521            }
1522          },
1523          statusCode: statusCode
1524        });
1525      }
1526      else{
1527        success(cache_data);
1528      }
1529      function success(response) {
1530        if (successFlag) {
1531          if (typeof args.success == 'object' && args.success.length == 2) {
1532            if (typeof window[args.success[0]] != 'undefined') {
1533              if (typeof window[args.success[0]][args.success[1]] == 'function') {
1534                if (filter) {
1535                  response = filter(response, instagram.filterArguments, args.args);
1536                }
1537                window[args.success[0]][args.success[1]](response);
1538              }
1539            }
1540          } else
1541          if (typeof args.success == 'string') {
1542            if (typeof window[args.success] == 'function') {
1543              if (filter) {
1544                response = filter(response, instagram.filterArguments, args.args);
1545              }
1546              window[args.success](response);
1547            }
1548          } else
1549          if (typeof args.success == 'function') {
1550            if (filter) {
1551              response = filter(response, instagram.filterArguments, args.args);
1552            }
1553            args.success(response);
1554          }
1555        }
1556      }
1557    }
1558    _this.getDataFromCache(wdi_callback, requestUrl);
1559  }
1560
1561
1562
1563  this.getDataFromCache = function (callback, cache_name) {
1564    jQuery.ajax({
1565      type: "POST",
1566      async: true,
1567      url: wdi_ajax.ajax_url,
1568      dataType:"json",
1569      data: {
1570        wdi_cache_name:cache_name,
1571        wdi_nonce:wdi_ajax.wdi_nonce,
1572        WDI_MINIFY:wdi_ajax.WDI_MINIFY,
1573        action:"wdi_get_cache_data",
1574      },
1575      success: function(data){
1576        if(data["wdi_debugging"]){
1577          console.log(data["wdi_debugging_data"]);
1578        }
1579        if(data["success"]){
1580          if(typeof data["cache_data"] !== "undefined" && data["cache_data"] !== null){
1581            var json_data = JSON.parse(data["cache_data"]);
1582            callback(json_data);
1583          }else{
1584            callback(false);
1585          }
1586        }else {
1587          callback(false);
1588        }
1589      }
1590    });
1591  }
1592
1593
1594  this.setDataToCache = function (cache_name, response) {
1595    jQuery.ajax({
1596      type: "POST",
1597      url: wdi_ajax.ajax_url,
1598      dataType:"json",
1599      data: {
1600        wdi_cache_name:cache_name,
1601        wdi_cache_response:JSON.stringify(response),
1602        wdi_nonce:wdi_ajax.wdi_nonce,
1603        action:"wdi_set_cache_data"
1604      },
1605      success: function(data){
1606
1607      }
1608    });
1609  }
1610
1611
1612}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.