app.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. Number.prototype.currency = function() { return '$' + this.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,') };
  2. function seconds_to_time(s) {
  3. var duration = moment.duration(s, 'seconds');
  4. return duration.format("DD-hh:mm");
  5. }
  6. function ts_to_remaining(ts) {
  7. return moment.unix(ts).fromNow();
  8. }
  9. function log() {
  10. console.log('LOG >>>', arguments);
  11. }
  12. function get_items() {
  13. fetch('db.json')
  14. .then(function(response) {
  15. return response.json();
  16. })
  17. .then(function(myJson) {
  18. app.items = myJson;
  19. });
  20. }
  21. var app = new Vue({
  22. el: '#app',
  23. data: {
  24. title: "egunner",
  25. items: [],
  26. debug: false
  27. },
  28. mounted: function () {
  29. // hide splash
  30. var splash = document.getElementById("splash");
  31. splash.style.display = "none";
  32. // unhide main container after mount
  33. this.$el.style.display = "block";
  34. },
  35. computed: {
  36. },
  37. methods: {
  38. },
  39. watch: {
  40. },
  41. });
  42. get_items();
  43. window.setInterval(function(){
  44. console.log('refresh');
  45. get_items();
  46. }, 5000);