Created
June 11, 2012 14:46
-
-
Save brianwisti/2910419 to your computer and use it in GitHub Desktop.
Metro "Hello World" JavaScript, but in CoffeeScript
This file contains 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
# Blank Metro Template, but in CoffeeScript | |
# Just a dumb rewrite of the default.js in | |
# http://msdn.microsoft.com/en-us/library/windows/apps/hh986964.aspx | |
buttonClickHandler = (eventInfo) -> | |
userName = document.getElementById("nameInput").value | |
greetingString = "Hello, #{userName}!"; # oh yeah, CS does string interpolation | |
document.getElementById("greetingOutput").innerText = greetingString | |
app = WinJS.Application | |
activation = Windows.ApplicationModel.Activation | |
WinJS.strictProcessing() | |
app.onactivated = (args) -> | |
if args.detail.kind == activation.ActivationKind.launch | |
# TODO: This application has been newly launched. Initialize | |
# your application here. | |
else | |
# TODO: This application has been reactivated from suspension. | |
# Restore application state here. | |
args.setPromise WinJS.UI.processAll() | |
helloButton = document.getElementById("helloButton") | |
helloButton.addEventListener("click", buttonClickHandler, false) | |
app.oncheckpoint = (args) -> | |
# TODO: This application is about to be suspended. Save any state | |
# that needs to persist across suspensions here. You might use the | |
# WinJS.Application.sessionState object, which is automatically | |
# saved and restored across suspension. If you need to complete an | |
# asynchronous operation before your application is suspended, call | |
# args.setPromise() | |
app.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to use coffescript inside windows store app