@extends('_layout')
@section('title', ' - Create new paste')
@section('description', 'All pastes must follow our TOS.')
@section('table')
    @include ('_sidebar_toggle')
    
    <form action="{{ url('/upload') }}" id="paste-form" method="POST" class="editor-form">
        {!! csrf_field() !!}
        <div class="sidebar" style="text-align: center;padding-top: 0;">
            @include('_logo')

            <div class="options">                
                <p style="color:red;" id="paste-error">{{ isset($error) ? $error : ''}}</p>
                
                @if($myUser == null)
                <p style="text-align: center;"><a style="color: #2a9fd6;" target="_blank" href="/register">Create an account</a> to manage your pastes</p>

<p style="color:red;text-align: center;font-size:15px;text-decoration:underline;"><a href="/tos" target="_blank" style="font-weight:bold;color: lightblue;">READ TOS BEFORE POSTING.</a><br> Posts that violate our terms WILL be removed.</p>
                @else
                <p style="text-align: center;">
                <b>Username:</b>
{{ $myUser->username }} - <a style="color: #2a9fd6;" id="logout-btn" href="#">(Logout)</a></p>
                @endif
                <h3>Title:</h3>
                <input type="text" name="pasteTitle" id="paste-title" maxlength="70" value="{{ old('pasteTitle') }}" placeholder="Paste title (no special chars)">

            </div>
            @if(!is_null($myUser) && $myUser->role >= 3)
            <div class="options">
                <h3 style="margin-top:0;">Paste Password:</h3>
                <p style="margin-top: 5px;">Option to make paste viewable only by people with the password</p>
                <input type="text" name="password" style="margin: 5px 0;" placeholder="Password...">
            </div>
            @endif
        @if(!is_null($myUser) && ($myUser->followers > 0 || $myUser->role >= 2)) {{-- has followers or is crim+ --}}
            <div class="options" style="text-align: left;">
            @if($myUser->followers > 0)
                <div><label for="notify-followers"><b style="margin-bottom: 5px;">Notify followers of paste:</b></label>
                <input type="checkbox" id="notify-followers" name="notify-followers" style="width: auto; float: right;"></div>
            @endif
            @if($myUser->role >= 2) {{-- crim+, paste visibility --}}
                <div style="{!! $myUser->followers > 0 ? 'margin-top: 5px;' : '' !!}">
                    <div style="text-align: center;">
                        <span style="font-weight:bold;text-align:center;text-decoration:underline;font-size: 15px;">Paste Visibility</span><br>
                    </div>
                    <label style="text-align: left;"><b style="margin-bottom: 5px;">Public</b></label>
                    <input type="radio" name="paste-visibility" value="public" checked style="width: auto; float: right;">
                    <br>
                    <label style="text-align: left;"><b style="margin-bottom: 5px;">Unlisted</b></label>
                    <input type="radio" name="paste-visibility" value="unlisted" style="width: auto; float: right;">
                    <br>
                    <label style="text-align: left;"><b style="margin-bottom: 5px;">Private</b></label>
                    <input type="radio" name="paste-visibility" value="private" style="width: auto; float: right;">
                </div>
            @endif
            </div>
            @else
            <input type="hidden" id="notify-followers" value="off">
        @endif
            <div class="options">
                @include('layouts.captcha')
            </div>

            <div class="options">
                <ul>
                    <li><input type="submit" id="create-paste" value="Create" class="button"></li>
                    <li><input type="reset" value="Clear" class="button"></li>
                </ul>
            </div>
            <p>Please note that all posted information is publicly available and must follow our <a href="https://{{$currentDomain}}/tos" style="text-decoration: underline;">TOS.</a></p>
        </div>

        <div class="editor-container">
            <textarea name="pasteContent" id="paste-content" class="editor mousetrap" wrap="off" placeholder="READ OUR TERMS OF SERVICE BEFORE CREATING A POST. Pastes that break TOS will be removed. https://{{ currentDomain() }}/tos&#13;READ OUR TERMS OF SERVICE BEFORE CREATING A POST. Pastes that break TOS will be removed. https://{{ currentDomain() }}/tos&#13;READ OUR TERMS OF SERVICE BEFORE CREATING A POST. Pastes that break TOS will be removed. https://{{ currentDomain() }}/tos">{{ $post }}</textarea>
        </div>
    </form>
    <script src="https://{{$currentDomain}}/legacy/jquery.min.js"></script>
    @if(env('CAPTCHA') == 'HCAPTCHA')
        <script src="https://js.hcaptcha.com/1/api.js" async defer></script>
        <script>
            $(document).ready(function(){ 
                $('#paste-form').on('submit', function(e){
                    $.post('/upload', {
                        _token: $('input[name=_token]').val(),
                        pasteTitle: $('#paste-title').val(),
                        pasteContent: $('#paste-content').val(),
                        hcaptcha_token: $('[name=h-captcha-response]').val(),
                        notifyFollowers: $('#notify-followers').prop('checked'),
                        pasteVisibility: $('input[name="paste-visibility"]:checked').val(),
                    }, function(resp){
                        if(resp.status == "err"){
                            $('#paste-error').text(resp.msg);
                            hcaptcha.reset();
                        }else{
                            window.location = resp.redirect;
                        }
                    }).fail(function(){
                        $('#paste-error').text('Error');
                    });
                    
                    e.preventDefault();
                });
            });
        </script>
    @elseif(env('CAPTCHA') == 'RECAPTCHA')
        <script src="https://www.google.com/recaptcha/api.js" async defer></script>
        <script>
            $(document).ready(function(){ 
                $('#paste-form').on('submit', function(e){
                    $.post('/upload', {
                        _token: $('input[name=_token]').val(),
                        pasteTitle: $('#paste-title').val(),
                        pasteContent: $('#paste-content').val(),
                        recaptcha_token: grecaptcha.getResponse(),
                        notifyFollowers: $('#notify-followers').prop('checked'),
                        pasteVisibility: $('input[name="paste-visibility"]:checked').val(),
                    }, function(resp){
                        if(resp.status == "err"){
                            $('#paste-error').text(resp.msg);
                            grecaptcha.reset();
                        }else{
                            window.location = resp.redirect;
                        }
                    }).fail(function(){
                        $('#paste-error').text('Error');
                    });
                    
                    e.preventDefault();
                });
            });
        </script>
        @elseif(env('CAPTCHA') == 'TURNSTILE')
            <script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
            <script>
                $(document).ready(function(){ 
                    $('#paste-form').on('submit', function(e){
                        $.post('/upload', {
                            _token: $('input[name=_token]').val(),
                            pasteTitle: $('#paste-title').val(),
                            pasteContent: $('#paste-content').val(),
                            turnstile_token: $('[name=cf-turnstile-response]').val(),
                            notifyFollowers: $('#notify-followers').prop('checked'),
                            pasteVisibility: $('input[name="paste-visibility"]:checked').val(),
                        }, function(resp){
                            if(resp.status == "err"){
                                $('#paste-error').text(resp.msg);
                                turnstile.reset();
                            }else{
                                window.location = resp.redirect;
                            }
                        }).fail(function(){
                            $('#paste-error').text('Error');
                        });
                        
                        e.preventDefault();
                    });
                });
            </script>
        @endif
@stop
<!-- Brenton t.me/brenton twitter.com/brenton_xxx <3 -->