出境ESN0处理工具
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>出境Es/N0</title>
</head>
<body>
<div>
<label>请输入原始数据:</label><br/>
<textarea name="" id="inputText" cols="30" rows="10" style="width: 400px;height:200px;"></textarea><br/><br/>
<button style="width: 100px;height: 60px" onclick="query()">查询处理结果</button><br/><br/>
<label>结果显示-time:</label><br/>
<textarea name="" id="queryResult1" cols="30" rows="10" style="width: 400px;height:200px;"></textarea><br/>
<label>结果显示-value:</label><br/>
<textarea name="" id="queryResult2" cols="30" rows="10" style="width: 400px;height:200px;"></textarea>
</div>
<script>
function msToDate(milliseconds) {
var date = new Date(milliseconds);
var year = date.getFullYear();
var month = ('0' + (date.getMonth() + 1)).slice(-2); // 月份是从0开始的
var day = ('0' + date.getDate()).slice(-2);
var hours = ('0' + date.getHours()).slice(-2);
var minutes = ('0' + date.getMinutes()).slice(-2);
var seconds = ('0' + date.getSeconds()).slice(-2);
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
function query(){
var inputStr = document.getElementById('inputText').value.trim();
var arr = JSON.parse(inputStr).data.historyReportData.fwdEsN0;
var arrCopy = arr.reverse();
var a1 = [];
var b1 = [];
for(var i =0 ;i<arr.length; i++){
a1.push(msToDate(arr[i][0]));
b1.push(arr[i][1]);
}
var obj = {a1: a1, b1: b1}
document.getElementById('queryResult1').value = obj.a1;
document.getElementById('queryResult2').value = obj.b1;
console.log(newStr);
}
</script>
</body>
</html>