mirror of
https://github.com/wahyd4/wahyd4.github.com.git
synced 2026-08-09 05:15:56 +10:00
- 308 posts reverse-extracted from wahyd4.github.com (Hexo 6.3.0 + NexT 8.25) - Hexo project with NexT theme, reading-experience custom styles - publish-post.sh: write post -> hexo build -> PR (master untouched)
31 lines
1.5 KiB
JavaScript
31 lines
1.5 KiB
JavaScript
// Custom JS injected by NexT custom_file_path.script
|
|
// (kept minimal — reserved for future enhancements)
|
|
(function () {
|
|
'use strict';
|
|
// Reading progress is handled by NexT's built-in component.
|
|
// Font-size adjuster for accessibility (A / A- / A+)
|
|
function createFontSizeControl() {
|
|
var postBody = document.querySelector('.post-body');
|
|
if (!postBody) return;
|
|
var bar = document.createElement('div');
|
|
bar.className = 'font-size-control';
|
|
bar.style.cssText = 'position:fixed;right:18px;bottom:90px;z-index:1000;background:rgba(0,0,0,0.65);color:#fff;border-radius:20px;padding:6px 4px;display:flex;flex-direction:column;gap:2px;user-select:none;';
|
|
var labels = [['A-', -1], ['A', 0], ['A+', 1]];
|
|
var current = 1.0;
|
|
labels.forEach(function (item) {
|
|
var btn = document.createElement('button');
|
|
btn.textContent = item[0];
|
|
btn.style.cssText = 'background:none;border:none;color:#fff;font-size:13px;cursor:pointer;padding:3px 8px;opacity:0.85;';
|
|
btn.title = item[0] === 'A-' ? '减小字号' : item[0] === 'A+' ? '增大字号' : '恢复默认';
|
|
btn.addEventListener('click', function () {
|
|
if (item[1] === 0) current = 1.0;
|
|
else current = Math.min(1.4, Math.max(0.8, current + item[1] * 0.1));
|
|
postBody.style.fontSize = current + 'em';
|
|
});
|
|
bar.appendChild(btn);
|
|
});
|
|
document.body.appendChild(bar);
|
|
}
|
|
document.addEventListener('DOMContentLoaded', createFontSizeControl);
|
|
})();
|