MediaWiki:RecentActivities.js:修订间差异
来自东方活动维基
无编辑摘要 |
无编辑摘要 |
||
第2行: | 第2行: | ||
xhr.open('GET', 'https://thonly.cc/proxy_thmarket/api/v1/events?include_pending=true&utf8=1', true); | xhr.open('GET', 'https://thonly.cc/proxy_thmarket/api/v1/events?include_pending=true&utf8=1', true); | ||
xhr.onreadystatechange = function() { | xhr.onreadystatechange = function() { | ||
if (xhr.readyState === 4) { | |||
if (xhr.status === 200) { | |||
let data = JSON.parse(xhr.responseText); | |||
//console.log(data); | |||
let divBlock = document.getElementById('RecentActivities'); | |||
data.forEach(element => { | |||
let name = element["name"]; | |||
let id = element["id"]; | |||
let img = element["images"]; | |||
let list_image_clip = element["list_image_clip"]; | |||
let location = element["location"]; | |||
let details = location["details"]; | |||
let url = "https://touhou.market/main/events/" + id; | |||
let imgUrl = `https://thonly.cc/proxy_thmarket/api/v1/images/${img}?format=webp&q=60&size=m&clip=${list_image_clip[0]},${list_image_clip[1]},${list_image_clip[2]},${list_image_clip[3]}`; | |||
let block = ` | |||
<div class="childbox-box"> | |||
<div class="childbox-image childbox-image-more" data-more="${url}" onclick="window.open('${url}');"> | |||
<div class="childbox-image-more-child" style="pointer-events: none;"> | |||
<a href="/File:24%E6%96%B0%E6%98%A5%E5%AE%B4%E5%9B%9B%E5%AD%A3.png" class="image"> | |||
<img alt="${img}" referrer="no-referrer" src="${imgUrl}" decoding="async" loading="lazy" width="1920" height="1080" data-file-width="1920" data-file-height="1080"> | |||
</a> | |||
</div> | |||
</div> | |||
<div class="childbox-text"> | |||
<div class="childbox-title">${name}</div> | |||
<div style="flex:1;font-size:14px;margin-top:10px">${details}</div> | |||
</div> | |||
</div>` | |||
if(divBlock) { | |||
divBlock.innerHTML += block | |||
} | |||
}); | |||
} else { | |||
console.error('Network response was not ok ' + xhr.statusText); | |||
} | |||
} | } | ||
}; | }; | ||
xhr.send(); | xhr.send(); |
2024年6月3日 (一) 12:39的版本
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://thonly.cc/proxy_thmarket/api/v1/events?include_pending=true&utf8=1', true);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
let data = JSON.parse(xhr.responseText);
//console.log(data);
let divBlock = document.getElementById('RecentActivities');
data.forEach(element => {
let name = element["name"];
let id = element["id"];
let img = element["images"];
let list_image_clip = element["list_image_clip"];
let location = element["location"];
let details = location["details"];
let url = "https://touhou.market/main/events/" + id;
let imgUrl = `https://thonly.cc/proxy_thmarket/api/v1/images/${img}?format=webp&q=60&size=m&clip=${list_image_clip[0]},${list_image_clip[1]},${list_image_clip[2]},${list_image_clip[3]}`;
let block = `
<div class="childbox-box">
<div class="childbox-image childbox-image-more" data-more="${url}" onclick="window.open('${url}');">
<div class="childbox-image-more-child" style="pointer-events: none;">
<a href="/File:24%E6%96%B0%E6%98%A5%E5%AE%B4%E5%9B%9B%E5%AD%A3.png" class="image">
<img alt="${img}" referrer="no-referrer" src="${imgUrl}" decoding="async" loading="lazy" width="1920" height="1080" data-file-width="1920" data-file-height="1080">
</a>
</div>
</div>
<div class="childbox-text">
<div class="childbox-title">${name}</div>
<div style="flex:1;font-size:14px;margin-top:10px">${details}</div>
</div>
</div>`
if(divBlock) {
divBlock.innerHTML += block
}
});
} else {
console.error('Network response was not ok ' + xhr.statusText);
}
}
};
xhr.send();