Return xhr request object from api functions.
This commit is contained in:
		
							parent
							
								
									5e9b7e2dd0
								
							
						
					
					
						commit
						f30528cc35
					
				
					 1 changed files with 42 additions and 42 deletions
				
			
		|  | @ -20,7 +20,7 @@ function _add_remove_photos(album_id, photo_ids, add_or_remove, callback) | |||
|         { photo_ids = photo_ids.join(","); } | ||||
|     data.append("photo_id", photo_ids); | ||||
| 
 | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.albums.add_child = | ||||
|  | @ -29,7 +29,7 @@ function add_child(album_id, child_id, callback) | |||
|     const url = `/album/${album_id}/add_child`; | ||||
|     const data = new FormData(); | ||||
|     data.append("child_id", child_id); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.albums.add_photos = | ||||
|  | @ -51,21 +51,21 @@ function create(title, parent_id, callback) | |||
|     { | ||||
|         data.append("parent_id", parent_id); | ||||
|     } | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.albums.delete = | ||||
| function _delete(album_id, callback) | ||||
| { | ||||
|     const url = `/album/${album_id}/delete`; | ||||
|     common.post(url, null, callback); | ||||
|     return common.post(url, null, callback); | ||||
| } | ||||
| 
 | ||||
| api.albums.get_all_albums = | ||||
| function get_all_albums(callback) | ||||
| { | ||||
|     const url = "/all_albums.json"; | ||||
|     common.get(url, callback); | ||||
|     return common.get(url, callback); | ||||
| } | ||||
| 
 | ||||
| api.albums.edit = | ||||
|  | @ -75,14 +75,14 @@ function edit(album_id, title, description, callback) | |||
|     const data = new FormData(); | ||||
|     data.append("title", title); | ||||
|     data.append("description", description); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.albums.refresh_directories = | ||||
| function refresh_directories(album_id, callback) | ||||
| { | ||||
|     const url = `/album/${album_id}/refresh_directories`; | ||||
|     common.post(url, null, callback); | ||||
|     return common.post(url, null, callback); | ||||
| } | ||||
| 
 | ||||
| api.albums.remove_child = | ||||
|  | @ -91,7 +91,7 @@ function remove_child(album_id, child_id, callback) | |||
|     const url = `/album/${album_id}/remove_child`; | ||||
|     const data = new FormData(); | ||||
|     data.append("child_id", child_id); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.albums.remove_photos = | ||||
|  | @ -105,7 +105,7 @@ function remove_thumbnail_photo(album_id, callback) | |||
| { | ||||
|     const url = `/album/${album_id}/remove_thumbnail_photo`; | ||||
|     const data = new FormData(); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.albums.set_thumbnail_photo = | ||||
|  | @ -114,14 +114,14 @@ function set_thumbnail_photo(album_id, photo_id, callback) | |||
|     const url = `/album/${album_id}/set_thumbnail_photo`; | ||||
|     const data = new FormData(); | ||||
|     data.append("photo_id", photo_id); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.albums.show_in_folder = | ||||
| function show_in_folder(album_id, callback) | ||||
| { | ||||
|     const url = `/album/${album_id}/show_in_folder`; | ||||
|     common.post(url, null, callback); | ||||
|     return common.post(url, null, callback); | ||||
| } | ||||
| 
 | ||||
| api.albums.callback_follow = | ||||
|  | @ -160,14 +160,14 @@ function create(b_url, title, callback) | |||
|     { | ||||
|         data.append("title", title); | ||||
|     } | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.bookmarks.delete = | ||||
| function _delete(bookmark_id, callback) | ||||
| { | ||||
|     const url = `/bookmark/${bookmark_id}/delete`; | ||||
|     common.post(url, null, callback); | ||||
|     return common.post(url, null, callback); | ||||
| } | ||||
| 
 | ||||
| api.bookmarks.edit = | ||||
|  | @ -177,7 +177,7 @@ function edit(bookmark_id, title, b_url, callback) | |||
|     const data = new FormData(); | ||||
|     data.append("title", title.trim()); | ||||
|     data.append("url", b_url.trim()); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| /**************************************************************************************************/ | ||||
|  | @ -189,7 +189,7 @@ function add_tag(photo_id, tagname, callback) | |||
|     const url = `/photo/${photo_id}/add_tag`; | ||||
|     const data = new FormData(); | ||||
|     data.append("tagname", tagname); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.batch_add_tag = | ||||
|  | @ -199,7 +199,7 @@ function batch_add_tag(photo_ids, tagname, callback) | |||
|     const data = new FormData(); | ||||
|     data.append("photo_ids", photo_ids.join(",")); | ||||
|     data.append("tagname", tagname); | ||||
|     common.post(url, data, add_remove_tag_callback); | ||||
|     return common.post(url, data, add_remove_tag_callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.batch_refresh_metadata = | ||||
|  | @ -208,7 +208,7 @@ function batch_refresh_metadata(photo_ids, callback) | |||
|     const url = "/batch/photos/refresh_metadata"; | ||||
|     const data = new FormData(); | ||||
|     data.append("photo_ids", photo_ids.join(",")); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.batch_remove_tag = | ||||
|  | @ -218,7 +218,7 @@ function batch_remove_tag(photo_ids, tagname, callback) | |||
|     const data = new FormData(); | ||||
|     data.append("photo_ids", photo_ids.join(",")); | ||||
|     data.append("tagname", tagname); | ||||
|     common.post(url, data, add_remove_tag_callback); | ||||
|     return common.post(url, data, add_remove_tag_callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.batch_set_searchhidden = | ||||
|  | @ -227,7 +227,7 @@ function batch_set_searchhidden(photo_ids, callback) | |||
|     const url = "/batch/photos/set_searchhidden"; | ||||
|     const data = new FormData(); | ||||
|     data.append("photo_ids", photo_ids.join(",")); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.batch_unset_searchhidden = | ||||
|  | @ -236,7 +236,7 @@ function batch_unset_searchhidden(photo_ids, callback) | |||
|     const url = "/batch/photos/unset_searchhidden"; | ||||
|     const data = new FormData(); | ||||
|     data.append("photo_ids", photo_ids.join(",")); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.copy_tags = | ||||
|  | @ -245,7 +245,7 @@ function copy_tags(photo_id, other_photo, callback) | |||
|     const url = `/photo/${photo_id}/copy_tags`; | ||||
|     const data = new FormData(); | ||||
|     data.append("other_photo", other_photo); | ||||
|     common.post(url, data, callback) | ||||
|     return common.post(url, data, callback) | ||||
| } | ||||
| 
 | ||||
| api.photos.delete = | ||||
|  | @ -254,7 +254,7 @@ function _delete(photo_id, delete_file, callback) | |||
|     const url = `/photo/${photo_id}/delete`; | ||||
|     const data = new FormData(); | ||||
|     data.append("delete_file", delete_file); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.generate_thumbnail = | ||||
|  | @ -266,7 +266,7 @@ function generate_thumbnail(photo_id, special, callback) | |||
|     { | ||||
|         data.append(x, special[x]); | ||||
|     } | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.get_download_zip_token = | ||||
|  | @ -275,7 +275,7 @@ function get_download_zip_token(photo_ids, callback) | |||
|     const url = "/batch/photos/download_zip"; | ||||
|     const data = new FormData(); | ||||
|     data.append("photo_ids", photo_ids.join(",")); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.download_zip = | ||||
|  | @ -296,7 +296,7 @@ api.photos.refresh_metadata = | |||
| function refresh_metadata(photo_id, callback) | ||||
| { | ||||
|     const url = `/photo/${photo_id}/refresh_metadata`; | ||||
|     common.post(url, null, callback); | ||||
|     return common.post(url, null, callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.remove_tag = | ||||
|  | @ -305,28 +305,28 @@ function remove_tag(photo_id, tagname, callback) | |||
|     const url = `/photo/${photo_id}/remove_tag`; | ||||
|     const data = new FormData(); | ||||
|     data.append("tagname", tagname); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.set_searchhidden = | ||||
| function set_searchhidden(photo_id, callback) | ||||
| { | ||||
|     const url = `/photo/${photo_id}/set_searchhidden`; | ||||
|     common.post(url, null, callback); | ||||
|     return common.post(url, null, callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.unset_searchhidden = | ||||
| function unset_searchhidden(photo_id, callback) | ||||
| { | ||||
|     const url = `/photo/${photo_id}/unset_searchhidden`; | ||||
|     common.post(url, null, callback); | ||||
|     return common.post(url, null, callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.show_in_folder = | ||||
| function show_in_folder(photo_id, callback) | ||||
| { | ||||
|     const url = `/photo/${photo_id}/show_in_folder`; | ||||
|     common.post(url, null, callback); | ||||
|     return common.post(url, null, callback); | ||||
| } | ||||
| 
 | ||||
| api.photos.callback_go_to_search = | ||||
|  | @ -349,7 +349,7 @@ function add_child(tag_name, child_name, callback) | |||
|     const url = `/tag/${tag_name}/add_child`; | ||||
|     const data = new FormData(); | ||||
|     data.append("child_name", child_name); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.tags.add_synonym = | ||||
|  | @ -358,7 +358,7 @@ function add_synonym(tag_name, syn_name, callback) | |||
|     const url = `/tag/${tag_name}/add_synonym`; | ||||
|     const data = new FormData(); | ||||
|     data.append("syn_name", syn_name); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.tags.create = | ||||
|  | @ -368,14 +368,14 @@ function create(name, description, callback) | |||
|     const data = new FormData(); | ||||
|     data.append("name", name); | ||||
|     data.append("description", description); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.tags.delete = | ||||
| function _delete(tag_name, callback) | ||||
| { | ||||
|     const url = `/tag/${tag_name}/delete`; | ||||
|     common.post(url, null, callback); | ||||
|     return common.post(url, null, callback); | ||||
| } | ||||
| 
 | ||||
| api.tags.easybake = | ||||
|  | @ -384,7 +384,7 @@ function easybake(easybake_string, callback) | |||
|     const url = "/tags/easybake"; | ||||
|     const data = new FormData(); | ||||
|     data.append("easybake_string", easybake_string); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.tags.edit = | ||||
|  | @ -394,14 +394,14 @@ function edit(tag_name, name, description, callback) | |||
|     const data = new FormData(); | ||||
|     data.append("name", name); | ||||
|     data.append("description", description); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.tags.get_all_tags = | ||||
| function get_all_tags(callback) | ||||
| { | ||||
|     const url = "/all_tags.json"; | ||||
|     common.get(url, callback); | ||||
|     return common.get(url, callback); | ||||
| } | ||||
| 
 | ||||
| api.tags.remove_child = | ||||
|  | @ -410,7 +410,7 @@ function remove_child(tag_name, child_name, callback) | |||
|     const url = `/tag/${tag_name}/remove_child`; | ||||
|     const data = new FormData(); | ||||
|     data.append("child_name", child_name); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.tags.remove_synonym = | ||||
|  | @ -419,7 +419,7 @@ function remove_synonym(tag_name, syn_name, callback) | |||
|     const url = `/tag/${tag_name}/remove_synonym`; | ||||
|     const data = new FormData(); | ||||
|     data.append("syn_name", syn_name); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.tags.callback_go_to_tags = | ||||
|  | @ -442,7 +442,7 @@ function edit(username, display_name, callback) | |||
|     const url = `/user/${username}/edit`; | ||||
|     const data = new FormData(); | ||||
|     data.append("display_name", display_name); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.users.login = | ||||
|  | @ -452,14 +452,14 @@ function login(username, password, callback) | |||
|     const data = new FormData(); | ||||
|     data.append("username", username); | ||||
|     data.append("password", password); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
| 
 | ||||
| api.users.logout = | ||||
| function logout(callback) | ||||
| { | ||||
|     const url = "/logout"; | ||||
|     common.post(url, null, callback); | ||||
|     return common.post(url, null, callback); | ||||
| } | ||||
| 
 | ||||
| api.users.register = | ||||
|  | @ -471,5 +471,5 @@ function register(username, display_name, password_1, password_2, callback) | |||
|     data.append("display_name", display_name); | ||||
|     data.append("password_1", password_1); | ||||
|     data.append("password_2", password_2); | ||||
|     common.post(url, data, callback); | ||||
|     return common.post(url, data, callback); | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue