Skip to content

Instantly share code, notes, and snippets.

@ThorstenHans
Last active August 29, 2015 13:56
Show Gist options
  • Save ThorstenHans/9001356 to your computer and use it in GitHub Desktop.
Save ThorstenHans/9001356 to your computer and use it in GitHub Desktop.
Introduction to CoffeeScript
myObject =
foo: 'bar'
isThisAwesome: true
requiresLessKeystrokes: true
complex:
ifYouAreInterestedIn: true
stillReadable: true
caption: 'CoffeeScript'
compilesTo: 'JavaScript'
cost: 0
myArray = ['New York', 'Rio', 'Tokio']
class SharePointRepository
constructor: (@listTitle)->
getInfo:()=>
console.log "Repository for #{@listTitle}"
class DocLibRepository extends SharePointRepository
constructor: (listTitle) ->
super listTitle
@isDocumentLibrary = true
getInfo: ()=>
console.log "Repository for doc lib #{@listTitle}"
myRepository = new SharePointRepository 'Tasks'
myRepository.getInfo()
myDocLibRepository = new DocLibRepository 'Documents'
myDocLibRepository.getInfo()
console.log myDocLibRepository.isDocumentLibrary
player =
isMuted: true
isPlaying: false
currentSong:
title: 'Five Fists'
artist: 'Hardcut'
duration: 3.15
if player.isMuted is off and player.isPlaying is on
console.log "Playing music very loud"
if not player.currentSong?
console.log "No song loaded"
unless player.isPlaying is off
console.log "music runs"
playNextSong() unless player.isPlaying is off
ctx = SP.ClientContext.get_current
docLib = ctx.get_web().get_lists().getByTitle 'Shared Documents'
ctx.load docLib, 'Include(Title,Description)'
ctx.executeQueryAsync ()=>
console.log "Library #{docLib.get_title()} with description #{docLib.get_description()} loaded"
, (sender, args)=>
console.log "Error while loading doc lib #{args.get_message()}"
numbers = [1,2,3,4,5,6,7,8,9]
prettyPrint = (n) ->
console.log "Processed number #{n}"
prettyPrint n for n in numbers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment