|
61 | 61 | text-decoration: none;
|
62 | 62 | color: white;
|
63 | 63 | }
|
| 64 | + a.kRxZy-link { |
| 65 | + color: #4CAF50; /* Green shade that blends well */ |
| 66 | + font-weight: bold; |
| 67 | + } |
| 68 | + a.kRxZy-link:hover { |
| 69 | + color: #388E3C; |
| 70 | + } |
64 | 71 | </style>
|
65 | 72 | <script>
|
66 | 73 | const secretCode = '972';
|
67 | 74 |
|
| 75 | + // Generate a key by shifting the baseKey based on the secret code |
68 | 76 | function generateKeyFromCode(code) {
|
69 | 77 | const baseKey = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
70 | 78 | let shiftedKey = '';
|
|
75 | 83 | return shiftedKey;
|
76 | 84 | }
|
77 | 85 |
|
| 86 | + // Encode the username using the generated key |
78 | 87 | function encodeUsername(username, key) {
|
79 | 88 | const baseKey = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
80 | 89 | let encoded = '';
|
|
89 | 98 | return encoded;
|
90 | 99 | }
|
91 | 100 |
|
| 101 | + // On page load, check if the user is logged in |
92 | 102 | window.onload = function() {
|
93 | 103 | if (localStorage.getItem('loggedIn') === 'true') {
|
94 | 104 | const username = localStorage.getItem('username');
|
95 |
| - const text = document.getElementById('text'); |
| 105 | + const textElements = document.querySelectorAll('.text'); |
96 | 106 | const loggedIn = document.getElementById('loggedIn');
|
97 |
| - |
98 |
| - text.style.display = 'none'; |
| 107 | + |
| 108 | + // Hide all elements with the class "text" |
| 109 | + textElements.forEach(function(element) { |
| 110 | + element.style.display = 'none'; |
| 111 | + }); |
| 112 | + |
| 113 | + // Show the welcome message |
99 | 114 | loggedIn.style.display = 'block';
|
100 |
| - loggedIn.textContent = `Welcome to your account ${username}!`; |
| 115 | + loggedIn.textContent = `Welcome to your account, ${username}!`; |
101 | 116 | } else {
|
102 | 117 | checkAuth();
|
103 | 118 | }
|
104 | 119 | };
|
105 | 120 |
|
| 121 | + // Check for authentication on page load |
106 | 122 | function checkAuth() {
|
107 | 123 | const urlParams = new URLSearchParams(window.location.search);
|
108 | 124 | const authSuccess = urlParams.get('success');
|
|
123 | 139 | }
|
124 | 140 | }
|
125 | 141 |
|
| 142 | + // Redirect to ScratchAuth for authentication |
126 | 143 | function registerScratchAuth() {
|
127 | 144 | const messageBox = document.getElementById("message");
|
128 | 145 | const redirectLocation = encodeURIComponent(window.location.href);
|
|
137 | 154 | }, 2000);
|
138 | 155 | }
|
139 | 156 |
|
| 157 | + // Redirect to APIAuth for authentication |
140 | 158 | function registerApiAuth() {
|
141 | 159 | const messageBox = document.getElementById("message");
|
142 | 160 | const redirectLocation = encodeURIComponent(window.location.href);
|
|
153 | 171 | </script>
|
154 | 172 | </head>
|
155 | 173 | <body>
|
156 |
| - <div id="text" class="header"> |
| 174 | + <!-- Header Content --> |
| 175 | + <div class="text header"> |
157 | 176 | <h1>Scratch Authentication</h1>
|
158 | 177 | </div>
|
159 |
| - <div id="loggedIn" class="header"></div> |
| 178 | + <div id="loggedIn" class="header" style="display: none;"></div> |
160 | 179 |
|
161 |
| - <div id="text" class="content"> |
| 180 | + <!-- Main Content --> |
| 181 | + <div class="text content"> |
162 | 182 | <h2>Welcome! Please log in to continue.</h2>
|
163 | 183 | <button onclick="registerScratchAuth()">Register With ScratchAuth</button>
|
164 |
| - <p id="message" id="text" class="message" aria-live="polite"></p> |
165 |
| - <p id="text"> |
| 184 | + <p id="message" class="message" aria-live="polite"></p> |
| 185 | + <p> |
166 | 186 | Please note: You will be redirected to an external site (ScratchAuth) for authentication. Once there,
|
167 | 187 | choose the "Cloud Data" option for the quickest sign-in method.
|
168 |
| - |
169 |
| - If you are unable to use the "Cloud Data" option, other sign-in methods are available on Scratch Auth's page, for example, profile commenting.</p> |
| 188 | + |
| 189 | + If you are unable to use the "Cloud Data" option, other sign-in methods are available on Scratch Auth's page, for example, profile commenting. |
| 190 | + </p> |
170 | 191 | </div>
|
171 | 192 |
|
172 |
| - <div id="text" class="container"> |
| 193 | + <!-- APIAuth Section --> |
| 194 | + <div class="text container"> |
173 | 195 | <h2>Login Using APIAuth</h2>
|
174 |
| - <button onclick="registerApiAuth()">Login With APIAuth (Made by <a href="https://scratch.mit.edu/users/kRxZy_kRxZy/" target="_blank" style="color: blue">kRxZy_kRxZy</a>)</button> |
| 196 | + <button onclick="registerApiAuth()">Login With APIAuth (Made by |
| 197 | + <a href="https://scratch.mit.edu/users/kRxZy_kRxZy/" target="_blank" class="kRxZy-link">kRxZy_kRxZy</a>)</button> |
| 198 | + </div> |
| 199 | + |
| 200 | + <!-- Report Issue Section --> |
| 201 | + <div class="text container"> |
| 202 | + <a href="https://github.com/Scratch-Coding-Hut/Scratch-Coding-Hut.github.io/issues/new"> |
| 203 | + <button>Having trouble signing in? Report an issue</button> |
| 204 | + </a> |
175 | 205 | </div>
|
176 |
| - <div id="text" class="container"><a href="https://github.com/Scratch-Coding-Hut/Scratch-Coding-Hut.github.io/issues/new"> |
177 |
| - <button>Having trouble signing in? Report an issue</button></a><div> |
178 | 206 | </body>
|
179 | 207 | </html>
|
0 commit comments