diff --git a/assets/js/constant.js b/assets/js/constant.js
new file mode 100644
index 0000000..1b87ea9
--- /dev/null
+++ b/assets/js/constant.js
@@ -0,0 +1,20 @@
+(function(win, undef){
+ var CONSTANTS = {
+ JS_VERSION : '0.3.0'
+ },
+ CONS_REG = {}
+ ;
+
+ function parseConstants(text) {
+ Object.each(CONSTANTS, function(value, key) {
+ var reg = CONS_REG[key] || (CONS_REG[key] = new RegExp('{{' + key + '}}', 'g'))
+ ;
+
+ text = text.replace(reg, value);
+ });
+
+ return text;
+ }
+
+ win['parseConstants'] = parseConstants;
+})(window);
\ No newline at end of file
diff --git a/assets/js/content.js b/assets/js/content.js
index 3d16268..7c6118c 100644
--- a/assets/js/content.js
+++ b/assets/js/content.js
@@ -29,20 +29,18 @@
type : 'GET',
success : function(text) {
if (hasMarked){
- var lexer, parsed;
+ var lexer;
if (parseHandler) {
lexer = marked.lexer(text);
- parsed = marked.parser(parseHandler(lexer));
+ text = marked.parser(parseHandler(lexer));
} else {
- parsed = marked(text);
+ text = marked(text);
}
-
- successHandler(parsed);
- } else {
- successHandler(text);
}
+ successHandler(parseConstants(text));
+
callback && callback();
},
error : function() {
@@ -168,7 +166,7 @@
if (!(matches = linkReg.exec(text))) {
title = text;
id = baseId + headerMenu.length;
- text = '[' + text + '](' + headerMenu.length + ')';
+ //text = '[' + text + '](' + headerMenu.length + ')';
} else {
title = matches[1];
id = matches[2].replace('#', baseId);
@@ -249,11 +247,6 @@
dom = $('
' + html + '
')
;
- // // use new window to open
- // dom.find('a[href^="http"]').each(function() {
- // $(this).attr('target', '_blank');
- // });
-
articleEl.html(html);
}
@@ -266,7 +259,7 @@
init();
} else if (hash.page !== hashParam.page) {
hashParam.page = hash.page;
- loadContent();
+ loadContent(done);
}
});
@@ -328,41 +321,66 @@
});
loadCategory(function() {
- loadContent(function() {
- var path = $.joinPath(name, page, section)
- ;
+ loadContent(done);
+ });
+ }
- articleEl.find('a.top').each(function() {
- var el = this,
- anchor = $(el),
- id = anchor.attr('id')
- ;
+ function done() {
+ var hash = parseHash(),
+ name = hash.name,
+ page = hash.page,
+ section = hash.section,
+ path = $.joinPath(name, page, section)
+ ;
- if (id === path) {
- win.scrollTo(0, anchor.offset().top);
- }
+ cateUl.find('a.link').each(function() {
+ var el = this,
+ anchor = $(el),
+ href = anchor.attr('href')
+ ;
+
+ if (href.indexOf('#' + name + '/' + page) === 0) {
+ var li = anchor.parent('li'),
+ groupLi = li.parent('ul').parent('li')
+ ;
+
+ [li, groupLi].forEach(function(e) {
+ e.addClass('active')
+ .siblings('.active').removeClass('active');
});
+ }
+ });
- dropdownUl = $('section.dropdown ul.dropdown-menu');
+ articleEl.find('a.top').each(function() {
+ var el = this,
+ anchor = $(el),
+ id = anchor.attr('id')
+ ;
- dropdownUl.on('mousemove', function(e) {
- dropdownUl.attr('open', 'true');
- }).on('mouseout', function(e) {
- dropdownUl.attr('open', 'false');
+ if (id === path) {
+ win.scrollTo(0, anchor.offset().top);
+ }
+ });
- winEl.one('scroll', function() {
- if (dropdownUl.attr('open') !== 'true') {
- dropdownUl.parent().removeClass('open');
- }
- });
- }).prev('a').on('click', function(e) {
- var el = this,
- anchor = $(el)
- ;
- anchor.parent().toggleClass('open');
- });
+ dropdownUl = $('section.dropdown ul.dropdown-menu');
+
+ dropdownUl.on('mousemove', function(e) {
+ dropdownUl.attr('open', 'true');
+ }).on('mouseout', function(e) {
+ dropdownUl.attr('open', 'false');
+
+ winEl.one('scroll', function() {
+ if (dropdownUl.attr('open') !== 'true') {
+ dropdownUl.parent().removeClass('open');
+ }
});
+ }).prev('a').on('click', function(e) {
+ var el = this,
+ anchor = $(el)
+ ;
+ anchor.parent().toggleClass('open');
});
+
}
$(function() {
diff --git a/content.html b/content.html
index 1858fd3..6c1ed66 100644
--- a/content.html
+++ b/content.html
@@ -91,6 +91,7 @@
+