Skip to content

Commit

Permalink
Add support to show version in the settings
Browse files Browse the repository at this point in the history
  • Loading branch information
deepjyoti30 committed Feb 27, 2022
1 parent 9276172 commit 0be6920
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ <h2 id="weather-text">Fetching Weather...</h2>
<!--JSON Editor-->
<script src="js/jsoneditor.min.js"></script>
<!--Custom JS-->
<script src="js/version.js"></script>
<script src="js/settings.js"></script>
<script src="js/autocomplete.js"></script>
<script src="js/search.js"></script>
Expand Down
1 change: 1 addition & 0 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
window.onload = function() {
this.populateVersionInSettings();
this.initBody();
this.listenForSettings();
}
Expand Down
30 changes: 30 additions & 0 deletions js/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Handle version related methods
*/

const VERSION = "v0.3"


function populateVersionInSettings() {
/**
* This method will populate the version field in the
* settings modal.
*
* This should be called once only since the version is
* constant throughout and changes with a new release (new installation)
*/
const versionElementId = "current--version--startpage"
document.getElementById(versionElementId).innerHTML = generateVersionString(VERSION)
}

function generateVersionString(version) {
/**
* Generate the version string to populate in the element.
*
* @param {string} version - The version to use in the version string
*
* @returns {string} - Returns a generated string to be used to show the version
* and the product name.
*/
return `startpage - ${version}`
}

0 comments on commit 0be6920

Please sign in to comment.