Skip to content
This repository has been archived by the owner on Mar 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #9 from heb12/updater
Browse files Browse the repository at this point in the history
Add Updating funtion
  • Loading branch information
MasterOfTheTiger authored Apr 24, 2018
2 parents 71f9b82 + 3c9935f commit c5f3c8b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
Binary file added app/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@
<div id="info" class="popup">
<div class="closePopup" onclick="closePopups()"><i class="fas fa-times"></i></div>
<h1>About this Program</h1>
<div id="technicalInfo">
<img src="icon.png" />
<p>Version: 0.1.0 <button id="checkUpdates" onclick="checkUpdates()">Check for updates</button></p>
<p id="latestUpdate" style="display:none"></p>
<p>Website: <span class="link">heb12.github.io</span></p>
</div>
<br /><br />
<p>This program was built by MasterOfTheTiger (mtiger.tk) as a simple Bible program for desktop systems.</p>
<blockquote><b>1</b> Therefore, since we are surrounded by such a great cloud of witnesses, we must get rid of every weight and the sin that clings so closely, and run with endurance the race set out for us, <b>2</b> keeping our eyes fixed on Jesus, the pioneer and perfecter of our faith. For the joy set out for him he endured the cross, disregarding its shame, and has taken his seat at the right hand of the throne of God. <span class="link" onclick="setChapter('Hebrews 12');closePopup()">Hebrews 12:1-2</span></blockquote>
<h3>Credits</h3>
Expand Down Expand Up @@ -183,6 +190,7 @@ <h2>Reset</h2>
</footer>
<script src="../node_modules/chapter-and-verse/chapterAndVerse.js"></script>
<script type="text/javascript" src="./script.js"></script>
<script src="updater.js"></script>
</body>

</html>
9 changes: 9 additions & 0 deletions app/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ and (max-width : 1000px) {
}
}

#technicalInfo {
display: block;
margin-bottom: 20px;
}
#technicalInfo img {
float: left;
margin-right: 20px;
}

/* This button CSS is from https://github.com/MasterOfTheTiger/apod-extension/blob/master/css/style.css under the MIT license */
button {
border-radius: 5px;
Expand Down
37 changes: 37 additions & 0 deletions app/updater.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Update this version number for every release:
const version = '0.1.0'
let timesChecked = localStorage.getItem('timesChecked');

function checkUpdates() {
console.log(timesChecked);
url = 'https://heb12.github.io/updater/desktop/latest.json' + '?' + timesChecked;
console.log(url);
if (navigator.onLine) {
console.log("Checking for updates...");
timesChecked = Number(timesChecked) + 1;
localStorage.setItem('timesChecked', timesChecked);
fetch(url)
.then(response => response.text())
.then(result => {
result = JSON.parse(result);
if (result != '') {
console.log(result);
if (result.version != version) {
console.log('This version is outdated. The newest version is ' + result.newest);
document.getElementById('latestUpdate').innerHTML = 'Latest version: ' + result.version + ' (get the newest version from <span class="link">heb12.github.io/update</span>)';
document.getElementById('latestUpdate').style.display = 'block';
} else {
console.log('Using latest version.');
document.getElementById('latestUpdate').innerHTML = 'Latest version: ' + result.version + ' (up to date)';
document.getElementById('latestUpdate').style.display = 'block';
}
} else {
// If for some reason the request returned as blank, it sends an error
console.log('Error requesting information for program version ' + version);
}
});
} else {
console.log('No internet connection!');
}
return result;
}

0 comments on commit c5f3c8b

Please sign in to comment.