feat(problemset): replace semantic-ui dropdown with native select for hardness filter
- Replace custom semantic-ui dropdown component with standard HTML select element - Simplify JavaScript by using native event listener instead of semantic-ui dropdown API - Remove unnecessary dropdown initialization and selection setting code - Maintain same functionality while reducing complexity and dependency on semantic-ui
This commit is contained in:
@@ -108,39 +108,31 @@
|
|||||||
$selected_hardness = 0;
|
$selected_hardness = 0;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="ui selection dropdown" id="hardness_dropdown" style="width: 120px; height: 28px; margin-left: 10px; vertical-align: middle;">
|
<select id="hardness_select" class="ui dropdown" style="width: 120px; height: 28px; margin-left: 10px; vertical-align: middle;">
|
||||||
<input type="hidden" id="hardness_value" value="<?php echo $selected_hardness; ?>">
|
<option value="0" <?php if ($selected_hardness == 0)
|
||||||
<i class="dropdown icon"></i>
|
echo 'selected'; ?>>全部难度</option>
|
||||||
<div class="default text">难度</div>
|
<?php for ($h = 1; $h <= 8; $h++) {
|
||||||
<div class="menu">
|
echo '<option value="' . $h . '"' . ($selected_hardness == $h ? ' selected' : '') . '>难度 ' . $h . '</option>';
|
||||||
<div class="item" data-value="0">全部难度</div>
|
} ?>
|
||||||
<?php for ($h = 1; $h <= 8; $h++) {
|
</select>
|
||||||
echo '<div class="item" data-value="' . $h . '">难度 ' . $h . '</div>';
|
|
||||||
} ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function () {
|
$(function () {
|
||||||
$('#hardness_dropdown').dropdown({
|
document.getElementById('hardness_select').addEventListener('change', function () {
|
||||||
onChange: function (value) {
|
var value = this.value;
|
||||||
var params = new URLSearchParams(window.location.search);
|
var params = new URLSearchParams(window.location.search);
|
||||||
if (value == '0' || value === '') {
|
if (value == '0' || value === '') {
|
||||||
params.delete('hardness');
|
params.delete('hardness');
|
||||||
} else {
|
} else {
|
||||||
params.set('hardness', value);
|
params.set('hardness', value);
|
||||||
}
|
|
||||||
params.delete('page');
|
|
||||||
window.location.href = '?' + params.toString();
|
|
||||||
}
|
}
|
||||||
|
params.delete('page');
|
||||||
|
var query = params.toString();
|
||||||
|
window.location.href = query ? ('?' + query) : window.location.pathname;
|
||||||
});
|
});
|
||||||
var hv = $('#hardness_value').val();
|
|
||||||
if (hv && hv !== '0') {
|
|
||||||
$('#hardness_dropdown').dropdown('set selected', hv);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user