{"size": 2324, "ext": "js", "max_stars_repo_path": "static/app.js", "max_stars_repo_name": "suapapa/twitch-lotto", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "static/app.js", "max_issues_repo_name": "suapapa/twitch-lotto", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "static/app.js", "max_forks_repo_name": "suapapa/twitch-lotto", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.6666666667, "max_line_length": 80, "alphanum_fraction": 0.3537005164}
var store = {
    state: {
        attendees: [],
        count: 3,
    }
}

new Vue({
    el: '#navcard',
    data: {
        iscard: true,
        shared: store.state,
    },
    methods: {
        fetch: function () {
            axios.get('/event')
                .then(resp => {
                    // console.log(resp)
                    resp.data.forEach(e => {
                        e.won = false
                        e.picked = false
                        this.shared.attendees.push(e)
                    })
                    this.iscard = false
                })
                .catch(error => {
                    alert(error.response.data.message)
                })
        },
        lotto: function () {
            var self = this
            var len = this.shared.attendees.length
            var cnt = parseInt(Math.random() * len * 20)
            while (this.shared.count) {
                var i = -1
                while (true) {
                    i++
                    setTimeout(function (i) {
                        self.shared.attendees[i % len].picked = true;
                        if (i > 0) {
                            self.shared.attendees[(i - 1) % len].picked = false;
                        }
                    }, 12, i)
                    if (i < cnt - 1) {
                        continue
                    }

                    cnt = parseInt(Math.random() * len * 20)
                    if (this.shared.attendees[i % len].won) {
                        continue
                    }
                    setTimeout(function (i) {
                        self.shared.attendees[i % len].won = true
                    }, 10, i)
                    break
                }
                this.shared.count -= 1
            }
        }
    }
})

new Vue({
    el: '#members',
    data: {
        shared: store.state,
    },
    filters: {
        truncate: function (str, limit) {
            if (str.length > limit) {
                str = str.substring(0, limit - 3) + '...'
            }
            return str
        }
    },
    methods: {
        exclude: function (index) {
            if (this.shared.attendees[index].won) {
                this.shared.count += 1
            }
            this.shared.attendees.splice(index, 1)
        }
    }
})