在scriptUi中,我能够按照这些说明创建一个简单的进度微调器,用于长时间等待:https://sites.google.com/site/scriptsexamples/learn-by-example/uiapp-examples-code-snippets/progress-indicators
我现在正在使用HtmlService来创建Ui,我不知道如何像以前那样设置微调器。
答案 0 :(得分:6)
我找到了一种方法。诀窍是调用一个内部函数,它既启动微调器又运行另一个函数。
HTML
<script>
function onSuccess() {
var div = document.getElementById('result');
div.innerHTML = '<div>Sucess!</div>';
}
function onFailure() {
var div = document.getElementById('result');
div.innerHTML = '<div>Fail!</div>';
}
function clickAction(){
var div = document.getElementById('result');
div.innerHTML = '<div> Copying...<br><img src="https://c4a54d10381f750e81dcc323aed21e2c95725815.googledrive.com/host/0Bwyqwd2fAHMMallsNkNOV0RfcTg/wait_progress.gif"></div>';
google.script.run
.withSuccessHandler(onSuccess)
.withFailureHandler(onFailure)
.testSpinner();
}
</script>
<button class="action" onclick="clickAction()"> Copy</button>
<button onclick="google.script.host.close()"> Close</button>
<div id='result'></div>
gs文件
function testSpinner(){
SpreadsheetApp.getActiveSpreadsheet().toast("Copying...","",-1);
Utilities.sleep(5000);
SpreadsheetApp.getActiveSpreadsheet().toast("Done.");
}