Skip to content

Instantly share code, notes, and snippets.

@brianwisti
Created June 11, 2012 14:46
Show Gist options
  • Save brianwisti/2910419 to your computer and use it in GitHub Desktop.
Save brianwisti/2910419 to your computer and use it in GitHub Desktop.
Metro "Hello World" JavaScript, but in CoffeeScript
# 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()
@knayamlohani
Copy link

how to use coffescript inside windows store app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment