我有两个问题。
首先,我写了一个JS,从JSON格式化输出中成为我的时间。
setInterval(function () {
$.ajax({
type: "GET",
url: "/api/status",
processData: true,
dataType: 'text',
cache: false,
headers: ({"Auth-Secret": $("input[id='authpass']").val()}),
success: function (data, textStatus, request) {
var status = jQuery.parseJSON(data);
/* Status information from Stream and Record */
$("input[id='streamStatus']").val(status.stream[0]);
$("input[id='recordStatus']").val(status.record[0]);
$("input[id='totalUsb']").val(status.storage[1] + "MB");
$("input[id='freeUsb']").val(status.storage[2] + "MB");
if (status.record[1] == "-1") {
if (status.record[1] < 60) {
$("#recordDuration").text(status.record[1] + "s" + " (start)");
} else if (status.record[1] < 3600) {
var minute = Math.floor(status.record[1] / 60);
var second = status.record[1] % 60;
if (second < 10) {
second = "0" + second;
}
$("#recordDuration").text(minute + ":" + second + " (start)");
} else {
var hour = Math.floor(status.record[1] / 3600);
var minute = Math.floor(status.record[1] / 60) - hour * 60;
if (minute < 10) {
minute = "0" + minute;
}
var second = status.record[1] % 60;
if (second < 10) {
second = "0" + second;
}
if (hour > 99) {
$("#recordDuration").text(hour + "h (start)");
} else {
$("#recordDuration").text(hour + ":" + minute + ":" + second + " (start)");
}
}
} else if (status.stream[1] > 0) {
if (status.stream[1] == -1) {
$("#recordDuration").text("infinite (no stop)");
}
else if (status.time < 60) {
$("#recordDuration").text(status.stream[1] + "s" + " (stop)");
} else if (status.stream[1] < 3600) {
var minute = Math.floor(status.stream[1] / 60);
var second = status.stream[1] % 60;
if (second < 10) {
second = "0" + second;
}
$("#recordDuration").text(minute + ":" + second + " (stop)");
} else {
var hour = Math.floor(status.stream[1] / 3600);
var minute = Math.floor(status.stream[1] / 60) - hour * 60;
if (minute < 10) {
minute = "0" + minute;
}
var second = status.stream[1] % 60;
if (second < 10) {
second = "0" + second;
}
if (hour > 99) {
$("#recordDuration").text(hour + "h (stop)");
} else {
$("#recordDuration").text(hour + ":" + minute + ":" + second + " (stop)");
}
}
if (status.record[1] == 0) {
$("#recordDuration").text("stopped");
} else if (status.record[1] < 60) {
$("#recordDuration").text(status.record[1] + "s");
} else if (status.record < 3600) {
var minute = Math.floor(status.record[1] / 60);
var second = status.record[1] % 60;
if (second < 10) {
second = "0" + second;
}
$("#recordDuration").text(minute + ":" + second);
} else {
var hour = Math.floor(status.record[1] / 3600);
var minute = Math.floor(status.record[1] / 60) - hour * 60;
if (minute < 10) {
minute = "0" + minute;
}
var second = status.record[1] % 60;
if (second < 10) {
second = "0" + second;
}
$("#recordDuration").val(hour + ":" + minute + ":" + second);
}
if (status.stream[1] == "0") {
$("#recordDuration").text("stopped");
} else if (status.stream[1] < 60) {
$("#recordDuration").text(status.stream[1] + "s");
} else if (status.stream[1] < 3600) {
var minute = Math.floor(status.stream[1] / 60);
var second = status.stream[1] % 60;
if (second < 10) {
second = "0" + second;
}
$("#recordDuration").text(minute + ":" + second);
} else {
var hour = Math.floor(status.stream[1] / 3600);
var minute = Math.floor(status.stream[1] / 60) - hour * 60;
if (minute < 10) {
minute = "0" + minute;
}
var second = status.stream[1] % 60;
if (second < 10) {
second = "0" + second;
}
$("#recordDuration").val(hour + ":" + minute + ":" + second);
}
}
}
});
}, 1000);
我有2个不同的计数器,一个用于录制计时器,另一个用于流式传输。 它们都必须写在#recordDuration输入框中。 这样做是有效的,当一个网站稍后作为另一个网站启动时,网站必须显示上次启动的计数器。
这是我的HTML输入框
<p style="margin-left: 10px; color:#0099FF" scope="row">duraction
<input type="time" style="border: 0px; font: 14px/1.231 sans-serif" value="00:00:00" id="recordDuration"
readonly/></p>
问题是,我在网站上的计数器将在5分钟后开始显示正确的计数器。 第二个问题,我的计数器无法在Chrome上运行。