class ExpFormatController extends BasicController {
    constructor(model) {
        super(model);
    }

    changeFormat(e) {
        var index = $(e.target).index();
        var channel = $(e.target).closest('div').children().eq(index - 1).attr('data-channel');
        var format = $(e.target).find(":selected").val();
        
        if (this.model.formatData.hasOwnProperty(channel)) {
            this.model.formatData[channel].format = format;
        } else {
            this.model.formatData[channel] = { format: format, name: "" };
        }
    }

    changeName(e) {
        var index = $(e.target).index();
        var channel = $(e.target).closest('div').children().eq(index - 2).attr('data-channel');
        var name = $(e.target).val();

        if (this.model.formatData.hasOwnProperty(channel)) {
            this.model.formatData[channel].name = name;
        } else {
            this.model.formatData[channel] = { format: 0, name: name };
        }
    }

    enableDistribution(e) {
        this.model.enableDistribution = $(e.target).is(':checked');
    }
}