<?php $this->xinclude('partials/header'); ?>
<?php $url_host = $_SERVER['HTTP_HOST']; ?>

<style>
.btn-clipboard {
    z-index: 10;
    padding: 0.25rem 0.5rem;
    font-size: 65%;
    color: #007bff;
    background-color: #fff;
    border: 1px solid;
    border-radius: 0.25rem;
}
</style>

<div class="protected-wrap">
    <h1 class="protected-title">Your Protected Links</h1>

    <div class="alert alert-success">
      <i class="fa fa-check" aria-hidden="true"></i> &nbsp; <strong>Success!</strong> your links successfully protected.
    </div>

    <div class="well">
        <h3 class="label label-success">Protected link</h3>
        <a href="/view/<?php echo $this->uid; ?>" target="_blank"><?php echo System\Config::app('scheme').'://'.System\Config::app('domain').'/view/'.$this->uid; ?></a>
        <button class="btn btn-clipboard" onClick="copy('<?php echo 'https://'.$url_host.'/view/'.$this->uid; ?>')">Copy</button>
    </div>


    <div class="well">
        <h3 class="label label-warning">Remove link</h3>
        <a href="/remove/<?php echo $this->delete_uid; ?>" target="_blank"><?php echo System\Config::app('scheme').'://'.System\Config::app('domain').'/remove/'.$this->delete_uid; ?></a>
        <button class="btn btn-clipboard" onClick="copy('<?php echo 'https://'.$url_host.'/remove/'.$this->delete_uid; ?>')">Copy</button>
    </div>

</div>

<?php $this->xinclude('partials/footer'); ?>


<script>
    function copy(textContent){
        var inp =document.createElement('input');
        document.body.appendChild(inp)
        inp.value = textContent
        inp.select();
        document.execCommand('copy',false);
        inp.remove();
        }
</script>