currencySwap


 

Number.prototype.pad = function(size) {
    var s = String(this);
    while (s.length < (size || 2)) {s = "0" + s;}
    return s;
}
Examples:

(9).pad();  //returns "09"


const swapTablo = d => {
  d = d.toString()
  while (d.length <  3) {d = '0' + d;}
  return d.toString().slice(0, -2).replace(/\B(?=(\d{3})+(?!\d))/g, ',') +
      `.${d.slice(-2)}`;
};

 

    format (d) {
      const res = (parseFloat(d) * 0.01).toFixed(2).toString().replace('.', ',')
      return res.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ')
    },
    format (d) {
      return (parseFloat(d) * 0.01).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ')
    },

 

function currencySwap(d){
    return d.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ")  + " тыс. руб." ;
}


function numberWithSpaces(x) {
    var parts = x.toString().split(".");
    parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, " ");
    return parts.join(".");
}

 

 

 

# авто высота для textarea
var text = jQuery('#your_textarea').val(),
    // look for any "\n" occurences
    matches = text.match(/\n/g),
    breaks = matches ? matches.length : 2;

jQuery('#your_textarea').attr('rows',breaks + 2);