var exId = getUrlParam("id");
$(function () {
    $.ajax({
        type: "POST",
        url: "/manage_exhibitions/edit",
        data: JSON.stringify({
            id: Number(exId)
        }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (exData) {
            formContent =
                `<div class="cover-panel">
            <div class="cover-frame">
                <img class="cover" id="cover" width="100" height="100" src="${exData.Cover}">
            </div>
            <div class="cover-input-panel">
                <h2>上传封面图</h2>
                <input type="file" id="upload-btn" accept="image/jpeg,image/png" onchange="upload(this)">
            </div>
        </div>
        <div class="classification-panel">
                <label>展览分类</label>
                <select id="classification">
                    <option value="1" ${selectState(1, exData.Classification)}>戏剧家协会</option>
                    <option value="3" ${selectState(3, exData.Classification)}>音乐家协会</option>
                    <option value="4" ${selectState(4, exData.Classification)}>美术家协会</option>
                    <option value="5" ${selectState(5, exData.Classification)}>曲艺家协会</option>
                    <option value="6" ${selectState(6, exData.Classification)}>舞蹈家协会</option>
                    <option value="7" ${selectState(7, exData.Classification)}>民间文艺家协会</option>
                    <option value="8" ${selectState(8, exData.Classification)}>摄影家协会</option>
                    <option value="9" ${selectState(9, exData.Classification)}>书法家协会</option>
                    <option value="13" ${selectState(13, exData.Classification)}>杂技家协会</option>
                    <option value="2" ${selectState(2, exData.Classification)}>影视家协会</option>
                    <option value="12" ${selectState(12, exData.Classification)}>企业（行业）文联</option>
                    <option value="10" ${selectState(10, exData.Classification)}>文艺评论家协会</option>
                    <option value="11" ${selectState(11, exData.Classification)}>志愿者协会</option>
                </select>
            </div>
        <div class="fine-work-panel">
                <label>精品</label>
                <input id="input-fine-work" type="checkbox" ${checkedState(exData.FineWork)}>
        </div>
        <div class="master-panel">
                <label>文艺名家</label>
                <input id="input-master" type="checkbox" ${checkedState(exData.Master)}>
            </div>
        <div class="title-panel">
            <input class="input-text" id="title" type="text" placeholder="主标题" value="${exData.Title}">
        </div>
        <div class="subtitle-panel">
            <input class="input-text" id="subtitle" type="text" placeholder="副标题" value="${exData.Subtitle}">
        </div>
        <div class="time-panel">
            <div>
                <label>开始时间</label>
                <input class="input-time" id="starttime" type="datetime-local" value="${conertToHtmlDate(exData.StartTime)}">
            </div>
            <div>
                <label>结束时间</label>
                <input class="input-time" id="endtime" type="datetime-local" value="${conertToHtmlDate(exData.EndTime)}">
            </div>
        </div>
        <div class="btn-panel">
            <input class="update-btn" type="button" value="更新" onclick="update()">
            <input class="delete-btn" type="button" value="删除" onclick="deleteExhibition()">
        </div>`
            $('form').html(formContent)

            // 开幕式、展厅、演播厅等
            content =
                `<div>
                    <h2>开幕式</h2>
                    <div class="edit-opening-ceremony-panel">
                        <input class="input-edit-opening-ceremony" type="button" value="编辑开幕式" onclick="editOpeningCeremony()">
                        <input class="input-use-opening-ceremony" type="button" value="使用" onclick="useOpeningCeremony(this)" ${checkVisibleState(!exData.OpeningCeremonyUsed)}>
                        <input class="input-cancel-use-opening-ceremony" type="button" value="取消使用" onclick="cancelUseOpeningCeremony(this)" ${checkVisibleState(exData.OpeningCeremonyUsed)}>
                    </div>
                </div>
                <hr>
                <div>
                    <h2>展厅/演播厅(<span style="color:red;">现代/古典展厅、现代/古典演播厅不可同时使用</span>)</h2>
                    <div class="exhibition-hall-studio-panel">
                        <div id="modern-exhibition-hall-panel">
                            <input class="input-edit-exhibition-hall" type="button" value="编辑现代展厅" onclick="editModernExhibitionHall()">
                            <input class="input-use-modern-exhibition-hall" type="button" value="使用" onclick="useModernExhibitionHall()" ${checkVisibleState(!exData.ExhibitionHallUsed || exData.Style != 1)}>
                            <input class="input-cancel-use-modern-exhibition-hall" type="button" value="取消使用" onclick="cancelModernUseExhibitionHall()" ${checkVisibleState(exData.ExhibitionHallUsed && exData.Style == 1)}>
                        </div>
                        <div id="ancient-exhibition-hall-panel">
                            <input class="input-edit-exhibition-hall" type="button" value="编辑古典展厅" onclick="editAncientExhibitionHall()">
                            <input class="input-use-ancient-exhibition-hall" type="button" value="使用" onclick="useAncientExhibitionHall()" ${checkVisibleState(!exData.ExhibitionHallUsed || exData.Style != 2)}>
                            <input class="input-cancel-use-ancient-exhibition-hall" type="button" value="取消使用" onclick="cancelAncientUseExhibitionHall()" ${checkVisibleState(exData.ExhibitionHallUsed && exData.Style == 2)}>
                        </div>
                        <hr>
                        <div class="modern-studio-panel" id="modern-studio-panel">
                            <input class="input-edit-studio" type="button" value="编辑现代演播厅" onclick="editModernStudio()">
                            <input class="input-use-modern-studio" type="button" value="使用" onclick="useModernStudio()" ${checkVisibleState(!exData.StudioUsed || exData.Style != 1)}>
                            <input class="input-cancel-use-modern-studio" type="button" value="取消使用" onclick="cancelUseModernStudio()" ${checkVisibleState(exData.StudioUsed && exData.Style == 1)}>
                        </div>
                        <div class="ancient-studio-panel" id="ancient-studio-panel">
                            <input class="input-edit-studio" type="button" value="编辑古典演播厅" onclick="editAncientStudio()">
                            <input class="input-use-ancient-studio" type="button" value="使用" onclick="useAncientStudio()" ${checkVisibleState(!exData.StudioUsed || exData.Style != 2)}>
                            <input class="input-cancel-use-ancient-studio" type="button" value="取消使用" onclick="cancelUseAncientStudio()" ${checkVisibleState(exData.StudioUsed && exData.Style == 2)}>
                        </div>
                    </div>
                </div>`
            $('#edit-hall-panel').html(content)
        },
        error: function (xhr, textStatus, error) {
            var msg = JSON.parse(xhr.responseText);
            alert(msg.error);
        }
    });
})

function back() {
    history.back();
}

function update() {
    var title = document.getElementById("title");
    if (title.value.length == 0) {
        alert("主标题不可为空！");
        return;
    }
    var subtitle = document.getElementById("subtitle");
    if (subtitle.value.length == 0) {
        alert("副标题不可为空！");
        return;
    }
    var startTime = document.getElementById("starttime");
    if (startTime.value.length == 0) {
        alert("开始时间不可为空！");
        return;
    }
    var endTime = document.getElementById("endtime");
    if (endTime.value.length == 0) {
        alert("结束时间不可为空！");
        return;
    }
    // 比较开始时间和结束时间
    var momentStartTime = moment(startTime.value)
    var momentEndTime = moment(endTime.value)
    if (momentEndTime.isSameOrBefore(momentStartTime)) {
        alert("结束时间必现大于开始时间")
        return
    }
    var cover = document.getElementById("cover");
    if (cover.src.length == 0) {
        alert("封面图不可为空！");
        return;
    }
    var fineWork = document.getElementById("input-fine-work")
    var master = document.getElementById("input-master")
    var classification = document.getElementById("classification");

    $.ajax({
        type: "POST",
        url: "/manage_exhibitions/update",
        data: JSON.stringify({
            id: Number(exId),
            title: title.value,
            subtitle: subtitle.value,
            start_time: dateFormat(startTime.value),
            end_time: dateFormat(endTime.value),
            cover: cover.src,
            fine_work: fineWork.checked,
            master: master.checked,
            classification: Number(classification.value)
        }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (user) {
            alert("更新展览成功");
        },
        error: function (xhr, textStatus, error) {
            var msg = JSON.parse(xhr.responseText);
            alert(msg.error);
        }
    });
}

function deleteExhibition() {
    if (exId == null) {
        alert("展览未保存，无法删除！")
        return
    }
    if (confirm("展览删除后不可恢复，确认删除吗？")) {
        $.ajax({
            type: "POST",
            url: "/manage_exhibitions/delete",
            data: JSON.stringify({
                id: Number(exId)
            }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (user) {
                alert("删除展览成功");
                back();
            },
            error: function (xhr, textStatus, error) {
                var msg = JSON.parse(xhr.responseText);
                alert(msg.error);
            }
        });
    }
}

// 编辑开幕式
function editOpeningCeremony() {
    window.location.assign("/view/html/edit_opening_ceremony.html?id=" + exId); // 展览id
}

// 编辑现代展厅
function editModernExhibitionHall() {
    window.location.assign("/view/html/edit_exhibition_hall.html?id=" + exId+"&style=1"); // 展览id
}

// 编辑古典展厅
function editAncientExhibitionHall() {
    window.location.assign("/view/html/edit_exhibition_hall.html?id=" + exId+"&style=2"); // 展览id
}

// 编辑现代演播厅
function editModernStudio() {
    window.location.assign("/view/html/edit_studio.html?id=" + exId+"&style=1"); // 展览id
}

// 编辑古典演播厅
function editAncientStudio() {
    window.location.assign("/view/html/edit_studio.html?id=" + exId+"&style=2"); // 展览id
}

// 展览场馆使用操作
// 开幕式使用操作
function useOpeningCeremony(btn) {
    if (confirm("使用开幕式后，游客将首先进入开幕式，之后进入展厅或演播厅，确认使用吗？")) {
        $.ajax({
            type: "POST",
            url: "/manage_exhibitions/use_opening_ceremony",
            data: JSON.stringify({ id: Number(exId) }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (user) {
                var btns = btn.parentNode.children
                for (let i = 0; i < btns.length; i++) {
                    if (btns[i].className == "input-cancel-use-opening-ceremony") {
                        btns[i].hidden = false
                    } else if (btns[i].className == "input-use-opening-ceremony") {
                        btns[i].hidden = true
                    }
                }
                alert("使用开幕式成功")
            },
            error: function (xhr, textStatus, error) {
                var msg = JSON.parse(xhr.responseText);
                alert(msg.error);
            }
        });
    }
}
function cancelUseOpeningCeremony(btn) {
    if (confirm("取消使用开幕式后，游客将不会进入开幕式，直接进入展厅或演播厅，确认取消使用吗？")) {
        $.ajax({
            type: "POST",
            url: "/manage_exhibitions/cancel_use_opening_ceremony",
            data: JSON.stringify({ id: Number(exId) }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (user) {
                var btns = btn.parentNode.children
                for (let i = 0; i < btns.length; i++) {
                    if (btns[i].className == "input-cancel-use-opening-ceremony") {
                        btns[i].hidden = true
                    } else if (btns[i].className == "input-use-opening-ceremony") {
                        btns[i].hidden = false
                    }
                }
                alert("取消使用开幕式成功")
            },
            error: function (xhr, textStatus, error) {
                var msg = JSON.parse(xhr.responseText);
                alert(msg.error);
            }
        });
    }
}
// 现代展厅使用操作
function useModernExhibitionHall() {
    if (confirm("展厅(现代/古典)与演播厅(现代/古典)同时只可选择一种，选择使用现代展厅后，古典展厅与所有演播厅将被取消使用，确认使用吗？")) {
        $.ajax({
            type: "POST",
            url: "/manage_exhibitions/use_exhibition_hall",
            data: JSON.stringify({
                id: Number(exId),
                style: 1
            }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (user) {
                // 现代展厅按钮操作
                var modernExhibitionBtns = document.getElementById("modern-exhibition-hall-panel").children
                for (let i = 0; i < modernExhibitionBtns.length; i++) {
                    if (modernExhibitionBtns[i].className == "input-cancel-use-modern-exhibition-hall") {
                        modernExhibitionBtns[i].hidden = false
                    } else if (modernExhibitionBtns[i].className == "input-use-modern-exhibition-hall") {
                        modernExhibitionBtns[i].hidden = true
                    }
                }
                // 古典展厅按钮操作
                var ancientExhibitionBtns = document.getElementById("ancient-exhibition-hall-panel").children
                for (let i = 0; i < ancientExhibitionBtns.length; i++) {
                    if (ancientExhibitionBtns[i].className == "input-cancel-use-ancient-exhibition-hall") {
                        ancientExhibitionBtns[i].hidden = true
                    } else if (ancientExhibitionBtns[i].className == "input-use-ancient-exhibition-hall") {
                        ancientExhibitionBtns[i].hidden = false
                    }
                }
                // 现代演播厅按钮操作
                var modernStudioBtns = document.getElementById("modern-studio-panel").children
                for (let i = 0; i < modernStudioBtns.length; i++) {
                    if (modernStudioBtns[i].className == "input-cancel-use-modern-studio") {
                        modernStudioBtns[i].hidden = true
                    } else if (modernStudioBtns[i].className == "input-use-modern-studio") {
                        modernStudioBtns[i].hidden = false
                    }
                }
                // 古典演播厅按钮操作
                var ancientStudioBtns = document.getElementById("ancient-studio-panel").children
                for (let i = 0; i < ancientStudioBtns.length; i++) {
                    if (ancientStudioBtns[i].className == "input-cancel-use-ancient-studio") {
                        ancientStudioBtns[i].hidden = true
                    } else if (ancientStudioBtns[i].className == "input-use-ancient-studio") {
                        ancientStudioBtns[i].hidden = false
                    }
                }
                alert("使用现代展厅成功")
            },
            error: function (xhr, textStatus, error) {
                var msg = JSON.parse(xhr.responseText);
                alert(msg.error);
            }
        });
    }
}
function cancelModernUseExhibitionHall() {
    if (confirm("取消使用现代展厅后，游客将不会再进入现代展厅，确认取消使用吗？")) {
        $.ajax({
            type: "POST",
            url: "/manage_exhibitions/cancel_use_exhibition_hall",
            data: JSON.stringify({
                id: Number(exId),
                style: 1
            }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (user) {
                // 展厅按钮操作
                var btns = document.getElementById("modern-exhibition-hall-panel").children
                for (let i = 0; i < btns.length; i++) {
                    if (btns[i].className == "input-cancel-use-modern-exhibition-hall") {
                        btns[i].hidden = true
                    } else if (btns[i].className == "input-use-modern-exhibition-hall") {
                        btns[i].hidden = false
                    }
                }
                alert("取消使用现代展厅成功")
            },
            error: function (xhr, textStatus, error) {
                var msg = JSON.parse(xhr.responseText);
                alert(msg.error);
            }
        });
    }
}

// 古典展厅使用操作
function useAncientExhibitionHall() {
    if (confirm("展厅(现代/古典)与演播厅(现代/古典)同时只可选择一种，选择使用古典展厅后，现代展厅与所有演播厅将被取消使用，确认使用吗？")) {
        $.ajax({
            type: "POST",
            url: "/manage_exhibitions/use_exhibition_hall",
            data: JSON.stringify({
                id: Number(exId),
                style: 2
            }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (user) {
                // 古典展厅按钮操作
                var ancientExhibitionBtns = document.getElementById("ancient-exhibition-hall-panel").children
                for (let i = 0; i < ancientExhibitionBtns.length; i++) {
                    if (ancientExhibitionBtns[i].className == "input-cancel-use-ancient-exhibition-hall") {
                        ancientExhibitionBtns[i].hidden = false
                    } else if (ancientExhibitionBtns[i].className == "input-use-ancient-exhibition-hall") {
                        ancientExhibitionBtns[i].hidden = true
                    }
                }
                // 现代展厅按钮操作
                var modernExhibitionBtns = document.getElementById("modern-exhibition-hall-panel").children
                for (let i = 0; i < modernExhibitionBtns.length; i++) {
                    if (modernExhibitionBtns[i].className == "input-cancel-use-modern-exhibition-hall") {
                        modernExhibitionBtns[i].hidden = true
                    } else if (modernExhibitionBtns[i].className == "input-use-modern-exhibition-hall") {
                        modernExhibitionBtns[i].hidden = false
                    }
                }
                // 现代演播厅按钮操作
                var modernStudioBtns = document.getElementById("modern-studio-panel").children
                for (let i = 0; i < modernStudioBtns.length; i++) {
                    if (modernStudioBtns[i].className == "input-cancel-use-modern-studio") {
                        modernStudioBtns[i].hidden = true
                    } else if (modernStudioBtns[i].className == "input-use-modern-studio") {
                        modernStudioBtns[i].hidden = false
                    }
                }
                // 古典演播厅按钮操作
                var ancientStudioBtns = document.getElementById("ancient-studio-panel").children
                for (let i = 0; i < ancientStudioBtns.length; i++) {
                    if (ancientStudioBtns[i].className == "input-cancel-use-ancient-studio") {
                        ancientStudioBtns[i].hidden = true
                    } else if (ancientStudioBtns[i].className == "input-use-ancient-studio") {
                        ancientStudioBtns[i].hidden = false
                    }
                }
                alert("使用古典展厅成功")
            },
            error: function (xhr, textStatus, error) {
                var msg = JSON.parse(xhr.responseText);
                alert(msg.error);
            }
        });
    }
}
function cancelAncientUseExhibitionHall() {
    if (confirm("取消使用古典展厅后，游客将不会再进入古典展厅，确认取消使用吗？")) {
        $.ajax({
            type: "POST",
            url: "/manage_exhibitions/cancel_use_exhibition_hall",
            data: JSON.stringify({
                id: Number(exId),
                style: 1
            }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (user) {
                // 展厅按钮操作
                var btns = document.getElementById("ancient-exhibition-hall-panel").children
                for (let i = 0; i < btns.length; i++) {
                    if (btns[i].className == "input-cancel-use-ancient-exhibition-hall") {
                        btns[i].hidden = true
                    } else if (btns[i].className == "input-use-ancient-exhibition-hall") {
                        btns[i].hidden = false
                    }
                }
                alert("取消使用古典展厅成功")
            },
            error: function (xhr, textStatus, error) {
                var msg = JSON.parse(xhr.responseText);
                alert(msg.error);
            }
        });
    }
}

// 现代演播厅使用操作
function useModernStudio() {
    if (confirm("展厅(现代/古典)与演播厅(现代/古典)同时只可选择一种，选择使用现代演播厅后，古典演播厅与所有展厅将被取消使用，确认使用吗？")) {
        $.ajax({
            type: "POST",
            url: "/manage_exhibitions/use_studio",
            data: JSON.stringify({
                id: Number(exId),
                style: 1
            }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (user) {
                // 现代演播厅按钮操作
                var modernStudioBtns = document.getElementById("modern-studio-panel").children
                for (let i = 0; i < modernStudioBtns.length; i++) {
                    if (modernStudioBtns[i].className == "input-cancel-use-modern-studio") {
                        modernStudioBtns[i].hidden = false
                    } else if (modernStudioBtns[i].className == "input-use-modern-studio") {
                        modernStudioBtns[i].hidden = true
                    }
                }
                // 古典演播厅按钮操作
                var ancientStudioBtns = document.getElementById("ancient-studio-panel").children
                for (let i = 0; i < ancientStudioBtns.length; i++) {
                    if (ancientStudioBtns[i].className == "input-cancel-use-ancient-studio") {
                        ancientStudioBtns[i].hidden = true
                    } else if (ancientStudioBtns[i].className == "input-use-ancient-studio") {
                        ancientStudioBtns[i].hidden = false
                    }
                }
                // 现代展厅按钮操作
                var modernExhibitionBtns = document.getElementById("modern-exhibition-hall-panel").children
                for (let i = 0; i < modernExhibitionBtns.length; i++) {
                    if (modernExhibitionBtns[i].className == "input-cancel-use-modern-exhibition-hall") {
                        modernExhibitionBtns[i].hidden = true
                    } else if (modernExhibitionBtns[i].className == "input-use-modern-exhibition-hall") {
                        modernExhibitionBtns[i].hidden = false
                    }
                }
                // 古典展厅按钮操作
                var ancientExhibitionBtns = document.getElementById("ancient-exhibition-hall-panel").children
                for (let i = 0; i < ancientExhibitionBtns.length; i++) {
                    if (ancientExhibitionBtns[i].className == "input-cancel-use-ancient-exhibition-hall") {
                        ancientExhibitionBtns[i].hidden = true
                    } else if (ancientExhibitionBtns[i].className == "input-use-ancient-exhibition-hall") {
                        ancientExhibitionBtns[i].hidden = false
                    }
                }
                alert("使用现代演播厅成功")
            },
            error: function (xhr, textStatus, error) {
                var msg = JSON.parse(xhr.responseText);
                alert(msg.error);
            }
        });
    }
}
function cancelUseModernStudio() {
    if (confirm("取消使用现代演播厅后，游客将不会再进入现代演播厅，确认取消使用吗？")) {
        $.ajax({
            type: "POST",
            url: "/manage_exhibitions/cancel_use_studio",
            data: JSON.stringify({
                id: Number(exId),
                style: 1
            }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (user) {
                var btns = document.getElementById("modern-studio-panel").children
                for (let i = 0; i < btns.length; i++) {
                    if (btns[i].className == "input-cancel-use-modern-studio") {
                        btns[i].hidden = true
                    } else if (btns[i].className == "input-use-modern-studio") {
                        btns[i].hidden = false
                    }
                }
                alert("取消使用现代演播厅成功")
            },
            error: function (xhr, textStatus, error) {
                var msg = JSON.parse(xhr.responseText);
                alert(msg.error);
            }
        });
    }
}

// 古典演播厅使用操作
function useAncientStudio() {
    if (confirm("展厅(现代/古典)与演播厅(现代/古典)同时只可选择一种，选择使用古典演播厅后，现代演播厅与所有展厅将被取消使用，确认使用吗？")) {
        $.ajax({
            type: "POST",
            url: "/manage_exhibitions/use_studio",
            data: JSON.stringify({
                id: Number(exId),
                style: 2
            }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (user) {
                // 古典演播厅按钮操作
                var ancientStudioBtns = document.getElementById("ancient-studio-panel").children
                for (let i = 0; i < ancientStudioBtns.length; i++) {
                    if (ancientStudioBtns[i].className == "input-cancel-use-ancient-studio") {
                        ancientStudioBtns[i].hidden = false
                    } else if (ancientStudioBtns[i].className == "input-use-ancient-studio") {
                        ancientStudioBtns[i].hidden = true
                    }
                }
                // 现代演播厅按钮操作
                var modernStudioBtns = document.getElementById("modern-studio-panel").children
                for (let i = 0; i < modernStudioBtns.length; i++) {
                    if (modernStudioBtns[i].className == "input-cancel-use-modern-studio") {
                        modernStudioBtns[i].hidden = true
                    } else if (modernStudioBtns[i].className == "input-use-modern-studio") {
                        modernStudioBtns[i].hidden = false
                    }
                }
                // 现代展厅按钮操作
                var modernExhibtionBtns = document.getElementById("modern-exhibition-hall-panel").children
                for (let i = 0; i < modernExhibtionBtns.length; i++) {
                    if (modernExhibtionBtns[i].className == "input-cancel-use-modern-exhibition-hall") {
                        modernExhibtionBtns[i].hidden = true
                    } else if (modernExhibtionBtns[i].className == "input-use-modern-exhibition-hall") {
                        modernExhibtionBtns[i].hidden = false
                    }
                }
                // 古典展厅按钮操作
                var ancientExhibtionBtns = document.getElementById("ancient-exhibition-hall-panel").children
                for (let i = 0; i < ancientExhibtionBtns.length; i++) {
                    if (ancientExhibtionBtns[i].className == "input-cancel-use-ancient-exhibition-hall") {
                        ancientExhibtionBtns[i].hidden = true
                    } else if (ancientExhibtionBtns[i].className == "input-use-ancient-exhibition-hall") {
                        ancientExhibtionBtns[i].hidden = false
                    }
                }
                alert("使用古典演播厅成功")
            },
            error: function (xhr, textStatus, error) {
                var msg = JSON.parse(xhr.responseText);
                alert(msg.error);
            }
        });
    }
}
function cancelUseAncientStudio() {
    if (confirm("取消使用古典演播厅后，游客将不会再进入古典演播厅，确认取消使用吗？")) {
        $.ajax({
            type: "POST",
            url: "/manage_exhibitions/cancel_use_studio",
            data: JSON.stringify({
                id: Number(exId),
                style: 2
            }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (user) {
                var btns = document.getElementById("ancient-studio-panel").children
                for (let i = 0; i < btns.length; i++) {
                    if (btns[i].className == "input-cancel-use-ancient-studio") {
                        btns[i].hidden = true
                    } else if (btns[i].className == "input-use-ancient-studio") {
                        btns[i].hidden = false
                    }
                }
                alert("取消使用古典演播厅成功")
            },
            error: function (xhr, textStatus, error) {
                var msg = JSON.parse(xhr.responseText);
                alert(msg.error);
            }
        });
    }
}

// upload
function upload(file) {
    uploadExhibitionCover(file, function (url) {
        var cover = document.getElementById("cover");
        cover.src = url;
    })
}