Created
December 22, 2012 11:37
-
-
Save sifu/4358543 to your computer and use it in GitHub Desktop.
a google app script UiApp, that tracks clicks on a button in a spreadsheet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doGet() { | |
var app = UiApp.createApplication(); | |
var button = app.createButton('Click Me'); | |
app.add(button); | |
var label = app.createLabel('The button was clicked.') | |
.setId('statusLabel') | |
.setVisible(false); | |
app.add(label); | |
var handler = app.createServerHandler('myClickHandler'); | |
handler.addCallbackElement(label); | |
button.addClickHandler(handler); | |
return app; | |
} | |
function myClickHandler(e) { | |
var app = UiApp.getActiveApplication(); | |
var label = app.getElementById('statusLabel'); | |
label.setVisible(true); | |
var ss = SpreadsheetApp.openById('0Ak4WxzRx93UYdHZwSXJDQ3dJblB4WU52M2VFd2R3NFE'); | |
var sheet = ss.getSheets()[0]; | |
sheet.getRange(sheet.getLastRow()+1, 1, 1, 2).setValues([[new Date(), 1]]); | |
app.close(); | |
return app; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment