Skip to content

Commit 00f624e

Browse files
committed
feat: add banner
1 parent e2d3b00 commit 00f624e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

js/ditto.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ function init_sidebar_section() {
9595
}
9696
location.hash = menu[i + 1];
9797
});
98+
create_banner($(ditto.sidebar_id).find('p:nth-child(3)').first());
99+
98100
}, "text").fail(function() {
99101
alert("Opps! can't find the sidebar file to display!");
100102
});
@@ -208,19 +210,24 @@ function li_create_linkage(li_tag, header_level) {
208210
}
209211

210212
function create_banner(element) {
213+
// 2019年11月20日
214+
var deadline = new Date(2019, 10, 20);
215+
if (deadline - (new Date()) < 0) return;
216+
211217
var styleStr = [
212218
'margin: 1em 0',
213219
'padding: 1em',
214220
'background-color: #c4e0e1',
215221
'border-radius: 5px',
216-
'font-size: 90%'
222+
'font-size: 75%',
223+
'color: #333333'
217224
].join(';');
218225

219-
var text = '<a href="">Vue 实战教程</a> ' +
220-
'深入学习一线大厂必备 Vue 技能。VIP 教程限时免费领取。' +
221-
'<a href="">⇐ 立即查看</a>';
226+
var text = '<span style="color: #4682BE;">ES6 实战教程</span> ' +
227+
'深入学习一线大厂必备 ES6 技能。VIP 教程限时免费领取。' +
228+
'<span style="color: #4682BE;">⇐ 立即查看</span>';
222229

223-
var banner = $('<div style="' + styleStr + '">' + text + '</div>')
230+
var banner = $('<a href="http://www.mawen.co/question/405" style="color: #333333;" target="_blank"><div style="' + styleStr + '">' + text + '</div></a>')
224231
.insertAfter(element);
225232
}
226233

@@ -261,7 +268,7 @@ function create_page_anchors() {
261268
.addClass('content-toc')
262269
.attr('id', 'content-toc');
263270

264-
create_banner(ul_tag);
271+
// create_banner(ul_tag);
265272

266273
for (var j = 0; j < headers.length; j++) {
267274
var li_tag = $('<li></li>').html('<a href="#' + location.hash.split('#')[1] + '#' + headers[j] + '">' + headers[j] + '</a>');

0 commit comments

Comments
 (0)