Switch to using jQuery XHR
[armadillo.git] / web_frontend / tv_renamer.js
1 //
2 // Armadillo File Manager
3 // Copyright (c) 2010-2011, Robert Sesek <http://www.bluestatic.org>
4 //
5 // This program is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free Software
7 // Foundation, either version 3 of the License, or any later version.
8 //
9
10 goog.provide('armadillo.TVRenamer');
11
12 goog.require('goog.Disposable');
13
14 /**
15 * Creates a helper to rename a file in a pretty format for TV episodes.
16 * @extends {goog.Disposable}
17 * @constructor
18 */
19 armadillo.TVRenamer = function(file) {
20 goog.base(this);
21
22 /**
23 * The file object
24 * @type {armadillo.File}
25 */
26 this.file_ = file;
27 }
28 goog.inherits(armadillo.TVRenamer, goog.Disposable);
29
30 /**
31 * @inheritDoc
32 */
33 armadillo.TVRenamer.prototype.disposeInternal = function() {
34 goog.base(this, 'disposeInternal');
35 this.file_ = null;
36 };
37
38 /**
39 * Performs the information lookup and renames the file if the lookup is
40 * successful.
41 */
42 armadillo.TVRenamer.prototype.run = function() {
43 var file = this.file_;
44 var callback = function(data, stauts, xhr) {
45 if (data['error']) {
46 app.showError(data['message']);
47 } else {
48 app.clearError();
49 file.move(data['path']);
50 }
51 };
52 app.sendRequest('tv_rename', {'path':this.file_.getFullPath()},
53 callback);
54 };