const subblogWindows = {};
function openSubblog(url, windowName, label) {
if (subblogWindows[windowName] && !subblogWindows[windowName].closed) {
try {
subblogWindows[windowName].focus();
showNotice(`🪟 すでに開いている ${label} を表示しました。`);
} catch (e) {
showNotice(`⚠️ ${label} を開くウィンドウにアクセスできませんでした。`);
}
} else {
const win = window.open(url, windowName);
if (win) {
subblogWindows[windowName] = win;
win.focus();
} else {
showNotice("🚫 ポップアップブロックが有効か、ウィンドウを開けませんでした。");
}
}
}
function showNotice(message) {
const box = document.createElement("div");
box.textContent = message;
box.style.position = "fixed";
box.style.bottom = "20px";
box.style.left = "50%";
box.style.transform = "translateX(-50%)";
box.style.background = "#333";
box.style.color = "#fff";
box.style.padding = "10px 16px";
box.style.borderRadius = "6px";
box.style.fontSize = "14px";
box.style.zIndex = 9999;
box.style.boxShadow = "0 2px 8px rgba(0,0,0,0.3)";
document.body.appendChild(box);
setTimeout(() => box.remove(), 4000);
}