<commit_before>/* replaceUrlParam - http://stackoverflow.com/questions/7171099/how-to-replace-url-parameter-with-javascript-jquery */
function replaceUrlParam(e,r,a){var n=new RegExp("("+r+"=).*?(&|$)"),c=e;return c=e.search(n)>=0?e.replace(n,"$1"+a+"$2"):c+(c.indexOf("?")>0?"&":"?")+r+"="+a};

var $ = jQuery;

// Money formatting
if ((typeof Shopify) === 'undefined') { Shopify = {}; }
if (!Shopify.formatMoney) {
  Shopify.formatMoney = function(cents, format) {
    // console.log("Shopify.formatMoney Format: ", format);
    var value = '',
        placeholderRegex = /\{\{\s*(\w+)\s*\}\}/,
        formatString = (format || "{% raw %}${{amount}}{% endraw %}");
    // console.log("Format String: ", formatString);
    // console.log(formatString.match(placeholderRegex))
    if (typeof cents == 'string') {
      cents = cents.replace('.','');
    }

    function defaultOption(opt, def) {
      return (typeof opt == 'undefined' ? def : opt);
    }

    function formatWithDelimiters(number, precision, thousands, decimal) {
      precision = defaultOption(precision, 2);
      thousands = defaultOption(thousands, ',');
      decimal   = defaultOption(decimal, '.');

      if (isNaN(number) || number == null) {
        return 0;
      }

      number = (number/100.0).toFixed(precision);

      var parts   = number.split('.'),
          dollars = parts[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + thousands),
          cents   = parts[1] ? (decimal + parts[1]) : '';

      return dollars + cents;
    }

    switch(formatString.match(placeholderRegex)[1]) {
      case 'amount':
        value = formatWithDelimiters(cents, 2);
        break;
      case 'amount_no_decimals':
        value = formatWithDelimiters(cents, 0);
        break;
      case 'amount_with_comma_separator':
        value = formatWithDelimiters(cents, 2, '.', ',');
        break;
      case 'amount_no_decimals_with_comma_separator':
        value = formatWithDelimiters(cents, 0, '.', ',');
        break;
    }

    return formatString.replace(placeholderRegex, value);
  };
}

// Functions
window.concrete = window.concrete || {};
concrete.cacheSelectors = function () {
  concrete.cache = {
    // General
    $html : $('html'),
    $body : $(document.body),
    // Visibility
    $toggleItemLink : $('.js_toggle'),
    $revealItemLink : $('.js_open'),
    $hideItemLink : $('.js_close'),
    // Collection Pages
    $changeView : $('.change-view'),
    // Products
    $productMainImage : $('#ProductMainImage'),
    $productThumbnailImages : $('#ProductThumbnailImages').find('a.thumbnail'),
    // Login Forms
    $recoverPasswordLink : $('#RecoverPasswordLink'),
    $hideRecoverPasswordLink : $('#HideRecoverPasswordLink'),
    $recoverPasswordForm : $('#RecoverPasswordForm'),
    $customerLoginForm : $('#LoginForm'),
    $passwordResetSuccess : $('#Reset<PASSWORD>')
    // Cart JS

    // TO DO

  };
};

// Initialize the functions
concrete.init = function () {
  concrete.cacheSelectors();
  concrete.visibilityManager();
  concrete.responsiveVideos();
  concrete.collectionViews();
  concrete.productImageSwitch();
  concrete.popups();
  concrete.loginForms();

  // Rivets seems to have a delay
  // This needs work!
  rivets.binders.cloak = {
    priority: -1000,
    bind: function(el) {
      el.style.opacity = 1;
    }
  }
};

// Get current window location
concrete.getHash = function () {
  return window.location.hash;
};

// responsive Videos<commit_msg>Notes for js to-do items<commit_after>/* replaceUrlParam - http://stackoverflow.com/questions/7171099/how-to-replace-url-parameter-with-javascript-jquery */
function replaceUrlParam(e,r,a){var n=new RegExp("("+r+"=).*?(&|$)"),c=e;return c=e.search(n)>=0?e.replace(n,"$1"+a+"$2"):c+(c.indexOf("?")>0?"&":"?")+r+"="+a};

var $ = jQuery;

// Money formatting
if ((typeof Shopify) === 'undefined') { Shopify = {}; }
if (!Shopify.formatMoney) {
  Shopify.formatMoney = function(cents, format) {
    // console.log("Shopify.formatMoney Format: ", format);
    var value = '',
        placeholderRegex = /\{\{\s*(\w+)\s*\}\}/,
        formatString = (format || "{% raw %}${{amount}}{% endraw %}");
    // console.log("Format String: ", formatString);
    // console.log(formatString.match(placeholderRegex))
    if (typeof cents == 'string') {
      cents = cents.replace('.','');
    }

    function defaultOption(opt, def) {
      return (typeof opt == 'undefined' ? def : opt);
    }

    function formatWithDelimiters(number, precision, thousands, decimal) {
      precision = defaultOption(precision, 2);
      thousands = defaultOption(thousands, ',');
      decimal   = defaultOption(decimal, '.');

      if (isNaN(number) || number == null) {
        return 0;
      }

      number = (number/100.0).toFixed(precision);

      var parts   = number.split('.'),
          dollars = parts[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + thousands),
          cents   = parts[1] ? (decimal + parts[1]) : '';

      return dollars + cents;
    }

    switch(formatString.match(placeholderRegex)[1]) {
      case 'amount':
        value = formatWithDelimiters(cents, 2);
        break;
      case 'amount_no_decimals':
        value = formatWithDelimiters(cents, 0);
        break;
      case 'amount_with_comma_separator':
        value = formatWithDelimiters(cents, 2, '.', ',');
        break;
      case 'amount_no_decimals_with_comma_separator':
        value = formatWithDelimiters(cents, 0, '.', ',');
        break;
    }

    return formatString.replace(placeholderRegex, value);
  };
}

// Functions
window.concrete = window.concrete || {};
concrete.cacheSelectors = function () {
  concrete.cache = {
    // General
    $html : $('html'),
    $body : $(document.body),
    // Visibility
    $toggleItemLink : $('.js_toggle'),
    $revealItemLink : $('.js_open'),
    $hideItemLink : $('.js_close'),
    // Collection Pages
    $changeView : $('.change-view'),
    // Products
    $productMainImage : $('#ProductMainImage'),
    $productThumbnailImages : $('#ProductThumbnailImages').find('a.thumbnail'),
    // Login Forms
    $recoverPasswordLink : $('#RecoverPasswordLink'),
    $hideRecoverPasswordLink : $('#HideRecoverPasswordLink'),
    $recoverPasswordForm : $('#RecoverPasswordForm'),
    $customerLoginForm : $('#LoginForm'),
    $passwordResetSuccess : $('#ResetSuccess')
    // Cart JS

    // TO DO
    // Move variables from "Variant Switching" function

  };
};

// Initialize the functions
concrete.init = function () {
  concrete.cacheSelectors();
  concrete.visibilityManager();
  concrete.responsiveVideos();
  concrete.collectionViews();
  concrete.productImageSwitch();
  concrete.popups();
  concrete.loginForms();

  // Rivets seems to have a delay
  // This needs work!
  rivets.binders.cloak = {
    priority: -1000,
    bind: function(el) {
      el.style.opacity = 1;
    }
  }
};

// Get current window location
concrete.getHash = function () {
  return window.location.hash;
};

// responsive Videos
{'fraction_non_alphanumeric': 0.18242857142857144, 'fraction_numerical': 0.008857142857142857, 'mean_word_length': 3.184698147041243, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 8, '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': '4969741', 'n_tokens_mistral': 2263, 'n_tokens_neox': 2165, 'n_words': 401}