› Foros › PC › Software libre
<?php $ptemp = `sensors | grep 'temp1' | awk '{print $2}'`;?>;
var tempString=<?php echo $ptemp; ?>;
var span_el2 = document.getElementById("proctemp");
var replaceWith2 = document.createTextNode(tempString);
span_el2.replaceChild(replaceWith2, span_el2.childNodes[0]);
setTimeout("doUptime()",1000);
<script language="javascript">
<!--
var upSeconds=<?php echo $uptimeSecs; ?>;
function doUptime() {
<?php $ptemp = `sensors | grep 'temp1' | awk '{print $2}'`;?>;
var tempString=<?php echo $ptemp; ?>;
var uptimeString = "";
var secs = parseInt(upSeconds % 60);
var mins = parseInt(upSeconds / 60 % 60);
var hours = parseInt(upSeconds / 3600 % 24);
var days = parseInt(upSeconds / 86400);
if (days > 0) {
uptimeString += days;
uptimeString += ((days == 1) ? " día" : " días");
}
if (hours > 0) {
uptimeString += ((days > 0) ? ", " : "") + hours;
uptimeString += ((hours == 1) ? " hora" : " horas");
}
if (mins > 0) {
uptimeString += ((days > 0 || hours > 0) ? ", " : "") + mins;
uptimeString += ((mins == 1) ? " minuto" : " minutos");
}
if (secs > 0) {
uptimeString += ((days > 0 || hours > 0 || mins > 0) ? ", " : "") + secs;
uptimeString += ((secs == 1) ? " segundo" : " segundos");
}
var span_el = document.getElementById("uptime");
var replaceWith = document.createTextNode(uptimeString);
span_el.replaceChild(replaceWith, span_el.childNodes[0]);
var span_el2 = document.getElementById("proctemp");
var replaceWith2 = document.createTextNode(tempString);
span_el2.replaceChild(replaceWith2, span_el2.childNodes[0]);
upSeconds++;
setTimeout("doUptime()",1000);
}
// -->
</script>
<?php $ptemp = `sensors | grep 'temp1' | awk '{print $2}'`;?>;
setInterval(function() {
$('#temperatura').load('temp.php');
}, 15000);