@php
$isDeveloperOrHigher = $myUser->isDeveloper(true);

@endphp
<!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{{ $paste->title }} - Doxbin (Admin)</title>

    <link rel="stylesheet" href="https://{{$currentDomain}}/legacy/app.css">
    <link rel="stylesheet" href="https://{{$currentDomain}}/files/doxbin.css">
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
    <link href="/legacy/css/show.css?r=44" rel="stylesheet">
    <link href="https://{{$currentDomain}}/legacy/google-code-prettify/tomorrow-night.css" rel="stylesheet">
    <link href="https://{{$currentDomain}}/legacy/toastr/toastr.min.css" rel="stylesheet">
	<style>
	
	</style>
    <script src="https://{{$currentDomain}}/legacy/custom.modernizr.js"></script>
    <script src="https://{{$currentDomain}}/legacy/jquery.min.js"></script>
	<script>
    
</script>
	<style>
    .options p{
        margin-top: 8px;
        color: #bababa;
    }
    .options p b{
        color: #ededed;
    }
    #hidedox,#editban{
        background-color: #753b3b;

    }
    #hidedox:hover,#editban:hover{
        background-color: #4d2727;
    }
    pre a:hover{
        text-decoration: underline;
    }
	</style>
	<script>
    var doxid = {{ $paste->id }};
	var flagid = {{ $flag->id }};
    var uName = "{{ ($myUser != null ? $myUser->username : '') }}";
    var uAdmin = {{ ($myUser != null ? $myUser->admin : 0) }};

    // var reasonForced = {{ !$paste->hidden && $myUser->admin == 0 && $myUser->mod == 1 ? 1 : 0}};
    var reasonForced = 0;
	</script>
    @include('_favicons')
</head>
<body class="bin" style="overflow-x: hidden;">
    {!! csrf_field() !!}
    <div class="wrapper">
        <div class="table">
        
        @include('_sidebar_toggle')

    <div class="sidebar">
        @include('_logo')
        
        @if(!is_null($myUser) && $isDeveloperOrHigher)
            @if(!is_null($staff_notes) && $staff_notes->count() > 0)
        <a href="#" class="btn staff-notes staff-notes-btn">View {{ $staff_notes->count() }} staff {{ str_plural('note', $staff_notes->count()) }}</a>
            @else
        <a href="#" class="btn staff-notes-lighter staff-notes-btn">Add Staff Note</a>
            @endif
        <div id="staffnotes" style="display: none;">
            <div class="options" style="border-bottom: 2px solid #753b3b;">
                <h3 style="margin: 5px 0 0 0; text-align: center;">Staff Notes</h3>
                <p style="margin: 0;text-align: center;">Viewable by all mods, managers and admins</p><br>
                <ul>
                <p id="staff-error-msg" style="color: red; padding: 0px; text-align: center; margin: 0;"></p>
                <li><textarea id="note" style="width: 100%;max-width: 100%;" placeholder="Note..."></textarea></li>
                <li><a class="btn" id="create-note" style="cursor: pointer;">Add Note</a></li>
                </ul>
                <div class="comment-container">
                    <div class="b-comments staff-notes-cont">
                @if($staff_notes->count() == 0)
                    <p style="text-align: center;">No notes</p>
                @endif
                @foreach ($staff_notes as $note)
                
                
                <div class="b-comments b-comment staff-note" style="padding-left: 10px; position: relative;" id="note{{$note->id}}">
                    <b>
                    @php
                    $commenter = App\User::find($note->uid);
                    @endphp
                    @if(!is_null($commenter))
                        {!! $commenter->getNameHtml(false) !!}
                    @else
                        [deleted]
                    @endif
                    </b> - <p title="{{ date('M jS, Y - g:iA', floor($note->date / 1000)) }}" style="display: inline;">
                    @php
                    echo age($note->date)
                    @endphp</p>
                    @if($myUser != null && $myUser->isManager(true))
                    <a href="#" data-nid="{{ $note->id }}" class="deletenote hidecomment">Delete</a>
                    @endif
                    <br>
                    <div class="b-content">{{$note->comment}}</div>
                    <br>
                </div>


                @endforeach
                    </div>
                </div>
            </div>
        </div>
        @endif



        <div class="options" style="padding-top:3px;">
            <div class="paste-properties">
            @if($paste->pinned)
            <span><i class="material-icons">push_pin</i><span>Pinned</span></span><br>
            @endif
            @if($paste->password != null)
            <span><i class="material-icons">password</i><span>Password protected</span></span><br>
            @endif
            @if($paste->private)
            <span><i class="material-icons">lock</i><span>Private</span></span><br>
            @endif
            @if($paste->unlisted)
            <span><i class="material-icons">visibility_off</i><span>Unlisted</span></span><br>
            @endif
            </div>

            @if ($myUser != null && $myUser->isManager(true)) <p><span style="font-weight:bold; color: white;">ID:</span> <span style="float: right;">{{$paste->id}}</span></p>@endif
            <p><span style="font-weight:bold; color: white;">Title:</span><span style="float: right;"><a target="_blank" style="color: #2a9fd6" href="/upload/{{ $paste->link }}">{{ $paste->title }}</a></span></p>
            <p><span style="font-weight:bold; color: white;">Created:</span><span style="float: right;"> {{ date('M jS, Y', strtotime($paste->created_at)) }}</span></p>
            
            <p><span style="font-weight:bold; color: white;">Created by:</span><span style="float: right;">
            @if ($created_by == null)
                Anonymous
            @elseif ($created_by == "[deleted]")
                [deleted]
            @else
                {!! $created_by->getNameHtml(true) !!}
            @endif
            </span>
            </p>
            <p><span style="font-weight:bold; color: white;">Views:</span> <span style="float: right;">{{ number_format($paste->views) }}</span></p>
            @if($paste->disable_cmts == 0)
                <p><span style="font-weight:bold; color: white;">Comments:</span> <span style="float: right;">{{ $paste->comments }}</span></p>
            @endif
        </div>

        <div class="options">
            <p style="margin-top:0;"><span style="font-weight:bold; color: white;">Flagged by:</span><span style="float: right;">
            @if($flagged_by)
                {!! $flagged_by->getNameHtml(true) !!}
            @else
                <b style="color: red">Doxbin</b>
            @endif
            </span></p>
            <p><span style="font-weight:bold; color: white;">Flagged at:</span><span style="float: right;">{{ age($flag->date) }}</span></p>
        </div>
        <div class="options">
            <ul>
                
                <li id="hide-reason-box">
    
@if ($isDeveloperOrHigher && !is_null($created_by) && !$paste->hidden)
                    <div id="removal-info"><input type="checkbox" id="notifyUser" val="0" style="width:auto;margin-right:3px;vertical-align:top;"><label for="notifyUser">Notify user</label></div>
{{-- @elseif($isDeveloperOrHigher && !is_null($created_by) && !$paste->hidden)
                    <div id="removal-info"><input type="hidden" id="notifyUser" val="1">User will be notified with the removal reason</div> --}}
@endif
                    @include('layouts.admin.remove_paste', ['required' => false, 'reason' => $flag->reason, 'paste' => $paste])

                    {{-- <textarea id="hide-reason"  placeholder="Reason (required)" style="{!! $paste->hidden ? 'display: none;' : '' !!}width: 100%;max-width: 100%;"></textarea> --}}
                </li>
                <li style="margin-top: 12px;"><a id="accept" href="#" class="btn raw">Accept &amp; Hide</a></li>
                <li style="margin-top: 15px;"><a id="deny" href="#" class="btn raw">Deny</a></li>
            </ul>
        </div>
        @if(!is_null($flag->reason))
        <div class="options">
            <p style="margin-top: 0px;"><b>Flag reason:</b><br>
                {{ $flag->reason }}</p>
        </div>
        @endif
		<div class="options" style="border-bottom: none;">
            <ul>
				<p id="error-msg" style="color: red; padding: 0px 0px 10px 0px; text-align: center; margin: 0;"></p>
            </ul>
		</div>
    </div>

    <div class="show-container" style="padding-left: 20px;">
        <pre style="color: white;margin: 0;">
{!! preg_replace("/((http|https|ftp|ftps)\:\/\/)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,13}(\:[0-9]+)?(\/[\/a-zA-Z0-9\?\=\@\_\.\-\;\'\[\]\#\!\&]*)?/", '<a href="$0" target="_blank" rel="noopener noreferrer">$0</a>', htmlentities($paste->content)) !!}
        </pre>
        </div>
        </div>
    </div>
	
    <script src="https://{{$currentDomain}}/legacy/jquery-ui-1.10.3.custom.min.js"></script>
    <script src="https://{{$currentDomain}}/legacy/mousetrap.min.js"></script>
    <script src="https://{{$currentDomain}}/legacy/google-code-prettify/prettify.js"></script>
    <script src="https://{{$currentDomain}}/legacy/tabby.js"></script>
    <script src="https://{{$currentDomain}}/legacy/zclip.min.js"></script>
    <script src="{{ asset('/legacy/bin.js') }}"></script>
    <script src="https://{{$currentDomain}}/legacy/toastr/toastr.min.js"></script>
    <script src="https://{{$currentDomain}}/legacy/logout.js"></script>
    <script src="{{ asset('/legacy/paste.js') }}"></script>
    <script>
    $(document).ready(function(){
        $('#accept').on('click', function(e){
            if($('#hide-reason').val().length < 1 && reasonForced){
                alert('Reason is required. Pastes created by a user will be notified');
            }else if($('#hide-reason').val().length > 255){
                alert('Hide reason is too long');
            }else{
                $.post('/admin/api/flag-action', {
                    _token: $('input[name=_token]').val(),
                    pid: doxid,
                    fid: flagid,
                    action: 'accept',
                    reason: $('#hide-reason').val(),
                    notifyUser: $('#notifyUser').prop('checked')
                }, function(resp){
                    if(resp.status == 'done'){
                        window.location = '/admin/flags';
                    }
                });
            }
            e.preventDefault();
        });
        $('#deny').on('click', function(e){
            $.post('/admin/api/flag-action', {
                _token: $('input[name=_token]').val(),
                pid: doxid,
                fid: flagid,
                action: 'deny'
            }, function(resp){
                if(resp.status == 'done'){
                    window.location = '/admin/flags';
                }
            });
            e.preventDefault();
        });
        $('#hide-dropdown').on('change', function(){
            $('#hide-reason').val(this.value);
        });



            
// @if($isDeveloperOrHigher)

    var staff_notes_default = "{{ $staff_notes->count() > 0 ? 'View ' . $staff_notes->count() . ' staff notes' : 'Add Staff ' . str_plural('Note', $staff_notes->count()) }}";
    var staff_notes_opened = false;
    $('.staff-notes-btn').on('click', function(e){
        if(!staff_notes_opened){
            $('#staffnotes').show();
            $('.staff-notes-btn').text("Close");
            staff_notes_opened = true;
        }else{
            $('#staffnotes').hide();
            $('.staff-notes-btn').text(staff_notes_default);
            staff_notes_opened = false;
        }
        e.preventDefault();
    });

// @endif



    $('#create-note').on('click', function(e){
		var username = "Anonymous";
		var note = $('#note').val();
        $.post('/admin/api/staff-comment', {
            _token: $('input[name=_token]').val(),
            pid: doxid,
            action: 'create',
            note: $('#note').val(),
            nid: 0
        }, function(resp){
            if(resp.status == "done"){
                $('#note').val('');
                username = htmlspecialchars(username.trim());
                note = htmlspecialchars(note.trim());
                if(uName != ""){
                    username = htmlspecialchars(uName);
                }
                if(username.length == 0){
                    username = "Anonymous";
                }
				$('.staff-notes-cont').append('<div class="b-comments b-comment" style="padding-left: 10px;"><b>' + (uName != "" ? '<a ' + (uAdmin != 0 ? 'style="color: red;"' : '') + 'href="/user/' + username + '">' + username + '</a>' : username) + '</b> - <p style="display: inline;">now</p><br><div class="b-content">' + note + '</div><br></div>');
            }else{
                alert('Error');
            }
        });
    });


    });
    </script>
</body>
</html>

