123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- function showGridIntro() {
- ads('show-intro');
- $('#grid-intro').fadeIn();
- }
- function closeGridIntro() {
- rds('show-intro');
- $('#grid-intro').fadeOut();
- }
- function openLeftBtn() {
- $('.leftbtn').toggleClass('active');
- }
- // 荣誉
- function showHonor() {
- $('.honorbox').fadeIn();
- $('.page').addClass('zuiwaimian');
- return false;
- }
- //说明
- function showInfo() {
- $('.infobox').fadeIn();
- $('.page').addClass('zuiwaimian');
- return false;
- }
- var unClickArr = [];
- var clickType = '';
- var cardArray = [];
- var isAutofan = true; //是否自动翻转
- var isSwitchingOver = true; //切换动画是否播放完毕
- // var changeTime = 1000 * 60 * 60 * 24; //默认2分钟切换一次类型 ---玉姐要求不再自动切换 故2分钟改成一天60*24 hxl
- function backClick() {
- isAutofan = true;
- $('.iframebox').fadeOut().html('');
- }
- function pingzhang(e, type, typename) {
- e.stopPropagation();
- isAutofan = false;
- $('.iframebox')
- .html(
- `<iframe src="./card.html?type=${type}&typename=${typename}"></iframe><div class="back_btn" onclick="backClick()"></div>`
- )
- .fadeIn();
- }
- var typeArr = Object.keys(material_gldata);
- /* function autoFanZhuan() {
- let num = 0;
- let tts = setInterval(() => {
- let lastNum = num; // 保存上一次的num值
- num = Math.floor(Math.random() * typeArr.length); // 重新生成num
- // 如果本次num与上一次num相同,则再计算一次num
- while (num === lastNum) {
- num = Math.floor(Math.random() * typeArr.length);
- }
- if (isAutofan && isSwitchingOver) {
- fanzhuan(typeArr[num]);
- $(".option li").removeClass("active");
- $(".option li").each(function () {
- if ($(this).find("span").text().trim() === typeArr[num]) {
- $(this).addClass("active");
- }
- });
- }
- isAutofan = true;
- }, changeTime);
- } */
- function fanzhuan(type) {
- unClickArr = [];
- for (let i = 0; i < cardArray.length; i++) {
- let item = lxs[cardArray[i]];
- if (item.material_gl?.includes(type) || type == '全部') {
- unClickArr.push(cardArray[i]);
- }
- }
- gridController.updateInit(unClickArr);
- }
- $(function () {
- getWwList();
- setTimeout(() => {
- $('.select').addClass('active');
- $('.option').addClass('active');
- }, 2000);
- $('.infobox').bind('mouseleave', function (e) {
- $('.infobox').fadeOut();
- $('.page').removeClass('zuiwaimian');
- });
- $('.infobox,.infobox span').bind('click', function (e) {
- $('.infobox').fadeOut();
- $('.page').removeClass('zuiwaimian');
- });
- $('.honorbox').bind('click', function (e) {
- $('.honorbox').fadeOut();
- $('.page').removeClass('zuiwaimian');
- });
- });
- // 获取文物列表
- function getWwList() {
- for (let id in lxs) {
- let item = lxs[id];
- cardArray.push(id);
- }
- let liStr =
- "<li class='active' onclick='choseWwType(this)'><span>全部</span></li>";
- typeArr.map((str) => {
- liStr += "<li onclick='choseWwType(this)'><span>" + str + '</span></li>';
- });
- $('.option').html(liStr);
- $('.option li').click(function () {});
- // autoFanZhuan();
- navigationController.startSite();
- gridController.init(cardArray);
- }
- function choseWwType(that) {
- $('.option li').removeClass('active');
- $(that).addClass('active');
- var _text = $(that).find('span').text();
- if (_text == clickType) return;
- clickType = _text;
- fanzhuan(_text);
- }
- //文物类型内容
- function getWwType(wwinfo) {
- let list = [
- 'dynasty',
- 'origin',
- 'crafts',
- 'decoration',
- 'material',
- 'type',
- 'inscription',
- 'usage',
- 'meaning',
- ];
- let list2 = [
- 'dynasty',
- 'origin',
- 'crafts_gl',
- 'decoration_gl',
- 'material',
- 'type_gl',
- 'inscription',
- 'usage',
- 'meaning',
- ];
- var html = '';
- var chtml = '';
- wwinfo.colors.split(',').map((item) => {
- return (chtml += `<i onclick="pingzhang(event,'colors','${item.replace(
- '#',
- ''
- )}')" style="background-color:${item}"></i>`);
- });
- html += `<li class='colors'>${chtml}</li>`;
- list.map((item, index) => {
- let info = list2[index];
- if (wwinfo[item] && wwinfo[info]) {
- html += `<li onclick="pingzhang(event,'${info}','${
- wwinfo[info].split('、')[0]
- }')">${wwinfo[item]}</li><br/>`;
- }
- });
- $('#wwtype').html(html);
- // if (window.isMobile) {
- // // 选择 class 为 scroll 的元素
- // const scrollElement = document.querySelector('#wwtype');
- // setTimeout(function () {
- // // 滚动到最右侧
- // scrollElement.scrollTo({
- // left: scrollElement.scrollWidth,
- // behavior: 'smooth',
- // });
- // }, 500);
- // // 2 秒后滚动回最左侧
- // setTimeout(() => {
- // scrollElement.scrollTo({
- // left: 0,
- // behavior: 'smooth',
- // });
- // }, 1500);
- // }
- }
- // 关联文物
- function showExplore(id) {
- let item = lxs[id];
- $('.exploreiframe')
- .fadeIn()
- .html(`<iframe src="./explore.html?id=${id}"></iframe>`);
- }
- //打开时间轴页面
- function showTimeline() {
- $('.select').addClass('zuiwaimian');
- if ($('.timelineicon').hasClass('active')) {
- return;
- }
- $('.option').removeClass('active');
- isAutofan = false;
- $('.typeicon').removeClass('active');
- $('.timelineicon').addClass('active');
- $('.timelinewrap').fadeIn(500);
- $('.timelineiframe').fadeIn().html(`<iframe src="./timeline.html"></iframe>`);
- $('.page').addClass('zuiwaimian');
- }
- //关闭时间轴页面
- function closeTimeline() {
- $('.select').removeClass('zuiwaimian');
- isAutofan = true;
- $('.timelineiframe').fadeOut().html('');
- $('.timelinewrap').fadeOut(500);
- $('.option').addClass('active');
- $('.typeicon').addClass('active');
- $('.timelineicon').removeClass('active');
- $('.page').removeClass('zuiwaimian');
- }
- //点击类型按钮
- function showTypeCont() {
- if ($('.typeicon').hasClass('active')) {
- return;
- }
- closeTimeline();
- }
- //关闭探索页面
- function closeExploreWrap() {
- isAutofan = true;
- $('.exploreiframe').fadeOut().html('');
- $('.explorewrap').fadeOut(500);
- $('.option').addClass('active');
- $('.typeicon').addClass('active');
- $('.timelineicon').removeClass('active');
- $('.page').removeClass('zuiwaimian');
- }
- // 打开关联页面
- function showAllExplore(id) {
- isAutofan = false;
- $('.explorewrap').fadeIn(500);
- getWwType(lxs[id]);
- showExplore(id);
- $('.page').addClass('zuiwaimian');
- }
- // 获取一个随机的id
- function getRandomId(excludeId, data) {
- if (data.length > 1) {
- var randomIndex;
- do {
- randomIndex = Math.floor(Math.random() * data.length);
- } while (data[randomIndex] === excludeId);
- return data[randomIndex];
- } else {
- return '';
- }
- }
|