MediaWiki:Gadget-SearchInshokuten.js
MediaWikiインターフェイスページ
その他の操作
注意: 保存後、変更を確認するにはブラウザーのキャッシュを消去する必要がある場合があります。
- Firefox / Safari: Shift を押しながら 再読み込み をクリックするか、Ctrl-F5 または Ctrl-R を押してください (Mac では ⌘-R)
- Google Chrome: Ctrl-Shift-R を押してください (Mac では ⌘-Shift-R)
- Microsoft Edge: Ctrl を押しながら 最新の情報に更新 をクリックするか、Ctrl-F5 を押してください。
document.addEventListener('DOMContentLoaded', function () {
const form = document.getElementById('searchForm');
if (!form) return;
// ---- SUBMIT ----
form.addEventListener('submit', function () {
const ids = ['searchText','genre','station','budget_min','budget_max'];
ids.forEach(id => {
const el = document.getElementById(id);
if (el && el.value.trim() === '') {
el.removeAttribute('name');
}
});
});
// ---- LOAD FROM URL ----
const params = new URLSearchParams(window.location.search);
params.forEach((value, key) => {
document.querySelectorAll(`[name="${key}"]`).forEach(el => {
if (el.type === "checkbox" || el.type === "radio") {
if (el.value === value) el.checked = true;
} else {
el.value = value;
}
});
});
// ---- CLEAR BUTTON ----
const clearBtn = document.querySelector('.clear-btn');
if (clearBtn) {
clearBtn.addEventListener('click', function () {
form.reset();
});
}
});