我真的很沮丧,因为我对倒数计时器一无所知......当我终于找到这个脚本时,我操纵它以便从分钟和秒而不是几秒开始倒计时......但只需运行它看看问题出在哪里...帮助!!!!
function doGet(e) {
var TIMER_SEC = '3:12';
var app = UiApp.createApplication();
//var button = app.createButton('Start/Pausa');
var timerDisplay = app.createLabel().setId('timerDisplay');
var timerValue = app.createTextBox().setId('timerValue').setName('timerValue').setVisible(false);
var chk = setTime(TIMER_SEC, app, timerDisplay, timerValue);
app.add(timerDisplay);
app.add(timerValue);
app.add(chk);
//app.add(button);
return app;
}
function handleTimer(e){
var app = UiApp.getActiveApplication();
var a;
var b=":0";
var t = e.parameter.timerValue;
var timerDisplay = app.getElementById('timerDisplay');
if(t!='0:00'){
if(t.substr(2,2)=="00"){
a=parseInt(t.substr(0,1))-1;
t=a.toString().concat(':59');
}
else{
a=parseInt(t.substr(2,2))-1;
if(a<10){
t=t.substr(0,1).concat(':0' + a.toString());
}
else{
t=t.substr(0,2).concat(a);
}
}
var timerValue = app.getElementById('timerValue');
var chk = setTime(t, app, timerDisplay, timerValue);
Utilities.sleep(1000);
chk.setValue(true,true);
}
else {
timerDisplay.setText('Finish!');
}
return app;
}
function setTime(time, app, timerDisplay, timerValue) {
timerDisplay.setText(time);
timerValue.setValue(time);
var handlerTimer = app.createServerHandler('handleTimer');
handlerTimer.addCallbackElement(timerValue);
var chk = app.createCheckBox('chk').addValueChangeHandler(handlerTimer).setValue(true,true).setVisible(false);
return chk;
}