PageSourceSearch

https://www.jalan.net/assets/js/jalanLiercoPopup.js

js jalan.net collected 2026-09-24 08:48:03 UTC 6,072 bytes, 244 lines download raw bytes

1/**
2 * @fileOverview LiercoPopup
3 */
4
5(function ($) {
6  'use strict';
7
8  /**
9   * LiercoPopup ƒNƒ‰ƒX
10   * @constructor
11   */
12  var LiercoPopup = function () {
13    this.initialize.apply(this, arguments);
14  };
15
16  /**
17   * ‰Šú‰»
18   */
19  LiercoPopup.prototype.initialize = function (options) {
20    this.config = $.extend({}, options);
21  };
22
23  /**
24   * ŽÀs
25   */
26  LiercoPopup.prototype.run = function () {
27    this.fetch();
28  };
29
30  /**
31   * ƒf[ƒ^‚ðŽûW‚·‚é
32   * @returns {Promise}
33   */
34  LiercoPopup.prototype.fetch = function () {
35    var self = this;
36
37    $
38      .ajax({
39        url: 'https://s9.r-ad.ne.jp/json',
40        dataType: 'JSON',
41        data: {
42          f: this.config.f,
43          m: this.config.m,
44          kid: this.config.kid
45        },
46        timeout: 5000
47      })
48      .done(function (json) {
49        if (json.length) {
50          self.setup();
51          self.render(json);
52        }
53      });
54  };
55
56  /**
57   * ƒŠƒGƒ‹ƒR˜g’ljÁ
58   */
59  LiercoPopup.prototype.setup = function () {
60    var modalFrame = (function () {/*
61      <div class="liercoPopup js-liercoPopup js-liercoPopupClose">
62        <div class="liercoPopup__content js-liercoPopupContent">
63          <span class="ji ji-close-round liercoPopup__close js-liercoPopupClose"></span>
64          <div class="liercoPopup__banner js-liercoPopupBanner"></div>
65        </div>
66      </div>
67      */}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1];
68
69    $('body').append(modalFrame);
70  };
71
72  /**
73   * ƒŠƒGƒ‹ƒR•`‰æ
74   */
75  LiercoPopup.prototype.render = function (data) {
76    var self = this;
77    var liercoItem = data[0];
78    var $a = $('<a>').attr('href', liercoItem.link_url).addClass('js-liercoPopupLink');
79    var $img = $('<img>').attr('src', liercoItem.image_url);
80    var $liercoPopupBanner = $('.js-liercoPopupBanner');
81
82    $a.append($img);
83    $liercoPopupBanner.append($a);
84
85    $img.on('load', function () {
86      $('html,body').addClass('showLiercoPopup');
87      self.setEvents();
88    });
89  };
90
91  /**
92   * ƒCƒxƒ“ƒgÝ’è
93   */
94  LiercoPopup.prototype.setEvents = function () {
95    var self = this;
96
97    $('.js-liercoPopupClose').on('click.liercoPopupClose', function () {
98      self.close();
99      self.hide();
100    });
101
102    $('.js-liercoPopupContent').on('click.liercoPopupContent', function (e) {
103      e.stopPropagation();
104    });
105
106    $('.js-liercoPopupLink').on('click.liercoPopupLink', function () {
107      self.hide();
108    });
109  };
110
111  /**
112   * •‚¶‚é
113   */
114  LiercoPopup.prototype.close = function () {
115    $('.js-liercoPopup').remove();
116    $('html,body').removeClass('showLiercoPopup');
117  };
118
119  /**
120   * Ä•\ަ‚µ‚È‚¢‚悤‚É‚·‚éBlocalStorage‚ۗ̕LŠúŒÀ‚Ɉˑ¶‚·‚é
121   * localStorage“o˜^ŽžAZing‚É‚à’l‚ª“¯Šú‚³‚ê‚é
122   * @see https://developer.mozilla.org/ja/docs/Web/API/Storage/setItem
123   */
124  LiercoPopup.prototype.hide = function () {
125    try {
126      localStorage.setItem(this.config.storageKey, this.config.f);
127
128    } catch (e) {
129      return;
130    }
131  };
132
133  window.LiercoPopup = LiercoPopup;
134
135})(window.jQuery);
136
137$(function () {
138  var getCookie = function (name) {
139    var cookies = '; ' + document.cookie;
140    var values = cookies.split('; ' + name + '=');
141    return 1 < values.length ? values[1].split(';')[0] : '';
142  };
143
144  // ƒƒOƒCƒ“Ï‚©‚ð”»’f‚·‚é
145  var capId = getCookie('jln_m').split('#')[2];
146  if (!capId) return;
147
148  // Ý’èƒtƒ@ƒCƒ‹‚ðŽæ“¾
149  $.ajax({
150      url: '/jalan/doc/jalanLiercoPopup_pc_f.json',
151      dataType: 'json',
152      timeout: 5000
153    })
154    .done(function (json) {
155      // •\oÝ’肪‚È‚¢ê‡‚͏ˆ—I—¹
156      if (!json || !json.f) return;
157      var frameId = json.f;
158
159      var storageKey = 'viewLiercoPopup';
160      var storageValue = localStorage.getItem(storageKey);
161
162      // localStorage‚É•\oÏ‚̍LID‚ª‘¶Ý‚µAŒ»Ý•\oÝ’è‚̍LID‚ƈê’v‚µ‚Ä‚¢‚éê‡A•\oÏ‚Ƃ݂Ȃ·
163      if (storageValue && storageValue === frameId) return;
164
165      // Zing‘Ήž‚̃uƒ‰ƒEƒU‚̂݁AZing‚ðŠm”F
166      if (window.zingTarget) {
167        var zingKey = localStorage.getItem('__zing__');
168
169        // __zing__“o˜^—L‚̏ꍇAŠù•\oƒf[ƒ^‚͂Ȃ¢ˆ×Aƒ|ƒbƒvƒAƒbƒv•\oˆ—‚Ɉڍs
170        if (zingKey) {
171          popUpCall();
172          return;
173        };
174
175        // __zing__“o˜^–³‚̏ꍇAZing‚ɕۑ¶‚³‚ê‚Ä‚¢‚é‰Â”\«‚ª‚ ‚éˆ×ApulledƒCƒxƒ“ƒgŠm”F‚ðs‚¤
176        function zingPulled() {
177          var zingData = null;
178          return new Promise(function(resolve, reject){
179            window.addEventListener('ZingStorage__pulled', function(e) {
180              zingData = e.detail;
181            });
182
183            var timeOutId = setTimeout(function () {
184              clearInterval(timerId);
185              reject();
186            }, 5000);
187
188            var timerId = setInterval(function () {
189              if (zingData !== null) {
190                clearInterval(timerId);
191                clearTimeout(timeOutId);
192                resolve(zingData);
193              }
194            }, 1000);
195          });
196        }
197
198        zingPulled().then(function (zingData) {
199          // Zing‚É“o˜^Ï‚̃f[ƒ^‚ª‘¶Ý‚µAZing“o˜^’l‚Æ•\oÝ’è’l‚ªˆê’v‚·‚éê‡Aˆ—I—¹
200          if (zingData.viewLiercoPopup && zingData.viewLiercoPopup === frameId) return;
201          // –¢•\o‚̏ꍇ‚̓|ƒbƒvƒAƒbƒv•\o‚Ɉڍs‚·‚é
202          popUpCall();
203
204        }).catch(function (error) {
205          // ƒGƒ‰[‚̏ꍇ‚͏ˆ—I—¹
206          return;
207        });
208
209      } else {
210        // ”ñ‘Ήžƒuƒ‰ƒEƒU‚̏ꍇAZing‚ÍŠm”F‚µ‚È‚¢
211        popUpCall();
212      }
213
214      function popUpCall () {
215        var
216          kid = getCookie('r_ad_token2'),
217          opt = {
218            f: frameId,
219            m: '1',
220            kid: kid,
221            storageKey: storageKey
222          };
223
224        if (kid) {
225          new window.LiercoPopup(opt).run();
226          return;
227        }
228
229        var timerId = setInterval(function () {
230          var kid = getCookie('r_ad_token2');
231          if (kid) {
232            clearInterval(timerId);
233            opt.kid = kid;
234            new window.LiercoPopup(opt).run();
235            return;
236          }
237        }, 1000);
238        setTimeout(function () {
239          clearInterval(timerId);
240        }, 10000);
241      };
242
243    });
244});

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.