AlkantarClanX12

Your IP : 18.220.97.161


Current Path : /home/thanudqk/public_html/LEGACY/
Upload File :
Current File : //home/thanudqk/public_html/LEGACY/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: [],
      totaldeposit: [],
    },
    mounted(){
      getJSON('https://guaranteedboard-default-rtdb.firebaseio.com/1PyKdlHuG83KXM7JtRoH-pv6qZMSC1iqqduQizslbyek/VN.json',
        (err, data) => {
          data.shift()
          this.turnover = data;
      });

      getJSON('https://guaranteedseat.firebaseio.com/VN15wEcbGFTW1DLPAijzDFCbYrUMse_Jh3z9xUOdmLjDl8/totaldeposit.json',
        (err, data) => {
          data.shift()
          this.totaldeposit = data;
      });
    },
    computed:{
        top5Turnover() {
          return this.turnover.splice(0, 15)
        },
        top5TotalDeposit() {
          console.log(this.totaldeposit)
          return this.totaldeposit.splice(16, 50)
        },
    },
    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)
      }
    }
  })