//-------------------------------------
//
//-------------------------------------
class FaroExportModel extends ObservableModel {
    constructor() {
        super();

        // Class constants
        this.cFaro = "Faro";
        this.cExportEnabled = "ExportEnabled";

        // Class properties
        this.FaroData = new Object();
        this.FaroExportEnabled = false;

        this.init();
    }

    init() {
        var deferred = new $.Deferred();
        var self = this;

        readSection("Faro").done(function(section) {
            self.FaroData = $.extend(true, self.FaroData, JSON.parse(section));

            self.FaroExportEnabled = self.FaroData[self.cExportEnabled.toLowerCase()] == 'true';

            self.notifyAll();
            deferred.resolve();
        });

        return deferred.promise();
    }

    persistData() {
        return writeSingle(this.cFaro, this.cExportEnabled, this.FaroExportEnabled, 'Faro');
    }
}

//-------------------------------------
//
//-------------------------------------
class FaroExportView extends BasicView {
    constructor(controller) {
        super(controller);
    }

    bindEvents() {
        super.bindEvents();

        $('#faro-export-enable').on('click', this.controller.enableExport.bind(this.controller));
    }

    update(model) {
        console.log(model);
        $('#faro-export-enable').prop('checked', model.FaroExportEnabled);
    }
}

//-------------------------------------
//
//-------------------------------------
class FaroExportController extends BasicController {
    constructor(model) {
        super(model);
    }

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