问题描述
我试图在Google应用脚本中创建一个进度条,当某个人点击一个按钮(Go)时,它会自动缓慢地开始和结束。在Firefox下载窗口中看到的东西。
这是我的代码。
函数doGet(e){
var app = UiApp.createApplication();
var progressPanel = app.loadComponent(progressbar_auto);
var gobutton = app.getElementById(go_btn);
var go_btn_handler = app.createServerHandler(updateProgressbar);
go_btn_handler.addCallbackElement(gobutton);
gobutton.addClickHandler(go_btn_handler)
app.add(progressPanel);
返回应用程序;
}
//函数时间(i){
// Utilities.sleep(5); (var i = 1; i //}
函数updateProgressbar(){
var app = UiApp.getActiveApplication()
{
app.getElementById(progress)。setWidth(i +'px');
time();
}
Logger.log(i);
返回应用程序;
}
但是根据这段代码for循环会执行非常快速和放大; ,进度条完成得非常快。有什么办法可以减缓这一点。
你可以在这里找到我的应用程序。
有什么方法可以添加滑动条来控制进度条。我们可以在PHP或HTML 5中做的事情。
谢谢 >不,没有真正的方法在Apps脚本上执行进度条。
尽管有一些解决方法。您可以将多个处理程序添加到同一个按钮,并在每个处理程序中使用不同的休眠时间,可以多次更新GUI。或者,正如大多数人所做的那样,在客户端处理程序(用于即时反馈)和第二个处理程序完成后显示一个无休止的gif动画,您实际完成该工作的ServerHandler将隐藏图像并返回结果。
I'm trying to create a progress bar in Google app scripting , which when some one click a button (Go) it will be automatically, slowly go to start to end . Something you see in Firefox download window. this is my code.
function doGet(e) {
var app = UiApp.createApplication();
var progressPanel = app.loadComponent("progressbar_auto");
var gobutton =app.getElementById("go_btn");
var go_btn_handler =app.createServerHandler("updateProgressbar");
go_btn_handler.addCallbackElement(gobutton);
gobutton.addClickHandler(go_btn_handler)
app.add(progressPanel);
return app;
}
//function time(i){
// Utilities.sleep(5);
// }
function updateProgressbar(){
var app = UiApp.getActiveApplication()
for(var i =1 ; i < 250 ; i++ ){
app.getElementById("progress").setWidth(i + 'px');
time();
}
Logger.log(i);
return app;
}
But according to this code for loop will execute very speedy & ,progress bar completed very quick . Is there any way to slow this.
You can find the my application here.
Is there any way to add a slide bar , to control the progress bar. Something we can do in php or HTML 5.
Thanks
No, there isn't a real way to do a progress bar on Apps Script.
There's some workarounds though. You can add multiple handlers to the same button, and in each one, with a different sleep time, you can update the GUI many times. Or, as most do, show an endless progress gif animation in a client handler (for instant feedback) and after your second handler finishes, a ServerHandler where you actually do the work, you hide the image and return the results.
这篇关于Google App脚本进度栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!