admin管理员组文章数量:1313822
I have created a simple webapp using Google Apps Scripts. The UI simply displays a couple of numbers being continuous updated in a FusionTable. A custom data acquisition system is running locally in my house and sending new results every minute up to the FusionTable. I wish to update the UI on my GAS webapp at one-minute intervals so that the new numbers are displayed.
I have half of the problem solved by running a time-driver trigger to periodically grab data from the FusionTable and store the numbers in my script's own ScriptDb. So this works fine to get my data in the right neighborhood. But I still do not see how to periodically update a textbox in my UI with the new data.
So far I have manually configured a refresh button on the UI that user can click to update the display with the most recent numbers stored in the ScriptDb. I am so close I can taste it!
Anyone have an idea?
I have created a simple webapp using Google Apps Scripts. The UI simply displays a couple of numbers being continuous updated in a FusionTable. A custom data acquisition system is running locally in my house and sending new results every minute up to the FusionTable. I wish to update the UI on my GAS webapp at one-minute intervals so that the new numbers are displayed.
I have half of the problem solved by running a time-driver trigger to periodically grab data from the FusionTable and store the numbers in my script's own ScriptDb. So this works fine to get my data in the right neighborhood. But I still do not see how to periodically update a textbox in my UI with the new data.
So far I have manually configured a refresh button on the UI that user can click to update the display with the most recent numbers stored in the ScriptDb. I am so close I can taste it!
Anyone have an idea?
Share Improve this question edited Nov 30, 2012 at 5:48 Who8MyLunch asked Nov 30, 2012 at 3:46 Who8MyLunchWho8MyLunch 1,19014 silver badges20 bronze badges3 Answers
Reset to default 5You can use the UiInstance.addTimer
method for auto refresh, but it's not documented and maybe not supported.
Its syntax is UiInstance.addTimer( ServerHandler , interval);
See the sample code below.
function doGet(e) {
var app = UiApp.createApplication();
app.add(app.createLabel(new Date()).setId("label"));
app.addTimer(app.createServerHandler("update") , 1000);
return app;
}
function update(e){
var app = UiApp.getActiveApplication();
app.getElementById("label").setText(new Date());
app.addTimer(app.createServerHandler("update") , 1000);
return app;
}
A sample app can be found here.
Use a spreadsheet for display. They autoupdate.
Stackoverflow, this is not a thanks but the solution, but for you:
- Make a spreadsheet
- add a service for posting
- have service update spreadsheet
- watch spreadsheet
Unfortunately, Google Apps Script doesn't yet have a timer facility to update the UI at frequent intervals. However, there is a hack that I wrote a while back and is available in the old Apps Script forum at http://productforums.google./forum/#!topic/apps-script/2pqhh_eTIvQ
There have been refinements over that you can search for in stackoverflow, but the basic premise remains the same i.e. you exploit the fact that you can programatically change the value of a checkbox AND trigger its change handler.
本文标签: javascriptAuto refresh Google Apps Scripts webapp UIStack Overflow
版权声明:本文标题:javascript - Auto refresh Google Apps Scripts webapp UI? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741939178a2406040.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论