Skip to content

Commit ba9cd67

Browse files
committed
updated page titles and refactored idea.js a little
1 parent 21a4d47 commit ba9cd67

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

404.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33

44
<head>
5-
<title>Ideas</title>
5+
<title>Dan Tao</title>
66
<link rel="stylesheet/less" type="text/css" href="/common.less" />
77
<link rel="stylesheet/less" type="text/css" href="/ideas.less" />
88
<script type="text/javascript" src="http://lesscss.org/js/less.js"></script>

idea.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ function isMarkdownFile(file) {
55
function displayIdea(response) {
66
var html = markdown.toHTML(response);
77
document.getElementById('idea').innerHTML = html;
8+
9+
var headings = document.getElementsByTagName('h1');
10+
if (headings.length > 0) {
11+
document.title = 'Dan Tao - ' + headings[0].textContent;
12+
}
813
}
914

1015
function makeAjaxRequest(url, callback) {
@@ -21,11 +26,23 @@ function makeAjaxRequest(url, callback) {
2126
request.send();
2227
}
2328

24-
window.addEventListener('load', function() {
29+
function loadIdeaForLocation() {
2530
var ideaName = window.location.pathname.match(/ideas\/(.*)$/);
31+
32+
if (!ideaName) {
33+
ideaName = window.location.search.match(/\bidea=([^&]*)/);
34+
}
35+
2636
if (ideaName) {
2737
makeAjaxRequest('/ideas/' + ideaName[1] + '.md', displayIdea);
2838
}
39+
}
2940

41+
function displayPathInFooter() {
3042
document.getElementById('path').textContent = window.location.pathname;
43+
}
44+
45+
window.addEventListener('load', function() {
46+
loadIdeaForLocation();
47+
displayPathInFooter();
3148
});

ideas/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33

44
<head>
5-
<title>Ideas</title>
5+
<title>Dan Tao - Ideas</title>
66
<link rel="stylesheet/less" type="text/css" href="/common.less" />
77
<link rel="stylesheet/less" type="text/css" href="/ideas.less" />
88
<script type="text/javascript" src="http://lesscss.org/js/less.js"></script>

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33

44
<head>
5-
<title>Daniel Tao</title>
5+
<title>Dan Tao</title>
66
<link rel="stylesheet/less" type="text/css" href="common.less" />
77
<link rel="stylesheet/less" type="text/css" href="index.less" />
88
<script type="text/javascript" src="http://lesscss.org/js/less.js"></script>

0 commit comments

Comments
 (0)