@php use App\Models\TickerMessages; @endphp
@extends('layout.app')
@section('scripts')
    <script>
        const i18n = {
            common: {
                error_occurred: "{{ __('app.common.error_occurred') }}"
            },
            ticker: {
                delete_success: "{{ __('app.ticker.delete_success') }}",
                insert_success: "{{ __('app.ticker.insert_success') }}"
            }
        };
    </script>
    <script src="{{ asset("js/intern.js") }}"></script>
    <script src="{{ asset("js/ticker/edit.js") }}"></script>
@endsection

@section('content')
    <h1>{{ __('app.ticker.title') }}</h1>
    <div id="fehlermeldung">{{ __('app.ticker.description') }}</div>
    <div class="split-left">
        <h2>{{ __('app.language.de') }}</h2>
        <label for="ticker_de">{{ __('app.ticker.active_messages') }}</label><br/><br/>
        <select name="ticker_de" id="ticker_de" multiple>
            @foreach(TickerMessages::where('language', 'de')->orderBy('updated_at', 'desc')->get() as $tm)
                <option value="{{$tm->id}}">{{$tm->message}}</option>
            @endforeach
        </select>
        <br/><br/>
        <button onclick="remove('de')">{{ __('app.ticker.delete_selected') }}</button>
        <br/><br/><br/>

        <label for="insert_de">{{ __('app.ticker.create_message') }} </label><br/>
        <input size="32" type="text" id="insert_de">
        <br/><br/>
        <button onclick="insert('de')">{{ __('app.ticker.add') }}</button>
    </div>
    <div class="split-right">
        <h2>{{ __('app.language.en') }}</h2>
        <label for="ticker_en">{{ __('app.ticker.active_messages') }}</label><br/><br/>
        <select name="ticker_en" id="ticker_en" multiple>
            @foreach(TickerMessages::where('language', 'en')->orderBy('updated_at', 'desc')->get() as $tm)
                <option value="{{$tm->id}}">{{$tm->message}}</option>
            @endforeach
        </select>
        <br/><br/>
        <button onclick="remove('en')">{{ __('app.ticker.delete_selected') }}</button>
        <br/><br/><br/>

        <label for="insert_de">{{ __('app.ticker.create_message') }} </label><br/>
        <input size="32" type="text" id="insert_en">
        <br/><br/>
        <button onclick="insert('en')">{{ __('app.ticker.add') }}</button>
    </div>

@endsection
