diff --git a/gitstats/gitstats.css b/gitstats/gitstats.css index 83d6bb8..563ba22 100644 --- a/gitstats/gitstats.css +++ b/gitstats/gitstats.css @@ -6,6 +6,12 @@ body { background-color: #ffffff; } +#theme { + position: absolute; + top: 10px; + right: 10px; +} + dt { font-weight: bold; float: left; diff --git a/gitstats/report_creator.py b/gitstats/report_creator.py index 5ebd969..c02093d 100644 --- a/gitstats/report_creator.py +++ b/gitstats/report_creator.py @@ -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", @@ -930,6 +931,12 @@ def print_header(self, file) -> None: + + + """ % (self.title, conf["style"], get_version) ) diff --git a/gitstats/script.js b/gitstats/script.js new file mode 100644 index 0000000..7ed7131 --- /dev/null +++ b/gitstats/script.js @@ -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'; + } +}