Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
LoydOsborne committed Mar 31, 2024
1 parent a6ed887 commit 717e143
Show file tree
Hide file tree
Showing 5 changed files with 1,459 additions and 0 deletions.
209 changes: 209 additions & 0 deletions resources/loyd-minecraft-ps3/index-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
const currentURL = window.location.href;

function redirectToDiscord() {
const baseURL = window.location.origin; // Extract base URL
const AuthUrl = `${baseURL}/oauth/discord/?callbackUrl=${encodeURIComponent(currentURL)}`;
window.location.href = AuthUrl;
}

document.addEventListener("DOMContentLoaded", function () {
const storedAccessToken = getCookie("accessToken");
displayContents();
// Redirect to login if access token is not found
if (!storedAccessToken) {
// window.location.href = `https://auth.scyted.tv/www.scyted.tv/discord?redirectUri=${currentURL}`;
displayLoginButton();
} else {
// Fetch user data from Discord API
fetchDiscordUserData(storedAccessToken)
.then(userData => {
// Display bot info and user info on the dashboard

displayUserInfo(userData);

const loggedInUserId = userData.id;

// Fetch the list of user IDs from the JSON file
// fetch('https://api.scyted.tv/wave-development/dashboard/access/scytedtv-user-access.json')
fetch('https://api.scyted.tv/website/dashboard/access/dashboard-access.json')
.then(response => response.json())
.then(userIds => {
// Check if the logged-in user's ID is in the list
if (!userIds.includes(loggedInUserId)) {
// Clear cookies
// document.cookie = "accessToken=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
// Redirect to the specified page if the user's ID is not in the
// window.location.href = `https://auth.scyted.tv/www.scyted.tv/discord?error=invalidAccess`;
displayContents();
displayUserInfo(userData);
}
})
.catch(error => {
console.error("Error fetching user IDs:", error);
// Handle error
});
})
.catch(error => {
console.error("Error fetching user data:", error);
// Clear cookies
// document.cookie = "accessToken=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
// Handle error (e.g., redirect to login page)
// window.location.href = `https://auth.scyted.tv/www.scyted.tv/discord?error=fetchingUserData`;
});
}
});

const urlParams = new URLSearchParams(window.location.hash.substring(1));
const accessToken = urlParams.get("access_token");

if (accessToken) {
try {
// Check if the access token is valid (add your validation logic here)
if (isValidAccessToken(accessToken)) {
// Store the access token in a cookie
setCookie("accessToken", accessToken, 30); // Set cookie to expire in 30 days
// Redirect to the dashboard
window.location.href = "./";
} else {
// Clear the accessToken cookie
clearCookie("accessToken");
}
} catch (error) {
console.error("Error setting accessToken:", error);
}
}

function isValidAccessToken(token) {
// Add your validation logic here
// Return true if the token is valid, otherwise return false
return true; // Placeholder, replace with actual validation
}

function setCookie(name, value, days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = name + "=" + value + ";" + expires + ";path=/";
}

function clearCookie(name) {
document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
}

function fetchDiscordUserData(accessToken) {
const apiUrl = 'https://discord.com/api/users/@me';

return fetch(apiUrl, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
})
.then(response => {
if (!response.ok) {
throw new Error(`Discord API Request Failed! Status: ${response.status}`);
}
return response.json();
});
}

function logout() {
// Clear cookies
document.cookie = "accessToken=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";

// Redirect to login page
window.location.href = `${currentURL}`;
}

function backButton() {
window.location.href = `../`;
}

function getCookie(name) {
const cookies = document.cookie.split("; ");
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].split("=");
if (cookie[0] === name) {
return cookie[1];
}
}
return null;
}









fetch('https://api.scyted.tv/resources/game-tracking/loyd-minecraft-ps3.json')
.then(response => response.json())
.then(data => {
const achievementsDiv = document.getElementById('achievements');
const completedAchievements = [];
const incompleteAchievements = [];

// Separate completed and incomplete achievements
data.achievements.forEach(achievement => {
if (achievement.achieved) {
completedAchievements.push(achievement);
} else {
incompleteAchievements.push(achievement);
}
});

// Sort completed achievements by date and time (newest to oldest)
completedAchievements.sort((a, b) => {
const dateA = new Date(a.date + ' ' + a.time);
const dateB = new Date(b.date + ' ' + b.time);
return dateB - dateA;
});

// Concatenate completed achievements with incomplete ones
const sortedAchievements = completedAchievements.concat(incompleteAchievements);

// Display achievements
sortedAchievements.forEach(achievement => {
const achievementDiv = document.createElement('div');
achievementDiv.classList.add('achievement');
if (achievement.achieved) {
achievementDiv.classList.add('achievement-unlocked');
} else {
achievementDiv.classList.add('achievement-locked');
achievementDiv.classList.add('incomplete');
}
const iconClass = achievement.achieved ? 'fas fa-check-circle' : 'far fa-circle';
achievementDiv.innerHTML = `
<div>
<i class="${iconClass}" style="font-size: 24px; color: ${achievement.achieved ? '#4caf50' : '#f44336'};"></i>
</div>
<div class="achievement-details">
<h3>${achievement.name}</h3>
<p>${achievement.description}</p>
<p class="achievement-status">${achievement.achieved ? 'Achieved' : 'Not achieved'}</p>
${achievement.achieved ? `
<div class="achievement-date-time date-time-box">
<i class="far fa-calendar-alt"></i> ${achievement.date} at ${achievement.time}
</div>
` : ''}
${achievement.type === 'Progress' ? `
<div class="progress-bar">
<div class="progress" style="width: ${calculateProgress(achievement.progress)};"></div>
<div class="progress-text">${achievement.progress}</div>
</div>
` : ''}
</div>
<img src="${achievement.image}" alt="${achievement.name}" class="achievement-image">
`;
achievementsDiv.appendChild(achievementDiv);
});
})
.catch(error => console.error('Error fetching data:', error));

function calculateProgress(progress) {
const progressParts = progress.split('/');
const current = parseInt(progressParts[0]);
const total = parseInt(progressParts[1]);
return `${(current / total) * 100}%`;
}
187 changes: 187 additions & 0 deletions resources/loyd-minecraft-ps3/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
---
title: Resource Directory
layout: page
type: resources
---
<style>
hr.has-background-black {
display: none;
}

h1.title {
display: none;
}
</style>
<link rel="stylesheet" href="https://api.scyted.tv/wave-development/dashboard/scytedtv-resources.css">
<link rel="stylesheet" href="https://api.scyted.tv/wave-development/dashboard/mobile-lock.css">
<body>

<!-- <div class="mobile-error">
<div id="error-message" style="color: red;">
ScytedTV Resources isn't currently available to mobile users at this time.
</div>
</div> -->

<div class="banner">
<img src="https://cdn.scyted.tv/website-assets/resource-portal/banner.jpg" alt="Banner Image" class="banner-image">
</div>

<div class="resource-container">

<div class="resource-wrapper">

<div class="resource-back" onclick="backButton()"><p>← back</p></div>

<div class="resource-info-box">
<img src="https://cdn.scyted.tv/website-assets/resource-portal/logos/loyd-minecraft-ps3.jpg" alt="Resource Image" class="resource-image">
<h3>Minecraft PS3 Achievements</h3>
Loyd's Minecraft PS3 achievement tracking.<br>
</div>

</div>

<div class="resource-box">

<div id="login-container" class="login-container">
</div>

<style>
.user-info-box {
flex: 1;
padding: 20px;
background-color: #fff;
border-radius: 8px;
margin-top: 10px;
text-align: left;
}
</style>
<style>
.achievements-container body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
color: #333;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.achievements-container .container {
max-width: 800px;
width: 100%;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
overflow-y: auto;
}
.achievements-container h1 {
font-size: 24px;
text-align: center;
margin-bottom: 20px;
color: #333;
}
.achievements-container .achievement {
border-bottom: 1px solid #ddd;
padding: 20px;
display: flex;
align-items: center;
}
.achievements-container .achievement:last-child {
border-bottom: none;
}
.achievements-container .achievement h3 {
margin: 0;
font-size: 18px;
color: #333;
margin-left: 15px;
}
.achievements-container .achievement p {
margin: 5px 0;
font-size: 14px;
color: #666;
margin-left: 15px;
}
.achievements-container .achievement-details {
flex-grow: 1;
margin-right: 20px;
}
.achievements-container .achievement-status {
font-size: 16px;
font-weight: bold;
color: #4caf50;
margin-left: 15px;
}
.achievements-container .achievement-status.incomplete {
color: #f44336;
}
.achievements-container .achievement-date-time {
font-size: 14px;
color: #888;
margin-left: 15px;
}
.achievements-container .date-time-box {
border: 1px solid #ddd;
border-radius: 5px;
padding: 5px 10px;
display: inline-block;
}
.achievements-container .progress-bar {
width: calc(100% - 55px);
height: 20px;
background-color: #f2f2f2;
border-radius: 10px;
margin-top: 5px;
overflow: hidden;
border: 1px solid #ddd;
margin-left: 15px;
position: relative;
}
.achievements-container .progress {
height: 100%;
background-color: #4caf50;
border-radius: 10px;
transition: width 0.5s ease-in-out;
}
.achievements-container .incomplete .progress {
background-color: #f44336;
}
.achievements-container .progress-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 14px;
color: #1a0180; /* Changed to dark gray */
z-index: 1;
}
</style>
<div class="container">

<div class="user-info-box" id="userInfoBox">

<h3>Minecraft PS3 Achievements</h3>

I'm someone who really enjoys collecting achievements and trophies from games. Some games I am attempting to get every acahievement possible. This page specifically targets my progress on the PlayStation 3 version of Minecraft. Below is the entire list of all of my achievements on the game that I update periodically.

<br><br>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">

<div class="achievements-container">
<div id="achievements"></div>
</div>

</div>
</div>
</div>
</div>

<script src="https://api.scyted.tv/wave-development/dashboard/page-loading-script.js"></script>
<script src="index-script.js"></script>
<script src="insert-scripts.js"></script>
<script src="https://api.scyted.tv/wave-development/dashboard/mobile-redirect.js"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-LF3ZTHGQHE"></script>

</body>
Loading

0 comments on commit 717e143

Please sign in to comment.