mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-11-19 13:13:46 +00:00
Update site.js
按构建记下的表判断第一张配图是否在开头附近,和入口页预加载的保持一致。
This commit is contained in:
@@ -5,6 +5,11 @@
|
||||
function encodedRoute(path) { return path.split('/').map(encodeURIComponent).join('/'); }
|
||||
// 图片前面的正文不到 1200 字(文首目录不算)时,大概率在首屏内
|
||||
function nearTop(img, root) {
|
||||
var images = window.CS_NOTES_FIRST_IMAGES;
|
||||
if (images) {
|
||||
var route = decode((location.hash.replace(/^#/, '').split('?')[0]) || '');
|
||||
return images[route] === img.getAttribute('src');
|
||||
}
|
||||
var block = img, chars = 0;
|
||||
while (block.parentElement && block.parentElement !== root && block.parentElement.tagName !== 'BODY') block = block.parentElement;
|
||||
for (var node = block.previousElementSibling; node; node = node.previousElementSibling) {
|
||||
|
||||
Reference in New Issue
Block a user