@extends('frontend.layouts.app_minimal')

@section('title', app_name() . ' | ' . __('navs.frontend.dashboard') )

@push('after-styles')
    <style>
        /*.nav.nav-tabs {*/
        /*    float: left;*/
        /*    display: block;*/
        /*    margin-right: 20px;*/
        /*    border-right: 1px solid #ddd;*/
        /*    !*padding-right: 15px;*!*/

        /*}*/


        /*.nav-tabs .nav-link {*/
        /*    border: 1px solid transparent;*/
        /*    border-top-left-radius: .25rem;*/
        /*    border-top-right-radius: .25rem;*/
        /*    background: #ccc;*/
        /*}*/

        /*.nav-tabs .nav-link.active {*/
        /*    background-color: whitesmoke;*/
        /*    border-color: #2aa8cc !important;*/
        /*}*/

        /*.nav-tabs .nav-link {*/
        /*    border: 1px solid transparent;*/
        /*    border-radius: 0px 0px 0px 10px;*/
        /*}*/

        /*.tab-content > .active {*/
        /*    display: block;*/
        /*    !*background: #007bff;*!*/
        /*    min-height: 165px;*/
        /*    padding-left: 20px;*/
        /*}*/

        /*.nav.nav-tabs {*/
        /*    float: left;*/
        /*    display: block;*/
        /*    !*margin-right: 20px;*!*/
        /*    border-bottom: 0;*/
        /*    border-right: 1px solid green;*/
        /*    padding-right: 0px;*/
        /*}*/

        /*.nav-item {*/
        /*    padding-bottom: 5px;*/
        /*}*/

        .hideonsmallscreen {
            display: none;
        }

        @media (max-width: 991px) {
            .nav.nav-tabs {
                display: none;
            }

            .hideonsmallscreen {
                display: block;
            }

        }


        .body_div img {
            max-width: 100% !important;
        }


    </style>
@endpush

@push('after-scripts')
    <script src="{{ asset('js/tinymce/tinymce.min.js') }}"></script>
    <script src="{{ asset('js/tinymce/jquery.tinymce.min.js') }}"></script>
{{--    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>--}}
{{--    <script src="{{ asset('js/strip-combining-marks.js') }}"></script>--}}
    <script type="text/javascript">
        var currenteditingid = -1;
        var currentdeletingid = -1;

        // import axios from 'axios';

        $(document).ready(function () {
            // Set up tab persistence across reloads
            if (location.hash.substr(0, 2) == "#!") {
                $("a[href='#" + location.hash.substr(2) + "']").tab("show");
            }

            $("a[data-toggle='tab']").on("shown.bs.tab", function (e) {
                var hash = $(e.target).attr("href");
                if (hash.substr(0, 1) == "#") {
                    location.replace("#!" + hash.substr(1));
                }

            });
            $('select').select2({
                placeholder: "Filter by tags",
                allowClear: true
            });

            $('div.modal').on('show.bs.modal', function (event) {
                let modal = $(this);
                modal.addClass('d-block'); // Boostrap class for display-block
            });
            $('div.modal').on('hide.bs.modal', function (event) {
                let modal = $(this);
                modal.removeClass('d-block');
            });

            $('a[data-toggle=modal], button[data-toggle=modal]').click(function () {
                currenteditingid = $(this).data('id');
                console.log($(this).data('channel'))
                switch ($(this).data('target')) {
                    case '#addthreaddialog':
                        $("#new_forum_channels_id").val($(this).data('channel'));
                        $("#new_post_channel_name").text($(this).data('channel_name'));

                        break;
                    case '#editthreaddialog':
                        if ($(this).data('id') > -1) {
                            getChannelDetails($(this).data('id'));
                        }
                        break;
                    default:
                        currenteditingid = -1;
                        currentdeletingid = -1;
                        break;
                }

                tinymce.init({
                    selector: '#new_thread_textarea',
                    menubar: false,
                    relative_urls: false,
                    remove_script_host: true,
                    document_base_url: "{{url('/')}}",
                    valid_elements: 'img[class=myclass|!src|border:0|alt|title|width|height|style],' +
                        'a[href|target=_blank],' +
                        'strong/b,div[align],strong/b,em/i,strike,u,' +
                        'p[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|title],' +
                        'ol[class|compact<compact|dir<ltr?rtl|id|lang|start|style|title|type],' +
                        'ul[class|compact<compact|dir<ltr?rtl|id|lang|start|style|title|type],',

                    plugins: [
                        "link image emoticons"
                    ],
                    mobile: {
                        theme: 'mobile',
                        plugins: ["link image emoticons"],
                        toolbar: ['bold', 'italic', 'link', 'image', 'emoticons']
                    },
                    contextmenu: 'link, image',
                    toolbar: 'bold italic | link image emoticons |',
                    file_picker_types: 'image',
                    images_upload_handler: function (blobInfo, success, failure) {
                        let data = new FormData();
                        data.append('uploaded_file', blobInfo.blob(), blobInfo.filename());
                        console.log('Uploading data')
                        axios.post('{{route('frontend.forum.storemedia')}}', data)
                            .then(function (res) {
                                console.log('Uploading success!')
                                //  console.log(res.data)
                                success(res.data.location);
                            })
                            .catch(function (err) {
                                failure('HTTP Error: ' + err.message);
                            });
                    }
                });
            });

            $('#addthreaddialog').submit(function (event) {
                // cancels the form submission
                console.log('addthreaddialog submitted');
                event.preventDefault();
                //$(this).modal('hide');

                var form = $(this).find("form").get()[0];

                wait(true)
                submitNewForm(form);
            });


        });

        function getDetails(id) {
            console.log('getDetails:' + id);
            $.ajax({
                url: '{!! URL::to('forum/channels')!!}/' + id + '/get',
                type: 'GET',
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(errorThrown);
                },
                success: function (data) {
                    //  console.log(data);
                    //$("#editcontactdialog").find("form").values(data);
                    populate($("#editthreaddialog"), data);
                    // changevalidation('edituserform');
                    //waitingDialog.hide();
                }
            });
        }


        function submitNewForm(form) {
            console.log(form)
            var data = new FormData(form);
            axios.post('{!! route('frontend.threads.store')!!}',
                data
            ).then(function (response) {
                console.log(response);
                if (response.data.status == 0) {
                    location.reload();
                } else {
                    alert('something went wrong with the update');
                }
            })
                .catch(function (error) {
                    console.log(error);
                    alert('something went wrong with the update');
                })
                .finally(function () {
                    // always executed
                    wait(false)
                });

        }


        // populates a form with data returned from Laravel
        function populate(frm, data) {
            $.each(data, function (key, value) {
                var $ctrl = $('[name=' + key + ']', frm);
                if ($ctrl.is("select")) {
                    $ctrl.select2('val', value);
                } else {

                    switch ($ctrl.attr("type")) {
                        case "text" :
                        case "hidden":
                            $ctrl.val(value);
                            break;
                        case "radio" :
                        case "checkbox":
                            $ctrl.each(function () {
                                if ($(this).attr('value') == value) {
                                    $(this).attr("checked", value);
                                }
                            });
                            break;

                        default:
                            $ctrl.val(value);
                    }

                }
            });
        }

        function wait(on) {
            console.log(on)
            if (on) {
                $('.load-spinner').modal('show');
            } else {
                setTimeout(function () {
                    $('.load-spinner').modal('hide');
                }, 500)

            }
        }
    </script>
@endpush
@section('content')

    {{--    --}}
    @if(isset($lab))
        {!! Breadcrumbs::render('frontend.lab.forum', $lab) !!}
    @else
        {!! Breadcrumbs::render('frontend.channels.index') !!}
    @endif
    {{-- Forum channels display--}}
    <div class="notification_section">
        <div class="row">
            <div class="col-12 navs-link-section-mobile">
                <div class="nav nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
                    <a class="nav-link active" id="channel_-1-tab" data-toggle="pill"
                       href="#channel_-1" role="tab" aria-controls="channel_-1"

                       aria-selected="true"><span>
                            @if(strlen(request()->query('search'))>0)
                                Search results:
                            @else
                                All
                            @endif
                            </span></a>
                    @foreach($channels as $channel)
                        <a class="nav-link" id="channel_{{$channel->id}}-tab" data-toggle="pill"
                           href="#channel_{{$channel->id}}" role="tab"
                           aria-controls="channel_{{$channel->id}}"
                           aria-selected="false"><span>{{$channel->name}}</span></a>
                    @endforeach
                </div>
            </div>
            <div class="col-2 navs-link-section">
                <div class="nav flex-column align-items-end nav-pills" id="v-pills-tab" role="tablist"
                     aria-orientation="vertical">
                    <a class="nav-link active" id="channel_-1-tab" data-toggle="pill"
                       href="#channel_-1" role="tab" aria-controls="channel_-1"
                       aria-selected="true"><span> @if(strlen(request()->query('search'))>0)
                                Search results:
                            @else
                                All
                            @endif</span></a>
                    @foreach($channels as $channel)
                        <a class="nav-link" id="channel_{{$channel->id}}-tab" data-toggle="pill"
                           href="#channel_{{$channel->id}}" role="tab"
                           aria-controls="channel_{{$channel->id}}"
                           aria-selected="false"><span>{{$channel->name}}</span></a>
                    @endforeach
                </div>
            </div>
            <div class="col-md-10 navs-tab-section">
                <div class="tab-content" id="v-pills-tabContent">
                    <div class="tab-pane fade show active" id="channel_-1" role="tabpanel"
                         aria-labelledby="channel_-1-tab">
                        <div class="tab-search-section">
                            @if(isset($lab))
                                {{html()->form('get',route('frontend.lab.forum', $lab->id))->class('form-inline')->open()}}
                            @else
                                {{html()->form('get',route('frontend.channels.index'))->class('form-inline')->open()}}
                            @endif
                            <div class="search_field">
                                <i class="fas fa-search"></i>
                                <input type="text" name="search" placeholder="Search"
                                       value="{{request()->query('search')}}">
                            </div>
                            <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-search"
                                                                                    aria-hidden="true"></i>
                            </button>
                            {{html()->form()->close()}}
                        </div>
                        <div>
                            @foreach($allthreads as $i => $thread)
                                <div class="row w-100" style="border-bottom: 1px solid grey; ">
                                    <div class="d-flex flex-row w-100">
                                        <div class="notification-time">
                                            <h5>{{date('h:m A'),strtotime($thread->created_at)}}</h5>
                                            <h5>{{date('d-m-y'),strtotime($thread->created_at)}}</h5>
                                        </div>
                                        <div class="post_section">
                                            <a href="{{$thread->path()}}">
                                                <div class="post_content">
                                                    <h5 class="post_content_title">{!! \Illuminate\Support\Str::highlightSearch($thread->title, urldecode(request()->query('search')))??''!!}
                                                        <span class="p-2 g_et_al_paragraph2">

                                                            <a href="{{$thread->path()}}#replies"> <i
                                                                    class="far fa-comment text-primary"></i><span
                                                                    class="text-muted"> {{$thread->replies->count()}}</span></a>
                                                       </span>
                                                        <br/>@foreach($thread->tags as $tag)
                                                            #{{$tag->text}}
                                                        @endforeach
                                                    </h5>

                                                    <p class="post_content_para"> {!! \Illuminate\Support\Str::highlightSearch(\App\Helpers\General\StringHelper::truncateWithoutTags($thread->body, 100), urldecode(request()->query('search'))) !!}</p>

                                                </div>
                                            </a>
                                        </div>
                                        <div class="posted_user_section">

                                            <h5 class="posted_user_title posted_user_name"><a
                                                    href="{{route('frontend.user.profile.view', $thread->user->uuid)}}"
                                                    style="text-decoration: none;color: inherit;">
                                                    <div class="posted_user_image">
                                                        <img style="width: 100%; height: 100%"
                                                             src="{{ $thread->user->getPicture(80) }}"
                                                             alt="logo_image"></div>
                                                    {{$thread->user->name}}</a>

                                            </h5>

                                            <h5 class="posted_user_title">
                                                @if($lab)
                                                    {{($thread->user->labs->where('id', $lab->id)->first()&&$thread->user->labs->where('id', $lab->id)->first()->pivot->admin)?'Admin':''}}
                                                @endif
                                            </h5>

                                        </div>

                                    </div>

                                </div>

                            @endforeach


                        </div>
                    </div>

                    @foreach($channels as $channel)
                        <div class="tab-pane fade show" id="channel_{{$channel->id}}" role="tabpanel"
                             aria-labelledby="channel_{{$channel->id}}-tab">
                            <div class="d-flex w-100 pb-1" style="border-bottom: 1px solid grey; ">
                                <h4 class="flex-grow-1 bd-highlight">Posts </h4>
                                @if($channel->is_announcement_forum=='1')
                                    @if(($lab&&($logged_in_user->labs->where('id', $lab->id)->first())&&$logged_in_user->labs->where('id', $lab->id)->first()->pivot->admin)||$logged_in_user->isAdmin())
                                        <div>
                                            <button class="btn btn-outline-primary" data-toggle="modal"
                                                    data-target="#addthreaddialog" data-channel="{{$channel->id}}"
                                                    data-channel_name="{{$channel->name}}">New
                                                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
                                                     fill="currentColor" class="bi bi-plus" viewBox="0 0 16 16">
                                                    <path
                                                        d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"/>
                                                </svg>
                                            </button>
                                        </div>
                                    @endif
                                @else
                                    {{--                                        Else we're just in a normal channel and not anything special--}}
                                    <div>
                                        <button class="btn btn-outline-primary" data-toggle="modal"
                                                data-target="#addthreaddialog" data-channel="{{$channel->id}}"
                                                data-channel_name="{{$channel->name}}">New
                                            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
                                                 fill="currentColor" class="bi bi-plus" viewBox="0 0 16 16">
                                                <path
                                                    d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"/>
                                            </svg>
                                        </button>
                                    </div>
                                @endif

                            </div>

                            <div>

                                @foreach($channel->threads as $i => $thread)
                                    <div class="row w-100" style="border-bottom: 1px solid grey; ">
                                        <div class="d-flex flex-row w-100">
                                            <div class="notification-time">
                                                <h5>{{date('h:m A'),strtotime($thread->created_at)}}</h5>
                                                <h5>{{date('d-m-y'),strtotime($thread->created_at)}}</h5>
                                            </div>
                                            <div class="post_section">
                                                <a href="{{$thread->path()}}">
                                                    <div class="post_content">
                                                        <h5 class="post_content_title">{!! \Illuminate\Support\Str::highlightSearch($thread->title, urldecode(request()->query('search')))??''!!}
<span class="p-2 g_et_al_paragraph2">

                                                            <a href="{{$thread->path()}}#replies"> <i
                                                                    class="far fa-comment text-primary"></i><span
                                                                    class="text-muted"> {{$thread->replies->count()}}</span></a>
                                                       </span>
                                                            <br/>@foreach($thread->tags as $tag)
                                                                #{{$tag->text}}
                                                            @endforeach
                                                        </h5>

                                                        <p class="post_content_para"> {!! \Illuminate\Support\Str::highlightSearch(\App\Helpers\General\StringHelper::truncateWithoutTags($thread->body, 100), urldecode(request()->query('search'))) !!}</p>

                                                    </div>
                                                </a>
                                            </div>



                                            <div class="posted_user_section">

                                                <h5 class="posted_user_title posted_user_name"><a
                                                        href="{{route('frontend.user.profile.view', $thread->user->uuid)}}"
                                                        style="text-decoration: none;color: inherit;">
                                                        <div class="posted_user_image">
                                                            <img style="width: 100%; height: 100%"
                                                                 src="{{ $thread->user->getPicture(80) }}"
                                                                 alt="logo_image"></div>
                                                        {{$thread->user->name}}</a>

                                                </h5>

                                                <h5 class="posted_user_title">
                                                    @if($lab)
                                                        {{($thread->user->labs->where('id', $lab->id)->first()&&$thread->user->labs->where('id', $lab->id)->first()->pivot->admin)?'Admin':''}}
                                                    @endif
                                                </h5>

                                            </div>

                                        </div>

                                    </div>

                                @endforeach


                            </div>
                        </div>


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

    {{--    <div class="row" style="margin-top: 10px; min-height: 500px">--}}

    {{--        <div class="col"--}}
    {{--             style="margin-left:20px; background-color: whitesmoke; border: 1px solid #2aa8cc; border-radius: 0px 10px 10px 10px; margin-right: 5px">--}}
    {{--            <div class="row hideonsmallscreen">--}}

    {{--                --}}{{--                    Shown on smaller screen--}}
    {{--                <div class="nav-item dropdown">--}}
    {{--                    <a class="nav-link dropdown-toggle" id="channelDropdown" role="button" data-toggle="dropdown"--}}
    {{--                       aria-haspopup="true" aria-expanded="false">--}}
    {{--                        <span class="g_et_al_header3">Channels</span>--}}
    {{--                    </a>--}}
    {{--                    <div class="dropdown-menu" aria-labelledby="channelDropdown">--}}
    {{--                        <li class="nav-item">--}}
    {{--                            <a class="nav-link active " data-toggle="tab"--}}
    {{--                               href="#channel_-1" role="tab"--}}
    {{--                            >All</a>--}}
    {{--                        @foreach($channels as $channel)--}}
    {{--                            <li class="nav-item">--}}
    {{--                                <a class="nav-link " data-toggle="tab"--}}
    {{--                                   href="#channel_{{$channel->id}}" role="tab"--}}
    {{--                                >{{$channel->name??''}}</a>--}}
    {{--                            </li>--}}
    {{--                        @endforeach--}}
    {{--                    </div>--}}
    {{--                </div>--}}
    {{--            </div>--}}
    {{--            --}}{{--            The top row--}}
    {{--            <div class="d-flex" style="border-bottom: 2px solid grey; padding-bottom: 5px">--}}
    {{--                <div class="p-2">--}}
    {{--                    <button class="btn btn-info" data-forum_channels_id="-1" data-toggle="modal"--}}
    {{--                            data-target="#addthreaddialog">New post--}}
    {{--                    </button>--}}
    {{--                </div>--}}
    {{--                <div class="p-2 ml-auto flex-grow" style="">--}}

    {{--                    {{html()->form('get',route('frontend.channels.index'))->class('form-inline')->open()}}--}}
    {{--                    <div class="input-group">--}}
    {{--                        {{ html()->multiselect('searchtags[]', $tags->pluck('text', 'id'))--}}
    {{--                                              ->class('form-control')--}}
    {{--                                              ->value(Request('searchtags')??'')--}}
    {{--                                              }}--}}
    {{--                        --}}{{--                    <label class="my-1 mr-2" for="search">Search</label>--}}
    {{--                    </div>--}}
    {{--                    --}}{{--                    <div class="input-group">--}}
    {{--                    --}}{{--                        {{ html()->text('search')--}}
    {{--                    --}}{{--                                               ->class('form-control form-control-sm')--}}
    {{--                    --}}{{--                                               ->value(Request('search')??'')--}}
    {{--                    --}}{{--                                               ->attribute('placeholder', 'Search string')--}}
    {{--                    --}}{{--                                               }}--}}
    {{--                    --}}{{--                    </div>--}}
    {{--                    --}}{{--                    <div class="input-group-btn">--}}
    {{--                    --}}{{--                        <button class="btn btn-default" type="submit">--}}
    {{--                    --}}{{--                            <i class="glyphicon glyphicon-search"></i>--}}
    {{--                    --}}{{--                        </button>--}}
    {{--                    --}}{{--                    </div>--}}
    {{--                    <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-search" aria-hidden="true"></i>--}}
    {{--                    </button>--}}
    {{--                    {{html()->form()->close()}}--}}
    {{--                    --}}{{--                   <input type="text" class="form-control" name="search"--}}
    {{--                    --}}{{--                                                                                                                        value="{{isset(Request::all()['search'])?Request::all()['search']:''}}">--}}
    {{--                    --}}{{--                        <button type="submit" class="btn btn-primary" style="vertical-align: bottom"><i--}}
    {{--                    --}}{{--                                class="fa fa-search" aria-hidden="true"></i></button>--}}
    {{--                </div>--}}
    {{--            </div>--}}

    {{--            --}}{{--            The --}}
    {{--            <div class="row ">--}}
    {{--                <div class="col-lg-2">--}}

    {{--                    --}}{{--Shown when on large screen --}}
    {{--                    <ul class="nav nav-tabs" id="myTab" role="tablist">--}}
    {{--                        <li class="nav-item">--}}
    {{--                            <a class="nav-link active " data-toggle="tab"--}}
    {{--                               href="#channel_-1" role="tab"--}}
    {{--                            >All</a>--}}
    {{--                        @foreach($channels as $channel)--}}
    {{--                            <li class="nav-item">--}}
    {{--                                <a class="nav-link " data-toggle="tab"--}}
    {{--                                   href="#channel_{{$channel->id}}" role="tab"--}}
    {{--                                >{{$channel->name??''}}</a>--}}
    {{--                            </li>--}}
    {{--                        @endforeach--}}
    {{--                    </ul>--}}


    {{--                </div>--}}
    {{--                <div class="col-lg-10">--}}
    {{--                    <div class="tab-content">--}}
    {{--                        <div class="tab-pane active" id="channel_-1"--}}
    {{--                             role="tabpanel">--}}
    {{--                            <div class="g_et_al_header3 mb-1">Latest discussions in All forums</div>--}}
    {{--                            @foreach($allthreads as $thread)--}}
    {{--                                --}}{{--Content--}}
    {{--                                <div class="row w-100" style="border-bottom: 1px solid grey; ">--}}
    {{--                                    <div class="d-flex flex-row w-100">--}}
    {{--                                        <div class="p-2 w-75" style="overflow-wrap: break-word; overflow-y: hidden">--}}
    {{--                                            <a href="{{$thread->path()}}">--}}
    {{--                                            <a href="{{$thread->path()}}">--}}
    {{--                                                {{$thread->channel->name??''}}--}}
    {{--                                                :<br/> {{$thread->title??''}}</a>--}}
    {{--                                        </div>--}}
    {{--                                        --}}{{--                                Name and date--}}
    {{--                                        <div class="p-2 g_et_al_paragraph2"--}}
    {{--                                             style="padding-top: 0 !important; overflow-wrap: break-word; overflow-y: hidden">{{$thread->user->name??''}}--}}
    {{--                                            <div class="g_et_al_timecell">{{$thread->created_at->diffForHumans()}}</div>--}}
    {{--                                        </div>--}}

    {{--                                    </div>--}}

    {{--                                    <div class="d-flex flex-row w-100">--}}
    {{--                                        <div class="p-2"--}}
    {{--                                             style="padding-top: 0 !important">--}}

    {{--                                        </div>--}}
    {{--                                        <div class=" p-2 body_div w-75"--}}
    {{--                                             style="padding-top: 0 !important;overflow-y: hidden">--}}
    {{--                                            {!! \App\Helpers\General\StringHelper::truncateWithoutTags($thread->body, 100) !!}--}}
    {{--                                        </div>--}}

    {{--                                        <div class="p-2 ml-auto g_et_al_paragraph2"--}}
    {{--                                             style="padding-top: 0 !important;">--}}
    {{--                                            @foreach($thread->tags as $tag)--}}
    {{--                                                #{{$tag->text}}--}}
    {{--                                            @endforeach--}}
    {{--                                        </div>--}}
    {{--                                        <div class="p-2 ml-auto g_et_al_paragraph2"--}}
    {{--                                             style="padding-top: 0 !important;">--}}
    {{--                                            <a href="{{$thread->path()}}#replies"> <i class="far fa-comment text-primary"></i><span class="text-muted"> {{$thread->replies->count()}}</span></a>--}}
    {{--                                        </div>--}}
    {{--                                    </div>--}}

    {{--                                </div>--}}


    {{--                            @endforeach--}}


    {{--                        </div>--}}
    {{--                        @foreach($channels as $channel)--}}

    {{--                            <div class="tab-pane " id="channel_{{$channel->id}}"--}}
    {{--                                 role="tabpanel">--}}
    {{--                                <div class="g_et_al_header3">Latest discussions in {{$channel->name??''}}</div>--}}
    {{--                                --}}{{--                                <table class="table table-hover">--}}
    {{--                                @foreach($channel->threads as $thread)--}}
    {{--                                    --}}{{--Content--}}
    {{--                                    <div class="row w-100" style="border-bottom: 1px solid grey; ">--}}
    {{--                                        <div class="d-flex flex-row w-100">--}}
    {{--                                            <div class="p-2 w-75" style="overflow-wrap: break-word; overflow-y: hidden">--}}
    {{--                                                <a href="{{$thread->path()}}">{{$thread->channel->name??''}}--}}
    {{--                                                    :<br/> {{$thread->title??''}}</a>--}}
    {{--                                            </div>--}}
    {{--                                            --}}{{--                                Name and date--}}
    {{--                                            <div class="p-2 g_et_al_paragraph2"--}}
    {{--                                                 style="padding-top: 0 !important; overflow-wrap: break-word; overflow-y: hidden">{{$thread->user->name??''}}--}}
    {{--                                                <div--}}
    {{--                                                    class="g_et_al_timecell">{{$thread->created_at->diffForHumans()}}</div>--}}
    {{--                                            </div>--}}

    {{--                                        </div>--}}

    {{--                                        <div class="d-flex flex-row w-100">--}}
    {{--                                            <div class="d-flex p-2 body_div"--}}
    {{--                                                 style="padding-top: 0 !important;overflow-y: hidden">--}}
    {{--                                                {!! \App\Helpers\General\StringHelper::truncateWithoutTags($thread->body, 100) !!}--}}
    {{--                                            </div>--}}
    {{--                                            <div class="p-2 ml-auto g_et_al_paragraph2"--}}
    {{--                                                 style="padding-top: 0 !important;">--}}
    {{--                                                @foreach($thread->tags as $tag)--}}
    {{--                                                    #{{$tag->text}}--}}
    {{--                                                @endforeach--}}

    {{--                                            </div>--}}

    {{--                                        </div>--}}
    {{--                                    </div>--}}
    {{--                                @endforeach--}}

    {{--                            </div>--}}
    {{--                        @endforeach--}}
    {{--                    </div>--}}
    {{--                </div>--}}
    {{--            </div>--}}


    {{--        </div>--}}

    {{--    </div>--}}







@endsection
@section('dialogs')
    <div id="addthreaddialog" class="modal fade" role="dialog">
        <div class="modal-dialog  modal-lg ">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="additemtitle">New post to <span id="new_post_channel_name"></span></h4>
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body">
                    {{--                    {!! html()->form()->class('form-horizontal')->open();Form::open( ['class'=>'form-horizontal', 'id'=>'addchannelform'])!!}--}}
                    {{html()->form()->class('form-horizontal')->open()}}

                    @include('frontend.forum.thread.form.new_thread', ['submitButtonText'=>'Add thread'])

                    {{ html()->form()->close() }}
                </div>
            </div>
        </div>
    </div>

{{--    <div id="editthreaddialog" class="modal fade" role="dialog">--}}
{{--        <div class="modal-dialog">--}}
{{--            <div class="modal-content">--}}
{{--                <div class="modal-header">--}}
{{--                    <h4 class="modal-title">Edit channel</h4>--}}
{{--                    <button type="button" class="close" data-dismiss="modal">&times;</button>--}}
{{--                </div>--}}
{{--                <div class="modal-body">--}}
{{--                    {!! Form::open( ['class'=>'form-horizontal', 'id'=>'editChannelform'])!!}--}}

{{--                    --}}{{--                    @include('frontend.forum.thread.form.threadform', ['submitButtonText'=>'Update thread'])--}}

{{--                    {!! Form::close() !!}--}}
{{--                </div>--}}
{{--            </div>--}}
{{--        </div>--}}
{{--    </div>--}}

    <div class="modal fade load-spinner" data-backdrop="static" data-keyboard="false" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <i class="fas fa-circle-notch fa-spin fa-3x mx-auto"></i>
            </div>
        </div>
    </div>
@endsection
