/* * 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. */ //these settings are defined in the firmware (conf_defaults.lua) and will be initialized in loadSettings() var settings = {}; var settingsPopup; //wrapper to prevent scoping issues in showSettings() function openSettingsWindow() { settingsWindow.loadSettings(function() { // reload settings settingsPopup.open(); }); } function SettingsWindow() { this.wifiboxURL; this.wifiboxCGIBinURL; this.window; this.btnOK; this.form; this.timeoutTime = 3000; this.saveSettingsTimeoutTime = 8000; this.retryDelay = 2000; // retry setTimout delay this.retryLoadSettingsDelay; // retry setTimout instance this.retrySaveSettingsDelay; // retry setTimout instance this.retryResetSettingsDelay; // retry setTimout instance this.restoreStateField this.restoredStateHideDelayTime = 3000; this.restoredStateHideDelay; // setTimout instance // Events SettingsWindow.SETTINGS_LOADED = "settingsLoaded"; this.updatePanel = new UpdatePanel(); this.printerPanel = new PrinterPanel(); var _networkPanel = new NetworkPanel(); var self = this; this.init = function(wifiboxURL,wifiboxCGIBinURL) { this.wifiboxURL = wifiboxURL; this.wifiboxCGIBinURL = wifiboxCGIBinURL; this.window = $("#popupSettings"); this.btnOK = this.window.find(".btnOK"); settingsPopup = new Popup($("#popupSettings"), $("#popupMask")); settingsPopup.setEnterEnabled(false); settingsPopup.setAutoCloseEnabled(false); this.btnOK.on('touchstart mousedown',settingsPopup.commit); $("#popupSettings").bind("onPopupCancel", function() { settingsPopup.close(); } ); $("#popupSettings").bind("onPopupCommit", self.submitwindow); this.window.find("#settingsContainer").load("settings.html", function() { console.log("Settings:finished loading settings.html, now loading settings..."); self.form = self.window.find("form"); self.form.submit(function (e) { self.submitwindow(e); }); $.ajax({ url: self.wifiboxURL + "/printer/listall", dataType: 'json', timeout: self.timeoutTime, success: function(response) { console.log("Settings:printer/listall response: ",response.data.printers); //console.log(" this: ",this); // network panel console.log("initialize network panel"); var $networkPanelElement = self.form.find("#networkPanel"); _networkPanel.init(wifiboxURL,wifiboxCGIBinURL,$networkPanelElement); $.each(response.data.printers, function(key, value) { // console.log(key,value); $('#printerType').append($('