forked from rc/aircox
		
	work on player
This commit is contained in:
		
							
								
								
									
										18
									
								
								assets/js/app.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								assets/js/app.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
import Vue from 'vue';
 | 
			
		||||
import Buefy from 'buefy';
 | 
			
		||||
 | 
			
		||||
Vue.use(Buefy);
 | 
			
		||||
 | 
			
		||||
export var app = null;
 | 
			
		||||
 | 
			
		||||
function loadApp() {
 | 
			
		||||
    app = new Vue({
 | 
			
		||||
      el: '#app',
 | 
			
		||||
      delimiters: [ '[[', ']]' ],
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
window.addEventListener('load', loadApp);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,18 +1,4 @@
 | 
			
		||||
import Vue from 'vue';
 | 
			
		||||
import Buefy from 'buefy';
 | 
			
		||||
 | 
			
		||||
Vue.use(Buefy);
 | 
			
		||||
 | 
			
		||||
var app = null;
 | 
			
		||||
 | 
			
		||||
function loadApp() {
 | 
			
		||||
    app = new Vue({
 | 
			
		||||
      el: '#app',
 | 
			
		||||
      delimiters: [ '[[', ']]' ],
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
window.addEventListener('load', loadApp);
 | 
			
		||||
import app from './app';
 | 
			
		||||
import LiveInfo from './liveInfo';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										37
									
								
								assets/js/liveInfo.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								assets/js/liveInfo.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,37 @@
 | 
			
		||||
 | 
			
		||||
export default class {
 | 
			
		||||
    constructor(url, timeout) {
 | 
			
		||||
        this.url = url;
 | 
			
		||||
        this.timeout = timeout;
 | 
			
		||||
        this.promise = null;
 | 
			
		||||
        this.items = [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    drop() {
 | 
			
		||||
        this.promise = null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fetch() {
 | 
			
		||||
        const promise = fetch(this.url).then(response =>
 | 
			
		||||
            response.ok ? response.json()
 | 
			
		||||
                        : Promise.reject(response)
 | 
			
		||||
        ).then(data => {
 | 
			
		||||
            this.items = data;
 | 
			
		||||
            return this.items
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
        this.promise = promise;
 | 
			
		||||
        return promise;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    refresh() {
 | 
			
		||||
        const promise = this.fetch();
 | 
			
		||||
        promise.then(data => {
 | 
			
		||||
            if(promise != this.promise)
 | 
			
		||||
                return [];
 | 
			
		||||
 | 
			
		||||
            window.setTimeout(() => this.refresh(), this.timeout*1000)
 | 
			
		||||
        })
 | 
			
		||||
        return promise
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user