PageSourceSearch

https://map.kobayashi.co.jp/f/js_libs/support_tool/js/history.js

js kobayashi.co.jp collected 2026-10-02 02:39:22 UTC 2,952 bytes, 128 lines download raw bytes

1var poiHistory = [];
2var key = "";
3
4function loadLocal() {
5  var data;
6  if (lsCheck()) {
7    data = localStorage.getItem(key);
8    if (data != null) {
9      poiHistory = JSON.parse(data);
10      removeOldItem();
11      removeOverMaxLength();
12      doSave();
13    }
14  }
15}
16
17function createList() {
18  if (typeof($("#js-history-list")) != "undefined") {
19    var html;
20
21    if (poiHistory.length == 0) {
22      html = '<li>最近見た店舗はありません。</li>';
23      $("#js-history-list").append(html);
24      return;
25    }
26
27    var tempHistory = poiHistory.slice();
28    tempHistory.reverse();
29
30    var maxLength = parseInt(jsConfig["m_history_max_length"]);
31    if (tempHistory.length < maxLength) {
32      maxLength = tempHistory.length;
33    }
34
35    for (var i = 0; i < maxLength; i++) {
36      html = '<li><a href="/b/' + retJson.layer + '/info/' + tempHistory[i].id + '/" class="arrow-link-left">' + tempHistory[i].name + '</a></li>';
37      $("#js-history-list").append(html);
38    }
39  }
40}
41
42function saveLocal() {
43  removeDupliateItem();
44  removeOldItem();
45
46  var item = {};
47  item.name = infoJSON.name;
48  item.id = infoJSON.id;
49  item.time = new Date().getTime();
50  poiHistory.push(item);
51
52  removeOverMaxLength();
53  doSave();
54}
55
56function doSave() {
57  if (lsCheck()) {
58    localStorage.setItem(key, JSON.stringify(poiHistory));
59  }
60}
61
62/**----------------
63/* 重複チェック
64-------------------**/
65function removeDupliateItem() {
66  for (var i = 0; i < poiHistory.length; i++) {
67    if (poiHistory[i].id == infoJSON.id) {
68      poiHistory.splice(i, 1);
69      break;
70    }
71  }
72}
73
74/**-----------------------
75/* 最大保存件数チェック
76--------------------------**/
77function removeOverMaxLength() {
78  var maxLength = parseInt(jsConfig["m_history_max_length"]);
79  if (poiHistory.length > maxLength) {
80    poiHistory = poiHistory.slice(-maxLength);
81  }
82}
83
84/**--------------------------
85/* 期限切れアイテムチェック
86-----------------------------**/
87function removeOldItem() {
88  var periodTime = new Date().getTime() - parseInt(jsConfig["m_history_period"]) * 24 * 60 * 60 * 1000;
89
90  var i = 0;
91  while (i < poiHistory.length) {
92    if (poiHistory[i].time < periodTime ) {
93      poiHistory.splice(i, 1);
94    } else {
95      i++;
96    }
97  }
98}
99
100/**-------------------------------
101/* localStorage 利用可否チェック
102----------------------------------**/
103function lsCheck() {
104  try {
105    if (('localStorage' in window) && window['localStorage'] !== null) {
106      // Safari のプライベートモード判定用
107      localStorage.setItem("mapi_info_history_test", "test");
108      localStorage.removeItem("mapi_info_history_test");
109      return true;
110    } else {
111      return false;
112    }
113  } catch(e) {
114    return false;
115  }
116}
117
118$( function() {
119  if (jsConfig["m_history_enabled"] == "false") return;
120
121  key = "mapi_info_history_" + retJson.layer;
122
123  loadLocal();
124  createList();
125  if (retJson.method == "info") {
126    saveLocal();
127  }
128})

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.