diff --git a/octoprint/static/js/ui.js b/octoprint/static/js/ui.js index 22d34f1..475b421 100644 --- a/octoprint/static/js/ui.js +++ b/octoprint/static/js/ui.js @@ -220,6 +220,26 @@ 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.tempString = ko.computed(function() { if (!self.temp()) return "-"; @@ -1222,12 +1242,10 @@ $(function() { }) }) - //~~ Temperature control + //~~ Temperature control (should really move to knockout click binding) - $("#temp_newTemp_set, .temp_newTemp_set").click(function() { + $("#temp_newTemp_set").click(function() { var newTemp = $("#temp_newTemp").val(); - if ($(this).data('temp') != null) - newTemp = $(this).data('temp'); $.ajax({ url: AJAX_BASEURL + "control/temperature", type: "POST", @@ -1236,10 +1254,8 @@ $(function() { success: function() {$("#temp_newTemp").val("")} }) }) - $("#temp_newBedTemp_set, .temp_newBedTemp_set").click(function() { + $("#temp_newBedTemp_set").click(function() { var newBedTemp = $("#temp_newBedTemp").val(); - if ($(this).data('temp') != null) - newBedTemp = $(this).data('temp'); $.ajax({ url: AJAX_BASEURL + "control/temperature", type: "POST", diff --git a/octoprint/templates/index.html b/octoprint/templates/index.html index 232d0b4..1e8fb0a 100644 --- a/octoprint/templates/index.html +++ b/octoprint/templates/index.html @@ -176,7 +176,7 @@