From 899d618efe7c821eda1b8799b19ced0c9702ad81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 23 Feb 2013 22:46:29 +0100 Subject: [PATCH] Couple of fixes while merging... --- octoprint/static/js/ui.js | 54 +++++++++++++++++++++------------- octoprint/templates/index.html | 24 ++++++++------- 2 files changed, 47 insertions(+), 31 deletions(-) diff --git a/octoprint/static/js/ui.js b/octoprint/static/js/ui.js index d16a1b8..d96485a 100644 --- a/octoprint/static/js/ui.js +++ b/octoprint/static/js/ui.js @@ -220,25 +220,37 @@ function TemperatureViewModel(settingsViewModel) { self.temperature_profiles = settingsViewModel.temperature_profiles; - self.setTemp = function(profile) { - $.ajax({ - url: AJAX_BASEURL + "control/temperature", - type: "POST", - dataType: "json", - data: { temp: profile.extruder }, - success: function() {$("#temp_newTemp").val("")} - }) - }; - - self.setBedTemp = function(profile) { - $.ajax({ - url: AJAX_BASEURL + "control/temperature", - type: "POST", - dataType: "json", - data: { temp: profile.bed }, - success: function() {$("#temp_newBedTemp").val("")} - }) - }; + self.setTempFromProfile = function(profile) { + if (!profile) + return; + self.setTemp(profile.extruder); + } + + self.setTemp = function(temp) { + $.ajax({ + url: AJAX_BASEURL + "control/temperature", + type: "POST", + dataType: "json", + data: { temp: temp }, + success: function() {$("#temp_newTemp").val("")} + }) + }; + + self.setBedTempFromProfile = function(profile) { + if (!profile) + return; + self.setBedTemp(profile.bed); + } + + self.setBedTemp = function(bedTemp) { + $.ajax({ + url: AJAX_BASEURL + "control/temperature", + type: "POST", + dataType: "json", + data: { bedTemp: bedTemp }, + success: function() {$("#temp_newBedTemp").val("")} + }) + }; self.tempString = ko.computed(function() { if (!self.temp()) @@ -1117,8 +1129,8 @@ function SettingsViewModel() { "logs": self.folder_logs() }, "temperature": { - "profiles": self.temperature_profiles(), - }, + "profiles": self.temperature_profiles() + } } $.ajax({ diff --git a/octoprint/templates/index.html b/octoprint/templates/index.html index 1e8fb0a..e73b105 100644 --- a/octoprint/templates/index.html +++ b/octoprint/templates/index.html @@ -175,13 +175,15 @@ @@ -203,12 +205,14 @@