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

    changeCriteria(e) {
        this.model.switchingCriteria = $(e.target).val();
        this.model.notifyAll();
    }

    changeHysteresis(e) {
        validateRange($(e.target), 1, 0, 20, 5);
        this.model.hysteresis = $(e.target).val();
    }

    selectAutomatic(e) {
        console.log($(e.target));
        var oppositeTack = ($(e.target).val() == "port") ? "stbd" : "port";
        $(e.target).closest('.radio-container').siblings().first().find('input[value="' + oppositeTack + '"]').prop('checked', true);
        $('#radio-container-1 input[name="manual-select"], #radio-container-2 input[name="manual-select"]').prop('checked', false);

        var portSensor = $('#radio-container-1 input[value="port"]:checked, #radio-container-2 input[value="port"]:checked').attr('data-sensor');
        var stbdSensor = $('#radio-container-1 input[value="stbd"]:checked, #radio-container-2 input[value="stbd"]:checked').attr('data-sensor');
        this.model.selectModeAutomatic(--portSensor, --stbdSensor);
        this.model.notifyAll();
    }

    selectManual(e) {
        this.model.selectModeManual($(e.target).val() - 1);
        this.model.notifyAll();
    }
}