import Vue from 'vue';
import lib from 'lib';
import BDY from '../../../depend/BDY/BDY';

export default {
	data () {
		return {
			game_id : lib.getLocalData("game_id"),
			game_zone : lib.getLocalData("game_zone"),
			user_id : lib.getLocalData("user_id"),
			staticUrl : lib.staticUrl,
            matchInfo : {},
            team_win : {},
            team_lose : {} 
		}
	},
	mounted () {
		this.getData();
	},
	beforeDestroy () {
	},
	methods: {
		getData () {
			let self = this;
			let api =  `${lib.apiUrl}/v3/player/dx5/${self.user_id}/game/${self.game_id}/`;
			lib.get(api, (ret) => {
                if(ret.player_game_list && ret.player_game_list[0]) {
                    self.formatData(ret.player_game_list[0]);
                }
            })
		},
        formatData (data) {
            this.matchInfo = {
                game_id : data.game_id,
				start_timestamp : data.start_timestamp.slice(-8,-3),
                game_length_in_minute : data.game_length_in_minute
            }
            this.team_win = data.team_win;
            this.team_lose = data.team_lose;
        },
		showFulData : function(event){
			var target = event.target;
			$(target).closest('li').removeClass('hiding-data').addClass("showing-data");
		},
		hideFulData : function(event){
			var target = event.target;
			$(target).closest('li').removeClass("showing-data").addClass('hiding-data');
		}
	}
}