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

Commit c5f3c8b

Browse files
Merge pull request #9 from heb12/updater
Add Updating funtion
2 parents 71f9b82 + 3c9935f commit c5f3c8b

4 files changed

Lines changed: 54 additions & 0 deletions

File tree

app/icon.png

1.36 KB
Loading

app/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@
100100
<div id="info" class="popup">
101101
<div class="closePopup" onclick="closePopups()"><i class="fas fa-times"></i></div>
102102
<h1>About this Program</h1>
103+
<div id="technicalInfo">
104+
<img src="icon.png" />
105+
<p>Version: 0.1.0 <button id="checkUpdates" onclick="checkUpdates()">Check for updates</button></p>
106+
<p id="latestUpdate" style="display:none"></p>
107+
<p>Website: <span class="link">heb12.github.io</span></p>
108+
</div>
109+
<br /><br />
103110
<p>This program was built by MasterOfTheTiger (mtiger.tk) as a simple Bible program for desktop systems.</p>
104111
<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>
105112
<h3>Credits</h3>
@@ -183,6 +190,7 @@ <h2>Reset</h2>
183190
</footer>
184191
<script src="../node_modules/chapter-and-verse/chapterAndVerse.js"></script>
185192
<script type="text/javascript" src="./script.js"></script>
193+
<script src="updater.js"></script>
186194
</body>
187195

188196
</html>

app/style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ and (max-width : 1000px) {
205205
}
206206
}
207207

208+
#technicalInfo {
209+
display: block;
210+
margin-bottom: 20px;
211+
}
212+
#technicalInfo img {
213+
float: left;
214+
margin-right: 20px;
215+
}
216+
208217
/* This button CSS is from https://github.com/MasterOfTheTiger/apod-extension/blob/master/css/style.css under the MIT license */
209218
button {
210219
border-radius: 5px;

app/updater.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Update this version number for every release:
2+
const version = '0.1.0'
3+
let timesChecked = localStorage.getItem('timesChecked');
4+
5+
function checkUpdates() {
6+
console.log(timesChecked);
7+
url = 'https://heb12.github.io/updater/desktop/latest.json' + '?' + timesChecked;
8+
console.log(url);
9+
if (navigator.onLine) {
10+
console.log("Checking for updates...");
11+
timesChecked = Number(timesChecked) + 1;
12+
localStorage.setItem('timesChecked', timesChecked);
13+
fetch(url)
14+
.then(response => response.text())
15+
.then(result => {
16+
result = JSON.parse(result);
17+
if (result != '') {
18+
console.log(result);
19+
if (result.version != version) {
20+
console.log('This version is outdated. The newest version is ' + result.newest);
21+
document.getElementById('latestUpdate').innerHTML = 'Latest version: ' + result.version + ' (get the newest version from <span class="link">heb12.github.io/update</span>)';
22+
document.getElementById('latestUpdate').style.display = 'block';
23+
} else {
24+
console.log('Using latest version.');
25+
document.getElementById('latestUpdate').innerHTML = 'Latest version: ' + result.version + ' (up to date)';
26+
document.getElementById('latestUpdate').style.display = 'block';
27+
}
28+
} else {
29+
// If for some reason the request returned as blank, it sends an error
30+
console.log('Error requesting information for program version ' + version);
31+
}
32+
});
33+
} else {
34+
console.log('No internet connection!');
35+
}
36+
return result;
37+
}

0 commit comments

Comments
 (0)