0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-24 10:07:57 +01:00
doodle3d-client/js/settings/PrinterPanel.js

60 lines
1.7 KiB
JavaScript
Raw Normal View History

2013-12-20 16:31:41 +01:00
/*
* This file is part of the Doodle3D project (http://doodle3d.com).
*
* Copyright (c) 2013, Doodle3D
* This software is licensed under the terms of the GNU GPL v2 or later.
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
*/
2013-12-01 18:38:02 +01:00
function PrinterPanel() {
this.printerType;
var _api = new PrinterAPI();
var _form = new FormPanel();
2013-12-01 18:38:02 +01:00
// ui elements
var _element;
var _printerSelector;
var _printerSettings;
var _self = this;
this.init = function(wifiboxURL,wifiboxCGIBinURL,panelElement) {
2014-02-04 22:56:58 +01:00
_form.init(wifiboxURL,wifiboxCGIBinURL,panelElement)
_api.init(wifiboxURL,wifiboxCGIBinURL);
_element = panelElement;
_printerSelector = _element.find("#printerType");
_printerSelector.change(_self.printerSelectorChanged);
// we use readForm to get all the settings we need to
// reload after changing printer type
_printerSettings = _form.readForm();
var gcodePanel = _element.find("#gcodePanel");
gcodePanel.coolfieldset({collapsed:true});
2013-12-01 18:38:02 +01:00
}
this.load = function(completeHandler) {
_api.listAll(function(data) {
$.each(data.printers, function(key, value) {
// console.log(key,value);
$('#printerType').append($('<option>').text(value).attr('value', key));
});
completeHandler();
});
}
2013-12-01 18:38:02 +01:00
this.printerSelectorChanged = function(e) {
_self.printerType = _printerSelector.find("option:selected").val();
var settings = {};
settings[_printerSelector.attr("name")] = _self.printerType;
_form.saveSettings(settings,function(validated) {
if(!validated) return;
_form.loadSettings(_printerSettings,function(settings) {
_form.fillForm(settings);
});
2013-12-01 18:38:02 +01:00
});
}
2013-12-20 16:31:41 +01:00
}