我需要添加什么代码才能切换按钮以运行脚本来“开始”,“结束”,重置和在工作表中打印这些结果?
/** This time tracker macro was built to help to edit during podcast speed up production workflow.*/
/** Records and prints, the value of the button pressed and files columns with the host or guest, date, timecode, and reason. Prints the value in A1*/
function setValue(cellName, value) {
SpreadsheetApp.getActiveSpreadsheet().getRange(cellName).setValue(value);
}
function getValue(cellName) {
return SpreadsheetApp.getActiveSpreadsheet().getRange(cellName).getValue();
}
function getNextRow() {
return SpreadsheetApp.getActiveSpreadsheet().getLastRow() +1;
}
/**Host and guest buttons. Trigger this button to start process of labeling in A1 cell*/
function host() {
setValue('A1', 'Host');
}
function guest1() {
setValue('A1', 'Guest 1');
}
function guest2() {
setValue('A1', 'Guest 2');
}
function guest3() {
setValue('A1', 'Guest 3');
}
function addRecord(a, b, c) {
var row = getNextRow();
setValue('A' + row, a);
setValue('B' + row, b);
setValue('C' + row, c);
}
/** Timecode clock*/
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Sheet1');
function countDownSeconds(seconds, minutes){
while (minutes >=0){
sheet.getRange(2,1).setValue(minutes);
while (seconds >= 0 ){
var m = sheet.getRange(2,1).getValue()
var s = sheet.getRange(2,2).getValue()
if (m === 'pausing' || s === 'pausing'|| m === 'reset' || s === 'reset' ) {
return
}
sheet.getRange(2,2).setValue(seconds);
SpreadsheetApp.flush();
Utilities.sleep(1000)
seconds --
}
seconds = 59;
minutes = sheet.getRange(2,1).getValue();
minutes --
}
}
function startTimer(){
var minutes = sheet.getRange(2,1).getValue()
var seconds = sheet.getRange(2,2).getValue()
countDownSeconds(seconds, minutes)
setValue('A1', 'Start');
}
function pause(){
var minutes = sheet.getRange(2,1).getValue()
var seconds = sheet.getRange(2,2).getValue()
sheet.getRange(2,1).setValue('pausing');
sheet.getRange(2,2).setValue('pausing');
SpreadsheetApp.flush();
Utilities.sleep(1000);
sheet.getRange(2,1).setValue(minutes)
sheet.getRange(2,2).setValue(seconds)
setValue('A1', 'Pause');
}
function reset(){
sheet.getRange(2,1).setValue('reset');
sheet.getRange(2,2).setValue('reset');
SpreadsheetApp.flush();
Utilities.sleep(1000);
sheet.getRange(2,1).setValue(0)
sheet.getRange(2,2).setValue(0)
setValue('A1', 'Reset');
}
function end() {
setValue('A1', 'End');
}
/**Reason. Trigger this button to end process of labeling so printed result starts with A1 cell*/
function micnoiseIn() {
addRecord(getValue('A1'), new Date(), 'Microphone Noise');
}
function mouthnoiseIn() {
addRecord(getValue('A1'), new Date(), 'Pop or Mouth Noise');
}
function stammerIn() {
addRecord(getValue('A1'), new Date(), 'Stammering');
}
function stammerOut() {
addRecord(getValue('A1'), new Date(), 'Stopped Stammering');
我希望是
按开始A1单元的“开始”时钟开始 A2打印开始| B2 00:00:00 | C2开始
“结束 印刷A *底| B2时间码| C *结束
按主持人+麦克风噪音与A1主持人 印刷的A *主机| B2时间码| C *麦克风噪音