AlkantarClanX12
Current Path : /proc/self/root/home/thanudqk/siamfreetour.com/ |
Current File : //proc/self/root/home/thanudqk/siamfreetour.com/app.js |
var getJSON = function (url, callback) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'json'; xhr.onload = function () { var status = xhr.status; if (status === 200) { callback(null, xhr.response); } else { callback(status, xhr.response); } }; xhr.send(); }; Number.prototype.pad = function (size) { var s = String(this); while (s.length < (size || 2)) { s = "0" + s; } return s; } var app = new Vue({ el: '#App', data: { turnover: [], withTickets: [2, 3, 4, 7, 8, 9, 10] }, mounted() { getJSON('https://guaranteedboard-default-rtdb.firebaseio.com/1PyKdlHuG83KXM7JtRoH-pv6qZMSC1iqqduQizslbyek/TH.json', (err, data) => { data.shift() this.turnover = data; }); }, computed: { top5Turnover() { return this.turnover.splice(0, 15) }, }, methods: { formatNumber(amount, decimalCount = 2, decimal = ".", thousands = ",") { try { decimalCount = Math.abs(decimalCount); decimalCount = isNaN(decimalCount) ? 2 : decimalCount; const negativeSign = amount < 0 ? "-" : ""; let i = parseInt(amount = Math.abs(Number(amount) || 0).toFixed(decimalCount)).toString(); let j = (i.length > 3) ? i.length % 3 : 0; return negativeSign + (j ? i.substr(0, j) + thousands : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands) + (decimalCount ? decimal + Math.abs(amount - i).toFixed(decimalCount).slice(2) : ""); } catch (e) { console.log(e) } }, padNumber(n, offset = false) { var start = 0 if (offset) { start += 15 } return (parseInt((start + n)) + 1).pad(2) }, hasTicket(place) { return this.withTickets.indexOf(parseInt(place)) > -1 ? true : false } } })