clientlib: Fixed some refactoring errors still referring to exports var

Closes #1079
This commit is contained in:
Gina Häußge 2015-10-02 14:26:51 +02:00
parent a28198edef
commit 5644b5dc01
2 changed files with 24 additions and 22 deletions

View file

@ -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) {

View file

@ -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);
})