之后是写script了
<script type=text/javascript>
var numberOfEmails_original= ;
var app = SysApplication;
appadd_init(applicationInitHandler);
function applicationInitHandler(sender args) {
InboxServiceGetLatestNumberOfEmails(OnCurrentNumberOfEmailsReady);
}
首先默认的当然是封邮件了有变量来存放当前邮件数量之后是在ajax中的初始化事件中调用webserice的方法了并且回调OnCurrentNumberOfEmailsReady方法
function OnCurrentNumberOfEmailsReady(result userContext methodName) {
numberOfEmails_original= result;
// Start Checking
StartChecking();
}
OnCurrentNumberOfEmailsReady方法将WEBSERVICE调用的结果(当前状态下有多少封信RESULT)返回给变量然后调用sartchecking()方法
function StartChecking() {
InboxServiceGetLatestNumberOfEmails(OnLastestNumberOfEmailsReady);
}
startchecking方法继续回调OnLastestNumberOfEmailsReady方法
function OnLastestNumberOfEmailsReady(result userContext methodName) {
var numberOfEmails_new= result;
if (numberOfEmails_new > numberOfEmails_original) {
ShowPopup();
$get(modalBody)innerHTML= numberOfEmails_new numberOfEmails_original;
// Update the count here
numberOfEmails_original= numberOfEmails_new;
}
// Start checking again
windowsetTimeout(StartChecking );
}
这个方法用当前邮件数原来邮件数就得出新增了多少封邮件了再将结果赋值给显示区域的modalbody并且记得把当前邮件数量的变量更新哦(numberOfEmails_original= numberOfEmails_new;)
然后再用setimeout来设置每隔毫秒检查一次了
function ShowPopup() {
$get(UpdateProgress)stylevisibility= visible;
$get(UpdateProgress)styledisplay= block;
}
function HidePopup() {
$get(UpdateProgress)stylevisibility= hidden;
$get(UpdateProgress)styledisplay= none;
}
</script>
[] []