44 lines
2.1 KiB
Python
44 lines
2.1 KiB
Python
import os
|
|
|
|
templates_to_update = [
|
|
'src/main/resources/templates/dao-tao-detail.html',
|
|
'src/main/resources/templates/posts/full-width.html',
|
|
'src/main/resources/templates/posts/livestream.html',
|
|
'src/main/resources/templates/posts/sidebar.html',
|
|
'src/main/resources/templates/posts/standard.html'
|
|
]
|
|
|
|
# We need to replace:
|
|
# groupHtml += '<button class="dao-tao-tab-btn custom-tab-btn ' + activeClass + '" data-tab-idx="' + index + '" style="padding: 10px 20px; border: 1px solid #ccc; background: ' + (index===0 ? '#0055a5' : '#f8f9fa') + '; color: ' + (index===0 ? 'white' : 'black') + '; cursor: pointer;">' + tab.title + '</button>';
|
|
# with:
|
|
# groupHtml += '<button class="dao-tao-tab-btn custom-tab-btn ' + activeClass + '" data-tab-idx="' + index + '">' + tab.title + '</button>';
|
|
|
|
# And remove:
|
|
# b.style.background = '#f8f9fa';
|
|
# b.style.color = 'black';
|
|
# btn.style.background = '#0055a5';
|
|
# btn.style.color = 'white';
|
|
|
|
for filepath in templates_to_update:
|
|
if not os.path.exists(filepath):
|
|
continue
|
|
|
|
with open(filepath, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# Replace the button HTML generator
|
|
target_str = """groupHtml += '<button class="dao-tao-tab-btn custom-tab-btn ' + activeClass + '" data-tab-idx="' + index + '" style="padding: 10px 20px; border: 1px solid #ccc; background: ' + (index===0 ? '#0055a5' : '#f8f9fa') + '; color: ' + (index===0 ? 'white' : 'black') + '; cursor: pointer;">' + tab.title + '</button>';"""
|
|
new_str = """groupHtml += '<button class="dao-tao-tab-btn custom-tab-btn ' + activeClass + '" data-tab-idx="' + index + '">' + tab.title + '</button>';"""
|
|
content = content.replace(target_str, new_str)
|
|
|
|
# Remove the JS inline styles logic
|
|
content = content.replace("b.style.background = '#f8f9fa';", "")
|
|
content = content.replace("b.style.color = 'black';", "")
|
|
content = content.replace("btn.style.background = '#0055a5';", "")
|
|
content = content.replace("btn.style.color = 'white';", "")
|
|
|
|
with open(filepath, 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
print(f"Updated JS in {filepath}")
|
|
|