@extends('webprofile.backend.layouts.master')

@section('title')
  {{ $title }}
@stop

@section('breadcrumbs')
<li><a href="{{ url('dashboard') }}">Dashboard</a></li>
<li class="active">Add API</li>
@stop

@section('content')
{!! Form::open(array('url' => route('autopost.store'), 'method' => 'POST', 'id' => 'autopost', 'class' => 'form-horizontal')) !!}
{!! csrf_field() !!}
<!-- page start-->
<div class="row">
	<div class="col-md-12">
	    <div class="panel panel-default">
	        <div class="panel-heading">
	            <h3 class="panel-title"><strong>Add</strong> API</h3>
	        </div>
	        <div class="panel-body">
	            <div class="row">
	                <div class="col-md-12">
	                    <div class="form-group @if ($errors->has('name')) has-error @endif">
	                        <label class="col-md-2 control-label">Name</label>
	                        <div class="col-md-10">
	                          {{ Form::text('name', old('name'), array('class' => 'form-control')) }}
	                          @if ($errors->has('name'))
	                          <label id="login-error" class="error" for="login">{{$errors->first('name')}}</label>
	                          @endif
	                        </div>
						</div>
						
	                    <div class="form-group @if ($errors->has('type')) has-error @endif">
	                        <label class="col-md-2 control-label">Type</label>
							<div class="col-md-10">
	                          {{ Form::select('type', ['facebook' => 'Facebook', 'twitter' => 'Twitter', 'telegram' => 'Telegram', 'alia' => 'Alia'], old('type'), array('class' => 'form-control fmtype', 'id' => 'type', 'placeholder' => '- Pilih -')) }}
	                          @if ($errors->has('type'))
	                          <label id="login-error" class="error" for="login">{{$errors->first('type')}}</label>
	                          @endif
	                        </div>
						</div>
						
						<div class="form-group @if ($errors->has('key_1')) has-error @endif" style="display:none;" id="fmkey_1">
	                        <label class="col-md-2 control-label" id="key_1">KEY 1</label>
	                        <div class="col-md-10">
	                          {{ Form::text('key_1', old('key_1'), array('class' => 'form-control')) }}
	                          @if ($errors->has('key_1'))
	                          <label id="login-error" class="error" for="login">{{$errors->first('key_1')}}</label>
	                          @endif
	                        </div>
						</div>

						<div class="form-group @if ($errors->has('key_2')) has-error @endif" style="display:none;" id="fmkey_2">
	                        <label class="col-md-2 control-label" id="key_2">KEY 2</label>
	                        <div class="col-md-10">
	                          {{ Form::text('key_2', old('key_2'), array('class' => 'form-control')) }}
	                          @if ($errors->has('key_2'))
	                          <label id="login-error" class="error" for="login">{{$errors->first('key_2')}}</label>
	                          @endif
	                        </div>
						</div>

						<div class="form-group @if ($errors->has('key_3')) has-error @endif" style="display:none;" id="fmkey_3">
	                        <label class="col-md-2 control-label" id="key_3">KEY 3</label>
	                        <div class="col-md-10">
	                          {{ Form::text('key_3', old('key_3'), array('class' => 'form-control')) }}
	                          @if ($errors->has('key_3'))
	                          <label id="login-error" class="error" for="login">{{$errors->first('key_3')}}</label>
	                          @endif
	                        </div>
						</div>

						<div class="form-group @if ($errors->has('key_4')) has-error @endif" style="display:none;" id="fmkey_4">
	                        <label class="col-md-2 control-label" id="key_4">KEY 4</label>
	                        <div class="col-md-10">
	                          {{ Form::text('key_4', old('key_4'), array('class' => 'form-control')) }}
	                          @if ($errors->has('key_4'))
	                          <label id="login-error" class="error" for="login">{{$errors->first('key_4')}}</label>
	                          @endif
	                        </div>
						</div>

						<div class="form-group @if ($errors->has('key_5')) has-error @endif" id="fmkey_5" style="display:none;">
	                        <label class="col-md-2 control-label" id="key_5">KEY 5</label>
	                        <div class="col-md-10">
	                          {{ Form::text('key_5', old('key_5'), array('class' => 'form-control')) }}
	                          @if ($errors->has('key_5'))
	                          <label id="login-error" class="error" for="login">{{$errors->first('key_5')}}</label>
	                          @endif
	                        </div>
						</div>

						<div class="form-group @if ($errors->has('key_6')) has-error @endif" id="fmkey_6" style="display:none;">
	                        <label class="col-md-2 control-label" id="key_6">KEY 6</label>
	                        <div class="col-md-10">
	                          {{ Form::text('key_6', old('key_6'), array('class' => 'form-control')) }}
	                          @if ($errors->has('key_6'))
	                          <label id="login-error" class="error" for="login">{{$errors->first('key_6')}}</label>
	                          @endif
	                        </div>
						</div>
	                </div>
	            </div>
	        </div>
	    </div>
	</div>
	<div class="col-md-12">
	    <div class="panel panel-default">
	        <div class="panel-footer">
              <a href="{{URL::to('webprofile/autopost')}}" class="btn btn-default pull-right">Batal</a>
	            <button class="btn btn-info pull-right">Simpan</button>
	        </div>
	    </div>
	</div>
</div>
{!! Form::close() !!}
<!-- page end-->
@stop

@section('script')
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-datepicker.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-file-input.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/summernote/summernote.js') !!}

<script>
	$("body").on("change", ".fmtype", function () {
		var type = $(this).val();

		$("#fmkey_1").hide();
		$("#fmkey_2").hide();
		$("#fmkey_3").hide();
		$("#fmkey_4").hide();
		$("#fmkey_5").hide();
		$("#fmkey_6").hide();

		if (type == 'facebook') {
			$("#key_1").html('APP ID');
			$("#fmkey_1").show();
			$("#key_2").html('FACEBOOK SECRET');
			$("#fmkey_2").show();
			$("#key_3").html('FACEBOOK GRAPH VERSION');
			$("#fmkey_3").show();
			$("#key_4").html('FACEBOOK ACCESS TOKEN');
			$("#fmkey_4").show();
			$("#fmkey_5").hide();
			$("#fmkey_6").hide();
		}
		
		if (type == 'twitter') {
			$("#key_1").html('TWITTER KEY');
			$("#fmkey_1").show();
			$("#key_2").html('TWITTER SECRET KEY');
			$("#fmkey_2").show();
			$("#key_3").html('TWITTER TOKEN');
			$("#fmkey_3").show();
			$("#key_4").html('TWITTER TOKEN SECRET');
			$("#fmkey_4").show();
			$("#key_5").html('TWITTER BEARER KEY');
			$("#fmkey_5").show();
			$("#fmkey_6").hide();
		}

		if (type == 'telegram') {
			$("#key_1").html('API TOKEN');
			$("#fmkey_1").show();
			$("#key_2").html('BOT USERNAME');
			$("#fmkey_2").show();
			$("#key_3").html('CHANNEL USERNAME');
			$("#fmkey_3").show();
			$("#key_4").html('CHANNEL SIGNATURE');
			$("#fmkey_4").show();
			$("#key_5").html('PROXY');
			$("#fmkey_5").show();
			$("#fmkey_6").hide();
		}
		if (type == 'alia') {
			$("#key_1").html('URL');
			$("#fmkey_1").show();
			$("#key_2").html('POSTS');
			$("#fmkey_2").show();
			
		}
	});
</script>
@stop
