: ''' }[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 오류
[ImgEdit] 처리 실패:
[ImgEdit] 로드 실패:
[ImgEdit] editor.setup 오류
포장중이니 잠시만 기다려주세요
포장 {done}/{total}
패키징 완료, 다운로드가 시작되었습니다
포장에 실패했습니다. 다시 시도해 주세요.
복사됨
복사 실패
잘못된 문자:
표현이 불완전합니다.
알 수 없는 기호:
추가 오른쪽 괄호
불법적인 표현
표현식에 중복된 내용이 있습니다.
이 사이트는 미러 사이트이므로 해당 기능이 비활성화되었습니다.
본 페이지의 내용은 홍무노트에서 발췌하였습니다. 저작권 및 기능은 원본 사이트에서만 사용하도록 승인되었습니다.
원본 사이트 방문
해당 줄을 찾아 삭제하세요.
제출하지 못했습니다. 나중에 다시 시도해 주세요.
(현재 데이터 합계
칼럼)
:''' }[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^=