3,389
个编辑
MCBBS Wiki欢迎您共同参与编辑!在参与编辑之前请先阅读Wiki方针。
如果在编辑的过程中遇到了什么问题,可以去讨论板提问。
为了您能够无阻碍地参与编辑 未验证/绑定过邮箱的用户,请尽快绑定/验证。
MCBBS Wiki GitHub群组已上线!
您可以在回声洞中发表吐槽!
服务器状态监控。点击进入
本站由MCBBS用户自行搭建,与MCBBS及东银河系漫游指南(北京)科技有限公司没有从属关系。点此了解 MCBBS Wiki 不是什么>>
Salt lovely(留言 | 贡献) 小 (// Edit via Wikiplus) |
Salt lovely(留言 | 贡献) 小 (// Edit via Wikiplus) |
||
| 第40行: | 第40行: | ||
$(function () { | $(function () { | ||
for (let a of Array.from(document.querySelectorAll('.mw-rollback-link a'))) { | for (let a of Array.from(document.querySelectorAll('.mw-rollback-link a'))) { | ||
a.addEventListener('click', | if (!a.hasAttribute('href')) { continue } | ||
a.addEventListener('click', (ev) => { | |||
ev.preventDefault() | |||
confirmUI('确定要回退此页面吗?', (confirmed) => { | |||
if (confirmed) { window.location.href = a.href } | |||
}) | |||
}) | }) | ||
} | } | ||
/** | |||
* 显示一个自定义确认框 | |||
* @param {string} text | |||
* @param {(confirmed:boolean)=>void} callback | |||
*/ | |||
function confirmUI(text = '', callback) { | |||
// 容器 | |||
let container = document.createElement('div') | |||
container.className = 'confirmUIcontainer' | |||
container.innerHTML = `<center>${text}</center>` | |||
// 确定按钮 | |||
let yesBtn = document.createElement('div') | |||
yesBtn.className = 'btn' | |||
yesBtn.style.setProperty('--hover-color', '#f9fde7') | |||
yesBtn.textContent = '确定' | |||
yesBtn.addEventListener('click', () => { | |||
callback(true) | |||
container.remove() | |||
}) | |||
container.appendChild(yesBtn) | |||
// 取消按钮 | |||
let noBtn = document.createElement('div') | |||
noBtn.className = 'btn' | |||
noBtn.style.setProperty('--hover-color', '#fdece7') | |||
noBtn.textContent = '取消' | |||
noBtn.addEventListener('click', () => { | |||
callback(false) | |||
container.remove() | |||
}) | |||
container.appendChild(noBtn) | |||
// 显示UI | |||
document.body.appendChild(container) | |||
// 调整位置 | |||
container.style.marginLeft = (container.offsetWidth * -0.5) + 'px' | |||
container.style.marginTop = (container.offsetHeight * -0.5) + 'px' | |||
} | |||
// CSS | |||
let s = document.createElement('style') | |||
s.textContent = ` | |||
.confirmUIcontainer{ | |||
position: fixed; | |||
border: 8px solid #0003; | |||
border-radius: 8px; | |||
overflow: hidden; | |||
padding: 0; | |||
top: 50%; | |||
left: 50%; | |||
min-width: 20vw; | |||
background: #FDF6E6; | |||
user-select: none; | |||
} | |||
.confirmUIcontainer > center{ | |||
padding: 1.2rem .6rem 1.2rem .6rem; | |||
font-size: 1.05rem; | |||
} | |||
.confirmUIcontainer .btn{ | |||
width: 50%; | |||
border: 1px solid #ccc; | |||
padding: 1rem; | |||
box-sizing: border-box; | |||
font-size: 1.15rem; | |||
line-height: 1.15rem; | |||
float: left; | |||
background-color: transparent; | |||
text-align: center; | |||
transition: .3s ease; | |||
cursor: pointer; | |||
} | |||
.confirmUIcontainer .btn:hover{ | |||
background-color: var(--hover-color,transparent); | |||
} | |||
` | |||
document.head.appendChild(s) | |||
}) | }) | ||