Switch to using jQuery XHR
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 26 Dec 2011 22:49:24 +0000 (17:49 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 26 Dec 2011 22:49:24 +0000 (17:49 -0500)
web_frontend/file.js
web_frontend/main.js
web_frontend/path_control.js
web_frontend/tv_renamer.js

index 94b0f4af2615869650fcb336c0d9c1693c822c78..66e758f9c6be0b390ea5ce38c0b1a661d9faed5f 100644 (file)
@@ -135,7 +135,7 @@ armadillo.File.prototype.draw = function() {
  */
 armadillo.File.prototype.remove = function() {
   var file = this;
-  var callback = function(data) {
+  var callback = function(data, status, xhr) {
     if (data['error']) {
       app.showError(data['message']);
       return;
@@ -154,7 +154,7 @@ armadillo.File.prototype.remove = function() {
  */
 armadillo.File.prototype.move = function(dest) {
   var file = this;
-  var callback = function(data) {
+  var callback = function(data, status, xhr) {
     if (data['error']) {
       app.showError(data['message']);
     } else {
index f46ab7399e2c0bbfcb5673514a66c4788341dcfc..bb0cab1e2720260010ccd36c616743ea4c3e3f14 100644 (file)
@@ -16,9 +16,7 @@ goog.require('goog.array');
 goog.require('goog.dom');
 goog.require('goog.fx.dom.FadeInAndShow');
 goog.require('goog.fx.dom.FadeOutAndHide');
-goog.require('goog.net.XhrIo');
 goog.require('goog.string.format');
-goog.require('goog.Uri.QueryData');
 
 armadillo.App = function() {
   var start_path = '/';
@@ -44,14 +42,18 @@ armadillo.App = function() {
 /**
  * Starts a new XHR service request from the backend.
  * @param  {string}  action  Action to perform.
- * @param  {Object}  extra_data  Extra data to add.
+ * @param  {Object}  data  Extra data to add.
  * @param  {Function}  callback  XHR callback.
+ * @return {jqXHR} The jQuery XHR object.
  */
-armadillo.App.prototype.sendRequest = function(action, extra_data, callback) {
-  var data = new goog.Uri.QueryData();
-  data.set('action', action);
-  data.extend(extra_data);
-  goog.net.XhrIo.send('service', callback, 'POST', data);
+armadillo.App.prototype.sendRequest = function(action, data, callback) {
+  data.action = action;
+  return $.ajax({
+      url: 'service',
+      type: 'POST',
+      data: data,
+      success: callback
+  });
 };
 
 /**
@@ -59,8 +61,7 @@ armadillo.App.prototype.sendRequest = function(action, extra_data, callback) {
  * @param  {string}  path  Path to list; relative to jail.
  */
 armadillo.App.prototype.list = function(path) {
-  var callback = function(e) {
-    var data = e.target.getResponseJson();
+  var callback = function(data, status, xhr) {
     if (data['error']) {
       app.showError(data['message']);
       return;  // Error.
@@ -196,8 +197,7 @@ armadillo.App.prototype.mkdirHandler_ = function() {
   var name = prompt('Name the new subdirectory', '');
   if (name != null && name != '') {
     var path = this.joinPath(this.getCurrentPath(), name);
-    this.sendRequest('mkdir', {'path':path}, function(e) {
-      var data = e.target.getResponseJson();
+    this.sendRequest('mkdir', {'path':path}, function(data, status, xhr) {
       if (data['error']) {
         app.showError(data['message']);
       } else {
index a45517c09542f5c1fef345e9ca0c66e5f9687911..3c6e8a2d4615bacda883a4554f4fbbfc916fb4c4 100644 (file)
@@ -152,8 +152,7 @@ armadillo.PathControl.prototype.createComponentNode_ = function(path, name) {
  * @param  {goog.ui.Menu}  The menu to attach items to
  */
 armadillo.PathControl.prototype.fetchMenuContents_ = function(path, name, menu) {
-  var callback = function(e) {
-    var data = e.target.getResponseJson();
+  var callback = function(data, status, xhr) {
     if (data['error']) {
       app.showError(data['message']);
       return;
index db794a089bf7824ad9c89a6b6bd3f16d99000376..a42de8aeeedd54bbae164e23f41484ec59adca77 100644 (file)
@@ -10,7 +10,6 @@
 goog.provide('armadillo.TVRenamer');
 
 goog.require('goog.Disposable');
-goog.require('goog.net.XhrIo');
 
 /**
  * Creates a helper to rename a file in a pretty format for TV episodes.
@@ -42,8 +41,7 @@ armadillo.TVRenamer.prototype.disposeInternal = function() {
  */
 armadillo.TVRenamer.prototype.run = function() {
   var file = this.file_;
-  var callback = function(xhr) {
-    var data = xhr.currentTarget.getResponseJson();
+  var callback = function(data, stauts, xhr) {
     if (data['error']) {
       app.showError(data['message']);
     } else {