Skip to content

Commit

Permalink
添加mix通常长度标签接口
Browse files Browse the repository at this point in the history
  • Loading branch information
dzyxdd committed Mar 17, 2024
1 parent 4bcda7a commit 7523de3
Show file tree
Hide file tree
Showing 7 changed files with 506 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ PythonUtils
docs/mix/auto-generated_html
docs/music_lib/auto-generated_html
docs/music_lib/music_call/auto-generated_html
docs/music_lib/music_call/auto-generated_md
docs/music_lib/music_call/auto-generated_md
site
9 changes: 5 additions & 4 deletions clean_cache.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@echo off

rd/s/q "docs/mix/auto-generated_html"
rd/s/q "docs/music_lib/auto-generated_html"
rd/s/q "docs/music_lib/music_call/auto-generated_html"
rd/s/q "docs/music_lib/music_call/auto-generated_md"
if exist "docs/mix/auto-generated_html" rd /s /q "docs/mix/auto-generated_html"
if exist "docs/music_lib/auto-generated_html" rd /s /q "docs/music_lib/auto-generated_html"
if exist "docs/music_lib/music_call/auto-generated_html" rd /s /q "docs/music_lib/music_call/auto-generated_html"
if exist "docs/music_lib/music_call/auto-generated_md" rd /s /q "docs/music_lib/music_call/auto-generated_md"
if exist "site" rd /s /q "site"
57 changes: 56 additions & 1 deletion docs/javascripts/add_copy_button.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
document$.subscribe(function () {

console.log('add_copy_button.js loaded')
let details = document.querySelectorAll('details.has_copy_button');

details.forEach(detail => {
Expand Down Expand Up @@ -35,4 +34,60 @@ document$.subscribe(function () {
});
})
})

// 获取所有的li元素和div元素
let liElements = document.querySelectorAll('.common_length');
let divElements = document.querySelectorAll('div.mix');
document.querySelectorAll('.return_all');
// 为每个li元素添加点击事件处理器
liElements.forEach(function (li) {
li.addEventListener('click', function () {
if (li.classList.contains('return_all')) {
divElements.forEach(function (div) {
div.style.display = 'block';
let previousH4 = div.previousElementSibling;
if (previousH4) previousH4.style.display = 'block';
});
return;
}
// 获取被点击的li元素的length类
let lengthClass = Array.from(li.classList).find(cls => cls.startsWith('length'));
// 遍历所有的div元素
divElements.forEach(function (div) {
// 获取当前div元素的前一个兄弟元素
let previousH4 = div.previousElementSibling;

// 如果div元素具有length类,显示它和它的h4
if (div.classList.contains(lengthClass)) {
div.style.display = 'block';
if (previousH4) previousH4.style.display = 'block';
}
// 否则,隐藏它和它的h4
else {
div.style.display = 'none';
if (previousH4) previousH4.style.display = 'none';
}
});
});
});

let aElements = document.querySelectorAll('a');
// 为每个a元素添加点击事件处理器
aElements.forEach(function (a) {
// 检查a元素的href属性是否包含'/mix/mix/'
if (a.href.includes('/mix/mix')) {
a.addEventListener('click', function () {

// 遍历所有的div元素
divElements.forEach(function (div) {
// 获取当前div元素的前一个兄弟元素
let previousH4 = div.previousElementSibling;

// 显示div元素和它的h4
div.style.display = 'block';
if (previousH4) previousH4.style.display = 'block';
});
});
}
});
})
17 changes: 17 additions & 0 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,21 @@ label input {
display: flex;
justify-content: center;
align-items: center;
}

.common_length {
font-size: smaller;
text-align: center;
display: inline-block !important;
margin: 0 3px !important;
padding: 0 10px;
min-width: 40px;
border-radius: 1000px;
background-color: rgba(255, 243, 35, 0.6);
}

.common_length_list {
align-items: center;
margin-top: 0.3em!important;
margin-bottom: 0.3em!important;
}
Loading

0 comments on commit 7523de3

Please sign in to comment.