проблема с автообновлением setinterval
вопрос в следующем: не обновляется календарь в виджете на symbian3
html:
--------------
<head>
<script type='text/javascript' src="MemoryInfo.js"></script>
<style type="text/css">
@import url("basic.css");
</style>
<title></title>
<meta http-equiv="Refresh" content="18000"; charset="windows-1251">
</head>
<body onload="init()">
<div id="kalendar">
<script>
function buildCal(m, y, cM, cH, cDW, cD, brdr){
var dim=[31,0,31,30,31,30,31,31,30,31,30,31];
var oD = new Date(y, m -1, 0);
oD.od=oD.getDay()+1;
var todaydate=new Date()
var scanfortoday=(y==todaydate.getFullYear() && m==todaydate.getMonth()+1)? todaydate.getDate() : 0 //DD added
dim[1]=(((oD.getFullYear()%100!=0)&&(oD.getFullYear()%4= =0))||(oD.getFullYear()%400==0))?29:28;
var t='<div class="'+cM+'"><table class="'+cM+'" cols="7" cellpadding="0" border="0" cellspacing="0" cellpadding="0"><tr align="center">';
for(s=0;s<7;s++)t+='<td class="'+cDW+'">'+"ПВСЧПСВ".substr(s,1)+'</td>';
t+='</tr><tr align="center">';
for(i=1;i<=35;i++){
var x=((i-oD.od>=0)&&(i-oD.od<dim[m-1]))? i-oD.od+1 : ' ';
if (x==scanfortoday)
x='<span id="today">'+x+'</span>'
t+='<td class="'+cD+'">'+x+' </td >';
if(((i)%7==0)&&(i<35))t+='</tr><tr align="center">';
}
return t+='</tr></table ></div>';
}
</script>
<script>
var todaydate=new Date()
var curmonth=todaydate.getMonth()+11
var curyear=todaydate.getFullYear()
</script>
<script>
document.getElementById("kalendar").innerHTML = buildCal(curmonth-10 ,curyear, "main", "month", "daysofweek", "days", 1);
setinterval("buildCal(m, y, cM, cH, cDW, cD, brdr)",9600000);
</script>
<div id="mini_view">
<div id="memory_bar">
<div id ="memory_bar_center">
<div id="memory_value">0%</div>
</div>
<div id="memory_abs_value">0 Mb</div>
</div>
<div id="memory_name">R</div>
......и тд....
</div>
</div>
<div id="full_view">
<img id="status_image" src="gfx/status_deactive.png"/>
<a href="#" onclick="update();" ><img id="app_icon" src="icon.png"/></a>
<h3 style="text-align:center;">Ergo's MemInfo</h3>
<table border="0" id="mem_text_values_table">
<tr>
<td><b>RAM</b></td>
<td id="text_mem_free">n/a</td>
<td>/</td>
<td id="text_mem_total">n/a</td>
<td>MB</td>
</tr>
......и тд....
</table>
</body>
</html>
-------------
js:
-------------
var systeminfo;
var bytesPerKb = 1024;
var refreshInterval = 120000; // 120s
var barWidth = 130; // in pixels
var refreshTimer;
var serviceObj = null;
function init() {
window.widget.prepareForTransition("fade");
document.getElementById("status_image").src="gfx/status_activating.png";
try{
systeminfo = document.embeds[0];
} catch (err){
document.getElementById("status_image").src="gfx/status_deactive.png";
return;
}
// Obtain the AppManager service object
try {
serviceObj = device.getServiceObject("Service.AppManager", "IAppManager");
} catch (ex) {
document.getElementById("status_image").src="gfx/status_deactive.png";
return;
}
if (widget.isrotationsupported)
{
widget.setDisplayPortrait();
}
// Start displaying menu
//menu.showSoftkeys();
window.menu.hideSoftkeys();
window.widget.performTransition();
// Start the graphics
updateNow();
}
widget.onshow = function()
{
updateNow();
}
winget.onhide = function()
{
if (refreshTimer != undefined)
{
clearTimeout(refreshTimer);
}
}
function update()
{
var memUsagePercent = Math.ceil(((systeminfo.totalram-systeminfo.freeram)/systeminfo.totalram) * 100);
var phoneMemPercent = getDriveInfo(0);
var massMemPercent = getDriveInfo(1);
var memCardPercent = getDriveInfo(2);
updateMemoryBar(memUsagePercent);
// TODO: hide non-existing drives in else clauses
if (phoneMemPercent != -1)
{
updatePhoneMemBar(phoneMemPercent);
}
if (massMemPercent != -1)
{
updateMassMemBar(massMemPercent);
document.getElementById("massmem_div").style.displ ay="inline";
}
else
{
document.getElementById("massmem_div").style.displ ay="none";
}
if (memCardPercent != -1)
{
updateMemCardBar(memCardPercent);
document.getElementById("memcard_div").style.displ ay="inline";
}
else
{
document.getElementById("memcard_div").style.displ ay="none";
}
setTextualValues();
if (refreshTimer != undefined)
{
clearTimeout(refreshTimer);
}
refreshTimer = setTimeout("update()", refreshInterval);
document.getElementById("status_image").src="gfx/status_active.png";
}
function updateNow()
{
document.getElementById("status_image").src="gfx/status_activating.png";
if (refreshTimer != undefined)
{
clearTimeout(refreshTimer);
}
update();
}
function updateMemoryBar(percentage)
{
var control = document.getElementById('dvShow')
var percentWidth = barWidth * (percentage/100);
percentWidth = Math.ceil(percentWidth);
var dvPercentWidth = document.getElementById('memory_bar_center');
dvPercentWidth.style.width = percentWidth.toString() + 'px';
setBarColor(percentage, dvPercentWidth);
var sPercent = document.createTextNode(percentage.toString() + "%");
var textValue = document.getElementById("memory_value");
textValue.innerHTML= percentage+"%";
}
function updatePhoneMemBar(percentage)
{
var control = document.getElementById('dvShow')
var percentWidth = barWidth * (percentage/100);
percentWidth = Math.ceil(percentWidth);
var dvPercentWidth = document.getElementById('phonemem_bar_center');
dvPercentWidth.style.width = percentWidth.toString() + 'px';
setBarColor(percentage, dvPercentWidth);
var sPercent = document.createTextNode(percentage.toString() + "%");
var textValue = document.getElementById("phonemem_value");
textValue.innerHTML= percentage+"%";
}
function updateMassMemBar(percentage)
{
var control = document.getElementById('dvShow')
var percentWidth = barWidth * (percentage/100);
percentWidth = Math.ceil(percentWidth);
var dvPercentWidth = document.getElementById('massmem_bar_center');
dvPercentWidth.style.width = percentWidth.toString() + 'px';
setBarColor(percentage, dvPercentWidth);
var sPercent = document.createTextNode(percentage.toString() + "%");
var textValue = document.getElementById("massmem_value");
textValue.innerHTML= percentage+"%";
}
function updateMemCardBar(percentage)
{
var control = document.getElementById('dvShow')
var percentWidth = barWidth * (percentage/100);
percentWidth = Math.ceil(percentWidth);
var dvPercentWidth = document.getElementById('memcard_bar_center');
dvPercentWidth.style.width = percentWidth.toString() + 'px';
setBarColor(percentage, dvPercentWidth);
var sPercent = document.createTextNode(percentage.toString() + "%");
var textValue = document.getElementById("memcard_value");
textValue.innerHTML= percentage+"%";
}
function getDriveInfo(driveNumber)
{
var returnValue = -1;
// Getting drivelist and splitting it into array
var drivesStr = systeminfo.drivelist;
if(drivesStr == undefined) {
return;
}
var drives = drivesStr.split(" ");
var drivesCount = drives.length;
if (drivesCount >= driveNumber && systeminfo.drivesize(drives[driveNumber]) > 0)
{
var driveSize = systeminfo.drivesize(drives[driveNumber]) / bytesPerKb;
var driveFree = systeminfo.drivefree(drives[driveNumber]) / bytesPerKb;
var returnValue = Math.ceil(((driveSize-driveFree)/driveSize) * 100);
}
return returnValue;
}
......и тд....
-------------
почему не срабатывает setinterval?
|