Skip to content

Commit edc86f0

Browse files
committed
separated the typescript types into classes, added handlebars
1 parent 842fa1a commit edc86f0

14 files changed

+267
-39
lines changed

web/app.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
// "any", so that we can use it anywhere, and assume it has any fields or
77
// methods, without the compiler producing an error.
88
var $: any;
9-
10-
// a global for the main ElementList of the program. See newEntryForm for
11-
// explanation
12-
var mainList: ElementList;
139
// a global for the EditEntryForm of the program. See newEntryForm for
1410
// explanation
1511
var editEntryForm: EditEntryForm;
1612

13+
// Prevent compiler errors when using Handlebars
14+
let Handlebars: any;
1715

1816
// The 'this' keyword does not behave in JavaScript/TypeScript like it does in
1917
// Java. Since there is only one NewEntryForm, we will save it to a global, so
@@ -30,8 +28,8 @@ $(document).ready(function () {
3028
// Create the object that controls the "Edit Entry" form
3129
editEntryForm = new EditEntryForm();
3230

33-
mainList = new ElementList();
34-
mainList.refresh();
31+
// Populate the Element List Singleton with data from the server
32+
ElementList.refresh();
3533

3634
// set up initial UI state
3735
$("#editElement").hide();
File renamed without changes.

web/css/ElementList.css

Whitespace-only changes.

web/css/NewEntryForm.css

Whitespace-only changes.

web/deploy.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@ rm $TARGETFOLDER/$WEBFOLDERNAME/deploy.sh
2525
# step 2: update our npm dependencies
2626
npm update
2727

28-
# step 3: copy javascript files
28+
# step 3: copy javascript files and handlebars files
2929
cp node_modules/jquery/dist/jquery.min.js $TARGETFOLDER/$WEBFOLDERNAME
30+
cp node_modules/handlebars/dist/handlebars.min.js $TARGETFOLDER/$WEBFOLDERNAME
3031

3132
# step 4: compile TypeScript files
3233
node_modules/typescript/bin/tsc app.ts --strict --outFile $TARGETFOLDER/$WEBFOLDERNAME/app.js
3334

3435
# step 5: copy css files
35-
cp app.css $TARGETFOLDER/$WEBFOLDERNAME
36+
cat app.css css/ElementList.css css/EditEntryForm.css css/NewEntryForm.css > $TARGETFOLDER/$WEBFOLDERNAME/app.css
37+
38+
# step 6: compile handlebars templates to the deploy folder
39+
node_modules/handlebars/bin/handlebars hb/ElementList.hb >> $TARGETFOLDER/$WEBFOLDERNAME/templates.js
40+
node_modules/handlebars/bin/handlebars hb/EditEntryForm.hb >> $TARGETFOLDER/$WEBFOLDERNAME/templates.js
41+
node_modules/handlebars/bin/handlebars hb/NewEntryForm.hb >> $TARGETFOLDER/$WEBFOLDERNAME/templates.js
3642

3743
echo fin

web/hb/EditEntryForm.hb

Whitespace-only changes.

web/hb/ElementList.hb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<table>
2+
<tbody>
3+
{{#each mData}}
4+
<tr>
5+
<td>{{this.mTitle}}</td>
6+
<td><button class="ElementList-editbtn" data-value="{{this.mId}}">Edit</button></td>
7+
<td><button class="ElementList-delbtn" data-value="{{this.mId}}">Delete</button></td>
8+
</tr>
9+
{{/each}}
10+
</tbody>
11+
</table>

web/hb/NewEntryForm.hb

Whitespace-only changes.

web/index.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<html>
22

33
<head>
4-
<title>Hello World</title>
5-
<link rel="stylesheet" href="app.css" />
4+
<title>Whisper Secrets into Trees</title>
5+
<link rel="stylesheet" href="css/app.css" />
66
<link href="https://fonts.googleapis.com/css?family=Fresca" rel="stylesheet">
77
<script src="jquery.min.js"></script>
88
<script src="app.js"></script>
9+
<script src="handlebars.min.js"></script>
10+
<script src="templates.js"></script>
911

1012
</head>
1113

@@ -30,11 +32,6 @@ <h3>Edit an Entry</h3>
3032
<button id="editButton">Update</button>
3133
<button id="editCancel">Cancel</button>
3234
</div>
33-
<div id="showElements">
34-
<h3>All Messages</h3>
35-
<button id="showFormButton">Add Message</button>
36-
<div id="messageList"></div>
37-
</div>
3835
</body>
3936

4037
</html>

web/package-lock.json

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

0 commit comments

Comments
 (0)