<commit_before>function searchToParams(search) {
  var pat = /([^?=&#]*)=([^?=&#]+)/g, params = {};
  decodeURIComponent(search)
    .replace(pat, function (a, b, c) {
      if (b in params) {
        if (!_.isArray(params[b])) {
          params[b] = [params[b]];
        }
        params[b].push(c);
      } else {
        params[b] = c;
      }
    });
  return params;
}

function paramsToSearch(params) {
  return _.reduce(params, function (search, val, key) {
    var arr = _.isArray(val) ? val : [val];
    return search + (search ? '&' : '?') +
      _.reduce(arr, function (segs, v) {
        return segs + (segs ? '&' : '') + key + '=' + encodeURIComponent(v);
      }, '');
  }, '');
}

function loadReady() {
  _.delay(function () {
    $('.back-btn').find('i').toggleClass('fa-spinner fa-spin fa-angle-left');
  }, 300);
  // show content
  //$('#content').removeClass('none');
  // jquery lazyload
  // placeholder not work due to zepto
  $('img.lazy').lazyload({
    load: function () {
      $(this).closest('.lazy-box').removeClass('unloaded');
    },
    threshold: 200,
    effect: 'fadeIn'
  });
}

function toggleFooter(show) {
  var $footer = $('#footer');
  if (show) {
    $footer.removeClass('none');
  } else {
    $footer.addClass('none');
  }
}
function makeFooterToggle() {
  var $window = $(window);
  var H = $window.height();
  $window.on('resize', _.debounce(function () {
    var h = $window.height();
    if (h < 0.7 * H) {
      toggleFooter(false);
    } else {
      // fix weixin keyboard toggle bug
      $window.scrollTop($window.scrollTop() - 1);
      toggleFooter(true);
    }
    H = h;
  }, 300));
}

function notify(msg, back) {
  // message
  alertify.alert(msg, function () {
    // redirect
    if (back === true) {
      history.back();
    } else if (_.isString(back)) {
      location.href = back;
    }
  });
}
function ask(msg, cb) {
  alertify.confirm(msg, cb);
}

function calcPrice(item) {
  item._price = item.promotingPrice != null ?
    item.promotingPrice :
    item.shopPrice;
}
function checkOnSale(item, num) {
  return item.onSale && item.store >= (num || 0);
}
function fetchOrderProfile(cb) {
  var profile = store.get('orderProfile');
  cb(profile);
}
function saveOrderProfile(profile, cb) {
  store.set('orderProfile', _.pick(profile, [
    'area', 'name', 'shortTel', 'tel', 'block', 'flat'
  ]));
  cb();
}
function saveCart(xItems, cb) {
  store.set('cartItems', _.map(xItems, function (xItem) {
    return _.pick(xItem, ['id', 'num', 'checked']);
  }));
  cb();
}
function saveCurrOrder(xItems, cb) {
  store.set('currOrderItems', _.map(xItems, function (xItem) {
    return _.pick(xItem, ['id', 'num']);
  }));
  cb();
}

function setTitle(title, shortTitle) {
  $('title').text(title);
  $('.title-text').text(shortTitle || title);
}

/* init */
var params = searchToParams(location.href);
var area;

function initPage(cb) {
  if (!$().text || !store.enabled) {<commit_msg>cart/order items sort by id<commit_after>function searchToParams(search) {
  var pat = /([^?=&#]*)=([^?=&#]+)/g, params = {};
  decodeURIComponent(search)
    .replace(pat, function (a, b, c) {
      if (b in params) {
        if (!_.isArray(params[b])) {
          params[b] = [params[b]];
        }
        params[b].push(c);
      } else {
        params[b] = c;
      }
    });
  return params;
}

function paramsToSearch(params) {
  return _.reduce(params, function (search, val, key) {
    var arr = _.isArray(val) ? val : [val];
    return search + (search ? '&' : '?') +
      _.reduce(arr, function (segs, v) {
        return segs + (segs ? '&' : '') + key + '=' + encodeURIComponent(v);
      }, '');
  }, '');
}

function loadReady() {
  _.delay(function () {
    $('.back-btn').find('i').toggleClass('fa-spinner fa-spin fa-angle-left');
  }, 300);
  // show content
  //$('#content').removeClass('none');
  // jquery lazyload
  // placeholder not work due to zepto
  $('img.lazy').lazyload({
    load: function () {
      $(this).closest('.lazy-box').removeClass('unloaded');
    },
    threshold: 200,
    effect: 'fadeIn'
  });
}

function toggleFooter(show) {
  var $footer = $('#footer');
  if (show) {
    $footer.removeClass('none');
  } else {
    $footer.addClass('none');
  }
}
function makeFooterToggle() {
  var $window = $(window);
  var H = $window.height();
  $window.on('resize', _.debounce(function () {
    var h = $window.height();
    if (h < 0.7 * H) {
      toggleFooter(false);
    } else {
      // fix weixin keyboard toggle bug
      $window.scrollTop($window.scrollTop() - 1);
      toggleFooter(true);
    }
    H = h;
  }, 300));
}

function notify(msg, back) {
  // message
  alertify.alert(msg, function () {
    // redirect
    if (back === true) {
      history.back();
    } else if (_.isString(back)) {
      location.href = back;
    }
  });
}
function ask(msg, cb) {
  alertify.confirm(msg, cb);
}

function calcPrice(item) {
  item._price = item.promotingPrice != null ?
    item.promotingPrice :
    item.shopPrice;
}
function checkOnSale(item, num) {
  return item.onSale && item.store >= (num || 0);
}
function fetchOrderProfile(cb) {
  var profile = store.get('orderProfile');
  cb(profile);
}
function saveOrderProfile(profile, cb) {
  store.set('orderProfile', _.pick(profile, [
    'area', 'name', 'shortTel', 'tel', 'block', 'flat'
  ]));
  cb();
}
function saveCart(xItems, cb) {
  store.set('cartItems', _(xItems).chain().map(function (xItem) {
    return _.pick(xItem, ['id', 'num', 'checked']);
  }).sortBy('id').value());
  cb();
}
function saveCurrOrder(xItems, cb) {
  store.set('currOrderItems', _(xItems).chain().map(function (xItem) {
    return _.pick(xItem, ['id', 'num']);
  }).sortBy('id').value());
  cb();
}

function setTitle(title, shortTitle) {
  $('title').text(title);
  $('.title-text').text(shortTitle || title);
}

/* init */
var params = searchToParams(location.href);
var area;

function initPage(cb) {
  if (!$().text || !store.enabled) {
{'fraction_non_alphanumeric': 0.20679839249832552, 'fraction_numerical': 0.004353650368385801, 'mean_word_length': 3.0743519781718964, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2043357', 'n_tokens_mistral': 2117, 'n_tokens_neox': 2104, 'n_words': 430}