<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">var HISTORY_KEY = 'commodity_history';

var lastCommoditiesFromCookie = function(limit, ignoreCommodityCode) {

  var history = Cookies.getJSON(getCommodityHistoryKey());

  if (!history) {
    return [];
  }

  if (ignoreCommodityCode) {
    history = history.filter(function(e) {
      return e.commodity_code != ignoreCommodityCode;
    });
  }

  if (!limit || 20 &lt; limit) {
    limit = 20;
  }

  if (limit &amp;&amp; 0 &lt; limit &amp;&amp; limit &lt; history.length) {
    history = history.slice(-1 * limit);
  }

  return history;
}


function getCommodityHistoryKey() {
  if ($('#swsCityCode').length &amp;&amp; $('#swsCityCode').val() !='') {
    // SWS CITY蟇ｾ蠢�
    return HISTORY_KEY + '_' + $('#swsCityCode').val();
  } else {
    return HISTORY_KEY;
  }
}


$(function() {

  if ($('#commodityCode').length &amp;&amp; $('#commodityCode').val()) {
    var historyKey = getCommodityHistoryKey();
    appendHistory(historyKey);
    if (historyKey !== HISTORY_KEY) {
      // 蜈ｱ騾壹�螻･豁ｴ縺ｫ繧りｿｽ蜉�縺吶ｋ
      appendHistory(HISTORY_KEY);
    }
  }

  function appendHistory(historyKey) {
    var history = Cookies.getJSON(historyKey);

    if (!history) {
      history = [];
    }

    history = history.filter(function(e) {
      return e.commodity_code != $('#commodityCode').val();
    });
    history.push({
      commodity_code : $('#commodityCode').val()
    });

    do {
      if (history.length &lt;= 21) {
        break;
      }
    } while (history.shift())

    Cookies.set(historyKey, history, {
      expires : 365
    });
  }

});
</pre></body></html>