2020-09-15 01:33:53 +00:00
|
|
|
const api = {};
|
2018-09-23 22:10:01 +00:00
|
|
|
|
2021-10-01 21:14:10 +00:00
|
|
|
/**************************************************************************************************/
|
|
|
|
api.admin = {};
|
|
|
|
|
|
|
|
api.admin.reload_config =
|
|
|
|
function reload_config(callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/admin/reload_config",
|
|
|
|
callback: callback,
|
|
|
|
});
|
2021-10-01 21:14:10 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 02:23:36 +00:00
|
|
|
api.admin.uncache =
|
|
|
|
function uncache(callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/admin/uncache",
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-07-23 02:23:36 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 22:10:01 +00:00
|
|
|
/**************************************************************************************************/
|
|
|
|
api.albums = {};
|
|
|
|
|
|
|
|
api.albums._add_remove_photos =
|
|
|
|
function _add_remove_photos(album_id, photo_ids, add_or_remove, callback)
|
|
|
|
{
|
2020-09-03 22:02:37 +00:00
|
|
|
let url;
|
2018-09-23 22:10:01 +00:00
|
|
|
if (add_or_remove === "add")
|
|
|
|
{ url = `/album/${album_id}/add_photo`; }
|
|
|
|
else if (add_or_remove === "remove")
|
|
|
|
{ url = `/album/${album_id}/remove_photo`; }
|
|
|
|
else
|
|
|
|
{ throw `should be 'add' or 'remove', not ${add_or_remove}.`; }
|
|
|
|
|
|
|
|
if (Array.isArray(photo_ids))
|
|
|
|
{ photo_ids = photo_ids.join(","); }
|
|
|
|
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: url,
|
|
|
|
data: {"photo_id": photo_ids},
|
|
|
|
callback: callback
|
|
|
|
});
|
2018-09-23 22:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.albums.add_child =
|
|
|
|
function add_child(album_id, child_id, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/album/${album_id}/add_child`,
|
|
|
|
data: {"child_id": child_id},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 22:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.albums.add_photos =
|
|
|
|
function add_photos(album_id, photo_ids, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return api.albums._add_remove_photos(album_id, photo_ids, "add", callback);
|
2018-09-23 22:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.albums.create =
|
|
|
|
function create(title, parent_id, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/albums/create_album",
|
|
|
|
data: {"title": title, "parent_id": parent_id},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 22:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.albums.delete =
|
|
|
|
function _delete(album_id, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/album/${album_id}/delete`,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 22:10:01 +00:00
|
|
|
}
|
|
|
|
|
2020-10-04 01:37:08 +00:00
|
|
|
api.albums.get_all_albums =
|
|
|
|
function get_all_albums(callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.get({
|
|
|
|
url: "/all_albums.json",
|
|
|
|
callback: callback,
|
|
|
|
});
|
2020-10-04 01:37:08 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 22:10:01 +00:00
|
|
|
api.albums.edit =
|
|
|
|
function edit(album_id, title, description, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/album/${album_id}/edit`,
|
|
|
|
data: {"title": title, "description": description},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 22:10:01 +00:00
|
|
|
}
|
|
|
|
|
2019-06-15 09:44:46 +00:00
|
|
|
api.albums.refresh_directories =
|
|
|
|
function refresh_directories(album_id, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/album/${album_id}/refresh_directories`,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2019-06-15 09:44:46 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 22:10:01 +00:00
|
|
|
api.albums.remove_child =
|
|
|
|
function remove_child(album_id, child_id, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/album/${album_id}/remove_child`,
|
|
|
|
data: {"child_id": child_id},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 22:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.albums.remove_photos =
|
|
|
|
function remove_photos(album_id, photo_ids, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return api.albums._add_remove_photos(album_id, photo_ids, "remove", callback);
|
2018-09-23 22:10:01 +00:00
|
|
|
}
|
|
|
|
|
2021-01-21 01:55:13 +00:00
|
|
|
api.albums.remove_thumbnail_photo =
|
|
|
|
function remove_thumbnail_photo(album_id, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/album/${album_id}/remove_thumbnail_photo`,
|
|
|
|
data: {},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2021-01-21 01:55:13 +00:00
|
|
|
}
|
|
|
|
|
2021-01-21 01:03:52 +00:00
|
|
|
api.albums.set_thumbnail_photo =
|
|
|
|
function set_thumbnail_photo(album_id, photo_id, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/album/${album_id}/set_thumbnail_photo`,
|
|
|
|
data: {"photo_id": photo_id},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2021-01-21 01:03:52 +00:00
|
|
|
}
|
|
|
|
|
2021-02-26 02:57:41 +00:00
|
|
|
api.albums.show_in_folder =
|
|
|
|
function show_in_folder(album_id, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/album/${album_id}/show_in_folder`,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2021-02-26 02:57:41 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 22:10:01 +00:00
|
|
|
api.albums.callback_follow =
|
|
|
|
function callback_follow(response)
|
|
|
|
{
|
2021-01-08 21:38:30 +00:00
|
|
|
if ((response.meta.status !== 200) || (! response.meta.json_ok) || (! response.data.id))
|
2018-09-23 22:10:01 +00:00
|
|
|
{
|
2020-11-07 06:34:01 +00:00
|
|
|
alert(JSON.stringify(response));
|
|
|
|
return;
|
2018-09-23 22:10:01 +00:00
|
|
|
}
|
2020-11-07 06:34:01 +00:00
|
|
|
window.location.href = "/album/" + response.data.id;
|
2018-09-23 22:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.albums.callback_go_to_albums =
|
|
|
|
function callback_go_to_albums(response)
|
|
|
|
{
|
2020-11-07 06:34:01 +00:00
|
|
|
if (response.meta.status !== 200)
|
2018-09-23 22:10:01 +00:00
|
|
|
{
|
2020-11-07 06:34:01 +00:00
|
|
|
alert(JSON.stringify(response));
|
|
|
|
return;
|
2018-09-23 22:10:01 +00:00
|
|
|
}
|
2020-11-07 06:34:01 +00:00
|
|
|
window.location.href = "/albums";
|
2018-09-23 22:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************************************/
|
|
|
|
api.bookmarks = {};
|
|
|
|
|
2018-09-23 22:43:42 +00:00
|
|
|
api.bookmarks.create =
|
|
|
|
function create(b_url, title, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/bookmarks/create_bookmark",
|
|
|
|
data: {"url": b_url.trim(), "title": title},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 22:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.bookmarks.delete =
|
|
|
|
function _delete(bookmark_id, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/bookmark/${bookmark_id}/delete`,
|
|
|
|
data: {},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 22:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.bookmarks.edit =
|
2019-01-13 22:58:23 +00:00
|
|
|
function edit(bookmark_id, title, b_url, callback)
|
2018-09-23 22:43:42 +00:00
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/bookmark/${bookmark_id}/edit`,
|
|
|
|
data: {"title": title.trim(), "url": b_url.trim()},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 22:43:42 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 22:10:01 +00:00
|
|
|
/**************************************************************************************************/
|
|
|
|
api.photos = {};
|
|
|
|
|
2018-09-23 22:52:19 +00:00
|
|
|
api.photos.add_tag =
|
|
|
|
function add_tag(photo_id, tagname, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/photo/${photo_id}/add_tag`,
|
|
|
|
data: {"tagname": tagname},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 22:52:19 +00:00
|
|
|
}
|
|
|
|
|
2020-08-31 02:18:06 +00:00
|
|
|
api.photos.batch_add_tag =
|
|
|
|
function batch_add_tag(photo_ids, tagname, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/batch/photos/add_tag",
|
|
|
|
data: {"photo_ids": photo_ids.join(","), "tagname": tagname},
|
|
|
|
add_remove_tag_callback: callback,
|
|
|
|
});
|
2020-08-31 02:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.photos.batch_refresh_metadata =
|
|
|
|
function batch_refresh_metadata(photo_ids, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/batch/photos/refresh_metadata",
|
|
|
|
data: {"photo_ids": photo_ids.join(",")},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2020-08-31 02:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.photos.batch_remove_tag =
|
|
|
|
function batch_remove_tag(photo_ids, tagname, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/batch/photos/remove_tag",
|
|
|
|
data: {"photo_ids": photo_ids.join(","), "tagname": tagname},
|
|
|
|
add_remove_tag_callback: callback,
|
|
|
|
});
|
2020-08-31 02:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.photos.batch_set_searchhidden =
|
|
|
|
function batch_set_searchhidden(photo_ids, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/batch/photos/set_searchhidden",
|
|
|
|
data: {"photo_ids": photo_ids.join(",")},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2020-08-31 02:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.photos.batch_unset_searchhidden =
|
|
|
|
function batch_unset_searchhidden(photo_ids, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/batch/photos/unset_searchhidden",
|
|
|
|
data: {"photo_ids": photo_ids.join(",")},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2020-08-31 02:18:06 +00:00
|
|
|
}
|
|
|
|
|
2021-04-29 20:12:37 +00:00
|
|
|
api.photos.copy_tags =
|
|
|
|
function copy_tags(photo_id, other_photo, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/photo/${photo_id}/copy_tags`,
|
|
|
|
data: {"other_photo": other_photo},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2021-04-29 20:12:37 +00:00
|
|
|
}
|
|
|
|
|
2020-02-27 02:57:29 +00:00
|
|
|
api.photos.delete =
|
|
|
|
function _delete(photo_id, delete_file, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/photo/${photo_id}/delete`,
|
|
|
|
data: {"delete_file": delete_file},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2020-02-27 02:57:29 +00:00
|
|
|
}
|
|
|
|
|
2020-01-12 22:52:03 +00:00
|
|
|
api.photos.generate_thumbnail =
|
|
|
|
function generate_thumbnail(photo_id, special, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/photo/${photo_id}/generate_thumbnail`,
|
|
|
|
data: special,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2020-01-12 22:52:03 +00:00
|
|
|
}
|
|
|
|
|
2020-08-31 02:18:06 +00:00
|
|
|
api.photos.get_download_zip_token =
|
|
|
|
function get_download_zip_token(photo_ids, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/batch/photos/download_zip",
|
|
|
|
data: {"photo_ids": photo_ids.join(",")},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2020-08-31 02:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.photos.download_zip =
|
|
|
|
function download_zip(zip_token)
|
|
|
|
{
|
2020-09-03 22:42:13 +00:00
|
|
|
const url = `/batch/photos/download_zip/${zip_token}.zip`;
|
2020-08-31 02:18:06 +00:00
|
|
|
window.location.href = url;
|
|
|
|
}
|
|
|
|
|
|
|
|
api.photos.callback_download_zip =
|
|
|
|
function callback_download_zip(response)
|
|
|
|
{
|
2020-09-03 22:02:37 +00:00
|
|
|
let zip_token = response.data.zip_token;
|
2020-08-31 02:18:06 +00:00
|
|
|
api.photos.download_zip(zip_token);
|
|
|
|
}
|
|
|
|
|
2018-09-23 22:52:19 +00:00
|
|
|
api.photos.refresh_metadata =
|
|
|
|
function refresh_metadata(photo_id, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/photo/${photo_id}/refresh_metadata`,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 22:52:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.photos.remove_tag =
|
|
|
|
function remove_tag(photo_id, tagname, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/photo/${photo_id}/remove_tag`,
|
|
|
|
data: {"tagname": tagname},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 22:52:19 +00:00
|
|
|
}
|
|
|
|
|
2021-06-02 00:51:31 +00:00
|
|
|
api.photos.search =
|
|
|
|
function search(parameters, callback)
|
|
|
|
{
|
|
|
|
parameters = parameters.toString();
|
|
|
|
let url = "/search.json";
|
|
|
|
if (parameters !== "" )
|
|
|
|
{
|
|
|
|
url += "?" + parameters;
|
|
|
|
}
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.get({
|
|
|
|
url: url,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2021-06-02 00:51:31 +00:00
|
|
|
}
|
|
|
|
|
2020-09-10 03:51:15 +00:00
|
|
|
api.photos.set_searchhidden =
|
|
|
|
function set_searchhidden(photo_id, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/photo/${photo_id}/set_searchhidden`,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2020-09-10 03:51:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.photos.unset_searchhidden =
|
|
|
|
function unset_searchhidden(photo_id, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/photo/${photo_id}/unset_searchhidden`,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2020-09-10 03:51:15 +00:00
|
|
|
}
|
|
|
|
|
2021-02-26 02:57:41 +00:00
|
|
|
api.photos.show_in_folder =
|
|
|
|
function show_in_folder(photo_id, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/photo/${photo_id}/show_in_folder`,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2021-02-26 02:57:41 +00:00
|
|
|
}
|
|
|
|
|
2020-02-27 02:57:29 +00:00
|
|
|
api.photos.callback_go_to_search =
|
2020-11-07 06:34:01 +00:00
|
|
|
function callback_go_to_search(response)
|
2020-02-27 02:57:29 +00:00
|
|
|
{
|
2020-11-07 06:34:01 +00:00
|
|
|
if (response.meta.status !== 200)
|
2020-02-27 02:57:29 +00:00
|
|
|
{
|
2020-11-07 06:34:01 +00:00
|
|
|
alert(JSON.stringify(response));
|
|
|
|
return;
|
2020-02-27 02:57:29 +00:00
|
|
|
}
|
2020-11-07 06:34:01 +00:00
|
|
|
window.location.href = "/search";
|
2020-02-27 02:57:29 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 22:10:01 +00:00
|
|
|
/**************************************************************************************************/
|
|
|
|
api.tags = {};
|
|
|
|
|
2018-09-23 23:41:34 +00:00
|
|
|
api.tags.add_child =
|
|
|
|
function add_child(tag_name, child_name, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/tag/${tag_name}/add_child`,
|
|
|
|
data: {"child_name": child_name},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 23:41:34 +00:00
|
|
|
}
|
|
|
|
|
2021-01-05 22:02:08 +00:00
|
|
|
api.tags.add_synonym =
|
|
|
|
function add_synonym(tag_name, syn_name, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/tag/${tag_name}/add_synonym`,
|
|
|
|
data: {"syn_name": syn_name},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2021-01-05 22:02:08 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 23:41:34 +00:00
|
|
|
api.tags.create =
|
|
|
|
function create(name, description, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/tags/create_tag`,
|
|
|
|
data: {"name": name, "description": description},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 23:41:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.tags.delete =
|
|
|
|
function _delete(tag_name, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/tag/${tag_name}/delete`,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 23:41:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.tags.easybake =
|
|
|
|
function easybake(easybake_string, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/tags/easybake",
|
|
|
|
data: {"easybake_string": easybake_string},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 23:41:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.tags.edit =
|
|
|
|
function edit(tag_name, name, description, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/tag/${tag_name}/edit`,
|
|
|
|
data: {"name": name, "description": description},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 23:41:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-29 23:51:59 +00:00
|
|
|
api.tags.get_all_tags =
|
|
|
|
function get_all_tags(callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.get({
|
|
|
|
url: "/all_tags.json",
|
|
|
|
callback: callback,
|
|
|
|
});
|
2020-09-29 23:51:59 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 23:41:34 +00:00
|
|
|
api.tags.remove_child =
|
|
|
|
function remove_child(tag_name, child_name, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/tag/${tag_name}/remove_child`,
|
|
|
|
data: {"child_name": child_name},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 23:41:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.tags.remove_synonym =
|
|
|
|
function remove_synonym(tag_name, syn_name, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/tag/${tag_name}/remove_synonym`,
|
|
|
|
data: {"syn_name": syn_name},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 23:41:34 +00:00
|
|
|
}
|
|
|
|
|
2020-02-27 22:57:27 +00:00
|
|
|
api.tags.callback_go_to_tags =
|
|
|
|
function callback_go_to_tags(response)
|
|
|
|
{
|
2020-11-07 06:34:01 +00:00
|
|
|
if (response.meta.status !== 200)
|
2020-02-27 22:57:27 +00:00
|
|
|
{
|
2020-11-07 06:34:01 +00:00
|
|
|
alert(JSON.stringify(response));
|
|
|
|
return;
|
2020-02-27 22:57:27 +00:00
|
|
|
}
|
2020-11-07 06:34:01 +00:00
|
|
|
window.location.href = "/tags";
|
2020-02-27 22:57:27 +00:00
|
|
|
}
|
2018-09-23 23:41:34 +00:00
|
|
|
|
2018-09-23 22:10:01 +00:00
|
|
|
/**************************************************************************************************/
|
|
|
|
api.users = {};
|
2018-09-23 23:50:27 +00:00
|
|
|
|
2021-01-02 03:46:31 +00:00
|
|
|
api.users.edit =
|
|
|
|
function edit(username, display_name, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/user/${username}/edit`,
|
|
|
|
data: {"display_name": display_name},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2021-01-02 03:46:31 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 23:50:27 +00:00
|
|
|
api.users.login =
|
|
|
|
function login(username, password, callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/login",
|
|
|
|
data: {"username": username, "password": password},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 23:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.users.logout =
|
|
|
|
function logout(callback)
|
|
|
|
{
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/logout",
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 23:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.users.register =
|
2019-08-26 21:32:51 +00:00
|
|
|
function register(username, display_name, password_1, password_2, callback)
|
2018-09-23 23:50:27 +00:00
|
|
|
{
|
2021-09-03 19:52:41 +00:00
|
|
|
const data = {
|
|
|
|
"username": username,
|
|
|
|
"display_name": display_name,
|
|
|
|
"password_1": password_1,
|
|
|
|
"password_2": password_2,
|
|
|
|
};
|
2022-09-30 00:34:35 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/register",
|
|
|
|
data: data,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2018-09-23 23:50:27 +00:00
|
|
|
}
|