PageSourceSearch

https://s.skygate.co.jp/pc/js/frameload.js?20260925233703

js skygate.co.jp collected 2026-09-25 14:58:32 UTC 4,895 bytes, 168 lines download raw bytes

1(function(window, $) {
2  var $document = $(document);
3  var output = function(message) {
4    if (window.console) {
5      console.log(message);
6    }
7  };
8
9  var getUnderScoreTemplateString = function(id) {
10    var str = $(id).html() || '';
11    str = str.split('\r\n').join('\n');
12    str = str.split('\r').join('\n');
13    return _.map(str.split('\n'), function(s) {
14      return $.trim(s);
15    }).join('');
16  };
17
18  var framePromiseMapById = {};
19  var framePromiseMapByKey = {};
20  var getFrame = function(frameInfo) {
21    var req = {};
22    var frameId = frameInfo.frameId;
23    var frameKey = frameInfo.frameKey;
24    if (frameId) {
25      if (framePromiseMapById[frameId]) {
26        return framePromiseMapById[frameId];
27      }
28      if (frameId.indexOf(',') !== -1) {
29        req.frameIds = _.map(frameId.split(','), function(id) {
30          return $.trim(id);
31        });
32      } else {
33        var promise = $.ajax('/common/frame?frameId=' + frameId, {
34          cache: false
35        });
36        framePromiseMapById[frameId] = promise;
37        return promise;
38      }
39    } else if (frameKey) {
40      if (framePromiseMapByKey[frameKey]) {
41        return framePromiseMapByKey[frameKey];
42      }
43      if (frameKey.indexOf(',') !== -1) {
44        req.frameKeys = _.map(frameKey.split(','), function(key) {
45          return $.trim(key);
46        });
47      } else {
48        var promise = $.ajax('/common/frame?frameKey=' + frameKey, {
49          cache: false
50        });
51        framePromiseMapByKey[frameKey] = promise;
52        return promise;
53      }
54    } else { 
55      return $.Deferred().reject();
56    }
57    return getFrames(req);
58  };
59
60  var getFrames = function(frameInfo) {
61    var frameIds = frameInfo.frameIds;
62    var frameKeys = frameInfo.frameKeys;
63    var dfd = $.Deferred();
64    var promises;
65    if (frameIds) {
66      promises = _.map(frameIds, function(id) {
67        return getFrame({'frameId': id});
68      });
69    } else if (frameKeys) {
70      promises = _.map(frameKeys, function(key) {
71        return getFrame({'frameKey': key});
72      });
73    } else {
74      return dfd.reject();
75    }
76    $.when.apply($, promises).done(function(var_args) {
77      var results =  Array.prototype.slice.call(arguments);
78      var args = frameIds || frameKeys
79      var datas =  _.reduce(args, function(ret, arg, index) {
80        ret[arg] = results[index][0];
81        return ret;
82      }, {});
83      dfd.resolve({
84        results: datas
85      });
86    });
87    return dfd.promise();
88  };
89
90  var metaFramesMap = {};
91  var getMetaFrames = function() {
92    return _.reduce($('input[name=metaFrameIds]'), function(promises, target) {
93      var promise = getFrame({'frameId': target.value}).done(function(data) {
94        if (data.content && data.content.metaFrameIds) {
95          $.extend(metaFramesMap, data.content.metaFrameIds);
96        }
97      });
98      promises.push(promise);
99      return promises;
100    }, []);
101  };
102
103  var templateMap = {};
104  var renderTemplates = function() {
105    return _.reduce($('.frameItem'), function(renderingPromises, target) {
106      var dfd = $.Deferred();
107      var $target = $(target);
108      var frameId = $target.attr('data-frameid');
109      var frameKey = $target.attr('data-framekey');
110      var frameName = $target.attr('data-framename');
111      if (frameName) {
112        frameId = metaFramesMap[frameName];
113        if (!frameId) {
114          output('frameName: ' + frameName + ' is undefined');
115          dfd.resolve();
116          return;
117        }
118      }
119      if (!frameId && !frameKey) {
120        output('frameId and frameKey are undefined');
121        dfd.resolve();
122        return;
123      }
124      var req = {};
125      if (frameId) {
126        req.frameId = frameId;
127      } else {
128        req.frameKey = frameKey;
129      }
130      getFrame(req).done(function(data) {
131        if (!data) {
132          $document.trigger('loadFrameItem', {
133            frameData: data,
134            targetElement: target
135          });
136          dfd.resolve();
137          return;
138        }
139        var templateId = $target.attr('data-template');
140        var template = templateMap[templateId];
141        if (!template) {
142          template = _.template(getUnderScoreTemplateString('#' + templateId));
143          templateMap[templateId] = template;
144        }
145        $target.append(template(data));
146        $document.trigger('loadFrameItem', {
147          frameData: data,
148          targetElement: target
149        });
150        dfd.resolve();
151      });
152      renderingPromises.push(dfd.promise());
153      return renderingPromises;
154    }, []);
155  }
156
157  $(function() {
158    var metaFramePromises = getMetaFrames();
159    $.when.apply($, metaFramePromises).done(function() {
160      var renderingPromises = renderTemplates();
161      $.when.apply($, renderingPromises).done(function() {
162        _.each(_.keys(templateMap), function(id) {
163          $('#' + id).remove();
164        });
165      });
166    });
167  });
168})(window, jQuery);

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.