
<?= $this->Html->script('csshttprequest.js') ?>
<?= $this->Html->script('jquery.atd.js') ?>
<?= $this->Html->css('atd.css') ?>
<section class="pcoded-main-container">
  <div class="pcoded-content">
    <div class="page-header">
      <div class="page-block">
        <div class="row align-items-center">
          <div class="col-md-12">
            <div class="page-header-title">
              <h5 class="m-b-10">Essay Result</h5>
            </div>                   
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-xl-12 col-md-12">
        <div class="card">
          <div class="card-body table-border-style">
            <div class="table-responsive panel">


             <div id="preview"><?= strip_tags(html_entity_decode($this->Text->autoParagraph(h($essayTest->essay)))); ?>.</div>

             <hr>
             <a onclick="javascript:check()" class="btn btn-primary">Spell check!</a>
             <a onclick="javascript:countError()" class="btn btn-secondary">Count Error!</a>
             <span> Grammer Errors : <span class="ge">0</span>  , Spelling Errors : <span class="se">0</span> </span>
           </div>
         </div>
       </div>
     </div>
   </div>
 </div>
</section>


<script language="javascript">
 function check()
 {
  AtD.checkCrossAJAX('preview', 
  {
   success : function(errorCount) 
   {
    if (errorCount == 0)
    {
     alert("No writing errors were found");
   }
 },

 error : function(reason)
 {
  alert(reason);
}
});
}

function countError(){
  var spell_err = $('.hiddenSpellError').length; 
  var grame_err = $('.hiddenGrammarError').length;

  $('.se').text(spell_err);
  $('.ge').text(grame_err);
}
</script>
<!-- 

<nav class="large-3 medium-4 columns" id="actions-sidebar">
    <ul class="side-nav">
        <li class="heading"><?= __('Actions') ?></li>
        <li><?= $this->Html->link(__('Edit Essay Test'), ['action' => 'edit', $essayTest->id]) ?> </li>
        <li><?= $this->Form->postLink(__('Delete Essay Test'), ['action' => 'delete', $essayTest->id], ['confirm' => __('Are you sure you want to delete # {0}?', $essayTest->id)]) ?> </li>
        <li><?= $this->Html->link(__('List Essay Test'), ['action' => 'index']) ?> </li>
        <li><?= $this->Html->link(__('New Essay Test'), ['action' => 'add']) ?> </li>
        <li><?= $this->Html->link(__('List Freelancers'), ['controller' => 'Freelancers', 'action' => 'index']) ?> </li>
        <li><?= $this->Html->link(__('New Freelancer'), ['controller' => 'Freelancers', 'action' => 'add']) ?> </li>
    </ul>
</nav>
<div class="essayTest view large-9 medium-8 columns content">
    <h3><?= h($essayTest->id) ?></h3>
    <table class="vertical-table">
        <tr>
            <th scope="row"><?= __('Freelancer') ?></th>
            <td><?= $essayTest->has('freelancer') ? $this->Html->link($essayTest->freelancer->name, ['controller' => 'Freelancers', 'action' => 'view', $essayTest->freelancer->id]) : '' ?></td>
        </tr>
        <tr>
            <th scope="row"><?= __('Id') ?></th>
            <td><?= $this->Number->format($essayTest->id) ?></td>
        </tr>
        <tr>
            <th scope="row"><?= __('G Mistakes') ?></th>
            <td><?= $this->Number->format($essayTest->g_mistakes) ?></td>
        </tr>
        <tr>
            <th scope="row"><?= __('Created') ?></th>
            <td><?= h($essayTest->created) ?></td>
        </tr>
    </table>
    <div class="row">
        <h4><?= __('Essay') ?></h4>
        <?= $this->Text->autoParagraph(h($essayTest->essay)); ?>
    </div>
</div>
 -->