<?php 

include('view/new_header_file.php');

?>

<link rel="stylesheet" type="text/css" href="node_modules/css-toggle-switch/dist/toggle-switch.css">

  <style type="text/css">

.item {

  display: block;

  position: absolute;

  z-index: 1;

  margin-top: 80px;

}



.item.muuri-item-dragging {

  z-index: 3;

}

.item.muuri-item-releasing {

  z-index: 2;

}

.item.muuri-item-hidden {

  z-index: 0;

}

  </style>

<style type="text/css">

    .panel-heading

  {

    background-color: #F7614E;

    text-align: center;

    padding: 7px !important;

    font-size: 18px !important;

    font-weight: 500;

  }

 

  .livetv

  {

    width: 100%;

    height: 400px;

    overflow: hidden;

    margin-top: -80px;

  }

  .resultPrice > span

  {

    text-align: center;

    font-size: 18px;

    color: #fff;

    padding: 10px;

  }

  .resultPrice{

    margin-top: -20px !important;

    margin-bottom: 0px !important;

  }

  

    .swal-modal

  {

    background-color: #202943;

  }

  .swal-title

  {

    color: #F7614E;

  }

  .swal-text

  {

    color: #fff;

  }

  .swal-icon--success:before, .swal-icon--success:after

  {

    background-color: #202943;  

  }

  .swal-icon--success__hide-corners {



    background-color: #202943;  

  }

  #tablelayout

  {

    height: 500px;

  }

  #boxlayout

  {

    height: 500px;

    overflow-y: scroll;

    overflow-x: hidden;

  }

</style>





<style type="text/css">

  .tableHeatMap > thead > tr > th, .tableHeatMap > tbody > tr > td

  {

    color: #fff !important;

    text-align: center !important;

    border: 1px solid #fff !important;

    min-width: 100px !important;

    padding: 16px 25px;

  }

  .tableHeatMap

  {

    width: 100%;

  }

  .tableHeatMap > thead

  {

    width: 100%;

  }

  .tableHeatMap > thead > tr

  {

    width: 100% !important;

  }

</style>



<style type="text/css">

  .hmLightTable > thead > tr > th

  {

    border: 1px solid #0E162D !important;

    color: #0E162D !important;

  }

  .hmLightTable > thead > tr > th

  {

    background: #eee !important;

  }

  .hmLightTable > tbody > tr > td

  {

    border: 1px solid #0E162D !important;

    color: #0E162D !important;

  }

</style>



  <!-- Add Tracker Modal -->

  <div class="modal fade" id="addTrackerModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">

    <div class="modal-dialog modal-dialog-centered" role="document">

      <div class="modal-content">

        <div class="modal-header">

          <h5 class="modal-title" id="exampleModalLongTitle">Add Tracker</h5>

          <button type="button" class="close" data-dismiss="modal" aria-label="Close">

            <span aria-hidden="true">&times;</span>

          </button>

        </div>

        <div class="modal-body">

          <form action="#" class="form" id="addTrackerForm">

            <input type="hidden" name="action" value="insertTracker">

             <div class="col-md-12">

              <label> Email </label>

                <input type="email" class="form form-control" required name="tracker_email" style="height: 50px;" />

             </div> 

             <div class="col-md-12">

              <label> Currency </label>

                <select style="height: 50px;" placeholder="Identifier" required class="form form-control newformcontrol" name="tracker_symbol" >

                    <option value="SGDCHF">SGDCHF </option>

                    <option value="NZDCHF">NZDCHF</option>

                    <option value="AUDCHF">AUDCHF</option>

                    <option value="SGDJPY">SGDJPY</option>

                    <option value="ZARJPY">ZARJPY</option>

                    <option value="TRYJPY">TRYJPY</option>

                    <option value="NZDCAD">NZDCAD</option>

                    <option value="GBPNZD">GBPNZD</option>

                    <option value="GBPCHF">GBPCHF</option>

                    <option value="GBPCAD">GBPCAD</option>

                    <option value="GBPAUD">GBPAUD</option>

                    <option value="EURNZD">EURNZD</option>

                    <option value="EURCHF">EURCHF</option>

                    <option value="EURCAD">EURCAD</option>

                    <option value="CADCHF">CADCHF</option>

                    <option value="AUDNZD">AUDNZD</option>

                    <option value="AUDCAD">AUDCAD</option>

                    <option value="GBPUSD">GBPUSD</option>

                    <option value="USDCHF">USDCHF</option>

                    <option value="USDCAD">USDCAD</option>

                    <option value="NZDUSD">NZDUSD</option>

                    <option value="NZDJPY">NZDJPY</option>

                    <option value="GBPJPY">GBPJPY</option>

                    <option value="EURGBP">EURGBP</option>

                    <option value="EURAUD">EURAUD</option>

                    <option value="CHFJPY">CHFJPY</option>

                    <option value="CADJPY">CADJPY</option>

                    <option value="AUDJPY">AUDJPY</option>

                    <option value="AUDUSD">AUDUSD</option>

                    <option value="EURJPY">EURJPY</option>

                    <option value="USDJPY">USDJPY</option>

                    <option value="EURUSD">EURUSD</option>

                  </select>

             </div> 

             <div class="col-md-12">

              <label>Price</label>

                <input type="text" class="form form-control" style="height: 50px;" required name="tracker_price" />

             </div> 

             <div class="col-md-12">

              <label>Length</label>

                <input name="tracker_length" required class="form form-control datetimepicker" style="height: 50px;" type="datetime-local">

             </div> 

             <div class="col-md-12" style="margin-top:1em;">

                <div class="row">

                  <div class="col-md-4">

                  </div>

                  <div class="col-md-3">

                    <button type="button" class="btn btn-secondary" data-dismiss="modal" style="width: 100%;">Close</button>    

                  </div>

                  <div class="col-md-5">

                    <input type="submit" class="btn btn-primary pull-right trackerSubmit" value="Add Tracker" style="background-color: #F15A24;width: 100%;border: none;">    

                  </div>

                </div>

                

                

            </div>

          </form>

        </div>

      </div>

    </div>

  </div>

  <!-- END Modal -->





  <!-- Add Tracker Modal -->

  <div class="modal fade" id="trackerModifyModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">

    <div class="modal-dialog modal-dialog-centered" role="document">

      <div class="modal-content">

        <div class="modal-header">

          <h5 class="modal-title" id="exampleModalLongTitle">Modify Tracker</h5>

          <button type="button" class="close" data-dismiss="modal" aria-label="Close">

            <span aria-hidden="true">&times;</span>

          </button>

        </div>

        <div class="modal-body">

          <form action="#" class="form" id="modifyTrackerId">

            <input type="hidden" name="tid" value="" id="tid">

            <input type="hidden" name="action" value="modifytrackeraction">

             <div class="col-md-12">

              <label> Email </label>

                <input type="email" id="temail" class="form form-control" required name="tracker_email_modify" />

             </div> 

             <div class="col-md-12">

              <label> Currency </label>

                <select placeholder="Identifier" id="tsymbol" required class="form form-control newformcontrol" name="tracker_symbol_modify" >

                    <option value="SGDCHF">SGDCHF </option>

                    <option value="NZDCHF">NZDCHF</option>

                    <option value="AUDCHF">AUDCHF</option>

                    <option value="SGDJPY">SGDJPY</option>

                    <option value="ZARJPY">ZARJPY</option>

                    <option value="TRYJPY">TRYJPY</option>

                    <option value="NZDCAD">NZDCAD</option>

                    <option value="GBPNZD">GBPNZD</option>

                    <option value="GBPCHF">GBPCHF</option>

                    <option value="GBPCAD">GBPCAD</option>

                    <option value="GBPAUD">GBPAUD</option>

                    <option value="EURNZD">EURNZD</option>

                    <option value="EURCHF">EURCHF</option>

                    <option value="EURCAD">EURCAD</option>

                    <option value="CADCHF">CADCHF</option>

                    <option value="AUDNZD">AUDNZD</option>

                    <option value="AUDCAD">AUDCAD</option>

                    <option value="GBPUSD">GBPUSD</option>

                    <option value="USDCHF">USDCHF</option>

                    <option value="USDCAD">USDCAD</option>

                    <option value="NZDUSD">NZDUSD</option>

                    <option value="NZDJPY">NZDJPY</option>

                    <option value="GBPJPY">GBPJPY</option>

                    <option value="EURGBP">EURGBP</option>

                    <option value="EURAUD">EURAUD</option>

                    <option value="CHFJPY">CHFJPY</option>

                    <option value="CADJPY">CADJPY</option>

                    <option value="AUDJPY">AUDJPY</option>

                    <option value="AUDUSD">AUDUSD</option>

                    <option value="EURJPY">EURJPY</option>

                    <option value="USDJPY">USDJPY</option>

                    <option value="EURUSD">EURUSD</option>

                  </select>

             </div> 

             <div class="col-md-12">

              <label>Price</label>

                <input type="text" id="tprice" class="form form-control" required name="tracker_price_modify" />

             </div> 

             <div class="col-md-12">

              <label>Length</label>

                <input name="tracker_length_modify" id="tlength" required class="form form-control datetimepicker" type="datetime-local">

             </div> 

             <div class="col-md-12" style="margin-top:1em;">

                <div class="row">

                  <div class="col-md-4">

                  </div>

                  <div class="col-md-3">

                    <button type="button" class="btn btn-secondary" data-dismiss="modal" style="width: 100%;">Close</button>    

                  </div>

                  <div class="col-md-5">

                    <input type="submit" class="btn btn-primary pull-right" value="Update Tracker" style="background-color: #F15A24;width: 100%;border: none;">    

                  </div>

                </div>

                

            </div>

          </form>

        </div>

      </div>

    </div>

  </div>

  <!-- END Modal -->





















    <div class="grid">

      

    <?php 



    $getlayout = $db->db->prepare("SELECT * FROM layout WHERE user = '$userId' AND layoutname = 'main'");

    $getlayout->execute();

    $fetchMainLayout = $getlayout->fetch();
 

      if (empty($fetchMainLayout)) {

      include('view/dashboard/rates.php');

      include('view/dashboard/commands.php');

      include('view/dashboard/alerts.php');  

      include('view/dashboard/heatmap.php');



    }else{



      $main_layout = unserialize($fetchMainLayout['layout']);

      foreach ($main_layout as $ml) {





         if ($ml == 'mainLayout2') {

          # code...

          include('view/dashboard/commands.php');

        }

        if ($ml == 'mainLayout1') {

          # code...

          include('view/dashboard/rates.php');      

        }

       



        if ($ml == 'mainLayout3') {

          # code...

          include('view/dashboard/alerts.php');

        }



        if ($ml == 'mainLayout5') {

          include('view/dashboard/heatmap.php');

        }


    }





    }



    





?>











  











  </div>




















<script src="node_modules/muuri/dist/muuri.min.js"></script>

<script src="node_modules/web-animations-js/web-animations.min.js"></script>





<?php 

include('view/new_footer_file.php');

?>

<script type="text/javascript">

var cloneMap = {};
var grid2 = new Muuri('.grid', {
  dragEnabled: true,
  dragContainer: document.body,
  dragSort: true,
   dragStartPredicate: {
    distance: 20,
    delay: 10,
    handle: false
  }
})
.on('receive', function (data) {
  cloneMap[data.item._id] = {
    item: data.item,
    grid: data.fromGrid,
    index: data.fromIndex
  };
})
.on('send', function (data) {
  delete cloneMap[data.item._id];
})
.on('dragReleaseStart', function (item) {


  var getPosition = item.getGrid();
  var getPosElement = getPosition['_items'];

  var idArray = [];


  for (var i = 0; i < getPosElement.length; i++) {
      
      var elements = getPosElement[i]['_element']['id'];
      idArray.push(elements);

  }


    var userid = '<?=$userId; ?>'

    $.post('/controller/layout.controller.php', {layout:idArray, user:userid})
    .done(function(data){

    });






  var cloneData = cloneMap[item._id];
  if (cloneData) {
    delete cloneMap[item._id];

    var clone = cloneData.item.getElement().cloneNode(true);
    clone.setAttribute('style', 'display:none;');
    clone.setAttribute('class', 'item');
    clone.children[0].setAttribute('style', '');
 
    cloneData.grid.add(clone, {index: cloneData.index});
    cloneData.grid.show(clone);
  }
});



  // Table Layout Rate Panel


 function hmfunc(values)
 {
      if (values == 'hmper') {

           $(".hmp").show();
           $(".hm").hide();
      }


      if (values == 'hmprice') {

           $(".hmp").hide();
           $(".hm").show();
      }
 }


heatmapController();
      table_rate_panel();
      boxed_rate_panel();
setTimeout(function()
{


      table_rate_panel();
      boxed_rate_panel();
  heatmapController();
  extra_heat_map();


}, 15000);




function heatmapController()
{
   $.post('/crons/heatmap-cron.php', $("#modifyTrackerId").serialize())
          .done(function(data){

            var data = JSON.parse(data);

            for (var i = 0; i < data.length; i++) {
                 
                  var result = JSON.parse(data[i]);
                  var sym = result['sym'];
                  var price = result['bid'];
                  var percentage = result['per'];

                  var sym = sym.replace('_','');
                  var sym = sym.toLowerCase();
                  var symid = "#"+sym+"hm";
                  $(symid).html(price);

                 var symperid = "#"+sym+"hmp";

                 if (percentage < 0) {
                      $(symperid).html("<span style='color:red;'>"+percentage+"%</span>");
                  }else{
                      $(symperid).html(percentage+"%");  
                  }



            }

          });
}



  function table_rate_panel()
  {
    $.post('/controller/rate.controller.php', { action:"tableshow"})
       .done(function (data)
       {
          $('#ratesPanel').html(data);
    });
  }


  function extra_heat_map()
  {
     // USD / EUR

          var eurusd = $("#eurusdhm").html();
          var usdeur = 1/ eurusd;

          var audusd = $("#audusdhm").html();
          var usdaud = 1 / audusd;
      
          var gbpusd = $("#gbpusdhm").html();
          var usdgbp = 1 / gbpusd;

          var nzdusd = $("#nzdusdhm").html();
          var usdnzd = 1 / nzdusd;

           var euraud = $("#euraudhm").html();
           var audeur = 1 / euraud;

           var gbpaud = $("#gbpaudhm").html();
           var audgbp = 1 / gbpaud;

           var eurgbp = $("#eurgbphm").html();
           var gbpeur = 1 / eurgbp;

           var eurnzd = $("#eurnzdhm").html();
           var nzdeur = 1 / eurnzd;

           var audnzd = $("#audnzdhm").html();
           var nzdaud = 1 / audnzd;

           var gbpnzd = $("#gbpnzdhm").html();
           var nzdgbp = 1 / gbpnzd;

           var eurcad = $("#eurcadhm").html();
           var cadeur = 1 / eurcad;

          var usdcad = $("#usdcadhm").html();
          var cadusd = 1 / usdcad;

          var audcad = $("#audcadhm").html();
          var cadaud = 1 / audcad;

          var gbpcad = $("#gbpcadhm").html();
          var cadgbp = 1 / gbpcad;

          var nzdcad = $("#nzdcadhm").html();
          var cadnzd = 1 / nzdcad;

           var eurchf = $("#eurchfhm").html();
           var chfeur = 1 / eurchf;

           var usdchf = $("#usdchfhm").html();
           var chfusd = 1 / usdchf;

           var audchf = $("#audchfhm").html();
           var chfaud = 1 / audchf;
         
           var gbpchf = $("#gbpchfhm").html();
           var chfgbp = 1 / gbpchf;

          var nzdchf = $("#nzdchfhm").html();
           var chfnzd = 1 / nzdchf;

         var sgdchf = $("#sgdchfhm").html();
           var chfsgd = 1 / sgdchf;

          var cadchf = $("#cadchfhm").html();
          var chfcad = 1 / cadchf;

          var eurjpy = $("#eurjpyhm").html();
          var jpyeur = 1 / eurjpy;


          var usdjpy = $("#usdjpyhm").html();
          var jpyusd = 1 / usdjpy;

          var audjpy = $("#audjpyhm").html();
          var jpyaud = 1 / audjpy;

          var gbpjpy = $("#gbpjpyhm").html();
          var jpygbp = 1 / gbpjpy;


          var nzdjpy = $("#nzdjpyhm").html();
          var jpynzd = 1 / nzdjpy;

          var cadjpy = $("#cadjpyhm").html();
          var jpycad = 1 / cadjpy;

          var chfjpy = $("#chfjpyhm").html();
          var jpychf = 1 / chfjpy;

          var hkdjpy = $("#hkdjpyhm").html();
          var jpyhkd = 1 / hkdjpy;

          var sgdjpy = $("#sgdjpyhm").html();
          var jpysgd = 1 / sgdjpy;

          var usdhkd = $("#usdhkdhm").html();
          var hkdusd = 1 / usdhkd;

          var eurhkd = $("#eurhkdhm").html();
          var hkdeur = 1 / eurhkd;

          var audhkd = $("#audhkdhm").html();
          var hkdaud = 1 / audhkd;

          var gbphkd = $("#gbphkdhm").html();
          var hkdgbp = 1 / gbphkd;

          // HKD / NZD
          var nzdhkd = $("#nzdhkdhm").html();
          var hkdnzd = 1 / nzdhkd;

          // HKD / CAD
          var cadhkd = $("#cadhkdhm").html();
          var hkdcad = 1 / cadhkd;

          // HKD / CHF
          var chfhkd = $("#chfhkdhm").html();

          var hkdchf = 1 / chfhkd;
         
          // HKD / SGD
          var sgdhkd = $("#sgdhkdhm").html();

          var hkdsgd = 1 / sgdhkd;
          
          // SGD / EUR
          var eursgd = $("#eursgdhm").html();
          
          var sgdeur = 1 / eursgd;

          // SGD / USD
          var usdsgd = $("#usdsgdhm").html();
          
          var sgdusd = 1 / usdsgd;

          // SGD / AUD
          var audsgd = $("#audsgdhm").html();
          
          var sgdaud = 1 / audsgd;

          // SGD / GBP
          var gbpsgd = $("#gbpsgdhm").html();
          
          var sgdgbp = 1 / gbpsgd;
          

          // SGD / NZD
          var nzdsgd = $("#nzdsgdhm").html();
          
          var sgdnzd = 1 / nzdsgd;

          // SGD / CAD
          var cadsgd = $("#cadsgdhm").html();
          
          var sgdcad = 1 / cadsgd;








        var chfjpyhmp = $("#chfjpyhmp").html();
        var cadjpyhmp = $("#cadjpyhmp").html();
        var nzdjpyhmp = $("#nzdjpyhmp").html();
        var gbpjpyhmp = $("#gbpjpyhmp").html();
        var audjpyhmp = $("#audjpyhmp").html();
        var usdjpyhmp = $("#usdjpyhmp").html();
        var eurjpyhmp = $("#eurjpyhmp").html();
        var cadchfhmp = $("#cadchfhmp").html();
        var sgdchfhmp = $("#sgdchfhmp").html();
        var nzdchfhmp = $("#nzdchfhmp").html();
        var gbpchfhmp = $("#gbpchfhmp").html();
        var audchfhmp = $("#audchfhmp").html();
        var usdchfhmp = $("#usdchfhmp").html();
        var eurchfhmp = $("#eurchfhmp").html();
        var nzdcadhmp = $("#nzdcadhmp").html();
        var cadsgdhmp = $("#cadsgdhmp").html();
        var nzdsgdhmp = $("#nzdsgdhmp").html();
        var gbpsgdhmp = $("#gbpsgdhmp").html();
        var audsgdhmp = $("#audsgdhmp").html();
        var usdsgdhmp = $("#usdsgdhmp").html();
        var eursgdhmp = $("#eursgdhmp").html();
        var sgdhkdhmp = $("#sgdhkdhmp").html();
        var chfhkdhmp = $("#chfhkdhmp").html();
        var cadhkdhmp = $("#cadhkdhmp").html();
        var nzdhkdhmp = $("#nzdhkdhmp").html();
        var gbphkdhmp = $("#gbphkdhmp").html();
        var eurhkdhmp = $("#eurhkdhmp").html();
        var usdhkdhmp = $("#usdhkdhmp").html();
        var sgdjpyhmp = $("#sgdjpyhmp").html();
        var hkdjpyhmp = $("#hkdjpyhmp").html();
        var audhkdhmp = $("#audhkdhmp").html();
        var audcadhmp = $("#audcadhmp").html();
        var usdcadhmp = $("#usdcadhmp").html();
        var eurusdhmp = $("#eurusdhmp").html();
        var audusdhmp = $("#audusdhmp").html();
        var gbpusdhmp = $("#gbpusdhmp").html();
        var nzdusdhmp = $("#nzdusdhmp").html();
        var euraudhmp = $("#euraudhmp").html();
        var gbpaudhmp = $("#gbpaudhmp").html();
        var eurgbphmp = $("#eurgbphmp").html();
        var nzdeurhmp = $("#nzdeurhmp").html();
        var audnzdhmp = $("#audnzdhmp").html();
        var gbpnzdhmp = $("#gbpnzdhmp").html();
        var eurcadhmp = $("#eurcadhmp").html();



        var hmpvalues = [chfjpyhmp, cadjpyhmp, nzdjpyhmp, gbpjpyhmp, audjpyhmp, usdjpyhmp, eurjpyhmp, cadchfhmp, sgdchfhmp, nzdchfhmp, gbpchfhmp, audchfhmp, usdchfhmp, eurchfhmp, nzdcadhmp, cadsgdhmp, nzdsgdhmp, gbpsgdhmp, audsgdhmp, usdsgdhmp, eursgdhmp, sgdhkdhmp, chfhkdhmp, cadhkdhmp, nzdhkdhmp, gbphkdhmp, eurhkdhmp, usdhkdhmp, sgdjpyhmp, hkdjpyhmp, audhkdhmp, audcadhmp, usdcadhmp, eurusdhmp, audusdhmp, gbpusdhmp, nzdusdhmp, euraudhmp, gbpaudhmp, eurgbphmp, nzdeurhmp, audnzdhmp, gbpnzdhmp, eurcadhmp];

        var hmpids = ["chfjpyhmp", "cadjpyhmp", "nzdjpyhmp", "gbpjpyhmp", "audjpyhmp", "usdjpyhmp", "eurjpyhmp", "cadchfhmp", "sgdchfhmp", "nzdchfhmp", "gbpchfhmp", "audchfhmp", "usdchfhmp", "eurchfhmp", "nzdcadhmp", "cadsgdhmp", "nzdsgdhmp", "gbpsgdhmp", "audsgdhmp", "usdsgdhmp", "eursgdhmp", "sgdhkdhmp", "chfhkdhmp", "cadhkdhmp", "nzdhkdhmp", "gbphkdhmp", "eurhkdhmp", "usdhkdhmp", "sgdjpyhmp", "hkdjpyhmp", "audhkdhmp", "audcadhmp", "usdcadhmp", "eurusdhmp", "audusdhmp", "gbpusdhmp", "nzdusdhmp", "euraudhmp", "gbpaudhmp", "eurgbphmp", "nzdeurhmp", "audnzdhmp", "gbpnzdhmp", "eurcadhmp"];


        for (var i = 0; i < hmpids.length; i++) {
            
            var hmp_id = hmpids[i];
            var hmp_value = hmpvalues[i];
            insertHmpValueFunction(hmp_id, hmp_value);
        }






          var forexidArray = ["#nzdgbphm", "#nzdaudhm", "#nzdeurhm", "#gbpeurhm", "#audgbphm", "#audeurhm", "#usdnzdhm", "#usdgbphm", "#usdaudhm", "#usdeurhm", "#sgdcadhm", "#sgdnzdhm", "#sgdgbphm", "#sgdaudhm", "#sgdusdhm", "#sgdeurhm", "#hkdsgdhm", "#hkdchfhm", "#hkdcadhm", "#hkdnzdhm", "#hkdgbphm", "#hkdaudhm", "#hkdeurhm", "#hkdusdhm", "#jpysgdhm", "#jpyhkdhm", "#jpychfhm", "#jpycadhm", "#jpynzdhm", "#jpygbphm", "#jpyaudhm", "#jpyusdhm", "#jpyeurhm", "#chfcadhm", "#chfsgdhm", "#chfnzdhm", "#chfgbphm", "#chfaudhm", "#chfusdhm", "#chfeurhm", "#cadnzdhm", "#cadgbphm", "#cadaudhm", "#cadusdhm","#cadeurhm"];

          var forexratearray = [nzdgbp, nzdaud, nzdeur, gbpeur, audgbp, audeur, usdnzd, usdgbp, usdaud, usdeur, sgdcad, sgdnzd, sgdgbp, sgdaud, sgdusd, sgdeur, hkdsgd, hkdchf, hkdcad, hkdnzd, hkdgbp, hkdaud, hkdeur, hkdusd,jpysgd, jpyhkd, jpychf, jpycad, jpynzd, jpygbp, jpyaud, jpyusd, jpyeur, chfcad, chfsgd, chfnzd, chfgbp, chfaud, chfusd, chfeur, cadnzd, cadgbp, cadaud, cadusd, cadeur];

          for (var i = 0; i < forexidArray.length; i++) {
               
               var forexid = forexidArray[i];
               var forextRate = forexratearray[i];
               forextRate = forextRate.toFixed(5);
               insertRateValue(forexid, forextRate);

          }
  }



  function insertHmpValueFunction(id, rate)
  {
      var firstthreecharid = id.substring(0, 3);
      var secondcharid = id.substring(3, 6);
      var thirdcharid = id.substring(6, 9);


      var reverse_id = secondcharid + firstthreecharid + thirdcharid;
      var reverse_full_id = $("#"+reverse_id);

      if (isNaN(rate) == false) {

        $(reverse_full_id).html('<span style="color:red;">0.00%</span>');

      }else{

          rate = rate.replace('%', '');
          rate = rate.replace('</span>', '');
          rate = rate.replace('<span style="color:red;">', '')

          var covertFloat = parseFloat(rate);
          covertFloat = covertFloat.toFixed(2);

          if (covertFloat < 0 ) {

              $(reverse_full_id).html('<span style="color:red;">'+covertFloat+'%</span>');
          
          }else{

              $(reverse_full_id).html(covertFloat + '%');

          }

      }

      

      



  }

   function insertRateValue(id, rate)
     {
          $(id).html(rate);
           var getsymbol = id.substring(1);
           var symbol1 = getsymbol.substring(0, 3);
           var symbol2 = getsymbol.substring(3, 6);
           var fullsymbol = symbol1 + "_"+symbol2;
           fullsymbol = fullsymbol.toUpperCase();

          $.post('/controller/heatmap-reverse.controller.php', {action:"reverse", sym:fullsymbol, rate:rate})
          .done(function(data){

          });

     }


  function boxed_rate_panel()
  {

             $.post('/controller/rate.controller.php', { action:"rateArray"})
             .done(function (data)
             {


                var json = JSON.parse(data);

                for (var i = 0; i < json.length; i++) {
                    

                    var encodedArray = JSON.parse(json[i]);

                    var inst = encodedArray['inst'];
                    var askPrice = encodedArray['askPrice'];
                    var bidPrice = encodedArray['bidPrice'];
                    var result = encodedArray['result'];
                    var trend = encodedArray['trend'];

                    var inst = inst.replace('_', '/');

                    var aPbeforePrice = askPrice.toString().split(".")[0]; 
                    var aPafterPrice = askPrice.toString().split(".")[1];

                    var bPbefore = bidPrice.toString().split(".")[0];
                    var bpafter = bidPrice.toString().split(".")[1];


                    var split1 = aPafterPrice.substring(0, 2);
                    var split2 = aPafterPrice.substring(2, 5);
                    var split3 = bpafter.substring(0, 2);
                    var split4 = bpafter.substring(2, 5);

                    var colorBackground = "";
                    var icon = "";

                    if (trend == "down") {

                      colorBackground = "#F7614E";
                      icon = '<i class="fa fa-arrow-down" style="margin-left:10px;"></i>';

                    }else{

                      colorBackground = "#49C279";
                      icon = '<i class="fa fa-arrow-up" style="margin-left:10px;"></i>';
                    }

                    var hd = "heading"+i;
                    var panel = "panel"+i;
                    var colRight = "colRight"+i;
                    var mp = "mP"+i;
                    var p = "p"+i;
                    var mPp = "mPp"+i;
                    var pp = "pp"+i;
                    var rp = "rp"+i;

                    $("#"+hd).html(inst + icon);
                    $("#"+hd).css('background-color',colorBackground);
                    $("#"+panel).css('border-color',colorBackground);
                    $("#"+colRight).css('border-color',colorBackground);
                    $("#"+mp).html(aPbeforePrice+".");
                    $("#"+p).html(split1 + "<sup>"+split2+"</sup>");
                    $("#"+mPp).html(bPbefore+".");
                    $("#"+pp).html(split3 + "<sup>"+split4+"</sup>");
                    $("#"+rp).html('<span style="background-color:'+colorBackground+'">'+result+'</span>');


                }

             });
  }











  function sendCommand(id)
  {
      
      var headingid ="#heading"+id;
      var getHeadings = $(headingid).html();
      var get_heading = getHeadings.substring(0, 7);
      get_heading = get_heading.replace('/', '');
      $("#TrialsymbolCommand").val(get_heading).change();

  }




</script>






<!-- Heat Map End Here -->