@php
$managerOrHigher = $myUser->isManager(true);
$devOrHigher = $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>{{ $original->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="https://{{$currentDomain}}/legacy/google-code-prettify/tomorrow-night.css" rel="stylesheet">
    <link href="https://{{$currentDomain}}/legacy/toastr/toastr.min.css" rel="stylesheet">
    <script src="https://{{$currentDomain}}/legacy/custom.modernizr.js"></script>
    <script src="https://{{$currentDomain}}/legacy/jquery.min.js"></script>
    <script src="{{ asset('/legacy/mousetrap.min.js') }}"></script>
    <script src="{{ asset('/legacy/google-code-prettify/prettify.js') }}"></script>
    <script src="{{ asset('/legacy/tabby.js') }}"></script>
    <script src="{{ asset('/legacy/zclip.min.js') }}"></script> 
    <script src="{{ asset('/legacy/toastr/toastr.min.js') }}"></script>
    <script src="{{ asset('/legacy/bin.js') }}"></script>
    <script src="{{ asset('/legacy/logout.js') }}"></script>
    <script src="{{ asset('/legacy/paste.js') }}"></script>
    <link href="/legacy/css/show.css" rel="stylesheet">
	<style>
    .options p{
        margin-top: 8px;
        color: #bababa;
    }
    .options p b{
        color: #ededed;
    }
    del{
        background-color: rgba(255, 0, 0, 0.3);
        padding-left: 7px;
        text-decoration: none;
    }
    ins{
        background-color: rgba(0, 255, 0, 0.25);
        padding-left: 7px;
        text-decoration: none;
    }
    ins::before{
        content: '+ ';
    }
    del::before{
        content: '- ';
    }
    #hidedox,#editban{
        background-color: #753b3b;

    }
    #hidedox:hover,#editban:hover{
        background-color: #4d2727;
    }
    pre a:hover{
        text-decoration: underline;
    }
	</style>
	<script>
	var doxid = {{ $original->id }};

    // @if($devOrHigher)

    var reasonForced = {{ $myUser->admin == 0 && $myUser->mod == 1 ? 1 : 0}};

    // @endif
	</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')
        
        <div class="options">
            <div class="paste-properties">
            @if($original->pinned)
            <span><i class="material-icons">push_pin</i><span>Pinned</span></span><br>
            @endif
            @if($original->password != null)
            <span><i class="material-icons">password</i><span>Password protected</span></span><br>
            @endif
            @if($original->private)
            <span><i class="material-icons">lock</i><span>Private</span></span><br>
            @endif
            @if($original->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;">{{$original->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/{{ $original->link }}">{{$original->title}}</a></span></p>
            <p><span style="font-weight:bold; color: white;">Created:</span><span style="float: right;">{{ date('M jS, Y', strtotime($original->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, true) !!}
            @endif
            </span></p>
            <p><span style="font-weight:bold; color: white;">Views:</span> <span style="float: right;">{{ number_format($original->views) }}</span></p>
            @if($original->disable_cmts == 0)
                <p><span style="font-weight:bold; color: white;">Comments:</span> <span style="float: right;">{{ $original->comments }}</span></p>
            @endif
        </div>
        <div class="options">
            <p style="margin-top:0;"><span style="font-weight:bold; color: white;">Edit added:</span> <span style="float: right;">{{ age($new->date) }}</span></p>
            @if($original->last_edited != null)
            <p><span style="font-weight:bold; color: white;">Last edit:</span> <span style="float: right;">{{ date('M jS, Y', floor($original->last_edited / 1000)) }}</span></p>
            @endif
        </div>
        @if(!empty($new->edit_reason))
        <div class="options">
        <p style="margin-top: 0;font-size: 14px;"><b>Edit reason:</b><br>
        {{ $new->edit_reason }}</p>
        </div>
        @endif
        <div class="options">
            <ul>
                <li><a id="accept" href="#" class="btn raw">Accept</a></li>
                <li><a id="deny" href="#" class="btn raw">Deny</a></li>
            </ul>
        </div>
        @if($devOrHigher)
        <div class="options">
            <ul>
                <li id="hide-reason-box" {!! $original->hidden == 1 ? 'style="display:none;"' : '' !!}>
@if($managerOrHigher && !is_null($created_by))
                    <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($devOrHigher && !is_null($created_by))
                    <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, 'paste' => $original])
                </li>
                <li><a id="hidedox" href="#" class="btn raw">{{ ($original->hidden == 1 ? 'Unhide' : 'Hide') }}</a></li>
                <li><a id="editban" href="#" class="btn raw">{{ ($original->editbanned == 1 ? 'Edit unban' : 'Edit ban') }}</a></li>
            </ul>
        </div>
        @endif
        <div class="options" style="margin-bottom: 0;">
            <ul>
                <li><a id="d" onclick="v('d')" href="javascript:void(0)" class="btn active">Difference highlights</a></li>
                <li><a id="o" onclick="v('o')" href="javascript:void(0)" class="btn">Original</a></li>
                <li><a id="e" onclick="v('e')" href="javascript:void(0)" class="btn raw">Edited</a></li>
            </ul>
        </div>
		<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 id="dp" style="color: white;margin: 0;">@if($showdiff)
{!! 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>', $diff) !!}
@else
<i style="font-size: 20px; color:red;text-align:center;">[Paste too big to highlight changes]</i><br><br>
{!! 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>', $diff) !!}
@endif
        </pre>
        <pre id="op" style="color: white;margin: 0;display:none;">
{!! 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>', $original->content) !!}
        </pre>
        <pre id="ep" style="color: white;margin: 0;display:none;">
{!! 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>', $new->newpost) !!}
        </pre>
        </div>
        </div>
    </div>
	
    <script src="https://{{$currentDomain}}/legacy/jquery-ui-1.10.3.custom.min.js"></script>
    <script>
        var s = 'd';
        function v(t){
            $('#' + s + 'p').hide();
            $('#' + s ).removeClass('active');
            $('#' + t + 'p').show();
            $('#' + t ).addClass('active');
            s = t;
        }
    $(document).ready(function(){
        $('#hide-dropdown').on('change', function(){ // Hide dropdown
            $('#hide-reason').val(this.value);
        });
        $('#hidedox').on('click', function(e){
            if($(this).text() == "Hide" && $('#hide-reason').val().length < 1 && reasonForced){
                alert('Reason is required. Pastes created by a user will be notified');
            }else if($(this).text() == "Hide" && $('#hide-reason').val().length > 255){
                alert('Hide reason is too long');
            }else{
                $.post('/admin/api/paste/hide', {
                    _token: $('input[name=_token]').val(),
                    pid: doxid,
                    reason: $('#hide-reason').val(),
                    notifyUser: $('#notifyUser').prop('checked')
                }, function(resp){
                    if(resp.status == "done"){
                        if(resp.hidden == 1){
                            $('#hide-reason-box').hide();
                            $('#hidedox').text('Unhide');
                        }else{
                            $('#hide-reason-box').show();
                            $('#hidedox').text('Hide');
                        }
                    }
                });
            }
            e.preventDefault();
        });
        $('#accept').on('click', function(e){
            $(this).text('...');
            $.post('/admin/api/edits', {
                _token: $('input[name=_token]').val(),
                doxid: doxid,
                action: 'accept'
            }, function(resp){
                if(resp.status == 'done'){
                    window.location = '/admin/edits';
                }
            });
            $(this).text('Accept');
            e.preventDefault();
        });
        $('#deny').on('click', function(e){
            $(this).text('...');
            $.post('/admin/api/edits', {
                _token: $('input[name=_token]').val(),
                doxid: doxid,
                action: 'deny'
            }, function(resp){
                if(resp.status == 'done'){
                    window.location = '/admin/edits';
                }
            });
            $(this).text('Deny');
            e.preventDefault();
        });
        $('#editban').on('click', function(e){
            $.post('/admin/api/edit-ban', {
                _token: $('input[name=_token]').val(),
                doxid: doxid
            }, function(resp){
                if(resp.status == 'done'){
                    if(resp.editban == 1){
                        $('#editban').text('Edit unban');
                    }else{
                        $('#editban').text('Edit ban');
                    }
                }
            });
            e.preventDefault();
        });
    });
    </script>
</body>
</html>

