Skip to content

Commit bf6eec5

Browse files
Colin Sheanogweii
authored andcommitted
Rebase of cheeaun#34 onto current master
This is just updating @michaelowen's original pull request. Here's a copy of his description: --- This simple modification will allow for optional tags by adding it at the end of your event, like so: ``` @USERNAME's life =============== - 24/02/1955 Born - ~1968 Summer job #job - 03/1976 Built a computer #life #job - 01/04/1976 Started a [company](http://en.wikipedia.org/wiki/Apple_Inc. "Apple Inc.") #job - 04/1976-2011 Whole bunch of interesting events ``` These can then be easily styled with a custom css: ```css border: 4px solid #1abc9c; } border: 4px solid #3498db; } ``` To see this working, I have it running myself currently and works like a charm: http://timeline.owens.nl/
1 parent 58a482b commit bf6eec5

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

config.example.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"customStylesheetURL": null,
33
"yearLength": 120,
4-
"hideAge": false
5-
}
4+
"hideAge": false,
5+
"hideTags": false
6+
}

index.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ <h1 id="title">Life</h1>
121121
config: {
122122
yearLength: 120, // 120px per year
123123
hideAge: false, // Hide age from year axis
124+
hideTags: false, // Hide tags from entries
124125
customStylesheetURL: null // Custom stylesheet
125126
},
126127
start: function(){
@@ -170,10 +171,15 @@ <h1 id="title">Life</h1>
170171
list.forEach(function(l){
171172
var matches = l.match(/\-\s+([\d\/\-\~]+)\s(.*)/i);
172173
var time = matches[1];
173-
var text = matches[2];
174+
var tags = [];
175+
var text = matches[2].replace(/#(\w+)/gi, function (hashtag, cleantag) {
176+
tags.push('tag-' + cleantag);
177+
return (life.config.hideTags ? '' : hashtag);
178+
});
174179
data.push({
175180
time: life.parseTime(time),
176-
text: text
181+
text: text,
182+
tags: tags
177183
});
178184
});
179185
return data;
@@ -267,7 +273,8 @@ <h1 id="title">Life</h1>
267273
d.text = d.text.replace(link[0], "<a href='" + link[2] + "'" + link_attr + ">" + link[1] + "</a>");
268274
}
269275

270-
return '<div class="event" style="margin-left: ' + offset.toFixed(2) + 'px">'
276+
return '<div class="event ' + d.tags.join(' ') + '" style="margin-left: '
277+
+ offset.toFixed(2) + 'px">'
271278
+ '<div class="time" style="width: ' + width.toFixed(2) + 'px"></div>'
272279
+ '<b>' + d.time.title + '</b> ' + d.text + '&nbsp;&nbsp;'
273280
+ '</div>';

0 commit comments

Comments
 (0)