<%@ Page Language="C#" AutoEventWireup="true" CodeFile="View.aspx.cs" Inherits="Board_One2one_View" meta:resourcekey="Page" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../libs/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../libs/fontawesome/css/all.min.css" >
    <script type="text/javascript" src="../../libs/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="../../libs/bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
    <style>
        .cBoxSubject {
            display: flex;
            font-size: 1.25rem;
        }
        .cBoxSubject .last {
            font-size: 1rem;
            margin-left: auto;
            padding-left: 4px;
        }
    </style>
    <script type="text/javascript">
        var darkView = { enabled: false };

        $(document).ready(function () {
            Dialog.setMessage('<asp:Literal runat="server" Text="<%$ Resources:Dialog, Title%>" />', '<asp:Literal runat="server" Text="<%$ Resources:Dialog, OK%>" />', '<asp:Literal runat="server" Text="<%$ Resources:Dialog, Cancel%>" />');
            Dialog.setUseBrowserConfirm(<%=AppSetting.UseBrowserConfirm%>);

            // 다크 모드 여부 확인
            if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
                var v = localStorage.getItem("board_darkview");
                if (v !== null) {
                    darkView = JSON.parse(v);
                } else {
                    darkView = { enabled: true };
                }
                SetDarkView(darkView.enabled);
            } else {
                document.getElementById("toggleDarkView").style.display = "none";
            }
        });

        function ReplyArticle() {
            location.href = "NewTM.aspx?action=reply&<%=_newPageParams%>";
        }

        function EditArticle() {
            location.href = "NewTM.aspx?action=modify&<%=_newPageParams%>";
        }

        function ConfirmDelete() {
            // 게시글을 삭제하시겠습니까?
            Dialog.confirm({
                content: '<asp:Literal runat="server" Text="<%$ Resources:, Msg01%>" />',
                ok: function () {
                    __doPostBack("DeleteButton", "");
                }
            });
        }

        function GotoList() {
            location.href = "List.aspx?<%=_listPageParams%>";
        }

        function ToggleDarkView() {
            darkView.enabled = !darkView.enabled;
            SetDarkView(darkView.enabled);
            localStorage.setItem("board_darkview", JSON.stringify(darkView));
            return false;
        }

        function SetDarkView(toggle) {
            if (toggle) {
                $("#bodyDiv").css({
                    "background-color": "rgba(0, 0, 0, 0)",
                    "color": $("body").css("color")
                });
            } else {
                $("#bodyDiv").css({
                    "background-color": "#fff",
                    "color": "#333"
                });
            }
        }
    </script>

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <CompositeScript>
                <Scripts>
                    <asp:ScriptReference Path="~/libs/tabs/common.js" />
                    <asp:ScriptReference Path="~/libs/tabs/dialog.js" />
                </Scripts>
            </CompositeScript>
        </asp:ScriptManager>

        <div class="container-fluid">
            <div class="row" id="toolBar" data-spy="affix">
                <div class="col-xs-12" style="padding-top:2px;padding-bottom:2px;">
                    <button type="button" id="replyToolButton" runat="server" disabled="disabled" class="btn btn-primary" onclick="ReplyArticle()"><asp:Localize ID="Localize1" runat="server" meta:resourcekey="L01">답글</asp:Localize></button>
                    <button type="button" id="editToolButton" runat="server" disabled="disabled" class="btn btn-primary" onclick="EditArticle()"><asp:Localize ID="Localize2" runat="server" meta:resourcekey="L02">수정</asp:Localize></button>
                    <button type="button" id="deleteToolButton" runat="server" disabled="disabled" class="btn btn-primary" onclick="ConfirmDelete()"><span class="fa-solid fa-trash-can"></span></button>
                    <span>&nbsp;</span>
                    <button type="button" id="closeToolButton" class="btn btn-primary" onclick="GotoList();"><span class="fa-solid fa-bars"></span></button>
                </div>
            </div>
        </div>

        <div class="container-fluid" style="padding-top:40px">
            <div class="cBoxSubject">
                <span><asp:Literal ID="SubjectLabel" runat="server" Mode="Encode" /></span>
                <span id="toggleDarkView" class="last"><a href="#" onclick="return ToggleDarkView()"><i class="fa-solid fa-circle-half-stroke"></i></a></span>
            </div>
            <div>
                <span class="text-muted"><small><asp:Literal ID="Author" runat="server" Mode="Encode" /></small></span>
            </div>
            <div>
                <span class="text-muted"><small><asp:Literal ID="WriteDate" runat="server" Mode="Encode" /></small></span>
            </div>
            <div id="attachPanel" runat="server" class="collapse">
                <hr />
                <div class="mc-likeLink" data-toggle="collapse" data-target="#attachList">
                    <div class="row" style="padding-bottom:0.5em">
                        <div class="col-xs-12">
                            <i class="fa-solid fa-paperclip"></i> <asp:Label ID="AttachSummaryLabel" runat="server"></asp:Label>
                        </div>
                    </div>
                </div>
                <div id="attachList" class="list-group collapse">
                    <asp:Literal ID="AttachListTag" runat="server" />
                </div>
            </div>
            <hr />
            <div id="bodyDiv" style="min-height: 150px;padding: 5px 10px;overflow:auto">
                <asp:PlaceHolder ID="MsgBodyHolder" runat="server" EnableViewState="false"></asp:PlaceHolder>
            </div>
            <div>&nbsp;</div>            
        </div>

        <div style="display:none">
            <asp:LinkButton ID="DeleteButton" runat="server" OnClick="DeleteButton_Click" Text="" /> 
        </div>
    </form>
</body>
</html>
