<?php 
include('view/new_header_file.php');
?>

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





      <div class="container-fluid">
         
         
              <?php 
                          include('view/heatmap.view.php');
                          ?>
    </div>


<?php
include('view/new_footer_file.php');
?>


<script type="text/javascript">
     function hmfunc(values)
     {
          if (values == 'hmper') {

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


          if (values == 'hmprice') {

               $(".hmp").hide();
               $(".hm").show();
          }
     }
</script>



<script type="text/javascript">
     

           setInterval(function(){

                     $.post('/controller/heatmap-eur.controller.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+"%");  
                          }

                          

                    }    

          });


           }, 3000);
















            setInterval(function(){

                     $.post('/controller/heatmap-usd.controller.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+"%");  
                          }
                    }

          });


           }, 3000);












          setInterval(function(){

                     $.post('/controller/heatmap-aud.controller.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+"%");  
                          }
                    }

          });


           }, 3000);









          setInterval(function(){

                     $.post('/controller/heatmap-gbp.controller.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+"%");  
                          }
                    }

          });


           }, 3000);














          setInterval(function(){

                     $.post('/controller/heatmap-cad.controller.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+"%");  
                          }
                    }

          });


           }, 3000);













          setInterval(function(){

                     $.post('/controller/heatmap-nzd.controller.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+"%");  
                          }
                    }

          });


           }, 3000);














               setInterval(function(){

                     $.post('/controller/heatmap-chf.controller.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+"%");  
                          }
                    }

          });


           }, 3000);







               /*   setInterval(function(){

                     $.post('/controller/heatmap-jpy.controller.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);
                    }

          });


           }, 3000);
*/











          setInterval(function(){

                     $.post('/controller/heatmap-hkd.controller.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+"%");  
                          }
                    }

          });


           }, 3000);












               setInterval(function(){

                     $.post('/controller/heatmap-sgd.controller.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+"%");  
                          }
                    }

          });


           }, 3000);




     setInterval(function(){



          // USD / EUR

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


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


          // GBP / USD


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


          // NZD / USD

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


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


           // GBP / AUD

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


           // GBP / EUR

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



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


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

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

           // CAD / EUR

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

           // CAD / USD


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


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



           // CAD / GBP

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

           // CAD / NZD

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


           // CHF / EUR

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


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

          // CHF / AUD


           var audchf = $("#audchfhm").html();
           var chfaud = 1 / audchf;
         
          // CHF / GBP


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

          // CHF / NZD


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


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



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



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

          // JPY / USD 

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


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


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


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


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

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

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


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

          // HKD / USD

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

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

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

          // HKD / GBP
          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 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);

          }


     }, 4000);

     


     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){

               console.log(data);

          });



     }



</script>