Skip to content

Commit

Permalink
moved scripts + added updater
Browse files Browse the repository at this point in the history
  • Loading branch information
puksh committed Oct 20, 2024
1 parent 888dc74 commit a29eea3
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 6 deletions.
13 changes: 7 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@
</a>
</div>

<script src="startButton.js"></script>
<script src="window.js"></script>
<script src="apps.js"></script>
<script src="debug.js"></script>
<script src="container.js"></script>
<script src="safari.js"></script>
<script src="scripts/startButton.js"></script>
<script src="scripts/window.js"></script>
<script src="scripts/apps.js"></script>
<script src="scripts/debug.js"></script>
<script src="scripts/container.js"></script>
<script src="scripts/safari.js"></script>
<script src="scripts/updater.js"></script>
<!-- <script src="linuxMint.js"></script>-->
</body>
<!-- 2024&copy; - contact me meow@kot.li onegaishimasu -->
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 39 additions & 0 deletions scripts/updater.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
async function fetchLatestCommitHash() {
const REPO_OWNER = "puksh"; // Replace with your GitHub username
const REPO_NAME = "kot.li-webpage"; // Replace with your GitHub repository name

try {
const response = await fetch(
`https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/commits`
);
const commits = await response.json();

if (commits.length > 0) {
// Get the latest commit hash and take the first 6 characters
const latestCommitHash = commits[0].sha.substring(0, 6);
return latestCommitHash;
} else {
throw new Error("No commits found.");
}
} catch (error) {
console.error("Error fetching latest commit hash:", error);
}
}

async function checkForUpdates() {
const storedCommitHash = localStorage.getItem("latestCommitHash");
const latestCommitHash = await fetchLatestCommitHash();

if (latestCommitHash && latestCommitHash !== storedCommitHash) {
// Update the local storage with the new commit hash
localStorage.setItem("latestCommitHash", latestCommitHash);

// Log the update
console.log(`Updated commit hash: ${latestCommitHash}`);

// Perform a full refresh to get the latest version
window.location.reload(true);
}
}

checkForUpdates();
File renamed without changes.

0 comments on commit a29eea3

Please sign in to comment.