Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit abac28c

Browse files
committed
...
1 parent 4cd263b commit abac28c

File tree

6 files changed

+50
-5
lines changed

6 files changed

+50
-5
lines changed

basic.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<script type="text/javascript">
88
function sayHello() {
99
alert('Hello from JavaScript!');
10+
console.log('hello in the console');
1011
}
1112
document.getElementById('mybutton').addEventListener('click', sayHello);
1213
</script>

dom1.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
<title>My First JS</title>
44
</head>
55
<body>
6-
<button id="mybutton">Click Me</button>
6+
<p>
7+
<button id="mybutton">Click Me</button>
8+
</p>
79
<ul id="clicklist"></ul>
810
<script type="text/javascript">
11+
// click list
912
var clicks = 0;
1013
var click_list = document.getElementById('clicklist');
1114
function addClick() {

dom2.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<html>
2+
<head>
3+
<title>My First JS</title>
4+
</head>
5+
<body>
6+
<p>
7+
<input type="text" id="text_box"/> Chars: <span id="chars_display"></span>
8+
</p>
9+
<script type="text/javascript">
10+
// chars in text box
11+
var text_box = document.getElementById('text_box');
12+
var chars_display = document.getElementById('chars_display');
13+
function updateDisplay() {
14+
chars_display.innerText = text_box.value.length;
15+
}
16+
text_box.addEventListener('keyup', updateDisplay);
17+
</script>
18+
</body>
19+
</html>

janky-blog/posts.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
{
77
"title": "test",
88
"body": "foo"
9+
},
10+
{
11+
"title": "Another post",
12+
"body": "fun timez"
913
}
1014
]

janky-blog/web.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ var app = express();
77

88
var POSTS_FILE = 'posts.json';
99

10-
// tell express to print requests in the console as they come in
11-
app.use(express.logger());
1210
// detail, not sure why express does't do this automatically
1311
app.use(express.urlencoded());
12+
// tell express to print requests in the console as they come in
13+
app.use(express.logger());
1414
// tell express to use handlebars as templating engine
1515
app.engine('handlebars', exphbs());
1616
app.set('view engine', 'handlebars');
@@ -51,5 +51,6 @@ app.post('/save', function(req, res) {
5151
});
5252
});
5353

54-
app.listen(3000);
55-
console.log('listening on http://localhost:3000/');
54+
app.listen(3000, function() {
55+
console.log('listening on http://localhost:3000/');
56+
});

timer.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<html>
2+
<head>
3+
<title>Timer</title>
4+
</head>
5+
<body>
6+
Seconds you've been on this page: <span id="time_display"></span>
7+
<script type="text/javascript">
8+
var seconds = 0;
9+
var display = document.getElementById('time_display');
10+
function update() {
11+
display.innerText = seconds.toString();
12+
seconds++;
13+
}
14+
setInterval(update, 1000);
15+
</script>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)