微件

微件:中立&怪物卡牌灵光一闪:修订间差异

来自卡厄思梦境WIKI

律Rhyme留言 | 贡献
无编辑摘要
律Rhyme留言 | 贡献
无编辑摘要
 
第50行: 第50行:
         .filter-btn-reset:hover {
         .filter-btn-reset:hover {
             background-color: #da190b;
             background-color: #da190b;
        }
        .filter-info {
            background-color: #e7f3fe;
            padding: 10px;
            margin: 10px 0;
            border-left: 4px solid #2196F3;
        }
        .filter-info ul {
            margin: 5px 0;
            padding-left: 20px;
         }
         }
     </style>
     </style>
第125行: 第135行:
             <div class="filter-btn filter-btn-reset" onclick="resetCardFilter()">重置</div>
             <div class="filter-btn filter-btn-reset" onclick="resetCardFilter()">重置</div>
         </div>
         </div>
    </div>
   
    <div id="current-filters" class="filter-info" style="display:none;">
        <strong>当前筛选:</strong>
        <ul id="filter-list"></ul>
     </div>
     </div>
      
      
     <script>
     <script>
         (function() {
         (function() {
             // 获取当前URL参数
             // 检查字符串是否包含某个值(用、分隔)
            function contains(str, value) {
                if (!str || !value) return false;
                var items = str.split('、');
                return items.indexOf(value) !== -1;
            }
           
            // 应用筛选到表格
            function filterTable() {
                var type = document.getElementById('filter-type').value;
                var dictInclude = document.getElementById('filter-dict-include').value;
                var dictExclude = document.getElementById('filter-dict-exclude').value;
                var classValue = document.getElementById('filter-class').value;
                var costMin = document.getElementById('filter-cost-min').value;
                var costMax = document.getElementById('filter-cost-max').value;
               
                var table = document.getElementById('card-results-table');
                if (!table) return;
               
                var rows = table.getElementsByTagName('tr');
                var visibleCount = 0;
               
                // 从第二行开始(跳过表头)
                for (var i = 1; i < rows.length; i++) {
                    var row = rows[i];
                    var show = true;
                   
                    // 筛选类型
                    if (type && show) {
                        var rowType = row.getAttribute('data-type') || '';
                        if (!contains(rowType, type)) {
                            show = false;
                        }
                    }
                   
                    // 筛选包含机制
                    if (dictInclude && show) {
                        var rowDictInclude = row.getAttribute('data-dict-include') || '';
                        if (!contains(rowDictInclude, dictInclude)) {
                            show = false;
                        }
                    }
                   
                    // 筛选排除机制
                    if (dictExclude && show) {
                        var rowDictExclude = row.getAttribute('data-dict-exclude') || '';
                        if (!contains(rowDictExclude, dictExclude)) {
                            show = false;
                        }
                    }
                   
                    // 筛选职业
                    if (classValue && show) {
                        var rowClass = row.getAttribute('data-class') || '';
                        if (!contains(rowClass, classValue)) {
                            show = false;
                        }
                    }
                   
                    // 筛选费用
                    if (show) {
                        var rowCostMin = parseInt(row.getAttribute('data-cost-min'));
                        var rowCostMax = parseInt(row.getAttribute('data-cost-max'));
                       
                        if (costMin && rowCostMin < parseInt(costMin)) {
                            show = false;
                        }
                        if (costMax && rowCostMax > parseInt(costMax)) {
                            show = false;
                        }
                    }
                   
                    row.style.display = show ? '' : 'none';
                    if (show) visibleCount++;
                }
               
                // 更新结果计数
                var countDiv = document.getElementById('result-count');
                if (countDiv) {
                    countDiv.innerHTML = "<em>共 " + visibleCount + " 条结果</em>";
                }
               
                // 显示当前筛选条件
                showCurrentFilters(type, dictInclude, dictExclude, classValue, costMin, costMax);
            }
           
            // 显示当前筛选条件
            function showCurrentFilters(type, dictInclude, dictExclude, classValue, costMin, costMax) {
                var filterDiv = document.getElementById('current-filters');
                var filterList = document.getElementById('filter-list');
               
                if (!filterDiv || !filterList) return;
               
                var filters = [];
                if (type) filters.push('<li>类型: ' + type + '</li>');
                if (dictInclude) filters.push('<li>包含机制: ' + dictInclude + '</li>');
                if (dictExclude) filters.push('<li>排除机制: ' + dictExclude + '</li>');
                if (classValue) filters.push('<li>职业: ' + classValue + '</li>');
                if (costMin) filters.push('<li>最低费用: ' + costMin + '</li>');
                if (costMax) filters.push('<li>最高费用: ' + costMax + '</li>');
               
                if (filters.length > 0) {
                    filterList.innerHTML = filters.join('');
                    filterDiv.style.display = 'block';
                } else {
                    filterDiv.style.display = 'none';
                }
            }
           
            // 获取URL参数
             function getUrlParams() {
             function getUrlParams() {
                 var params = {};
                 var params = {};
第143行: 第267行:
             }
             }
              
              
             // 初始化表单值
             // 初始化表单值并应用筛选
             function initializeFilters() {
             function initializeFilters() {
                 var params = getUrlParams();
                 var params = getUrlParams();
                  
                  
                 var typeElem = document.getElementById('filter-type');
                 if (params.type) {
                var dictIncludeElem = document.getElementById('filter-dict-include');
                    document.getElementById('filter-type').value = params.type;
                var dictExcludeElem = document.getElementById('filter-dict-exclude');
                var classElem = document.getElementById('filter-class');
                var costMinElem = document.getElementById('filter-cost-min');
                var costMaxElem = document.getElementById('filter-cost-max');
               
                if (typeElem && params.type) {
                    typeElem.value = params.type;
                 }
                 }
                 if (dictIncludeElem && params.dict_include) {
                 if (params.dict_include) {
                     dictIncludeElem.value = params.dict_include;
                     document.getElementById('filter-dict-include').value = params.dict_include;
                 }
                 }
                 if (dictExcludeElem && params.dict_exclude) {
                 if (params.dict_exclude) {
                     dictExcludeElem.value = params.dict_exclude;
                     document.getElementById('filter-dict-exclude').value = params.dict_exclude;
                 }
                 }
                 if (classElem && params['class']) {
                 if (params['class']) {
                     classElem.value = params['class'];
                     document.getElementById('filter-class').value = params['class'];
                 }
                 }
                 if (costMinElem && params.cost_min) {
                 if (params.cost_min) {
                     costMinElem.value = params.cost_min;
                     document.getElementById('filter-cost-min').value = params.cost_min;
                 }
                 }
                 if (costMaxElem && params.cost_max) {
                 if (params.cost_max) {
                     costMaxElem.value = params.cost_max;
                     document.getElementById('filter-cost-max').value = params.cost_max;
                 }
                 }
               
                // 应用筛选
                filterTable();
             }
             }
              
              
             // 应用筛选
             // 应用筛选并更新URL
             window.applyCardFilter = function() {
             window.applyCardFilter = function() {
                 var params = [];
                 var params = [];
第202行: 第322行:
                 }
                 }
                  
                  
                 window.location.href = url;
                 // 使用 pushState 避免页面刷新
                if (window.history && window.history.pushState) {
                    window.history.pushState({}, '', url);
                    filterTable();
                } else {
                    window.location.href = url;
                }
             };
             };
              
              
             // 重置筛选
             // 重置筛选
             window.resetCardFilter = function() {
             window.resetCardFilter = function() {
                 window.location.href = window.location.pathname;
                 document.getElementById('filter-type').value = '';
                document.getElementById('filter-dict-include').value = '';
                document.getElementById('filter-dict-exclude').value = '';
                document.getElementById('filter-class').value = '';
                document.getElementById('filter-cost-min').value = '';
                document.getElementById('filter-cost-max').value = '';
               
                if (window.history && window.history.pushState) {
                    window.history.pushState({}, '', window.location.pathname);
                    filterTable();
                } else {
                    window.location.href = window.location.pathname;
                }
             };
             };
              
              

2025年11月3日 (一) 13:36的最新版本