<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>
<link href="https://fonts.googleapis.com/css?family=Nanum+Gothic&display=swap" rel="stylesheet">
<script>
var socket=io.connect("http://eassetdeals.in:4003");
$(document).ready(function(){
	socket.on("tr_emit",function(data){
		//console.log(data.trdata.replace('</td><td>', ""));
		var dd=data.trdata.split('</td><td>');
		//console.log(dd);
		var ddd=dd[0].split('>');
		console.log(ddd);
		if(ddd[3]){
		$("#"+data.trid+'_rate').html(dd[3]);
		}else{
		$("#"+data.trid+'_rate').html(dd[1]);
		}
		$("#"+data.trid+'_chg').html(dd[2]+' ('+dd[3]+'%)');
		//$("#div"+data.trid).css("border-left","2px solid "+data.color);
		$("#div"+data.trid).css("background-color",data.color);
		setTimeout(function(){ $("#div"+data.trid).css("background","#212F3C"); }, 2000);
	});
	socket.on("tr_emit_user",function(data){
		//console.log(data.trid);
		$("tr#"+data.trid).html(data.tr);
//		$("tr#"+data.trid+" td:nth-child(2)").css("background-color",data.color);
//		setTimeout(function(){ $("tr#"+data.trid+" td:nth-child(2)").css("background","none"); }, 2000);
	});
	setInterval(function(){
				var cur_rate_class=$("#cur_rate").attr("class");
				//console.log(cur_rate_class);
				//$(".GOLD_ticker").text($("tr#GOLD td:nth-child(2)").text());
				if(cur_rate_class!=""){
				var v=$("tr#"+cur_rate_class+" td:nth-child(2)").text();
				}
				$("#cur_rate").val(v);
				}, 1000);
	$("#metal_select").change(function(){
				var vall=$(this).val();
				var t=vall.split("-");
				$("#cur_rate").attr("class",t[0]);
			//	$("#limit").attr("class",t[0]+"_ticker form-control");
			});
			$("#marketprice").click(function(){
				if ($('input[type="checkbox"]').is(':checked')){
					$("#limit").attr('disabled',true);
				}else{
					$("#limit").removeAttr('disabled');
				}
				//
			});
});
</script>
</head>
<style>
.metal_divs{margin:5px; background:#212F3C; border:2px solid #E5E7E9;border-radius:10px;}
.metalname{font-size:12px;color:#E5E7E9;}
.metalrate{font-size:16px; color:#fff;}
.metalchg{font-size:10px;color:#E5E7E9;}
</style>
<body style="font-family: 'Nanum Gothic'; background:#34495E;">
	<div class="container">
    	<div class="row">
        	<?php $metals=$this->db->get("metals")->result();
					foreach($metals as $d){?>
                    <div class="col-md-4 col-xs-4 text-center" style="padding:5px;">
                    	<div class="metal_divs"  id="div<?php echo $d->metal;?>">
                    	<span class="metalname"><?php echo $d->metal;?></span><br/>
                        <b class="metalrate" id="<?php echo $d->metal;?>_rate">0</b><br/>
                        <span class="metalchg" id="<?php echo $d->metal;?>_chg"></span>
                        
                        </div>
                    </div>
                    <?php }?>
        </div>
    </div>
</body>
</html>

