Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions gitstats/gitstats.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ body {
background-color: #ffffff;
}

#theme {
position: absolute;
top: 10px;
right: 10px;
}

dt {
font-weight: bold;
float: left;
Expand Down
7 changes: 7 additions & 0 deletions gitstats/report_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def create(self, data, path):
basedir = os.path.dirname(os.path.abspath(__file__))
for file in (
conf["style"],
"script.js",
"sortable.js",
"arrow-up.gif",
"arrow-down.gif",
Expand Down Expand Up @@ -930,6 +931,12 @@ def print_header(self, file) -> None:
<script type="text/javascript" src="sortable.js"></script>
</head>
<body>
<select id="theme">
<option value="default">White</option>
<option value="green">Green</option>
</select>
<script type="text/javascript" src="script.js"></script>
"""
% (self.title, conf["style"], get_version)
)
Expand Down
43 changes: 43 additions & 0 deletions gitstats/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const themeSelect = document.getElementById('theme');

// Get the current theme from local storage
const currentTheme = localStorage.getItem('theme');

// If a theme is stored in local storage, apply it to the page
if (currentTheme) {
document.body.style.color = getThemeColor(currentTheme);
document.body.style.backgroundColor = getThemeBackgroundColor(currentTheme);
}

// Add an event listener to the theme select element
themeSelect.addEventListener('change', () => {
const theme = themeSelect.value;
// Store the selected theme in local storage
localStorage.setItem('theme', theme);
// Apply the selected theme to the page
document.body.style.color = getThemeColor(theme);
document.body.style.backgroundColor = getThemeBackgroundColor(theme);
});

// Helper functions to get the theme color and background color
function getThemeColor(theme) {
switch (theme) {
case 'default':
return 'black';
case 'green':
return 'black';
default:
return 'black';
}
}

function getThemeBackgroundColor(theme) {
switch (theme) {
case 'default':
return '#ffffff';
case 'green':
return '#dfd';
default:
return '#ffffff';
}
}