2018-07-23 03:08:12 +00:00
|
|
|
var albums = {};
|
2018-03-10 01:38:40 +00:00
|
|
|
|
2018-07-23 03:08:12 +00:00
|
|
|
albums.create_child_prompt_button = null;
|
|
|
|
albums.create_child_title_entry = null;
|
|
|
|
albums.create_child_submit_button = null;
|
|
|
|
albums.create_child_cancel_button = null;
|
2018-03-10 01:38:40 +00:00
|
|
|
|
2018-07-23 03:08:12 +00:00
|
|
|
albums.open_creator_prompt =
|
2018-03-10 01:38:40 +00:00
|
|
|
function open_creator_prompt(event)
|
|
|
|
{
|
2018-07-23 03:08:12 +00:00
|
|
|
albums.create_child_prompt_button.classList.add("hidden");
|
|
|
|
albums.create_child_title_entry.classList.remove("hidden");
|
|
|
|
albums.create_child_title_entry.focus();
|
|
|
|
albums.create_child_submit_button.classList.remove("hidden");
|
|
|
|
albums.create_child_cancel_button.classList.remove("hidden");
|
2018-03-10 01:38:40 +00:00
|
|
|
}
|
|
|
|
|
2018-07-23 03:08:12 +00:00
|
|
|
albums.cancel_create_child =
|
2018-03-10 01:38:40 +00:00
|
|
|
function cancel_create_child(event)
|
|
|
|
{
|
2018-07-23 03:08:12 +00:00
|
|
|
albums.create_child_prompt_button.classList.remove("hidden");
|
|
|
|
albums.create_child_title_entry.value = "";
|
|
|
|
albums.create_child_title_entry.classList.add("hidden");
|
|
|
|
albums.create_child_submit_button.classList.add("hidden");
|
|
|
|
albums.create_child_cancel_button.classList.add("hidden");
|
2018-03-10 01:38:40 +00:00
|
|
|
}
|
|
|
|
|
2018-07-23 03:08:12 +00:00
|
|
|
albums.create_album_and_follow =
|
2018-03-10 01:38:40 +00:00
|
|
|
function create_album_and_follow(title, parent)
|
|
|
|
{
|
|
|
|
var url = "/albums/create_album";
|
|
|
|
var data = new FormData();
|
|
|
|
if (title !== undefined)
|
|
|
|
{
|
|
|
|
data.append("title", title);
|
|
|
|
}
|
|
|
|
if (parent !== undefined)
|
|
|
|
{
|
|
|
|
data.append("parent", parent);
|
|
|
|
}
|
|
|
|
function receive_callback(response)
|
|
|
|
{
|
|
|
|
if (response["meta"]["status"] == 200 && response["data"]["id"])
|
|
|
|
{
|
|
|
|
window.location.href = "/album/" + response["data"]["id"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
console.log(response);
|
|
|
|
}
|
|
|
|
}
|
2018-07-23 02:12:08 +00:00
|
|
|
common.post(url, data, receive_callback);
|
2018-03-10 01:38:40 +00:00
|
|
|
}
|
|
|
|
|
2018-07-23 03:08:12 +00:00
|
|
|
albums.submit_create_child =
|
2018-03-10 01:38:40 +00:00
|
|
|
function submit_create_child(event)
|
|
|
|
{
|
|
|
|
var title = document.getElementById("create_child_title_entry").value;
|
|
|
|
if (! title)
|
|
|
|
{
|
|
|
|
title = undefined;
|
|
|
|
}
|
|
|
|
var parent_id = ALBUM_ID;
|
2018-07-23 03:08:12 +00:00
|
|
|
albums.create_album_and_follow(title, parent_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
albums.on_pageload =
|
|
|
|
function on_pageload()
|
|
|
|
{
|
|
|
|
albums.create_child_prompt_button = document.getElementById("create_child_prompt_button");
|
|
|
|
albums.create_child_title_entry = document.getElementById("create_child_title_entry");
|
|
|
|
albums.create_child_submit_button = document.getElementById("create_child_submit_button");
|
|
|
|
albums.create_child_cancel_button = document.getElementById("create_child_cancel_button");
|
|
|
|
common.bind_box_to_button(albums.create_child_title_entry, albums.create_child_submit_button);
|
2018-03-10 01:38:40 +00:00
|
|
|
}
|
2018-07-23 03:08:12 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", albums.on_pageload);
|