「MediaWiki:Gadget-SearchInshokuten.js」の版間の差分
MediaWikiインターフェイスページ
その他の操作
編集の要約なし タグ: 手動差し戻し |
編集の要約なし タグ: 差し戻し済み |
||
| 1行目: | 1行目: | ||
document.addEventListener('DOMContentLoaded', function () { | |||
document | const form = document.getElementById('searchForm'); | ||
const | if (!form) return; | ||
// ---- SUBMIT ---- | |||
searchText | 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); | const params = new URLSearchParams(window.location.search); | ||
params.forEach((value, key) => { | 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'); | const clearBtn = document.querySelector('.clear-btn'); | ||
if (clearBtn) { | |||
clearBtn.addEventListener('click', function () { | |||
form.reset(); | |||
}); | |||
} | |||
}); | }); | ||
2025年12月8日 (月) 18:10時点における版
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();
});
}
});