// demonstrates how to add custom autoDJ script

autoDJ.sources.myCustomSource = { // 'myCustomSource' needs to be unique in order to not interferre with other addons !!!
    name: function () {
        return 'Played# > X (autoDJ script)'
    },
    order: 50,
    config: {
        playLimit: 10 // the default
    },
    loadConfig: function (panel) {
        app.getValue('sampleAutoDJ_Addon', this.config);
        panel.innerHTML =
            '<div >' +
            '  <label>Play counter treshold:</label>' +
            '  <input type="number" min="0" max="500" class="thinControl">' +
            '</div>';
        this.number = qe(panel, '[type=number]');
        this.number.value = this.config.playLimit;
    },
    saveConfig: function (panel) {
        this.number = qe(panel, '[type=number]');
        this.config.playLimit = this.number.value;
        app.setValue('sampleAutoDJ_Addon', this.config);
    },
    execute: function (addCount) {
        this.config = app.getValue('sampleAutoDJ_Addon', this.config);
        return autoDJ.getRandomList(app.db.getTracklist('SELECT * FROM Songs WHERE PlayCounter > ' + this.config.playLimit, -1), addCount);
    }
}