@extends('layouts.master')

@section('title', 'IV Media - Increase your popularity')
@section('content')
<!-- Start content -->
<div class="content">
    <div class="container-fluid">

        <div class="row">
            <div class="col-xl-12">
                <div class="page-title-box">
                    <h4 class="page-title float-left">Dashboard</h4>

                    <ol class="breadcrumb float-right">
                        <li class="breadcrumb-item"><a href="{{ url('/') }}">{!! \App\Helper::panelName() !!}</a>
                        </li>
                        <li class="breadcrumb-item active">Dashboard</li>
                    </ol>

                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
        <!-- end row -->


        <div class="row">
            @if ($flash = session('message')) {
              <div class="col-md-12">
                <div class="alert alert-success" role="alert">
                  <ul>
                  @foreach ($flash as $key => $val)
                    <li>{{$key.'  '.$val}}</li>
                  @endforeach
                  </ul>
                </div>
              </div>
            @endif
            <div class="col-lg-6 col-md-12">

                @if($result = session('result'))
                    {!! $result !!}
                @endif
                <div class="card-box">

                    <h4 class="header-title m-t-0 m-b-30"><span class="label label-primary">{{ auth()->user()->level }}</span> {!! \App\Helper::panelName() !!} PANEL COMMENT</h4>
                    

                    <div class="row">
                        <div class="col-12">
                            <form action="{{ url('server/comment') }}" method="POST">
                                
                                @captcha()
                                {{ csrf_field() }}
                                @if(\Carbon\Carbon::now() > auth()->user()->delay->comment)
                                
                                <fieldset class="form-group">
                                    <label for="url">URL Foto</label>
                                    <input type="text" class="form-control {{ $errors->has('jumlah') ? 'parsley-error' : '' }}" id="url" placeholder="https://www.instagram.com/p/Ba6Cz_7hMnT/" name="url">
                                    @if ($errors->has('url'))
                                        <span class="help-block">
                                            <ul class="parsley-errors-list filled"><li class="parsley-required">{{ $errors->first('url') }}</li></ul>
                                        </span>
                                    @endif
                                </fieldset>
                                <fieldset class="form-group">
                                    <label for="jumlah">Komentar (Max 10 baris = 10 comment) Submit Lebih Kan Dari Target</label>
<textarea class="form-control {{ $errors->has('comment') ? 'parsley-error' : '' }}" rows="4" cols="500" name="comment" placeholder="1 Baris 1 Komentar
Iv media keren
Follback kak
Like Back Please
Fotonya Bagus kak
Kerja bagus, selamat !
ok, gud" id="jumlah"></textarea>
                                    @if ($errors->has('comment'))
                                        <span class="help-block">
                                            <ul class="parsley-errors-list filled"><li class="parsley-required">{{ $errors->first('comment') }}</li></ul>
                                        </span>
                                    @endif
                                    <div class="mt-3">Total Baris: <span id="linesUsed">0</span><div>
                                </fieldset>
                                <button type="submit" id="submitBtn" class="btn btn-block btn-primary">Submit</button>
                                
                        
                    @else
                        <div class="alert alert-danger" role="alert">
                            Please wait {{ \Carbon\Carbon::parse(auth()->user()->delay->comment)->diffForHumans() }} to submit comment
                        </div>
                        
                        <div class="alert alert-success" role="alert">
                            Success Submit Comment ! ^_^ 
                        </div>
                        @php ($button = '<button type="submit" id="submitBtn" class="btn btn-block btn-danger" disabled>Please Wait</button>')
                    @endif
                    
                                
                            </form>
                        </div>
                    </div><!-- end row -->
                </div>
            </div>
            <div class="col-lg-6 col-md-12">
                <div class="card-box">
                    <h4 class="header-title m-t-0 m-b-30"><span class="label label-primary">{{ auth()->user()->level }}</span> {!! \App\Helper::panelName() !!} PANEL COMMENT</h4>
                    <ul class="list-group">
                      <li class="list-group-item">Selamat Datang Di {!! \App\Helper::panelName() !!} PANEL</li>
                      <li class="list-group-item">Data Base UNLIMITED</li>
                      <li class="list-group-item">1 Baris 1 Komentar</li>
                      <li class="list-group-item">Maksimal 10 Baris</li>
                      <li class="list-group-item">Instagram Jangan Di <span class="label label-danger"><i class="fa fa-lock"></i> Private</span></li>
                      {{-- <li class="list-group-item">Delay <span class="label label-success">@if($id != 9){{ constant("DELAY_".strtoupper(auth()->user()->level)) }} MENIT @else 15 Menit @endif</span></li> --}}
                    </ul>
                </div>
            </div>
        </div>
        <!-- end row -->


    </div>
    <!-- container -->

</div>
<!-- content -->
@endsection

@section('js')
<script>
  var resizefunc = [];
  var lines = 10;
    var linesUsed = $('#linesUsed');

    $('#jumlah').keydown(function(e) {

        newLines = $(this).val().split("\n").length;
        linesUsed.text(newLines);

        if(e.keyCode == 13 && newLines >= lines) {
linesUsed.css('color', 'red');
            return false;
            
        }
        else {
            linesUsed.css('color', '');
        }
        
    });

    $('#jumlah').on('paste', function(){
        newLines = $(this).val().split("\n").length;
        linesUsed.text(newLines);

        if(newLines >= lines) {
            linesUsed.css('color', 'red');
            
            return false;
        }
        else {
            linesUsed.css('color', '');
        }
    });
    

</script>
@endsection
