Skip to content

Commit acddd86

Browse files
committed
Updates for chapter 2 and 3
1 parent 7652e45 commit acddd86

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

2/listings/barista.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
houseRoast = null
1+
houseRoast = 'Yirgacheffe'
22

33
hasMilk = (style) ->
44
switch style.toLowerCase()
5-
when "latte", "cappucino"
5+
when 'latte', 'cappucino', 'mocha'
66
yes
77
else
88
no

2/listings/barista.js

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

3/listings/3.7.coffee

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,21 @@ init = ->
4646
response.end "#{attendees + friends}" #8
4747

4848
server.listen 8080, '127.0.0.1' #9
49+
console.log 'Now running at http://127.0.0.1:8080'
4950

5051
#10
5152
clientScript = coffee.compile '''
53+
get = (path, callback) ->
54+
req = new XMLHttpRequest()
55+
req.onload = (e) -> callback req.responseText
56+
req.open 'get', path
57+
req.send()
58+
5259
showAttendees = ->
53-
$.get "/count", (response) ->
54-
document.querySelector("#how-many-attendees").innerHTML ="#{response} attendees!"
60+
out = document.querySelector '#how-many-attendees'
61+
get '/count', (response) ->
62+
out.innerHTML = "#{response} attendees!"
63+
5564
showAttendees()
5665
setInterval showAttendees, 1000
5766
'''
@@ -62,7 +71,6 @@ init = ->
6271
<title>How many people are coming?</title>
6372
<body>
6473
<div id='how-many-attendees'></div>
65-
<script src='http://code.jquery.com/jquery-1.6.2.js'></script>
6674
<script>
6775
#{clientScript}
6876
</script>

0 commit comments

Comments
 (0)