Initial Commit
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
Number.prototype.toFixedDown = function (digits) {
|
||||
var re = new RegExp("(\\d+\\.\\d{" + digits + "})(\\d)");
|
||||
var m = this.toString().match(re);
|
||||
return m ? parseFloat(m[1]) : this.valueOf();
|
||||
};
|
||||
|
||||
Number.prototype.truncate = function (digits) {
|
||||
var num = this.valueOf().toFixedDown(digits);
|
||||
num = num.toString();
|
||||
var intero = String(num.split('.')[0]);
|
||||
var fraction = String(num.split('.')[1]);
|
||||
var padding = '';
|
||||
if (isNaN(intero)) return '';
|
||||
|
||||
if (fraction == 'undefined') {
|
||||
fraction = '';
|
||||
padding = new Array(Math.max(digits - fraction.length, 0) + 1).join('0');
|
||||
if (digits > 0) {
|
||||
num += '.' + padding;
|
||||
}
|
||||
} else {
|
||||
padding = new Array(Math.max(digits - fraction.length, 0) + 1).join('0');
|
||||
num += padding;
|
||||
}
|
||||
return num;
|
||||
};
|
||||
|
||||
//funzione per l'arrotondamento delle cifre decimali in eccesso dal 5
|
||||
Number.prototype.toFixedExcess = function(precision){
|
||||
precision = (parseInt(precision) == 0) ? 0:(parseInt(precision) || 2);
|
||||
var num = this.valueOf();
|
||||
var pow = Math.pow(10,precision);
|
||||
return (Math.round( num * pow ) / pow).toFixed(precision);
|
||||
};
|
||||
|
||||
//Funzione per arrotondare correttamente i numeri in modo da correggere l'errore delle somme e differenze
|
||||
function myParseFloat(number){
|
||||
//console.log("MyParseFloat-Old: "+number);
|
||||
var newnumber = new Number(number+'').toFixed(12);
|
||||
//console.log("MyParseFloat-New: "+newnumber);
|
||||
return parseFloat(newnumber);
|
||||
}
|
||||
|
||||
//Funzione che implementa il pad left di una stringa
|
||||
Number.prototype.padLeft = function (n,str) {
|
||||
return (this < 0 ? '-' : '') +
|
||||
Array(n-String(Math.abs(this)).length+1)
|
||||
.join(str||'0') +
|
||||
(Math.abs(this));
|
||||
};
|
||||
|
||||
const checkIfAddressIsInArea = (location, area) => {
|
||||
if (google.maps.geometry.poly.containsLocation(location, area)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const checkIfAddressIsInAreaLatLon = (lat, lon) => {
|
||||
const location = new google.maps.LatLng(lat, lon);
|
||||
if (google.maps.geometry.poly.containsLocation(location, area)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user