-
Notifications
You must be signed in to change notification settings - Fork 0
/
highlight.js
38 lines (31 loc) · 950 Bytes
/
highlight.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// This JavaScript code is from tDiary's highlight plughin (highlight.rb),
// just slightly modified for Studs.
var highlightElem = null;
var saveClass = null;
function highlightElement(name) {
if (highlightElem) {
highlightElem.className = saveClass;
highlightElem = null;
}
highlightElem = getHighlightElement(name);
if (!highlightElem) return;
saveClass = highlightElem.className;
highlightElem.className = "highlight";
}
function getHighlightElement(id) {
return document.getElementById(id);
}
function handleLinkClick() {
highlightElement(this.hash.substr(1));
}
function dohighlight(){
if (document.location.hash) {
highlightElement(document.location.hash.substr(1));
}
hereURL = document.location.href.split(/#/)[0];
for (var i=0; i<document.links.length; ++i) {
if (hereURL == document.links[i].href.split(/#/)[0]) {
document.links[i].onclick = handleLinkClick;
}
}
}