Use const for api.js url/data variables.
This commit is contained in:
parent
c091e5fa36
commit
d6a46ed551
1 changed files with 56 additions and 56 deletions
|
@ -14,7 +14,7 @@ function _add_remove_photos(album_id, photo_ids, add_or_remove, callback)
|
||||||
else
|
else
|
||||||
{ throw `should be 'add' or 'remove', not ${add_or_remove}.`; }
|
{ throw `should be 'add' or 'remove', not ${add_or_remove}.`; }
|
||||||
|
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
|
|
||||||
if (Array.isArray(photo_ids))
|
if (Array.isArray(photo_ids))
|
||||||
{ photo_ids = photo_ids.join(","); }
|
{ photo_ids = photo_ids.join(","); }
|
||||||
|
@ -26,8 +26,8 @@ function _add_remove_photos(album_id, photo_ids, add_or_remove, callback)
|
||||||
api.albums.add_child =
|
api.albums.add_child =
|
||||||
function add_child(album_id, child_id, callback)
|
function add_child(album_id, child_id, callback)
|
||||||
{
|
{
|
||||||
let url = `/album/${album_id}/add_child`;
|
const url = `/album/${album_id}/add_child`;
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("child_id", child_id);
|
data.append("child_id", child_id);
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,8 @@ function add_photos(album_id, photo_ids, callback)
|
||||||
api.albums.create =
|
api.albums.create =
|
||||||
function create(title, parent_id, callback)
|
function create(title, parent_id, callback)
|
||||||
{
|
{
|
||||||
let url = "/albums/create_album";
|
const url = "/albums/create_album";
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
if (title !== undefined)
|
if (title !== undefined)
|
||||||
{
|
{
|
||||||
data.append("title", title);
|
data.append("title", title);
|
||||||
|
@ -57,15 +57,15 @@ function create(title, parent_id, callback)
|
||||||
api.albums.delete =
|
api.albums.delete =
|
||||||
function _delete(album_id, callback)
|
function _delete(album_id, callback)
|
||||||
{
|
{
|
||||||
let url = `/album/${album_id}/delete`;
|
const url = `/album/${album_id}/delete`;
|
||||||
common.post(url, null, callback);
|
common.post(url, null, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.albums.edit =
|
api.albums.edit =
|
||||||
function edit(album_id, title, description, callback)
|
function edit(album_id, title, description, callback)
|
||||||
{
|
{
|
||||||
let url = `/album/${album_id}/edit`;
|
const url = `/album/${album_id}/edit`;
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("title", title);
|
data.append("title", title);
|
||||||
data.append("description", description);
|
data.append("description", description);
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
|
@ -74,15 +74,15 @@ function edit(album_id, title, description, callback)
|
||||||
api.albums.refresh_directories =
|
api.albums.refresh_directories =
|
||||||
function refresh_directories(album_id, callback)
|
function refresh_directories(album_id, callback)
|
||||||
{
|
{
|
||||||
let url = `/album/${album_id}/refresh_directories`;
|
const url = `/album/${album_id}/refresh_directories`;
|
||||||
common.post(url, null, callback);
|
common.post(url, null, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.albums.remove_child =
|
api.albums.remove_child =
|
||||||
function remove_child(album_id, child_id, callback)
|
function remove_child(album_id, child_id, callback)
|
||||||
{
|
{
|
||||||
let url = `/album/${album_id}/remove_child`;
|
const url = `/album/${album_id}/remove_child`;
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("child_id", child_id);
|
data.append("child_id", child_id);
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
}
|
}
|
||||||
|
@ -125,8 +125,8 @@ api.bookmarks = {};
|
||||||
api.bookmarks.create =
|
api.bookmarks.create =
|
||||||
function create(b_url, title, callback)
|
function create(b_url, title, callback)
|
||||||
{
|
{
|
||||||
let url = "/bookmarks/create_bookmark";
|
const url = "/bookmarks/create_bookmark";
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("url", b_url.trim());
|
data.append("url", b_url.trim());
|
||||||
title = title.trim();
|
title = title.trim();
|
||||||
if (title)
|
if (title)
|
||||||
|
@ -139,15 +139,15 @@ function create(b_url, title, callback)
|
||||||
api.bookmarks.delete =
|
api.bookmarks.delete =
|
||||||
function _delete(bookmark_id, callback)
|
function _delete(bookmark_id, callback)
|
||||||
{
|
{
|
||||||
let url = `/bookmark/${bookmark_id}/delete`;
|
const url = `/bookmark/${bookmark_id}/delete`;
|
||||||
common.post(url, null, callback);
|
common.post(url, null, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.bookmarks.edit =
|
api.bookmarks.edit =
|
||||||
function edit(bookmark_id, title, b_url, callback)
|
function edit(bookmark_id, title, b_url, callback)
|
||||||
{
|
{
|
||||||
let url = `/bookmark/${bookmark_id}/edit`;
|
const url = `/bookmark/${bookmark_id}/edit`;
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("title", title.trim());
|
data.append("title", title.trim());
|
||||||
data.append("url", b_url.trim());
|
data.append("url", b_url.trim());
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
|
@ -159,8 +159,8 @@ api.photos = {};
|
||||||
api.photos.add_tag =
|
api.photos.add_tag =
|
||||||
function add_tag(photo_id, tagname, callback)
|
function add_tag(photo_id, tagname, callback)
|
||||||
{
|
{
|
||||||
let url = `/photo/${photo_id}/add_tag`;
|
const url = `/photo/${photo_id}/add_tag`;
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("tagname", tagname);
|
data.append("tagname", tagname);
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
}
|
}
|
||||||
|
@ -168,8 +168,8 @@ function add_tag(photo_id, tagname, callback)
|
||||||
api.photos.batch_add_tag =
|
api.photos.batch_add_tag =
|
||||||
function batch_add_tag(photo_ids, tagname, callback)
|
function batch_add_tag(photo_ids, tagname, callback)
|
||||||
{
|
{
|
||||||
let url = "/batch/photos/add_tag";
|
const url = "/batch/photos/add_tag";
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("photo_ids", photo_ids.join(","));
|
data.append("photo_ids", photo_ids.join(","));
|
||||||
data.append("tagname", tagname);
|
data.append("tagname", tagname);
|
||||||
common.post(url, data, add_remove_tag_callback);
|
common.post(url, data, add_remove_tag_callback);
|
||||||
|
@ -178,8 +178,8 @@ function batch_add_tag(photo_ids, tagname, callback)
|
||||||
api.photos.batch_refresh_metadata =
|
api.photos.batch_refresh_metadata =
|
||||||
function batch_refresh_metadata(photo_ids, callback)
|
function batch_refresh_metadata(photo_ids, callback)
|
||||||
{
|
{
|
||||||
let url = "/batch/photos/refresh_metadata";
|
const url = "/batch/photos/refresh_metadata";
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("photo_ids", photo_ids.join(","));
|
data.append("photo_ids", photo_ids.join(","));
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
}
|
}
|
||||||
|
@ -187,8 +187,8 @@ function batch_refresh_metadata(photo_ids, callback)
|
||||||
api.photos.batch_remove_tag =
|
api.photos.batch_remove_tag =
|
||||||
function batch_remove_tag(photo_ids, tagname, callback)
|
function batch_remove_tag(photo_ids, tagname, callback)
|
||||||
{
|
{
|
||||||
let url = "/batch/photos/remove_tag";
|
const url = "/batch/photos/remove_tag";
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("photo_ids", photo_ids.join(","));
|
data.append("photo_ids", photo_ids.join(","));
|
||||||
data.append("tagname", tagname);
|
data.append("tagname", tagname);
|
||||||
common.post(url, data, add_remove_tag_callback);
|
common.post(url, data, add_remove_tag_callback);
|
||||||
|
@ -197,8 +197,8 @@ function batch_remove_tag(photo_ids, tagname, callback)
|
||||||
api.photos.batch_set_searchhidden =
|
api.photos.batch_set_searchhidden =
|
||||||
function batch_set_searchhidden(photo_ids, callback)
|
function batch_set_searchhidden(photo_ids, callback)
|
||||||
{
|
{
|
||||||
let url = "/batch/photos/set_searchhidden";
|
const url = "/batch/photos/set_searchhidden";
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("photo_ids", photo_ids.join(","));
|
data.append("photo_ids", photo_ids.join(","));
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
}
|
}
|
||||||
|
@ -206,8 +206,8 @@ function batch_set_searchhidden(photo_ids, callback)
|
||||||
api.photos.batch_unset_searchhidden =
|
api.photos.batch_unset_searchhidden =
|
||||||
function batch_unset_searchhidden(photo_ids, callback)
|
function batch_unset_searchhidden(photo_ids, callback)
|
||||||
{
|
{
|
||||||
let url = "/batch/photos/unset_searchhidden";
|
const url = "/batch/photos/unset_searchhidden";
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("photo_ids", photo_ids.join(","));
|
data.append("photo_ids", photo_ids.join(","));
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
}
|
}
|
||||||
|
@ -215,8 +215,8 @@ function batch_unset_searchhidden(photo_ids, callback)
|
||||||
api.photos.delete =
|
api.photos.delete =
|
||||||
function _delete(photo_id, delete_file, callback)
|
function _delete(photo_id, delete_file, callback)
|
||||||
{
|
{
|
||||||
let url = `/photo/${photo_id}/delete`;
|
const url = `/photo/${photo_id}/delete`;
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("delete_file", delete_file);
|
data.append("delete_file", delete_file);
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
}
|
}
|
||||||
|
@ -224,8 +224,8 @@ function _delete(photo_id, delete_file, callback)
|
||||||
api.photos.generate_thumbnail =
|
api.photos.generate_thumbnail =
|
||||||
function generate_thumbnail(photo_id, special, callback)
|
function generate_thumbnail(photo_id, special, callback)
|
||||||
{
|
{
|
||||||
let url = `/photo/${photo_id}/generate_thumbnail`
|
const url = `/photo/${photo_id}/generate_thumbnail`
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
for (x in special)
|
for (x in special)
|
||||||
{
|
{
|
||||||
data.append(x, special[x]);
|
data.append(x, special[x]);
|
||||||
|
@ -236,8 +236,8 @@ function generate_thumbnail(photo_id, special, callback)
|
||||||
api.photos.get_download_zip_token =
|
api.photos.get_download_zip_token =
|
||||||
function get_download_zip_token(photo_ids, callback)
|
function get_download_zip_token(photo_ids, callback)
|
||||||
{
|
{
|
||||||
let url = "/batch/photos/download_zip";
|
const url = "/batch/photos/download_zip";
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("photo_ids", photo_ids.join(","));
|
data.append("photo_ids", photo_ids.join(","));
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ function get_download_zip_token(photo_ids, callback)
|
||||||
api.photos.download_zip =
|
api.photos.download_zip =
|
||||||
function download_zip(zip_token)
|
function download_zip(zip_token)
|
||||||
{
|
{
|
||||||
let url = `/batch/photos/download_zip/${zip_token}.zip`;
|
const url = `/batch/photos/download_zip/${zip_token}.zip`;
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,15 +259,15 @@ function callback_download_zip(response)
|
||||||
api.photos.refresh_metadata =
|
api.photos.refresh_metadata =
|
||||||
function refresh_metadata(photo_id, callback)
|
function refresh_metadata(photo_id, callback)
|
||||||
{
|
{
|
||||||
let url = `/photo/${photo_id}/refresh_metadata`;
|
const url = `/photo/${photo_id}/refresh_metadata`;
|
||||||
common.post(url, null, callback);
|
common.post(url, null, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.photos.remove_tag =
|
api.photos.remove_tag =
|
||||||
function remove_tag(photo_id, tagname, callback)
|
function remove_tag(photo_id, tagname, callback)
|
||||||
{
|
{
|
||||||
let url = `/photo/${photo_id}/remove_tag`;
|
const url = `/photo/${photo_id}/remove_tag`;
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("tagname", tagname);
|
data.append("tagname", tagname);
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
}
|
}
|
||||||
|
@ -291,8 +291,8 @@ api.tags = {};
|
||||||
api.tags.add_child =
|
api.tags.add_child =
|
||||||
function add_child(tag_name, child_name, callback)
|
function add_child(tag_name, child_name, callback)
|
||||||
{
|
{
|
||||||
let url = `/tag/${tag_name}/add_child`;
|
const url = `/tag/${tag_name}/add_child`;
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("child_name", child_name);
|
data.append("child_name", child_name);
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
}
|
}
|
||||||
|
@ -300,8 +300,8 @@ function add_child(tag_name, child_name, callback)
|
||||||
api.tags.create =
|
api.tags.create =
|
||||||
function create(name, description, callback)
|
function create(name, description, callback)
|
||||||
{
|
{
|
||||||
let url = `/tags/create_tag`;
|
const url = `/tags/create_tag`;
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("name", name);
|
data.append("name", name);
|
||||||
data.append("description", description);
|
data.append("description", description);
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
|
@ -310,15 +310,15 @@ function create(name, description, callback)
|
||||||
api.tags.delete =
|
api.tags.delete =
|
||||||
function _delete(tag_name, callback)
|
function _delete(tag_name, callback)
|
||||||
{
|
{
|
||||||
let url = `/tag/${tag_name}/delete`;
|
const url = `/tag/${tag_name}/delete`;
|
||||||
common.post(url, null, callback);
|
common.post(url, null, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.tags.easybake =
|
api.tags.easybake =
|
||||||
function easybake(easybake_string, callback)
|
function easybake(easybake_string, callback)
|
||||||
{
|
{
|
||||||
let url = "/tags/easybake";
|
const url = "/tags/easybake";
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("easybake_string", easybake_string);
|
data.append("easybake_string", easybake_string);
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
}
|
}
|
||||||
|
@ -326,8 +326,8 @@ function easybake(easybake_string, callback)
|
||||||
api.tags.edit =
|
api.tags.edit =
|
||||||
function edit(tag_name, name, description, callback)
|
function edit(tag_name, name, description, callback)
|
||||||
{
|
{
|
||||||
let url = `/tag/${tag_name}/edit`;
|
const url = `/tag/${tag_name}/edit`;
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("name", name);
|
data.append("name", name);
|
||||||
data.append("description", description);
|
data.append("description", description);
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
|
@ -336,8 +336,8 @@ function edit(tag_name, name, description, callback)
|
||||||
api.tags.remove_child =
|
api.tags.remove_child =
|
||||||
function remove_child(tag_name, child_name, callback)
|
function remove_child(tag_name, child_name, callback)
|
||||||
{
|
{
|
||||||
let url = `/tag/${tag_name}/remove_child`;
|
const url = `/tag/${tag_name}/remove_child`;
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("child_name", child_name);
|
data.append("child_name", child_name);
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
}
|
}
|
||||||
|
@ -345,8 +345,8 @@ function remove_child(tag_name, child_name, callback)
|
||||||
api.tags.remove_synonym =
|
api.tags.remove_synonym =
|
||||||
function remove_synonym(tag_name, syn_name, callback)
|
function remove_synonym(tag_name, syn_name, callback)
|
||||||
{
|
{
|
||||||
let url = `/tag/${tag_name}/remove_synonym`;
|
const url = `/tag/${tag_name}/remove_synonym`;
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("syn_name", syn_name);
|
data.append("syn_name", syn_name);
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
}
|
}
|
||||||
|
@ -370,8 +370,8 @@ api.users = {};
|
||||||
api.users.login =
|
api.users.login =
|
||||||
function login(username, password, callback)
|
function login(username, password, callback)
|
||||||
{
|
{
|
||||||
let url = "/login";
|
const url = "/login";
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("username", username);
|
data.append("username", username);
|
||||||
data.append("password", password);
|
data.append("password", password);
|
||||||
common.post(url, data, callback);
|
common.post(url, data, callback);
|
||||||
|
@ -380,15 +380,15 @@ function login(username, password, callback)
|
||||||
api.users.logout =
|
api.users.logout =
|
||||||
function logout(callback)
|
function logout(callback)
|
||||||
{
|
{
|
||||||
let url = "/logout";
|
const url = "/logout";
|
||||||
common.post(url, null, callback);
|
common.post(url, null, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.users.register =
|
api.users.register =
|
||||||
function register(username, display_name, password_1, password_2, callback)
|
function register(username, display_name, password_1, password_2, callback)
|
||||||
{
|
{
|
||||||
let url = "/register";
|
const url = "/register";
|
||||||
let data = new FormData();
|
const data = new FormData();
|
||||||
data.append("username", username);
|
data.append("username", username);
|
||||||
data.append("display_name", display_name);
|
data.append("display_name", display_name);
|
||||||
data.append("password_1", password_1);
|
data.append("password_1", password_1);
|
||||||
|
|
Loading…
Reference in a new issue