メニューを切り替える
個人設定メニューを切り替える
個人メニューを切り替える
ログインしていません
編集を行うと、IPアドレスが公開されます。

「MediaWiki:Gadget-SearchInshokuten.js」の版間の差分

MediaWikiインターフェイスページ
編集の要約なし
タグ: 差し戻し済み
ページの白紙化
タグ: 白紙化 手動差し戻し
 
(同じ利用者による、間の7版が非表示)
1行目: 1行目:
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();
    });
  }
});

2025年12月9日 (火) 18:21時点における最新版