GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — update to local parse and es6 · knut0815/fullstack-javascript@5ad4fe6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • chapter3
    • chapter3.md
    • media
      • compass.png
      • parse-sdk.png
  • chapter4
    • chapter4.md
  • chapter5
    • chapter5.md
  • chapter6
    • chapter6.md
  • chapter7
    • chapter7.md
  • chapter8
    • chapter8.md
  • code
    • 03-board-parse-rest/js
      • app.js
    • 03-parse-sdk
      • app.js
      • index.html
    • 03-weather
      • index.php
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎chapter3/chapter3.md‎

Copy file name to clipboardExpand all lines: chapter3/chapter3.md
+373-313Lines changed: 373 additions & 313 deletions
  • Display the source diff
  • Display the rich diff
Large diffs are not rendered by default.
Collapse file

‎chapter3/media/compass.png‎

Copy file name to clipboard
127 KB
  • Display the source diff
  • Display the rich diff
Loading
Collapse file

‎chapter3/media/parse-sdk.png‎

Copy file name to clipboard
116 KB
  • Display the source diff
  • Display the rich diff
Loading
Collapse file

‎chapter4/chapter4.md‎

Copy file name to clipboardExpand all lines: chapter4/chapter4.md
+8-8Lines changed: 8 additions & 8 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ including models, subviews, and collections.
5959

6060
Full source code for the Hello World app is available under
6161
`05``-backbone/hello-world` and on
62-
[GitHub](https://github.com/azat-co/fullstack-javascript/tree/master/05-backbone/hello-world)
63-
(https://github.com/azat-co/fullstack-javascript/tree/master/05-backbone/hello-world).
62+
[GitHub](https://github.com/azat-co/fullstack-javascript/tree/master/code/05-backbone/hello-world)
63+
(https://github.com/azat-co/fullstack-javascript/tree/master/code/05-backbone/hello-world).
6464

6565
Backbone.js Dependencies
6666
------------------------
@@ -236,7 +236,7 @@ demonstrates the project: <http://bit.ly/1O7xRCY>.
236236
The full source code of this example is under
237237
`05``-backbone/collections`. It's built on top of the "Hello World"
238238
example from the Setting up Backbone.js App from Scratch exercise, which
239-
is available for download at [GitHub](https://github.com/azat-co/fullstack-javascript/tree/master/05-backbone/collections) (https://github.com/azat-co/fullstack-javascript/tree/master/05-backbone/collections).
239+
is available for download at [GitHub](https://github.com/azat-co/fullstack-javascript/tree/master/code/05-backbone/collections) (https://github.com/azat-co/fullstack-javascript/tree/master/code/05-backbone/collections).
240240

241241
We should add some data to play around with, and to hydrate our views.
242242
To do this, add this right after the `<script>` tag and before the
@@ -727,7 +727,7 @@ Backbone.js Views and Subviews with Underscore.js
727727
Supplemental video which walks you through the implementation and
728728
demonstrates the project: <http://bit.ly/1k0ZnUB>. And this example i>s
729729
available at
730-
<https://github.com/azat-co/fullstack-javascript/tree/master/05-backbone/subview>.
730+
<https://github.com/azat-co/fullstack-javascript/tree/master/code/05-backbone/subview>.
731731

732732
Subviews are Backbone Views that are created and used inside of another
733733
Backbone View. A subviews concept is a great way to abstract (separate)
@@ -1353,7 +1353,7 @@ This is the `apple.tpl.js` file:
13531353
</figure>'
13541354

13551355
Try to start the application now. The full code is at
1356-
https://github.com/azat-co/fullstack-javascript/tree/master/05-backbone/refactor.
1356+
https://github.com/azat-co/fullstack-javascript/tree/master/code/05-backbone/refactor.
13571357

13581358

13591359

@@ -1669,7 +1669,7 @@ the Developers Tool, you can see a difference in how the files are
16691669
loaded.
16701670

16711671
The old file shown in Figure 4-2
1672-
(https://github.com/azat-co/fullstack-javascript/tree/master/05-backbone/refactor/index.html)
1672+
(https://github.com/azat-co/fullstack-javascript/tree/master/code/05-backbone/refactor/index.html)
16731673
loads our JavaScript scripts in a serial manner, whereas the new file
16741674
shown in Figure 4-3
16751675
(https://github.com/azat-co/fullstack-javascript/blob/master/05-backbone/amd/index.html)
@@ -1773,10 +1773,10 @@ For more information, check out the official r.js documentation at
17731773
[`requirejs.org/docs/optimization.html`](http://requirejs.org/docs/optimization.html).
17741774

17751775
The example code is available at
1776-
https://github.com/azat-co/fullstack-javascript/tree/master/05-backbone/r
1776+
https://github.com/azat-co/fullstack-javascript/tree/master/code/05-backbone/r
17771777

17781778
and
1779-
https://github.com/azat-co/fullstack-javascript/tree/master/05-backbone/r/build.
1779+
https://github.com/azat-co/fullstack-javascript/tree/master/code/05-backbone/r/build.
17801780

17811781
For uglification of JS files (which decreases the file sizes), we can
17821782
use the [Uglify2](https://github.com/mishoo/UglifyJS2) module. To
Collapse file

‎chapter5/chapter5.md‎

Copy file name to clipboardExpand all lines: chapter5/chapter5.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ implementation of user actions by binding them to asynchronous updates
4949
of the collection.
5050

5151
The application is available at
52-
<https://github.com/azat-co/fullstack-javascript/tree/master/06-board-backbone-parse-sdk>,
52+
<https://github.com/azat-co/fullstack-javascript/tree/master/code/06-board-backbone-parse-sdk>,
5353
but again you are encouraged to start from scratch and try to write your
5454
own code using the example only as a reference.
5555

@@ -634,7 +634,7 @@ something like this:
634634

635635
The full source code of the Backbone.js and Parse.com Message Board
636636
application is available at
637-
<https://github.com/azat-co/fullstack-javascript/tree/master/06-board-backbone-parse-sdk>.
637+
<https://github.com/azat-co/fullstack-javascript/tree/master/code/06-board-backbone-parse-sdk>.
638638

639639
Taking Message Board Further
640640
============================
Collapse file

‎chapter6/chapter6.md‎

Copy file name to clipboardExpand all lines: chapter6/chapter6.md
+4-4Lines changed: 4 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ between Node.js versions):
5555
- [nvm](https://github.com/creationix/nvm) (<https://github.com/creationix/nvm>)
5656

5757
As usual, you could copy example code at
58-
https://github.com/azat-co/fullstack-javascript/tree/master/07-hello, or
58+
https://github.com/azat-co/fullstack-javascript/tree/master/code/07-hello, or
5959
write your own program from scratch. If you wish to do the latter,
6060
create a folder `hello` for your "Hello World" Node.js application. Then
6161
create file a `server.js` and line by line type the code below.
@@ -359,7 +359,7 @@ Deploying to Heroku
359359

360360
For Heroku deployment, we need to create two extra files: `Procfile` and
361361
`package.json`. You could get the source code from
362-
https://github.com/azat-co/fullstack-javascript/tree/master/07-hello or
362+
https://github.com/azat-co/fullstack-javascript/tree/master/code/07-hello or
363363
write your own one.
364364

365365
The structure of the "Hello World" application looks like this:
@@ -417,7 +417,7 @@ time we start/reset the server, the data will be lost.
417417

418418
We'll start with a simple test case first to illustrate the Test-Driven
419419
Development approach. The full code is available at
420-
https://github.com/azat-co/fullstack-javascript/tree/master/08-test.
420+
https://github.com/azat-co/fullstack-javascript/tree/master/code/08-test.
421421

422422
Unit Testing Node.js
423423
--------------------
@@ -677,7 +677,7 @@ Also returning a new message in a JSON-as-a-string format:
677677

678678
Here is the full code of `mb-server.js` minus the comments. It's
679679
also available at
680-
[08-test](https://github.com/azat-co/fullstack-javascript/tree/master/08-test):
680+
[08-test](https://github.com/azat-co/fullstack-javascript/tree/master/code/08-test):
681681

682682
var http = require('http')
683683
// Loads http module
Collapse file

‎chapter7/chapter7.md‎

Copy file name to clipboardExpand all lines: chapter7/chapter7.md
+4-4Lines changed: 4 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ var dbConnUrl = process.env.MONGOLAB_URI ||
321321
```
322322

323323
Here is our updated cross-environment ready `app.js` file
324-
(https://github.com/azat-co/fullstack-javascript/tree/master/10-db-connect-heroku).
324+
(https://github.com/azat-co/fullstack-javascript/tree/master/code/10-db-connect-heroku).
325325
I added a method to get the list of collections `listCollections`
326326
instead of getting the list of the databases (we have only one database
327327
in MongoLab right now):
@@ -381,7 +381,7 @@ Heroku app, if you know the name of that app.
381381

382382
The project folder needs to have `Procfile` and `package.json`. You can
383383
copy them from
384-
https://github.com/azat-co/fullstack-javascript/tree/master/10-db-connect-heroku.
384+
https://github.com/azat-co/fullstack-javascript/tree/master/code/10-db-connect-heroku.
385385

386386
Now you can push you code to Heroku with:
387387

@@ -440,7 +440,7 @@ client.connect(dbConnUrl, {}, function(error, db) {
440440
```
441441

442442
The final Heroku-deployment-ready project is located at
443-
https://github.com/azat-co/fullstack-javascript/tree/master/11-db-serverunder.
443+
https://github.com/azat-co/fullstack-javascript/tree/master/code/11-db-serverunder.
444444

445445
After the deployment you should be able to open the URL provided by
446446
Heroku and see the list of collections. If it's a newly created app with
@@ -460,7 +460,7 @@ http://bit.ly/1QnsfoE.
460460
We should have everything set up for writing the Node.js application
461461
that will work both locally and on Heroku. The source code is available
462462
at
463-
https://github.com/azat-co/fullstack-javascript/tree/master/12-board-api-mongonder.
463+
https://github.com/azat-co/fullstack-javascript/tree/master/code/12-board-api-mongonder.
464464
The structure of the application is simple:
465465

466466
```
Collapse file

‎chapter8/chapter8.md‎

Copy file name to clipboardExpand all lines: chapter8/chapter8.md
+5-5Lines changed: 5 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ file
353353
})
354354

355355
This is it. For your reference, the front-end app source code is at
356-
[https://github.com/azat-co/fullstack-javascript/tree/master/13-board-u](https://github.com/azat-co/fullstack-javascript/tree/master/13-board-ui)
356+
[https://github.com/azat-co/fullstack-javascript/tree/master/code/13-board-u](https://github.com/azat-co/fullstack-javascript/tree/master/code/13-board-ui)
357357
in the GitHub folder. I won't list it here because we had only a few
358358
changes comparing with the Parse SDK project. The next piece of the
359359
puzzle is the back end.
@@ -366,7 +366,7 @@ through the implementation and demonstrates the project:
366366
http://bit.ly/1QnsvEb.
367367

368368
The back-end Node.js application source code is at
369-
<https://github.com/azat-co/fullstack-javascript/tree/master/14-board-api>
369+
<https://github.com/azat-co/fullstack-javascript/tree/master/code/14-board-api>
370370
in the GitHub folder, which has this structure:
371371

372372
/14-board-api
@@ -558,9 +558,9 @@ you through the implementation and demonstrates the project:
558558
http://bit.ly/1QnsvEb.
559559

560560
For your convenience, we have the front-end app at
561-
https://github.com/azat-co/fullstack-javascript/tree/master/13-board-ui
561+
https://github.com/azat-co/fullstack-javascript/tree/master/code/13-board-ui
562562
and the back-end app with CORS is located at
563-
https://github.com/azat-co/fullstack-javascript/tree/master/14-board-api.
563+
https://github.com/azat-co/fullstack-javascript/tree/master/code/14-board-api.
564564
By now, you probably know what to do, but as a reference, below are the
565565
steps to deploy these examples to Heroku.
566566

@@ -731,7 +731,7 @@ Another header that we send back with the response is `Content-Length`:
731731
So this piece of code goes into the request handler of the server, which
732732
is inside of the database connect call. Just like the Russian Matreshka
733733
dolls. Confusing? Just refer to the full source code at
734-
<https://github.com/azat-co/fullstack-javascript/tree/master/15-board-web>.
734+
<https://github.com/azat-co/fullstack-javascript/tree/master/code/15-board-web>.
735735

736736
Another, more elegant way is to use Node.js frameworks as Connect
737737
(<http://www.senchalabs.org/connect/static.html>), or Express
Collapse file

‎code/03-board-parse-rest/js/app.js‎

Copy file name to clipboard
+60-63Lines changed: 60 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,73 @@
1-
// const parseAppID = 'your-parse-app-id'
2-
// const parseRestKey = 'your-rest-api-key'
3-
41
// Azat's app, change these values to your own keys
52
const parseAppID = 'APPLICATION_ID'
63
const parseRestKey = 'MASTER_KEY'
74
const apiBase = `http://localhost:1337/parse`
85

96
$(document).ready(function(){
10-
getMessages()
11-
$('#send').click(function(){
12-
const $sendButton = $(this)
13-
$sendButton.html('<img src="img/spinner.gif" width="20"/>')
14-
const username = $('input[name=username]').val()
15-
const message = $('input[name=message]').val()
16-
$.ajax({
17-
url: `${apiBase}/classes/MessageBoard`,
18-
headers: {
19-
'X-Parse-Application-Id': parseAppID,
20-
'X-Parse-REST-API-Key': parseRestKey
21-
},
22-
contentType: 'application/json',
23-
dataType: 'json',
24-
processData: false,
25-
data: JSON.stringify({
26-
'username': username,
27-
'message': message
28-
}),
29-
type: 'POST',
30-
success: function() {
31-
console.log('sent')
32-
getMessages()
33-
$sendButton.html('SEND')
34-
},
35-
error: function() {
36-
console.log('error')
37-
$sendButton.html('SEND')
38-
}
39-
})
40-
})
7+
getMessages()
8+
$('#send').click(function(){
9+
const $sendButton = $(this)
10+
$sendButton.html('<img src="img/spinner.gif" width="20"/>')
11+
const username = $('input[name=username]').val()
12+
const message = $('input[name=message]').val()
13+
$.ajax({
14+
url: `${apiBase}/classes/MessageBoard`,
15+
headers: {
16+
'X-Parse-Application-Id': parseAppID,
17+
'X-Parse-REST-API-Key': parseRestKey
18+
},
19+
contentType: 'application/json',
20+
dataType: 'json',
21+
processData: false,
22+
data: JSON.stringify({
23+
'username': username,
24+
'message': message
25+
}),
26+
type: 'POST',
27+
success: function() {
28+
console.log('sent')
29+
getMessages()
30+
$sendButton.html('SEND')
31+
},
32+
error: function() {
33+
console.log('error')
34+
$sendButton.html('SEND')
35+
}
36+
})
37+
})
4138
})
4239

4340
function getMessages() {
44-
$.ajax({
45-
url: `${apiBase}/classes/MessageBoard?limit=1000`,
46-
headers: {
47-
'X-Parse-Application-Id': parseAppID,
48-
'X-Parse-REST-API-Key': parseRestKey
49-
},
50-
contentType: 'application/json',
51-
dataType: 'json',
52-
type: 'GET',
53-
success: (data) => {
54-
console.log('get')
55-
updateView(data)
56-
},
57-
error: () => {
58-
console.log('error')
59-
}
60-
})
41+
$.ajax({
42+
url: `${apiBase}/classes/MessageBoard?limit=1000`,
43+
headers: {
44+
'X-Parse-Application-Id': parseAppID,
45+
'X-Parse-REST-API-Key': parseRestKey
46+
},
47+
contentType: 'application/json',
48+
dataType: 'json',
49+
type: 'GET',
50+
success: (data) => {
51+
console.log('get')
52+
updateView(data)
53+
},
54+
error: () => {
55+
console.log('error')
56+
}
57+
})
6158
}
6259

6360
function updateView(messages) {
64-
// messages.results = messages.results.reverse()
65-
const table = $('.table tbody')
66-
table.html('')
67-
$.each(messages.results, (index, value) => {
68-
const trEl = (`<tr><td>
69-
${value.username}
70-
</td><td>
71-
${value.message}
72-
</td></tr>`)
73-
table.append(trEl)
74-
})
75-
console.log(messages)
61+
// messages.results = messages.results.reverse()
62+
const table = $('.table tbody')
63+
table.html('')
64+
$.each(messages.results, (index, value) => {
65+
const trEl = (`<tr><td>
66+
${value.username}
67+
</td><td>
68+
${value.message}
69+
</td></tr>`)
70+
table.append(trEl)
71+
})
72+
console.log(messages)
7673
}
Collapse file

‎code/03-parse-sdk/app.js‎

Copy file name to clipboardExpand all lines: code/03-parse-sdk/app.js
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,28 @@ $(document).ready(function() {
44
const parseApplicationId = 'APPLICATION_ID'
55
const parseJavaScriptKey = 'MASTER_KEY'
66

7-
//change parseApplicationId and parseJavaScriptKey to values from Parse.com application dashboard
87
Parse.initialize(parseApplicationId, parseJavaScriptKey)
98
Parse.serverURL = 'http://localhost:1337/parse'
109

11-
var Test = Parse.Object.extend('Test')
12-
var test = new Test()
13-
var query = new Parse.Query(Test);
10+
const Test = Parse.Object.extend('Test')
11+
const test = new Test()
12+
const query = new Parse.Query(Test)
1413

1514
$('.btn-save').click(function(){
1615
try {
17-
var data = JSON.parse($('textarea').val())
16+
const data = JSON.parse($('textarea').val())
1817
} catch (e) {
1918
alert('Invalid JSON')
2019
}
2120
if (!data) return false
2221
test.save(data, {
23-
success: function(object) {
24-
console.log('Parse.com object is saved: ', object)
25-
$('.log').html(JSON.stringify(object, null, 2))
26-
//alternatively you could use alert('Parse.com object is saved')
22+
success: (result) => {
23+
console.log('Parse.com object is saved: ', result)
24+
$('.log').html(JSON.stringify(result, null, 2))
25+
//alternatively you could use alert('Parse object is saved')
2726
},
28-
error: function(object) {
29-
console.log('Error! Parse.com object is not saved: ', object)
27+
error: (error) => {
28+
console.log(`Error! Parse.com object is not saved: ${error}`)
3029
}
3130
})
3231
})
@@ -37,8 +36,9 @@ $(document).ready(function() {
3736
$('.log').html(JSON.stringify(results, null, 2))
3837
},
3938
error: function(error) {
40-
alert("Error: " + error.code + " " + error.message);
39+
alert(`Error: ${error.code} ${error.message}`)
4140
}
42-
});
41+
})
4342
})
43+
4444
})

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.