文章详情 作者点击 可跳转pubmed和google
This commit is contained in:
265
js/article_v2.js
265
js/article_v2.js
@@ -101,6 +101,113 @@ margin-left: calc((100% - 190px - 65px)/2) !important;
|
|||||||
margin-top:10px;
|
margin-top:10px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
.zuo_zhe_name .article-author-link {
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.zuo_zhe_name .article-author-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
/* 部署默认隐藏,浏览器调试时将 display 改为 block 即可启用 */
|
||||||
|
.article-author-popup {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 10001;
|
||||||
|
// display: none !important;
|
||||||
|
min-width: 280px;
|
||||||
|
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #333;
|
||||||
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
|
||||||
|
padding: 14px 16px 18px;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: #333;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.article-author-popup-arrow {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
.article-author-popup-arrow-border,
|
||||||
|
.article-author-popup-arrow-inner {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-style: solid;
|
||||||
|
}
|
||||||
|
.article-author-popup-arrow-border {
|
||||||
|
margin-bottom: -8px;
|
||||||
|
border-width: 8px 8px 0;
|
||||||
|
border-color: #333 transparent transparent;
|
||||||
|
}
|
||||||
|
.article-author-popup-arrow-inner {
|
||||||
|
margin-bottom: -6px;
|
||||||
|
border-width: 7px 7px 0;
|
||||||
|
border-color: #fff transparent transparent;
|
||||||
|
}
|
||||||
|
.article-author-popup.is-below .article-author-popup-arrow {
|
||||||
|
bottom: auto;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
.article-author-popup.is-below .article-author-popup-arrow-border {
|
||||||
|
margin-bottom: 0;
|
||||||
|
margin-top: -8px;
|
||||||
|
border-width: 0 8px 8px;
|
||||||
|
border-color: transparent transparent #333;
|
||||||
|
}
|
||||||
|
.article-author-popup.is-below .article-author-popup-arrow-inner {
|
||||||
|
margin-bottom: 0;
|
||||||
|
margin-top: -6px;
|
||||||
|
border-width: 0 7px 7px;
|
||||||
|
border-color: transparent transparent #fff;
|
||||||
|
}
|
||||||
|
.article-author-popup-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
.article-author-popup-name {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 15px;
|
||||||
|
padding-right: 12px;
|
||||||
|
}
|
||||||
|
.article-author-popup-close {
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 1;
|
||||||
|
color: #666;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.article-author-popup-affiliation {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #333;
|
||||||
|
line-height: 22px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
.article-author-popup-affiliation sup {
|
||||||
|
color: rgb(0, 112, 192);
|
||||||
|
}
|
||||||
|
.article-author-popup-search {
|
||||||
|
border-top: 1px solid #e0e0e0;
|
||||||
|
padding-top: 10px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
.article-author-popup-search a {
|
||||||
|
color: #006699;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.article-author-popup-search a:hover {
|
||||||
|
color: #004466;
|
||||||
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
document.head.appendChild(style);
|
document.head.appendChild(style);
|
||||||
@@ -478,6 +585,158 @@ function renderCitations(citations, doi) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function escapeAuthorAttr(str) {
|
||||||
|
return String(str || '').replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<');
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatAuthorSearchName(name) {
|
||||||
|
if (!name || name.length < 3) return name || '';
|
||||||
|
if (name.charAt(2) === '-') {
|
||||||
|
return name.substring(0, 2) + name.substring(3);
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAuthorAffiliationHtml(ors, organs) {
|
||||||
|
if (!ors || !organs || !organs.length) return '';
|
||||||
|
var aliases = String(ors).split(/[,,\s]+/).filter(Boolean);
|
||||||
|
var lines = [];
|
||||||
|
for (var a = 0; a < aliases.length; a++) {
|
||||||
|
for (var i = 0; i < organs.length; i++) {
|
||||||
|
if (String(organs[i].alias) === String(aliases[a])) {
|
||||||
|
lines.push('<sup>' + organs[i].alias + '</sup> ' + organs[i].organ_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lines.join('<br/>');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPubMedAuthorUrl(name) {
|
||||||
|
var searchName = formatAuthorSearchName(name);
|
||||||
|
return 'https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=search&term=' + encodeURIComponent(searchName);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGoogleScholarAuthorUrl(name) {
|
||||||
|
var searchName = formatAuthorSearchName(name);
|
||||||
|
return 'https://scholar.google.com/scholar?as_q=&num=10&btnG=Search+Scholar&as_sauthors=' +
|
||||||
|
encodeURIComponent('"' + searchName + '"') +
|
||||||
|
'&as_publication=&as_ylo=&as_yhi=&as_sdt=1&as_sdtp=&as_vis=1&hl=en';
|
||||||
|
}
|
||||||
|
|
||||||
|
var articleAuthorPopupTrigger = null;
|
||||||
|
|
||||||
|
function hideArticleAuthorPopup() {
|
||||||
|
articleAuthorPopupTrigger = null;
|
||||||
|
$('#article-author-popup').hide().removeClass('is-below is-active');
|
||||||
|
}
|
||||||
|
|
||||||
|
function positionArticleAuthorPopup() {
|
||||||
|
var $trigger = articleAuthorPopupTrigger;
|
||||||
|
var $popup = $('#article-author-popup');
|
||||||
|
if (!$trigger || !$trigger.length || !$popup.length || !$popup.is(':visible')) return;
|
||||||
|
|
||||||
|
var rect = $trigger[0].getBoundingClientRect();
|
||||||
|
var triggerCenterX = rect.left + rect.width / 2;
|
||||||
|
var gap = 12;
|
||||||
|
|
||||||
|
$popup.css({ visibility: 'hidden', display: 'block' });
|
||||||
|
var popupWidth = $popup.outerWidth();
|
||||||
|
var popupHeight = $popup.outerHeight();
|
||||||
|
var left = triggerCenterX - popupWidth / 2;
|
||||||
|
var top = rect.top - popupHeight - gap;
|
||||||
|
var isBelow = false;
|
||||||
|
|
||||||
|
left = Math.max(8, Math.min(left, window.innerWidth - popupWidth - 8));
|
||||||
|
if (top < 8) {
|
||||||
|
top = rect.bottom + gap;
|
||||||
|
isBelow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var arrowLeft = triggerCenterX - left;
|
||||||
|
arrowLeft = Math.max(16, Math.min(arrowLeft, popupWidth - 16));
|
||||||
|
|
||||||
|
$popup.toggleClass('is-below', isBelow);
|
||||||
|
$popup.css({
|
||||||
|
left: left + 'px',
|
||||||
|
top: top + 'px',
|
||||||
|
visibility: 'visible'
|
||||||
|
});
|
||||||
|
$popup.find('.article-author-popup-arrow').css('left', arrowLeft + 'px');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showArticleAuthorPopup($trigger, authorName, affiliation) {
|
||||||
|
var $popup = $('#article-author-popup');
|
||||||
|
if (!$popup.length) {
|
||||||
|
$('body').append(
|
||||||
|
'<div id="article-author-popup" class="article-author-popup">' +
|
||||||
|
'<div class="article-author-popup-header">' +
|
||||||
|
'<div class="article-author-popup-name"></div>' +
|
||||||
|
'<span class="article-author-popup-close" title="Close">×</span>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div class="article-author-popup-affiliation"></div>' +
|
||||||
|
'<div class="article-author-popup-search">Search author on: ' +
|
||||||
|
'<a class="article-author-popup-pubmed" href="#" target="_blank">PubMed</a> | ' +
|
||||||
|
'<a class="article-author-popup-scholar" href="#" target="_blank">Google Scholar</a>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div class="article-author-popup-arrow">' +
|
||||||
|
'<span class="article-author-popup-arrow-border"></span>' +
|
||||||
|
'<span class="article-author-popup-arrow-inner"></span>' +
|
||||||
|
'</div></div>'
|
||||||
|
);
|
||||||
|
$popup = $('#article-author-popup');
|
||||||
|
$popup.find('.article-author-popup-close').on('click', function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
hideArticleAuthorPopup();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
articleAuthorPopupTrigger = $trigger;
|
||||||
|
$popup.addClass('is-active').show();
|
||||||
|
|
||||||
|
if (!$popup.find('.article-author-popup-arrow').length) {
|
||||||
|
$popup.append(
|
||||||
|
'<div class="article-author-popup-arrow">' +
|
||||||
|
'<span class="article-author-popup-arrow-border"></span>' +
|
||||||
|
'<span class="article-author-popup-arrow-inner"></span></div>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$popup.find('.article-author-popup-name').text(authorName);
|
||||||
|
$popup.find('.article-author-popup-affiliation').html(affiliation || '');
|
||||||
|
$popup.find('.article-author-popup-pubmed').attr('href', getPubMedAuthorUrl(authorName));
|
||||||
|
$popup.find('.article-author-popup-scholar').attr('href', getGoogleScholarAuthorUrl(authorName));
|
||||||
|
|
||||||
|
positionArticleAuthorPopup();
|
||||||
|
requestAnimationFrame(function () {
|
||||||
|
positionArticleAuthorPopup();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function initArticleAuthorPopup(organs) {
|
||||||
|
$(document).off('click.articleAuthorLink', '.zuo_zhe_name .article-author-link');
|
||||||
|
$(document).on('click.articleAuthorLink', '.zuo_zhe_name .article-author-link', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
var $link = $(this);
|
||||||
|
var authorName = $link.attr('data-author-name') || $.trim($link.text());
|
||||||
|
var affiliation = getAuthorAffiliationHtml($link.attr('data-author-ors'), organs);
|
||||||
|
showArticleAuthorPopup($link, authorName, affiliation);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).off('click.articleAuthorPopupOutside');
|
||||||
|
$(document).on('click.articleAuthorPopupOutside', function (e) {
|
||||||
|
if (!$(e.target).closest('#article-author-popup, .article-author-link').length) {
|
||||||
|
hideArticleAuthorPopup();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(window).off('scroll.articleAuthorPopup resize.articleAuthorPopup');
|
||||||
|
$(window).on('scroll.articleAuthorPopup resize.articleAuthorPopup', function () {
|
||||||
|
positionArticleAuthorPopup();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 文章内容
|
// 文章内容
|
||||||
function article_con() {
|
function article_con() {
|
||||||
$('.wen_jian .left .toggle-btn').html('Author Information ▼')
|
$('.wen_jian .left .toggle-btn').html('Author Information ▼')
|
||||||
@@ -709,10 +968,11 @@ function article_con() {
|
|||||||
} else {
|
} else {
|
||||||
ORC_ID = '<a href="https://orcid.org/' + j_authior[i].orcid + '" target="_blank"><img src="img/or_id.png" alt="" style="width: 15px;margin-left: 3px;"></a>'
|
ORC_ID = '<a href="https://orcid.org/' + j_authior[i].orcid + '" target="_blank"><img src="img/or_id.png" alt="" style="width: 15px;margin-left: 3px;"></a>'
|
||||||
}
|
}
|
||||||
|
var authorLink = '<span class="article-author-link" data-author-name="' + escapeAuthorAttr(j_authior[i].author_name) + '" data-author-ors="' + escapeAuthorAttr(j_authior[i].ors) + '">' + j_authior[i].author_name + '</span>';
|
||||||
if (i == j_authior.length - 1) {
|
if (i == j_authior.length - 1) {
|
||||||
stra += j_authior[i].author_name + '<sup>' + j_authior[i].ors + rep + '</sup>' + ORC_ID + mes
|
stra += authorLink + '<sup>' + j_authior[i].ors + rep + '</sup>' + ORC_ID + mes
|
||||||
} else {
|
} else {
|
||||||
stra += j_authior[i].author_name + '<sup>' + j_authior[i].ors + rep + '</sup>' + ORC_ID + mes + ', '
|
stra += authorLink + '<sup>' + j_authior[i].ors + rep + '</sup>' + ORC_ID + mes + ', '
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,6 +986,7 @@ function article_con() {
|
|||||||
str += strg + "</div>";
|
str += strg + "</div>";
|
||||||
|
|
||||||
$('.wen_jian .left>div.zuo_zhe').html(str);
|
$('.wen_jian .left>div.zuo_zhe').html(str);
|
||||||
|
initArticleAuthorPopup(j_organ);
|
||||||
$('.wen_jian .left>div.zuo_zhe>sup').css({
|
$('.wen_jian .left>div.zuo_zhe>sup').css({
|
||||||
color: commonSupColor,
|
color: commonSupColor,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user