From 5644b5dc01e2bbe62ca99484913025064e076ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 2 Oct 2015 14:26:51 +0200 Subject: [PATCH] clientlib: Fixed some refactoring errors still referring to exports var Closes #1079 --- src/octoprint/static/js/app/client/control.js | 32 ++++++++++--------- .../static/js/app/client/timelapse.js | 14 ++++---- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/octoprint/static/js/app/client/control.js b/src/octoprint/static/js/app/client/control.js index 15c8ca08..d1a0eae7 100644 --- a/src/octoprint/static/js/app/client/control.js +++ b/src/octoprint/static/js/app/client/control.js @@ -8,27 +8,29 @@ var customUrl = "api/printer/command/custom"; var commandUrl = "api/printer/command"; + var sendGcodeWithParameters = function(commands, parameters, opts) { + commands = commands || []; + parameters = parameters || {}; + + if (typeof commands === "string") { + commands = [commands]; + } + + return OctoPrint.postJson(commandUrl, { + commands: commands, + parameters: parameters + }, opts); + }; + OctoPrint.control = { + sendGcodeWithParameters: sendGcodeWithParameters, + getCustomControls: function (opts) { return OctoPrint.get(customUrl, opts); }, sendGcode: function (commands, opts) { - return exports.sendGcodeWithParameters(commands, undefined, opts); - }, - - sendGcodeWithParameters: function (commands, parameters, opts) { - commands = commands || []; - parameters = parameters || {}; - - if (typeof commands === "string") { - commands = [commands]; - } - - return OctoPrint.postJson(commandUrl, { - commands: commands, - parameters: parameters - }, opts); + return sendGcodeWithParameters(commands, undefined, opts); }, sendGcodeScript: function (script, context, opts) { diff --git a/src/octoprint/static/js/app/client/timelapse.js b/src/octoprint/static/js/app/client/timelapse.js index 6ecf8e96..5acaeef8 100644 --- a/src/octoprint/static/js/app/client/timelapse.js +++ b/src/octoprint/static/js/app/client/timelapse.js @@ -5,23 +5,23 @@ factory(window.OctoPrint, window.$); } })(window || this, function(OctoPrint, $) { - var exports = {}; - var url = "api/timelapse"; var timelapseUrl = function(filename) { return url + "/" + filename; }; + var getTimelapseData = function (opts) { + return OctoPrint.get(url, opts); + }; + OctoPrint.timelapse = { - get: function (opts) { - return OctoPrint.get(url, opts); - }, + get: getTimelapseData, list: function (opts) { var deferred = $.Deferred(); - exports.get(opts) + getTimelapseData(opts) .done(function (response, status, request) { deferred.resolve(response.files, status, request); }) @@ -42,7 +42,7 @@ getConfig: function (opts) { var deferred = $.Deferred(); - exports.get(opts) + getTimelapseData(opts) .done(function (response, status, request) { deferred.resolve(response.config, status, request); })