Uname: Linux webm012.cluster130.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 8.0.30 [ PHP INFO ] PHP os: Linux
Server Ip: 145.239.37.162
Your Ip: 216.73.216.190
User: dreampi (1009562) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : formatting.js
import {settings} from '../../../plugins/settings.js'

const thousandSeparatorMap = {
      1: ',',
      2: '.',
      3: ' ',
      4: ' '
}

const decimalSeparatorMap = {
      1: '.',
      2: ',',
      3: '.',
      4: ','
}


function getCurrencySymbol () {
  return settings.payments.currency
}

function getPriceThousandSeparator () {
  return thousandSeparatorMap[settings.payments.priceSeparator]
}

function getPriceDecimalSeparator () {
  return decimalSeparatorMap[settings.payments.priceSeparator]
}

function getPriceNumberOfDecimalPlaces () {
  return settings.payments.priceNumberOfDecimals
}

function getPricePrefix () {
  if (settings.payments.priceSymbolPosition === 'after' || settings.payments.priceSymbolPosition === 'afterWithSpace') {
    return ''
  } else if (settings.payments.priceSymbolPosition === 'before') {
    return getCurrencySymbol()
  } else {
    return getCurrencySymbol() + ' '
  }
}

function getPriceSuffix () {
  if (settings.payments.priceSymbolPosition === 'before' || settings.payments.priceSymbolPosition === 'beforeWithSpace') {
    return ''
  } else if (settings.payments.priceSymbolPosition === 'after') {
    return getCurrencySymbol()
  } else {
    return ' ' + getCurrencySymbol()
  }
}

function useFormattedPrice (price) {
  let showCurrency = !settings.payments.hideCurrencySymbolFrontend
  let decimalPlaces = getPriceNumberOfDecimalPlaces()
  let thousandSeparator = getPriceThousandSeparator()
  let decimalSeparator = getPriceDecimalSeparator()
  let pricePrefix = getPricePrefix()
  let priceSuffix = getPriceSuffix()

  let i = parseInt(price = Math.abs(+price || 0).toFixed(decimalPlaces)) + ''
  let j = i.length > 3 ? i.length % 3 : 0

  return (showCurrency ? pricePrefix : '') + (j ? i.substr(0, j) + thousandSeparator : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousandSeparator) + (decimalPlaces ? decimalSeparator + Math.abs(price - i).toFixed(decimalPlaces).slice(2) : '') + (showCurrency ? priceSuffix : '')
}

function capitalizeFirstLetter (string) {
  return string.charAt(0).toUpperCase() + string.slice(1)
}

function useRandomIntFromInterval (min, max) {
  // min and max included
  return Math.floor(Math.random() * (max - min + 1) + min)
}

function useCurrencyOptions () {
  return  {
    thousands: getPriceThousandSeparator(),
    decimal: getPriceDecimalSeparator(),
    precision: getPriceNumberOfDecimalPlaces(),
    suffix: getPriceSuffix(),
    prefix: getPricePrefix(),
  }
}

export {
  useCurrencyOptions,
  useFormattedPrice,
  useRandomIntFromInterval,
  capitalizeFirstLetter,
  getCurrencySymbol,
}
© 2026 GrazzMean-Shell