PageSourceSearch

https://www.bertrandtrichet.com/static/_common/instagram-35621030b…c701197838069d298328e0a425fbeb6023438944.js

js bertrandtrichet.com collected 2026-10-07 19:27:41 UTC 9,320 bytes, 211 lines download raw bytes

1(function() {
2  (function() {
3    var $, APIClient, instagram;
4    $ = this.jQuery;
5    APIClient = (function() {
6      function APIClient(accessToken1, apiPrologue) {
7        this.accessToken = accessToken1 != null ? accessToken1 : null;
8        this.apiPrologue = apiPrologue != null ? apiPrologue : "https://graph.instagram.com/me";
9        if (this.accessToken == null) {
10          throw new Error("You must provide an accessToken parameter when instantiating an APIClient object.");
11        }
12      }
13
14      APIClient.prototype.requestEndpoint = function(endpoint) {
15        var apiEndpoint;
16        apiEndpoint = endpoint.indexOf("?") > 0 ? endpoint + "&access_token=" + this.accessToken : endpoint + "/?access_token=" + this.accessToken;
17        return $.ajax({
18          url: this.apiPrologue + "/" + apiEndpoint,
19          dataType: "jsonp"
20        });
21      };
22
23      APIClient.prototype.getRecentMedia = function(count) {
24        var params, url;
25        url = this.apiPrologue;
26        params = {
27          dataType: "jsonp",
28          data: {
29            access_token: this.accessToken,
30            fields: "media.limit(" + count + "){media_url,permalink,thumbnail_url,username}"
31          }
32        };
33        return this.fetchDataUntilGotEnough(url, params, count);
34      };
35
36      APIClient.prototype.fetchDataUntilGotEnough = function(url, params, count) {
37        var deferred, handleError, handleResponse, recursiveInstagramFetcher, result;
38        result = [];
39        deferred = $.Deferred();
40        handleResponse = function(response) {
41          var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
42          result = result.concat((ref = response != null ? (ref1 = response.media) != null ? ref1.data : void 0 : void 0) != null ? ref : []);
43          if ((response != null ? response.error : void 0) != null) {
44            return deferred.resolve(response);
45          } else if (result.length >= count) {
46            return deferred.resolve({
47              data: result,
48              count: count
49            });
50          } else if ((response != null ? (ref2 = response.media) != null ? (ref3 = ref2.data) != null ? ref3.length : void 0 : void 0 : void 0) && ((response != null ? (ref4 = response.media) != null ? (ref5 = ref4.paging) != null ? ref5.next : void 0 : void 0 : void 0) == null)) {
51            if (typeof Raven !== "undefined" && Raven !== null) {
52              Raven.captureMessage('Instagram account doesn’t have enough images');
53            }
54            return deferred.resolve({
55              data: result
56            });
57          } else if ((response != null ? (ref6 = response.media) != null ? (ref7 = ref6.paging) != null ? ref7.next : void 0 : void 0 : void 0) != null) {
58            return recursiveInstagramFetcher(response.media.paging.next);
59          } else {
60            return deferred.resolve(instagram.constructError(instagram.UNKNOWN_ERROR));
61          }
62        };
63        handleError = function(error) {
64          try {
65            return deferred.resolve(JSON.parse(error.responseText));
66          } catch (error1) {
67            return deferred.resolve(instagram.constructError(instagram.UNKNOWN_ERROR));
68          }
69        };
70        recursiveInstagramFetcher = function(url, params) {
71          if (params == null) {
72            params = {
73              dataType: 'jsonp'
74            };
75          }
76          return $.ajax(url, params).then(handleResponse, handleError);
77        };
78        recursiveInstagramFetcher(url, params);
79        return deferred;
80      };
81
82      return APIClient;
83
84    })();
85    instagram = this.instagram = {
86      NO_ACCESS_TOKEN_ERROR: "IGApiException",
87      INVALID_ACCESS_TOKEN_ERROR: "OAuthException",
88      UNKNOWN_ERROR: "unknown",
89      constructError: function(type) {
90        return {
91          error: {
92            type: type
93          }
94        };
95      },
96      config: (function(_this) {
97        return function() {
98          var ref, ref1;
99          return (ref = _this.social) != null ? (ref1 = ref.instagram) != null ? ref1.accessToken : void 0 : void 0;
100        };
101      })(this),
102      populate: function($modules, cb) {
103        var $instagramModule, accessToken, instagramClient;
104        if ($modules != null) {
105          $modules = $modules.filter(function(_, el) {
106            return $(el).find("[data-social-type='instagram']").length === 1;
107          });
108        }
109        $instagramModule = $modules != null ? $modules : $("[data-social-type='instagram']").closest("._4ORMAT_content_page_row");
110        if (!($instagramModule.length > 0)) {
111          return;
112        }
113        accessToken = instagram.config();
114        if (accessToken == null) {
115          instagram.render({
116            el: $instagramModule,
117            error: instagram.NO_ACCESS_TOKEN_ERROR
118          });
119          return typeof cb === "function" ? cb($instagramModule) : void 0;
120        }
121        instagramClient = new APIClient(accessToken);
122        return $instagramModule.each(function(_, el) {
123          var imageCount, instagramWrapper, ref;
124          instagramWrapper = $(el).find(".js-format-instagram-wrapper")[0];
125          imageCount = (ref = instagramWrapper.dataset.imageCount) != null ? ref : 6;
126          return instagramClient.getRecentMedia(imageCount).then(function(response) {
127            if ((response != null ? response.error : void 0) != null) {
128              instagram.render({
129                el: el,
130                error: response.error.type
131              });
132            } else {
133              instagram.render({
134                data: response.data,
135                el: el,
136                settings: instagramWrapper.dataset
137              });
138            }
139            return typeof cb === "function" ? cb($(el)) : void 0;
140          });
141        });
142      },
143      updateImageCount: function(el, settings, cb) {
144        var accessToken, imageCount, instagramClient, ref;
145        accessToken = instagram.config();
146        if (accessToken == null) {
147          instagram.render({
148            el: el,
149            error: instagram.NO_ACCESS_TOKEN_ERROR
150          });
151          return typeof cb === "function" ? cb($(el)) : void 0;
152        }
153        instagramClient = new APIClient(accessToken);
154        imageCount = (ref = settings.imageCount) != null ? ref : 6;
155        return instagramClient.getRecentMedia(imageCount).then(function(response) {
156          if ((response != null ? response.error : void 0) != null) {
157            instagram.render({
158              el: el,
159              error: response.error.type
160            });
161          } else {
162            instagram.render({
163              data: response.data,
164              el: el,
165              settings: settings
166            });
167          }
168          return typeof cb === "function" ? cb($(el)) : void 0;
169        });
170      },
171      render: function(arg) {
172        var $el, $instagramContainer, content, data, el, error, settings;
173        settings = arg.settings, data = arg.data, el = arg.el, error = arg.error;
174        content = error != null ? error === instagram.NO_ACCESS_TOKEN_ERROR ? "<div class='js-format-instagram-container format-instagram-container error error-no-access'>\n</div>" : error === instagram.INVALID_ACCESS_TOKEN_ERROR ? "<div class='js-format-instagram-container format-instagram-container error error-failed-access'>\n</div>" : "<div class='js-format-instagram-container format-instagram-container error error-unknown empty'>\n</div>" : data.length === 0 ? "<div class='js-format-instagram-container format-instagram-container error empty'>\n</div>" : instagram.renderImages({
175          data: data,
176          el: el,
177          settings: settings
178        });
179        $el = $(el);
180        $instagramContainer = $el.find(".js-format-instagram-container ");
181        if ($instagramContainer.length > 0) {
182          $instagramContainer.replaceWith(content);
183        } else {
184          $el.find(".js-format-instagram-wrapper").append(content);
185        }
186        return $el.toggleClass("_4ORMAT_site_hidden", (error != null) || data.length === 0);
187      },
188      renderImages: function(arg) {
189        var data, el, items, ref, settings;
190        data = arg.data, el = arg.el, settings = arg.settings;
191        items = data.reduce(function(res, post) {
192          return res + ("<div class=\"format-instagram-preview\">\n  <a href=\"" + post.permalink + "\" target=\"_blank\" rel=\"noopener\">\n    <div class=\"format-instagram-preview-image\"\n      style=\"background-image:url(" + (post.thumbnail_url || post.media_url) + ");\"></div>\n  </a>\n</div>");
193        }, "");
194        items = items + instagram.renderAttribution(data);
195        return "<div class='js-format-instagram-container format-instagram-container image-row-count-" + ((ref = settings.imagesPerRow) != null ? ref : 3) + "'>\n  " + items + "\n</div>";
196      },
197      renderAttribution: function(data) {
198        if (!(data.length > 0)) {
199          return "";
200        }
201        return "<div class=\"format-instagram-attribution\">\n  Follow\n  <a href=\"https://www.instagram.com/" + data[0].username + "/\" target=\"_blank\" rel=\"noopener\">@" + data[0].username + "</a>\n  on Instagram\n</div>";
202      }
203    };
204    return $(function() {
205      if (!_4ORMAT_DATA.page.content_editable) {
206        return instagram.populate();
207      }
208    });
209  }).call(_4ORMAT);
210
211}).call(this);

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.