Last active
August 29, 2015 13:56
-
-
Save ThorstenHans/9001356 to your computer and use it in GitHub Desktop.
Introduction to 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
myObject = | |
foo: 'bar' | |
isThisAwesome: true | |
requiresLessKeystrokes: true | |
complex: | |
ifYouAreInterestedIn: true | |
stillReadable: true | |
caption: 'CoffeeScript' | |
compilesTo: 'JavaScript' | |
cost: 0 | |
myArray = ['New York', 'Rio', 'Tokio'] |
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
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 |
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
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 |
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
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()}" |
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
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