: ''' }[c];
});
}
function stripExt(name) {
return String(name).replace(/\.[^.]+$/, '');
}
function resolveEl(ref) {
if (!ref) return null;
return typeof ref === 'string' ? document.getElementById(ref) : ref;
}
function format(str, data) {
if (!data) return str;
Object.keys(data).forEach(function (k) {
str = str.split('{' + k + '}').join(data[k]);
});
return str;
}
function readI18n(sel) {
var out = {};
var box = document.querySelector(sel || '#ie-i18n');
if (!box) return out;
box.querySelectorAll('[data-key]').forEach(function (el) {
out[el.getAttribute('data-key')] = el.textContent.trim();
});
return out;
}
function loadImage(file) {
return new Promise(function (resolve, reject) {
var reader = new FileReader();
reader.onload = function (e) {
var img = new Image();
img.onload = function () { resolve(img); };
img.onerror = function () { reject(new Error('image decode failed')); };
img.src = e.target.result;
};
reader.onerror = function () { reject(new Error('file read failed')); };
reader.readAsDataURL(file);
});
}
function canvasToBlob(canvas, type, quality) {
return new Promise(function (resolve, reject) {
canvas.toBlob(function (blob) {
if (blob) resolve(blob);
else reject(new Error('canvas export failed'));
}, type, quality);
});
}
function makeCanvas(w, h) {
var c = document.createElement('canvas');
c.width = Math.max(1, Math.round(w));
c.height = Math.max(1, Math.round(h));
return c;
}
function ctxOf(canvas) {
return canvas.getContext('2d');
}
function fitSize(w, h, maxW, maxH) {
if (!maxW && !maxH) return { w: w, h: h };
var scale = Math.min(maxW ? maxW / w : Infinity, maxH ? maxH / h : Infinity, Infinity);
if (scale >= 1) return { w: w, h: h }; // 不放大
return { w: Math.max(1, Math.round(w * scale)), h: Math.max(1, Math.round(h * scale)) };
}
function thumbnail(img, maxSide, bg) {
var s = fitSize(img.naturalWidth, img.naturalHeight, maxSide, maxSide);
var c = makeCanvas(s.w, s.h);
var ctx = ctxOf(c);
if (bg) { ctx.fillStyle = bg; ctx.fillRect(0, 0, s.w, s.h); }
ctx.drawImage(img, 0, 0, s.w, s.h);
return c.toDataURL('image/jpeg', 0.9);
}
function buildUI(root, opts, labels) {
var uid = 'ie' + Math.random().toString(36).slice(2, 7);
var ids = {
drop: uid + '-drop',
input: uid + '-input',
panel: uid + '-panel',
preview: uid + '-preview',
toolbar: uid + '-toolbar',
addMore: uid + '-add-more',
downAll: uid + '-download-all',
clear: uid + '-clear',
count: uid + '-count',
list: uid + '-list',
empty: uid + '-empty'
};
var html =
'
[ImgEdit] readOptions xảy ra lỗi
Quá trình xử lý [ImgEdit] không thành công:
[ImgEdit] Tải không thành công:
[ImgEdit] editor.setup xảy ra lỗi
Đang đóng gói, vui lòng chờ
Đóng gói {xong}/{total}
Quá trình đóng gói đã hoàn tất, quá trình tải xuống đã bắt đầu
Đóng gói không thành công, vui lòng thử lại
Đã sao chép
Sao chép không thành công
Chữ ký trái phép:
Biểu thức chưa hoàn chỉnh
Biểu tượng chưa biết:
Mở ngoặc kép bên phải dư thừa
Biểu thức bất hợp pháp
Biểu thức có nội dung dư thừa
Trang web này là một trang web nhân bản và chức năng đã bị vô hiệu hóa
Nội dung của trang này được lấy từ Hồng Mục Ghi chú; bản quyền và chức năng chỉ được cấp phép sử dụng trên trang web gốc.
Truy cập trang web gốc
Định vị đến dòng đó rồi xóa đi.
Gửi thất bại, vui lòng thử lại sau một lúc.
(Total số liệu hiện tại là
Danh sách)
:''' }[c];
});
}
// ============ 主题切换(与博客首页同一套:data-theme + tui-theme)============
function isDark() {
var el = document.documentElement;
return el.getAttribute('data-theme') === 'dark' || el.classList.contains('dark-mode');
}
function setTheme(dark) {
var el = document.documentElement;
el.setAttribute('data-theme', dark ? 'dark' : 'light');
el.classList.toggle('dark-mode', dark); // 兼容部分工具内部旧的 .dark-mode 规则
try {
localStorage.setItem('tui-theme', dark ? 'dark' : 'light');
localStorage.setItem('a6_dark_mode', dark ? '1' : '0');
} catch (e) {}
}
function initTheme() {
var btn = document.getElementById('tuiThemeBtn') || document.getElementById('t-theme');
if (!btn) return;
function sync() { btn.classList.toggle('is-dark', isDark()); }
sync();
btn.addEventListener('click', function () {
setTheme(!isDark());
sync();
});
}
// ============ 返回顶部 ============
function initTop() {
var btn = document.getElementById('tuiTopBtn');
if (!btn) return;
function onScroll() {
btn.style.display = (window.pageYOffset > 300) ? '' : 'none';
}
window.addEventListener('scroll', onScroll, { passive: true });
onScroll();
btn.addEventListener('click', function () {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
}
// ============ 工具目录:精确悬浮在内容卡片右侧 ============
// 用 JS 读取主体卡片的真实右边界来定位(不依赖 CSS 计算),
// 右侧空间不足时自动回退为顶部横滑胶囊(移除 inline 定位即可)。
function initTocFloat() {
var aside = document.querySelector('.t-toc-aside');
var main = document.querySelector('.t-layout .t-main');
if (!aside || !main) return;
var GAP = 14; // 目录与卡片间距
var W = 224; // 目录宽度(与 CSS 的 .t-toc-aside 宽度保持一致)
function reset() {
aside.style.position = '';
aside.style.left = '';
aside.style.right = '';
aside.style.top = '';
aside.style.width = '';
aside.style.maxHeight = '';
aside.style.overflowY = '';
aside.classList.remove('is-floating');
}
function layout() {
reset();
if (window.innerWidth < 1024) return; // 窄屏:胶囊布局
var box = main.getBoundingClientRect();
var left = Math.round(box.left - GAP - W); // 目录放在卡片左侧(与内容页目录一致)
if (left < 8) return; // 左侧放不下:胶囊布局
aside.style.position = 'fixed';
aside.style.left = left + 'px';
aside.style.top = '84px';
aside.style.width = W + 'px';
aside.style.maxHeight = 'calc(100vh - 110px)';
aside.style.overflowY = 'auto';
aside.style.zIndex = '5';
aside.classList.add('is-floating');
}
layout();
window.addEventListener('resize', layout, { passive: true });
window.addEventListener('load', layout);
window.setTimeout(layout, 300); // 字体/图片加载后校正一次
}
// ============ 外观设置(配色 + 字号,记忆在 localStorage) ============
function initAppearance() {
var btn = document.getElementById('tAppearanceBtn');
var panel = document.getElementById('tAppearance');
if (!btn || !panel) return;
function read(k) { try { return localStorage.getItem(k) || ''; } catch (e) { return ''; } }
function write(k, v) { try { localStorage.setItem(k, v); } catch (e) {} }
function apply(accent, fs) {
var el = document.documentElement;
if (accent && accent !== 'default') { el.setAttribute('data-accent', accent); }
else { el.removeAttribute('data-accent'); }
if (fs && fs !== 'm') { el.setAttribute('data-fs', fs); }
else { el.removeAttribute('data-fs'); }
var i, list = panel.querySelectorAll('[data-accent]');
for (i = 0; i < list.length; i++) {
list[i].classList.toggle('is-on', list[i].getAttribute('data-accent') === (accent || 'default'));
}
list = panel.querySelectorAll('[data-fs]');
for (i = 0; i < list.length; i++) {
list[i].classList.toggle('is-on', list[i].getAttribute('data-fs') === (fs || 'm'));
}
}
var cur = { accent: read('t-accent') || 'default', fs: read('t-fs') || 'm' };
apply(cur.accent, cur.fs);
btn.addEventListener('click', function (e) {
e.stopPropagation();
panel.hidden = !panel.hidden;
});
var close = document.getElementById('tAppearanceClose');
if (close) close.addEventListener('click', function () { panel.hidden = true; });
panel.addEventListener('click', function (e) {
var t = e.target;
if (!t || !t.getAttribute) return;
var ac = t.getAttribute('data-accent');
var fs = t.getAttribute('data-fs');
if (ac) { cur.accent = ac; write('t-accent', ac); apply(cur.accent, cur.fs); }
if (fs) { cur.fs = fs; write('t-fs', fs); apply(cur.accent, cur.fs); }
});
document.addEventListener('click', function (e) {
if (panel.hidden) return;
if (panel.contains(e.target) || e.target === btn) return;
panel.hidden = true;
});
}
// 页面底部脚本加载,DOM 已就绪,直接初始化
initTheme();
initTop();
initTocFloat();
initAppearance();
// ============ 对外暴露 ============
window.Tools = {
isLocal: isLocalFile || isWrongHost,
audio: getAudio,
toast: toast,
copy: copy,
note: note,
chord: chord,
midiName: midiName,
midiFreq: midiFreq,
NOTE_NAMES: NOTE_NAMES,
esc: esc,
theme: initTheme,
};
// ============ 本地/非法域名提示 ============
if (window.Tools.isLocal) {
document.addEventListener('DOMContentLoaded', function () {
var tip = document.createElement('div');
tip.style.cssText = 'position:fixed;left:50%;top:20px;transform:translateX(-50%);'
+ 'background:#e74c3c;color:#fff;padding:10px 20px;border-radius:8px;'
+ 'font-size:.9rem;z-index:99999;';
tip.textContent = '请从 4s5.cn 访问本工具';
document.body.appendChild(tip);
setTimeout(function () { tip.style.opacity = '0'; tip.style.transition = 'opacity .5s'; }, 3000);
setTimeout(function () { tip.parentNode && tip.parentNode.removeChild(tip); }, 3600);
});
}
})();
(function (window, document) {
'use strict';
var SEL = 'ins.adsbygoogle, ins.adsbygoogle iframe, iframe[id^=