Files
journal_com/js/scientist/scientist_oid.js
2025-05-19 13:38:12 +08:00

171 lines
7.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
function initOid() {
var o_ID = getQueryString('o_id'); //Online First
// Online First点进去的文章列表
if (o_ID != null) {
var urlList = {
list: 'api/Main/getOnlineFirstArticles'
}
commonInit()
var online_first = {};
online_first.pageIndex = 1;
online_first.pageSize = 10;
var totalPage;//总页码
var totalRecords;//总数据条数
var pageNo = online_first.pageIndex;//当前页码
$.ajax({
type: 'post', url: apiUrl + urlList.list,
data: online_first,
success: function (result) {
if (result.code == 0) {
$('.wenz_list>h4').html('Online First');
totalPage = result.data.count % online_first.pageSize == 0 ? (result.data.count / online_first.pageSize) : (Math.ceil(result.data.count / online_first.pageSize));
totalRecords = result.data.count;
$('.wenz_list .tioashu').html(result.data.count);
initArticle(result.data.articles)
//生成分页
//有些参数是可选的比如lang若不传有默认值
kkpager.generPageHtml({
pno: pageNo,
//总页码
total: totalPage,
//总数据条数
totalRecords: totalRecords,
mode: 'click',//默认值是link可选link或者click
click: function (n) {
this.selectPage(n);
//除了第一页写逻辑跳转
online_first.pageIndex = n;
$.ajax({
type: 'post', url: apiUrl + urlList.list,
data: online_first,
success: function (result) {
if (result.code == 0) {
$('.goup-container').click();
totalRecords = result.data.count;
$('.wenz_list .tioashu').html(result.data.count);
$('.wenz_list>h4').html('Online First');
initArticle(result.data.articles)
} else {
ShowDanger("请求失败!");
}
},
error: function () {
ShowDanger("error");
}
})
return false;
}, lang: {
firstPageText: 'First page',
firstPageTipText: 'First page',
lastPageText: 'Last page',
lastPageTipText: 'Last page',
prePageText: 'Previous page',
prePageTipText: 'Previous page',
nextPageText: 'Next page',
nextPageTipText: 'Next page',
totalPageBeforeText: '',
totalPageAfterText: '',
currPageBeforeText: 'on page ',
currPageAfterText: '',
totalInfoSplitStr: ' of ',
totalRecordsBeforeText: '',
totalRecordsAfterText: '',
gopageBeforeText: '   Go to page',
gopageButtonOkText: 'Go',
gopageAfterText: 'page',
buttonTipBeforeText: '第',
buttonTipAfterText: '页'
}
});
} else {
ShowDanger("请求失败!");
}
},
error: function () {
ShowDanger("error");
}
})
function initArticle(arr) {
var str = "";
for (var i = 0; i < arr.length; i++) {
if (arr[i].icon == '') {
continue
}
if (arr[i].icon == '') {
var img_i = 'img/baiss.png'
} else {
var img_i = imgarticleUrl + arr[i].icon
}
var baseInfo = commonGetItemHtml({ data: arr[i], i: i, img_i: img_i, c_t_a: '' })
str += `
<li>
<div class="dbt_header" style="height: 37px;line-height: 32px;">${arr[i].type}${baseInfo.pub_date}<div class="url_top">${baseInfo.lr_top}</div></div><a id="${arr[i].article_id}" target="_blank"
href="article.html?J_num=${arr[i].journal_id}&a_id=${arr[i].article_id}"
class="txt_biaoti">${baseInfo.otStat}${arr[i].title}</a>
<div class="authorList">${arr[i].authortitle}<br>
<a href="/${arr[i].usx}" target="_blank" > ${arr[i].journal_title}</a>.&nbsp;${arr[i].stage_year},&nbsp;${arr[i].stage_vol}${baseInfo.stage_}${baseInfo.npp_}<a
target="_blank" href="https://doi.org/${arr[i].doi}">${baseInfo.doi_}</a>
</div>
<div class="links_">${baseInfo.link_}</div>
<div class="apwrap"><a onclick="imgbig(this)" class="imgdiv">${baseInfo.person_img}</a>${baseInfo.trad_tion}<br
clear="both"></div>
</li>
`
}
$('.wenz_list>ul').html(str);
$('.links_ .txt_copy').css('background', localStorage.Journals_color);
commonHandleClickHtml()
addStyleToElement();
}
function addStyleToElement() {
// 获取所有具有 .url_top 类的元素
var elements = document.querySelectorAll('.article .art_main .new_art > ul li .url_top');
elements.forEach(function(element) {
element.style.margin = '0 0 0 20px';
element.style.display = 'inline-block';
});
// 获取所有具有 .url_top a 类的元素
var links = document.querySelectorAll('.article .art_main .new_art > ul li .url_top a');
links.forEach(function(link) {
link.style.marginRight = '10px';
link.style.padding = '3px 0';
link.style.fontFamily = 'Calibri';
link.style.fontSize = '15px';
});
// 设置最后一个 a 元素的 margin-right 为 0
var lastLink = document.querySelector('.article .art_main .new_art > ul li .url_top a:last-child');
if (lastLink) {
lastLink.style.marginRight = '0';
}
// 为 a 元素添加 hover 效果
links.forEach(function(link) {
link.addEventListener('mouseenter', function() {
link.style.textDecoration = 'underline';
});
link.addEventListener('mouseleave', function() {
link.style.textDecoration = 'none';
});
});
}
// 调用函数将样式应用到元素
}
}