Restore status text #152

This commit is contained in:
peteruithoven 2014-01-02 15:09:36 +01:00
parent dfcd3ee2c2
commit d5220225cc
2 changed files with 19 additions and 1 deletions

View File

@ -32,6 +32,7 @@ function SettingsWindow() {
this.apFieldSet;
this.clientFieldSet;
this.restoreStateField;
this.networks;
this.currentNetwork; // the ssid of the network the box is on
this.selectedNetwork; // the ssid of the selected network in the client mode settings
@ -45,6 +46,9 @@ function SettingsWindow() {
this.retrieveNetworkStatusDelay; // setTimout delay
this.retrieveNetworkStatusDelayTime = 1000;
this.restoredStateHideDelayTime = 3000;
this.restoredStateHideDelay // setTimout instance
// Events
SettingsWindow.SETTINGS_LOADED = "settingsLoaded";
@ -115,7 +119,8 @@ function SettingsWindow() {
self.apFieldSet = self.form.find("#apSettings");
self.clientFieldSet = self.form.find("#clientSettings");
self.btnRestoreSettings = self.form.find("#restoreSettings");
self.restoreStateField = self.form.find("#restoreState");
btnAP.on('touchstart mousedown',self.showAPSettings);
btnClient.on('touchstart mousedown',self.showClientSettings);
btnRefresh.on('touchstart mousedown',self.refreshNetworks);
@ -276,6 +281,10 @@ function SettingsWindow() {
//$("#restoreSettings").addClass("disabled");
self.btnRestoreSettings.attr("disabled", true);
clearTimeout(self.restoredStateHideDelay);
self.setRestoreState("Restoring...");
//console.log(" self.wifiboxURL: ",self.wifiboxURL);
if (communicateWithWifibox) {
@ -296,6 +305,10 @@ function SettingsWindow() {
$(document).trigger(SettingsWindow.SETTINGS_LOADED);
self.btnRestoreSettings.removeAttr("disabled");
self.setRestoreState("Settings restored");
// auto hide status
clearTimeout(self.restoredStateHideDelay);
self.restoredStateHideDelay = setTimeout(function() { self.setRestoreState(""); },self.restoredStateHideDelayTime);
}
}
}).fail(function() {
@ -305,6 +318,9 @@ function SettingsWindow() {
});
}
}
this.setRestoreState = function(text) {
self.restoreStateField.html(text);
}
this.displayValidationError = function(key,msg) {
var formElement = self.form.find("[name|='"+key+"']");
formElement.addClass("error");

View File

@ -175,9 +175,11 @@
<input type="button" onclick="settingsWindow.downloadGcode()" name="downloadGcode" value="Download GCODE" class="button" id="downloadGcode"/>
<input type="button" onclick="settingsWindow.downloadSvg()" name="downloadSvg" value="Download SVG" class="button" id="downloadSvg"/>
</fieldset>
<fieldset id="restorePanel">
<legend>Restore</legend>
<input type="button" name="restoresettings" value="Restore settings to defaults" class="button" id="restoreSettings"/>
<span id="restoreState"></span>
</fieldset>
</form><br/>
</div>