##// END OF EJS Templates
Rename callback parameters to success/error
Thomas Kluyver -
Show More
@@ -91,14 +91,14 b' define(['
91 // notebook's path.
91 // notebook's path.
92 that.contents.new_notebook(that.notebook.notebook_path,
92 that.contents.new_notebook(that.notebook.notebook_path,
93 {
93 {
94 success_callback: function (data, status, xhr) {
94 success: function (data, status, xhr) {
95 window.open(
95 window.open(
96 utils.url_join_encode(
96 utils.url_join_encode(
97 that.base_url, 'notebooks',
97 that.base_url, 'notebooks',
98 data.path, data.name
98 data.path, data.name
99 ), '_blank');
99 ), '_blank');
100 },
100 },
101 error_callback: function(xhr, status, error) {
101 error: function(xhr, status, error) {
102 var msg;
102 var msg;
103 if (xhr.responseJSON && xhr.responseJSON.message) {
103 if (xhr.responseJSON && xhr.responseJSON.message) {
104 msg = xhr.responseJSON.message;
104 msg = xhr.responseJSON.message;
@@ -1922,8 +1922,8 b' define(['
1922 var that = this;
1922 var that = this;
1923 this.contents.save_file(this.notebook_path, this.notebook_name, model, {
1923 this.contents.save_file(this.notebook_path, this.notebook_name, model, {
1924 extra_settings: extra_settings,
1924 extra_settings: extra_settings,
1925 success_callback: $.proxy(this.save_notebook_success, this, start),
1925 success: $.proxy(this.save_notebook_success, this, start),
1926 error_callback: function (xhr, status, error) {
1926 error: function (xhr, status, error) {
1927 that.events.trigger('notebook_save_failed.Notebook');
1927 that.events.trigger('notebook_save_failed.Notebook');
1928 }
1928 }
1929 });
1929 });
@@ -2078,12 +2078,12 b' define(['
2078 var that = this;
2078 var that = this;
2079 this.contents.rename_file(this.notebook_path, this.notebook_name,
2079 this.contents.rename_file(this.notebook_path, this.notebook_name,
2080 this.notebook_path, new_name, {
2080 this.notebook_path, new_name, {
2081 success_callback: function (json, status, xhr) {
2081 success: function (json, status, xhr) {
2082 var name = that.notebook_name = json.name;
2082 var name = that.notebook_name = json.name;
2083 that.session.rename_notebook(name, json.path);
2083 that.session.rename_notebook(name, json.path);
2084 that.events.trigger('notebook_renamed.Notebook', json);
2084 that.events.trigger('notebook_renamed.Notebook', json);
2085 },
2085 },
2086 error_callback: $.proxy(this.rename_error, this)
2086 error: $.proxy(this.rename_error, this)
2087 });
2087 });
2088 };
2088 };
2089
2089
@@ -2134,8 +2134,8 b' define(['
2134 this.notebook_path = notebook_path;
2134 this.notebook_path = notebook_path;
2135 this.events.trigger('notebook_loading.Notebook');
2135 this.events.trigger('notebook_loading.Notebook');
2136 this.contents.load_file(notebook_path, notebook_name, {
2136 this.contents.load_file(notebook_path, notebook_name, {
2137 success_callback: $.proxy(this.load_notebook_success, this),
2137 success: $.proxy(this.load_notebook_success, this),
2138 error_callback: $.proxy(this.load_notebook_error, this)
2138 error: $.proxy(this.load_notebook_error, this)
2139 });
2139 });
2140 };
2140 };
2141
2141
@@ -2349,8 +2349,8 b' define(['
2349 Notebook.prototype.list_checkpoints = function () {
2349 Notebook.prototype.list_checkpoints = function () {
2350 var that = this;
2350 var that = this;
2351 this.contents.list_checkpoints(this.notebook_path, this.notebook_name, {
2351 this.contents.list_checkpoints(this.notebook_path, this.notebook_name, {
2352 success_callback: $.proxy(this.list_checkpoints_success, this),
2352 success: $.proxy(this.list_checkpoints_success, this),
2353 error_callback: function(xhr, status, error_msg) {
2353 error: function(xhr, status, error_msg) {
2354 that.events.trigger('list_checkpoints_failed.Notebook');
2354 that.events.trigger('list_checkpoints_failed.Notebook');
2355 }
2355 }
2356 });
2356 });
@@ -2383,8 +2383,8 b' define(['
2383 Notebook.prototype.create_checkpoint = function () {
2383 Notebook.prototype.create_checkpoint = function () {
2384 var that = this;
2384 var that = this;
2385 this.contents.create_checkpoint(this.notebook_path, this.notebook_name, {
2385 this.contents.create_checkpoint(this.notebook_path, this.notebook_name, {
2386 success_callback: $.proxy(this.create_checkpoint_success, this),
2386 success: $.proxy(this.create_checkpoint_success, this),
2387 error_callback: function (xhr, status, error_msg) {
2387 error: function (xhr, status, error_msg) {
2388 that.events.trigger('checkpoint_failed.Notebook');
2388 that.events.trigger('checkpoint_failed.Notebook');
2389 }
2389 }
2390 });
2390 });
@@ -2456,8 +2456,8 b' define(['
2456 var that = this;
2456 var that = this;
2457 this.contents.restore_checkpoint(this.notebook_path, this.notebook_name,
2457 this.contents.restore_checkpoint(this.notebook_path, this.notebook_name,
2458 checkpoint, {
2458 checkpoint, {
2459 success_callback: $.proxy(this.create_checkpoint_success, this),
2459 success: $.proxy(this.create_checkpoint_success, this),
2460 error_callback: function (xhr, status, error_msg) {
2460 error: function (xhr, status, error_msg) {
2461 that.events.trigger('checkpoint_restore_failed.Notebook');
2461 that.events.trigger('checkpoint_restore_failed.Notebook');
2462 }
2462 }
2463 });
2463 });
@@ -2487,8 +2487,8 b' define(['
2487 var that = this;
2487 var that = this;
2488 this.contents.delete_checkpoint(this.notebook_path, this.notebook_name,
2488 this.contents.delete_checkpoint(this.notebook_path, this.notebook_name,
2489 checkpoint, {
2489 checkpoint, {
2490 success_callback: $.proxy(this.create_checkpoint_success, this),
2490 success: $.proxy(this.create_checkpoint_success, this),
2491 error_callback: function (xhr, status, error_msg) {
2491 error: function (xhr, status, error_msg) {
2492 that.events.trigger('checkpoint_delete_failed.Notebook', [xhr, status, error]);
2492 that.events.trigger('checkpoint_delete_failed.Notebook', [xhr, status, error]);
2493 }
2493 }
2494 });
2494 });
@@ -34,13 +34,13 b' define(['
34 /**
34 /**
35 * Load a file.
35 * Load a file.
36 *
36 *
37 * Calls success_callback with file JSON model, or error_callback with error.
37 * Calls success with file JSON model, or error with error.
38 *
38 *
39 * @method load_notebook
39 * @method load_notebook
40 * @param {String} path
40 * @param {String} path
41 * @param {String} name
41 * @param {String} name
42 * @param {Function} success_callback
42 * @param {Function} success
43 * @param {Function} error_callback
43 * @param {Function} error
44 */
44 */
45 Contents.prototype.load_file = function (path, name, options) {
45 Contents.prototype.load_file = function (path, name, options) {
46 // We do the call with settings so we can set cache to false.
46 // We do the call with settings so we can set cache to false.
@@ -49,8 +49,8 b' define(['
49 cache : false,
49 cache : false,
50 type : "GET",
50 type : "GET",
51 dataType : "json",
51 dataType : "json",
52 success : options.success_callback,
52 success : options.success,
53 error : options.error_callback || function() {}
53 error : options.error || function() {}
54 };
54 };
55 var url = this.api_url(path, name);
55 var url = this.api_url(path, name);
56 $.ajax(url, settings);
56 $.ajax(url, settings);
@@ -64,30 +64,30 b' define(['
64 * @param {String} path The path to create the new notebook at
64 * @param {String} path The path to create the new notebook at
65 */
65 */
66 Contents.prototype.new_notebook = function(path, options) {
66 Contents.prototype.new_notebook = function(path, options) {
67 var error_callback = options.error_callback || function() {};
67 var error = options.error || function() {};
68 var settings = {
68 var settings = {
69 processData : false,
69 processData : false,
70 cache : false,
70 cache : false,
71 type : "POST",
71 type : "POST",
72 dataType : "json",
72 dataType : "json",
73 success : options.success_callback || function() {},
73 success : options.success || function() {},
74 error : options.error_callback || function() {}
74 error : options.error || function() {}
75 };
75 };
76 $.ajax(this.api_url(path), settings);
76 $.ajax(this.api_url(path), settings);
77 };
77 };
78
78
79 Contents.prototype.delete_file = function(name, path, options) {
79 Contents.prototype.delete_file = function(name, path, options) {
80 var error_callback = options.error_callback || function() {};
80 var error = options.error || function() {};
81 var that = this;
81 var that = this;
82 var settings = {
82 var settings = {
83 processData : false,
83 processData : false,
84 cache : false,
84 cache : false,
85 type : "DELETE",
85 type : "DELETE",
86 dataType : "json",
86 dataType : "json",
87 success : options.success_callback || function() {},
87 success : options.success || function() {},
88 error : function(xhr, status, error) {
88 error : function(xhr, status, error) {
89 utils.log_ajax_error(xhr, status, error);
89 utils.log_ajax_error(xhr, status, error);
90 error_callback(xhr, status, error);
90 error(xhr, status, error);
91 }
91 }
92 };
92 };
93 var url = this.api_url(path, name);
93 var url = this.api_url(path, name);
@@ -103,8 +103,8 b' define(['
103 data : JSON.stringify(data),
103 data : JSON.stringify(data),
104 dataType: "json",
104 dataType: "json",
105 contentType: 'application/json',
105 contentType: 'application/json',
106 success : options.success_callback || function() {},
106 success : options.success || function() {},
107 error : options.error_callback || function() {}
107 error : options.error || function() {}
108 };
108 };
109 var url = this.api_url(path, name);
109 var url = this.api_url(path, name);
110 $.ajax(url, settings);
110 $.ajax(url, settings);
@@ -118,8 +118,8 b' define(['
118 type : "PUT",
118 type : "PUT",
119 data : JSON.stringify(model),
119 data : JSON.stringify(model),
120 contentType: 'application/json',
120 contentType: 'application/json',
121 success : options.success_callback || function() {},
121 success : options.success || function() {},
122 error : options.error_callback || function() {}
122 error : options.error || function() {}
123 };
123 };
124 if (options.extra_settings) {
124 if (options.extra_settings) {
125 $.extend(settings, options.extra_settings);
125 $.extend(settings, options.extra_settings);
@@ -136,8 +136,8 b' define(['
136 var url = this.api_url(path, name, 'checkpoints');
136 var url = this.api_url(path, name, 'checkpoints');
137 var settings = {
137 var settings = {
138 type : "POST",
138 type : "POST",
139 success: options.success_callback || function() {},
139 success: options.success || function() {},
140 error: options.error_callback || function() {}
140 error: options.error || function() {}
141 };
141 };
142 $.ajax(url, settings);
142 $.ajax(url, settings);
143 };
143 };
@@ -146,8 +146,8 b' define(['
146 var url = this.api_url(path, name, 'checkpoints');
146 var url = this.api_url(path, name, 'checkpoints');
147 var settings = {
147 var settings = {
148 type : "GET",
148 type : "GET",
149 success: options.success_callback,
149 success: options.success,
150 error: options.error_callback || function() {}
150 error: options.error || function() {}
151 };
151 };
152 $.ajax(url, settings);
152 $.ajax(url, settings);
153 };
153 };
@@ -156,8 +156,8 b' define(['
156 var url = this.api_url(path, name, 'checkpoints', checkpoint_id);
156 var url = this.api_url(path, name, 'checkpoints', checkpoint_id);
157 var settings = {
157 var settings = {
158 type : "POST",
158 type : "POST",
159 success: options.success_callback || function() {},
159 success: options.success || function() {},
160 error: options.error_callback || function() {}
160 error: options.error || function() {}
161 };
161 };
162 $.ajax(url, settings);
162 $.ajax(url, settings);
163 };
163 };
@@ -166,8 +166,8 b' define(['
166 var url = this.api_url(path, name, 'checkpoints', checkpoint_id);
166 var url = this.api_url(path, name, 'checkpoints', checkpoint_id);
167 var settings = {
167 var settings = {
168 type : "DELETE",
168 type : "DELETE",
169 success: options.success_callback || function() {},
169 success: options.success || function() {},
170 error: options.error_callback || function() {}
170 error: options.error || function() {}
171 };
171 };
172 $.ajax(url, settings);
172 $.ajax(url, settings);
173 };
173 };
@@ -190,7 +190,7 b' define(['
190 * @method list_notebooks
190 * @method list_notebooks
191 * @param {String} path The path to list notebooks in
191 * @param {String} path The path to list notebooks in
192 * @param {Function} load_callback called with list of notebooks on success
192 * @param {Function} load_callback called with list of notebooks on success
193 * @param {Function} error_callback called with ajax results on error
193 * @param {Function} error called with ajax results on error
194 */
194 */
195 Contents.prototype.list_contents = function(path, options) {
195 Contents.prototype.list_contents = function(path, options) {
196 var settings = {
196 var settings = {
@@ -198,8 +198,8 b' define(['
198 cache : false,
198 cache : false,
199 type : "GET",
199 type : "GET",
200 dataType : "json",
200 dataType : "json",
201 success : options.success_callback,
201 success : options.success,
202 error : options.error_callback || function() {}
202 error : options.error || function() {}
203 };
203 };
204
204
205 $.ajax(this.api_url(path), settings);
205 $.ajax(this.api_url(path), settings);
@@ -62,14 +62,14 b' require(['
62 $('#new_notebook').button().click(function (e) {
62 $('#new_notebook').button().click(function (e) {
63 contents.new_notebook(common_options.notebook_path,
63 contents.new_notebook(common_options.notebook_path,
64 {
64 {
65 success_callback: function (data, status, xhr) {
65 success: function (data, status, xhr) {
66 window.open(
66 window.open(
67 utils.url_join_encode(
67 utils.url_join_encode(
68 common_options.base_url, 'notebooks',
68 common_options.base_url, 'notebooks',
69 data.path, data.name
69 data.path, data.name
70 ), '_blank');
70 ), '_blank');
71 },
71 },
72 error_callback: function(xhr, status, error) {
72 error: function(xhr, status, error) {
73 var msg;
73 var msg;
74 if (xhr.responseJSON && xhr.responseJSON.message) {
74 if (xhr.responseJSON && xhr.responseJSON.message) {
75 msg = xhr.responseJSON.message;
75 msg = xhr.responseJSON.message;
@@ -143,8 +143,8 b' define(['
143 NotebookList.prototype.load_list = function () {
143 NotebookList.prototype.load_list = function () {
144 var that = this
144 var that = this
145 this.contents.list_contents(that.notebook_path, {
145 this.contents.list_contents(that.notebook_path, {
146 success_callback: $.proxy(this.draw_notebook_list, this),
146 success: $.proxy(this.draw_notebook_list, this),
147 error_callback: function(xhr, status, error) {
147 error: function(xhr, status, error) {
148 utils.log_ajax_error(xhr, status, error);
148 utils.log_ajax_error(xhr, status, error);
149 that.draw_notebook_list([], "Error connecting to server.");
149 that.draw_notebook_list([], "Error connecting to server.");
150 }
150 }
@@ -332,7 +332,7 b' define(['
332 class: "btn-danger",
332 class: "btn-danger",
333 click: function() {
333 click: function() {
334 notebooklist.contents.delete_file(nbname, path, {
334 notebooklist.contents.delete_file(nbname, path, {
335 success_callback: function() {
335 success: function() {
336 notebooklist.notebook_deleted(path, nbname);
336 notebooklist.notebook_deleted(path, nbname);
337 }
337 }
338 });
338 });
General Comments 0
You need to be logged in to leave comments. Login now