<commit_before><template>
<div id="timer" class="text-center">
    <div v-bind:class="['h2', [this.running ? 'text-success' : '']]">
        {{ hours }}:{{ minutes }}:{{ seconds }}
    </div>
    <div class="btn-group btn-group-sm" role="group">
        <button id="timer-start"
                class="btn btn-success"
                v-on:click="toggle"
                v-bind:disabled="this.running">Start</button>
        <button id="timer-stop"
                class="btn btn-success"
                v-on:click="toggle"
                v-bind:disabled="!this.running">Stop</button>
        <button id="timer-reset"
                class="btn btn-danger"
                v-on:click="reset"
                v-bind:disabled="this.total === 0">Reset</button>
    </div>
</div>
</template>


<script>
export default {
    data() {
        return {
            running: false,
            total: 0,
            hours: '00',
            minutes: '00',
            seconds: '00',
        };
    },
    mounted() {
        this.bus.$on('toggleTimer', () => {
            this.toggle();
        });
    },
    methods: {
        tick: function () {
            ++this.total;
            this.hours = pad(Math.floor(this.total / 3600));
            this.minutes = pad(Math.floor(this.total % 3600 / 60));
            this.seconds = pad(this.total % 3600 % 60);
        },
        toggle: function () {
            this.running = !this.running;
            if (this.running) {
                this.interval = setInterval(this.tick, 1000, this);
            }
            else {
                clearInterval(this.interval);
            }
        },
        reset: function() {
            this.total = 0;
            this.hours = '00';
            this.minutes = '00';
            this.seconds = '00';
        }
    }
}
</script><commit_msg>Allow an offset to be provided to Timer.<commit_after><template>
<div id="timer" class="text-center">
    <div v-bind:class="['h2', [this.running ? 'text-success' : '']]">
        {{ hours }}:{{ minutes }}:{{ seconds }}
    </div>
    <div class="btn-group btn-group-sm" role="group">
        <button id="timer-start"
                class="btn btn-success"
                v-on:click="toggle"
                v-bind:disabled="this.running">Start</button>
        <button id="timer-stop"
                class="btn btn-success"
                v-on:click="toggle"
                v-bind:disabled="!this.running">Stop</button>
        <button id="timer-reset"
                class="btn btn-danger"
                v-on:click="reset"
                v-bind:disabled="this.total === 0">Reset</button>
    </div>
</div>
</template>


<script>
export default {
    data() {
        return {
            running: false,
            total: 0,
            hours: '00',
            minutes: '00',
            seconds: '00',
        };
    },
    methods: {
        tick: function () {
            ++this.total;
            this.hours = pad(Math.floor(this.total / 3600));
            this.minutes = pad(Math.floor(this.total % 3600 / 60));
            this.seconds = pad(this.total % 3600 % 60);
        },
        toggle: function (offset) {
            this.running = !this.running;
            if (typeof offset === 'number') {
                this.total = offset;
            }
            if (this.running) {
                this.interval = setInterval(this.tick, 1000, this);
            }
            else {
                clearInterval(this.interval);
            }
        },
        reset: function() {
            this.total = 0;
            this.hours = '00';
            this.minutes = '00';
            this.seconds = '00';
        }
    },
    mounted() {
        this.bus.$on('timerToggle', function(offset) {
            this.toggle(offset);
        }.bind(this));
    }
}
</script>
{'fraction_non_alphanumeric': 0.159958180867747, 'fraction_numerical': 0.01881860951385259, 'mean_word_length': 1.4438058748403575, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1776576', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1092, 'n_words': 203}