Files
journal_com/js/articleJS/index.js
2024-09-25 16:34:51 +08:00

338 lines
14 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
}
function commonGetAxiosData(url, type, data) {
var resultData;
$.ajax({
type: type,
url: apiUrl + url,
data: data,
}).then((result) => {
if (result.code == 0) {
resultData = result.data
} else {
ShowDanger("请求失败!");
resultData = null
}
})
return resultData;
}
function commonInit() {
$('.art_side').css('display', 'none');
$('.art_main_con').css('width', '1070px');
$('.new_art > h4').css('padding', ' 0 4px 16px 6px');
}
function commonGetItemHtml(doc) {
var data = doc.data;
var i = doc.i;
var img_i = doc.img_i;
var c_t_a = doc.c_t_a;
var tong_geogle = doc.tong_geogle;
console.log('img_i at line 31:', img_i)
var baseInfo = {
doi_: !data.doi ? '' : `https://doi.org/${data.doi}`,
npp_: data.npp == '' || data.npp == ' ' ? '' : `: ${data.npp}.  `,
html_: '',
otStat: '',
pub_date: '',
mp4_: data.article_id != '172' ? '' : `<a href="https://youtu.be/3eDbnHRkFKQ" target="_blank"><img src="img/link_5.png" width="50" height="16" style="margin-left: 10px"></a>`,
c_t_a: '',
trad_tion: '',
lr_top: '',
person_img: '',
tong_geogle: tong_geogle ? tong_geogle : '',
pdf_: !data.file_pdf || data.file_pdf == '' ? '' : `<img src="img/link_3.jpg" width="14" height="16"><a href="${imgFileUrl}articlePDF/${data.file_pdf}" target="_blank" class="txt_pdf" alt="${data.article_id}">PDF</a>&nbsp;(&nbsp;<span style="color: red">${data.pdf_num}</span>&nbsp;)`,
cite_: !data.cite_num || data.cite_num == 0 ? '' :
`&nbsp;<span article_id="${data.article_id}" class="cite_box" style="color: #7a2702;">
<img src="img/link_6.jpg" width="14" height="16">
WOS Citations&nbsp;(&nbsp;<span style="color: red">${data.cite_num}</span>&nbsp;)
<ul class="export_cite "> </ul>
</span>`,
abstract: data.abstract.replace(new RegExp("0, 102, 204", "g"), "0,102,153"),
link_: '',
stage_: '',
}
if (data.has_html == 0) {
if (data.file_html == '') {
baseInfo.html_ = ''
} else {
baseInfo.html_ = '<img src="img/link_2.png" width="14" height="16"><a href="' + imgFileUrl + 'articleHTML/' + data.file_html + '" target="_blank" class="txt_html" alt="' + data.article_id + '">HTML</a>&nbsp;(&nbsp;<span style="color: red">' + data.html_num + '</span>&nbsp;)&nbsp;&nbsp;'
}
} else {
baseInfo.html_ = '<img src="img/link_2.png" width="14" height="16"><a href="article.html?J_num=' + Jour_num + '&a_id=' + data.article_id + '&s_htm=1" target="_blank" class="txt_html" alt="' + data.article_id + '">HTML</a>&nbsp;(&nbsp;<span style="color: red">' + data.html_num + '</span>&nbsp;)&nbsp;&nbsp;'
}
if (data.stage_no == '0') {
baseInfo.stage_ = ''
} else {
baseInfo.stage_ = '&nbsp;(' + data.stage_no + ')'
}
if (data.other_state == 0) {
baseInfo.otStat = ''
} else if (data.other_state == 1) {
baseInfo.otStat = '<span class="otStat">Editorial Expression of Concern</span>'
} else if (data.other_state == 2) {
baseInfo.otStat = '<span class="otStat">Retracted</span>'
}
if (data.isShowOtime == 1) {
if (data.pub_date && data.pub_date != '') {
baseInfo.pub_date = `<div class="url_data">Published Date: ${data.pub_date}</div>`
}
}
if (data.article_id == '86' || data.article_id == '176' || data.article_id == '455' || data.article_id == '400' || data.article_id == '145' || data.article_id == '116' || data.article_id == '717' || data.article_id == '632' || data.article_id == '24') {
baseInfo.person_img = '<img src="' + img_i + '" alt="" style="width: 120px">'
} else {
baseInfo.person_img = '<img src="' + img_i + '" alt="">'
}
if (c_t_a == 'different') {
if (data.journal_id == 22) {
baseInfo.c_t_a = '<button class="txt_copy cite_txt_button" >&nbsp;<img src="img/link_7.jpg" width="14" height="16">引用这篇文章<ul class="export" style="z-index:10;"><li id="txt_copy_' + i + '" class="Exc_1">>> 复制引用信息</li><li class="Exc_2"><i class="fa fa-download"></i> 下载EndNote格式</li><li class="Exc_3"><i class="fa fa-download"></i> 下载RIS格式</li><li class="Exc_4"><i class="fa fa-download"></i> 下载BibTex格式</li><li class="Exc_5"><i class="fa fa-download"></i> 下载text格式</li><div class="triangle"></div></ul></button>'
} else {
baseInfo.c_t_a = '<button class="txt_copy cite_txt_button">&nbsp;<img src="img/link_7.jpg" width="14" height="16">Cite this article<ul class="export" style="z-index:10;"><li id="txt_copy_' + i + '" class="Exc_1">>> Copy citation information</li><li class="Exc_2"><i class="fa fa-download"></i> Export citation to EndNote</li><li class="Exc_3"><i class="fa fa-download"></i> Export citation to RIS</li><li class="Exc_4"><i class="fa fa-download"></i> Export citation to BibTex</li><li class="Exc_5"><i class="fa fa-download"></i> Export citation to txt</li><div class="triangle"></div></ul></button>'
}
} else {
baseInfo.c_t_a = '<button class="txt_copy cite_txt_button">&nbsp;<img src="img/link_7.jpg" width="14" height="16">Cite this article<ul class="export" style="z-index:10;"><li id="txt_copy_' + i + '" class="Exc_1">>> Copy citation information</li><li class="Exc_2"><i class="fa fa-download"></i> Export citation to EndNote</li><li class="Exc_3"><i class="fa fa-download"></i> Export citation to RIS</li><li class="Exc_4"><i class="fa fa-download"></i> Export citation to BibTex</li><li class="Exc_5"><i class="fa fa-download"></i> Export citation to txt</li><div class="triangle"></div></ul></button>'
}
baseInfo.link_ = `<img src="img/link_1.png" width="14" height="16"><a class="txt_zhaiyao" alt="${data.article_id}">Abstract</a>&nbsp;(&nbsp;<span style="color: red">${data.abs_num}</span>&nbsp;)&nbsp;&nbsp;&nbsp;${baseInfo.html_}${baseInfo.pdf_}${baseInfo.mp4_}${baseInfo.c_t_a}${baseInfo.cite_}${baseInfo.tong_geogle}
<p class="txt_content">${data.cite}</p><div>${data.abstract}</div>`;
if (data.tradition_tag == '' || data.tradition_tag == null) {
var maxwidth = 500;//显示多少字符
if (data.abstract.length > maxwidth) {
var abstNew = data.abstract.replace(/<.*?>/ig, "")
abstNew = abstNew.substring(0, maxwidth)
abstNew = abstNew.substring(0, maxwidth - abstNew.split(" ").pop().length)
baseInfo.trad_tion = '<div>' + abstNew + '...</div>'
} else {
baseInfo.trad_tion = '<div>' + data.abstract + '</div>'
}
} else {
baseInfo.trad_tion = '<div><h3>' + data.tradition_tag + '</h3><p>' + data.tradition + '</p></div>'
}
if (data.topic && data.topic.length > 0) {
for (var t = 0; t < data.topic.length; t++) {
baseInfo.lr_top += '<a href="topic_list.html?J_num=' + Jour_num + '&t_id=' + data.topic[t].journal_topic_id + '" target="_blank">' + data.topic[t].title + '</a>'
}
}
return baseInfo
}
function commonHandleClickHtml() {
// 点击Abstract显示隐藏
$('.txt_zhaiyao').click(function () {
$(this).nextAll('div').toggle();
if ($(this).nextAll('div').css("display") == 'block') {
var num = $(this).next().html();
$.ajax({
type: 'post', url: apiUrl + 'yuan/Article/addArticleNum', async: false,
data: { "article_id": $(this).attr('alt'), "type": 'abs' },
success: function (result) {
if (result.code == 0) {
num = num * 1 + 1 * 1
}
}
})
$.ajax({
type: 'post', url: apiUrl + 'super/Publish/addVisitNum',
data: { 'type': Jour_num, 'is_detail': '1' },
success: function (result) {
}
});
$(this).next().html(num);
}
})
$('.txt_html').click(function () {
var num = $(this).next().html();
$.ajax({
type: 'post', url: apiUrl + 'yuan/Article/addArticleNum', async: false,
data: { "article_id": $(this).attr('alt'), "type": 'html' },
success: function (result) {
if (result.code == 0) {
num = num * 1 + 1 * 1
}
}
})
$.ajax({
type: 'post', url: apiUrl + 'super/Publish/addVisitNum',
data: { 'type': Jour_num, 'is_detail': '1' },
success: function (result) {
}
});
$(this).next().html(num);
})
$('.txt_pdf').click(function () {
var num = $(this).next().html();
$.ajax({
type: 'post', url: apiUrl + 'yuan/Article/addArticleNum', async: false,
data: { "article_id": $(this).attr('alt'), "type": 'pdf' },
success: function (result) {
if (result.code == 0) {
num = num * 1 + 1 * 1
}
}
})
$.ajax({
type: 'post', url: apiUrl + 'super/Publish/addVisitNum',
data: { 'type': Jour_num, 'is_detail': '1' },
success: function (result) {
}
});
$(this).next().html(num);
})
$('.export_cite').css('display', 'none');
$(document).click(function (e) {
if (!$(e.target).is('.export_cite') && !$(e.target).is('.cite_box')) {
$('.export_cite').hide();
}
})
$('.cite_box').click(function () {
$('.export_cite').css('display', 'none');
commonGetCiteList($(this).attr('article_id'))
$(this).find('.export_cite').fadeIn(200);
})
$('.export_cite').click(function (e) { e.stopPropagation() })
// 点击弹窗出现 复制和下载
$('.txt_content').css('display', 'none');
$('.export').css('display', 'none');
$(document).click(function (e) {
if (!$(e.target).is('.export') && !$(e.target).is('.txt_copy')) {
$('.export').hide();
}
})
$('.txt_copy').click(function () {
$('.export').css('display', 'none');
$(this).find('.export').fadeIn(200);
})
$('.Exc_1').click(function () {
var content_ = $(this).parents('.txt_copy').nextAll('.txt_content').text();
var clipboard = new Clipboard('#' + $(this).attr('id'), {
text: function () {
return content_;
}
})
clipboard.on('success', function (e) {
ShowSuccess("Citation information has been copied!");
});
})
$('.Exc_2').click(function () {
var ecx_id = $(this).parents('.links_').siblings('.txt_biaoti').attr('id')
$.ajax({
type: 'post', url: apiUrl + 'api/Article/getArticleenw', async: false,
data: { "article_id": ecx_id },
success: function (result) {
var a = document.createElement('a');
a.href = result.data.url;
a.download = ''
a.click();
}
})
})
$('.Exc_3').click(function () {
var ecx_id = $(this).parents('.links_').siblings('.txt_biaoti').attr('id')
$.ajax({
type: 'post', url: apiUrl + 'api/Article/getArticleRis', async: false,
data: { "article_id": ecx_id },
success: function (result) {
var a = document.createElement('a');
a.href = result.data.url;
a.download = ''
a.click();
}
})
})
$('.Exc_4').click(function () {
var ecx_id = $(this).parents('.links_').siblings('.txt_biaoti').attr('id')
$.ajax({
type: 'post', url: apiUrl + 'api/Article/getArticlebib', async: false,
data: { "article_id": ecx_id },
success: function (result) {
var a = document.createElement('a');
a.href = result.data.url;
a.download = ''
a.click();
}
})
})
$('.Exc_5').click(function () {
var ecx_id = $(this).parents('.links_').siblings('.txt_biaoti').attr('id')
$.ajax({
type: 'post', url: apiUrl + 'api/Article/getArticletext', async: false,
data: { "article_id": ecx_id },
success: function (result) {
var a = document.createElement('a');
a.href = result.data.url;
a.download = ''
a.click();
}
})
})
}
//获取 cite 并添加 html
function commonGetCiteList(a_ID) {
$('.cite_box .export_cite').html('<div class="loader-01"></div>');
var journalCiteStr = ''
$.ajax({
type: 'post', url: apiUrl + 'api/Article/getArticleCites',
data: {
"article_id": a_ID
},
success: function (result) {
if (result.code == 0) {
var arr = result.data.list
for (let i in arr) {
journalCiteStr += `
<div class='cite_list_item' style="margin-bottom:10px;podding:10px 0;display:flex;border-bottom: ${i != arr.length - 1 ? '1px solid #ccc' : 'none'};}"><p style="margin-right:10px;">${Number(i) + 1}.</p>
<div>
<p style="display: block; line-height: 20px;
font-size: 13px;
margin-bottom: 3px;"> <a style="color:#205493 !important;"
target="_blank"
href="${arr[i].doi ? 'https://doi.org/' + arr[i].doi : ''}">
${arr[i].article_name}
</a></p>
<p style="line-height: 14px;margin-bottom: 10px;">
<span style="color: #a2b1b6;
font-size: 13px;">${arr[i].author ? `${arr[i].author},` : ''} ${arr[i].journal_name}${arr[i].vol ? `${arr[i].vol},` : ''}
</span>
<span style="margin-left:5px;color:#205493 !important;">
</span></p></div>
</div> `
}
journalCiteStr += ` <div class="cite_triangle"></div>`
$('.cite_box .export_cite').html(journalCiteStr);
}
}
})
}