-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
224 lines (185 loc) · 6.06 KB
/
Copy pathindex.html
File metadata and controls
224 lines (185 loc) · 6.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Course Login</title>
<script src="https://accounts.google.com/gsi/client" async defer></script>
<style>
body {
font-family: Arial, sans-serif;
max-width: 680px;
margin: 60px auto;
padding: 0 20px;
color: #222;
}
.card {
border: 1px solid #ddd;
border-radius: 12px;
padding: 24px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}
.error {
border-color: #e5b2b2;
background: #fff6f6;
}
h1 {
margin-top: 0;
font-size: 28px;
}
.muted {
color: #666;
}
code {
background: #f5f5f5;
padding: 2px 5px;
border-radius: 4px;
}
.course-list {
margin-top: 16px;
padding-left: 20px;
}
#googleSignInButton {
margin-top: 18px;
}
</style>
</head>
<body>
<div class="card" id="app">
<h1>Course Login</h1>
<p class="muted">Loading...</p>
</div>
<script>
const GOOGLE_CLIENT_ID = '934616809748-lf1o5mrqq34c3vefb8mhlup2nbghi743.apps.googleusercontent.com';
const COURSE_CONFIGS = {
'samsung-ds-2026': {
title: 'Samsung Electronics DS Course',
description: 'Sign in with the Google account registered for the Samsung Electronics DS course.',
appsScriptUrl: 'https://script.google.com/macros/s/AKfycby9EA8ECBtCH8lW78SC8lDVPLPdxSbeKdcIJSElfgh3ZQ0fqF0J23T479g-icfhWQuo/exec',
},
'sct-2026-spring': {
title: '삼성물산(건설부문)--서울대 AI/Data 심화과정',
description: 'Sign in with a Google account to access the course page. First-time users will be asked to identify themselves by name and team number.',
appsScriptUrl: 'https://script.google.com/macros/s/AKfycbzh0WKDRYex8glKqjVSKclxr1IBe3AXtzNpv5wz9Nmu7SbgtUy_7T_SnzY6ATHRb6Tc/exec',
},
};
function escapeHtml(value) {
return String(value ?? '')
.replaceAll('&', '&')
.replaceAll('<', '<')
.replaceAll('>', '>')
.replaceAll('"', '"')
.replaceAll("'", ''');
}
function getCourseKey() {
const params = new URLSearchParams(window.location.search);
return params.get('course') || '';
}
function getCourseConfig() {
const courseKey = getCourseKey();
return COURSE_CONFIGS[courseKey] || null;
}
function renderError(message) {
document.getElementById('app').className = 'card error';
document.getElementById('app').innerHTML = `
<h1>Course Login</h1>
<p>${escapeHtml(message || 'Invalid course link.')}</p>
<p class="muted">
Please use the course link provided by the instructor.
</p>
`;
}
function renderUnknownCourse(courseKey) {
renderError('Invalid course link.');
}
function renderLoginPage() {
const courseKey = getCourseKey();
const course = getCourseConfig();
if (!course) {
renderUnknownCourse(courseKey);
return;
}
if (
!GOOGLE_CLIENT_ID ||
GOOGLE_CLIENT_ID === 'PASTE_YOUR_GOOGLE_CLIENT_ID_HERE'
) {
renderError('GOOGLE_CLIENT_ID is not configured.');
return;
}
if (
!course.appsScriptUrl ||
course.appsScriptUrl.startsWith('PASTE_')
) {
renderError(`Apps Script URL is not configured for course: ${courseKey}`);
return;
}
document.title = course.title;
document.getElementById('app').className = 'card';
document.getElementById('app').innerHTML = `
<h1>${escapeHtml(course.title)}</h1>
<p>${escapeHtml(course.description)}</p>
<p class="muted">
After sign-in, you will be redirected to the course viewer.
</p>
<div id="googleSignInButton"></div>
<p class="muted">
If you have multiple Google accounts, choose the one listed in the course roster.
</p>
`;
initializeGoogleSignIn();
}
function initializeGoogleSignIn() {
if (!window.google || !google.accounts || !google.accounts.id) {
setTimeout(initializeGoogleSignIn, 100);
return;
}
google.accounts.id.initialize({
client_id: GOOGLE_CLIENT_ID,
callback: handleCredentialResponse,
});
google.accounts.id.renderButton(
document.getElementById('googleSignInButton'),
{
type: 'standard',
theme: 'outline',
size: 'large',
text: 'signin_with',
shape: 'rectangular',
logo_alignment: 'left',
}
);
}
function handleCredentialResponse(response) {
const courseKey = getCourseKey();
const course = getCourseConfig();
if (!course) {
renderUnknownCourse(courseKey);
return;
}
if (!response || !response.credential) {
renderError('Google sign-in did not return a credential.');
return;
}
document.getElementById('app').innerHTML = `
<h1>${escapeHtml(course.title)}</h1>
<p>Signing in...</p>
`;
const form = document.createElement('form');
form.method = 'POST';
form.action = course.appsScriptUrl;
const tokenInput = document.createElement('input');
tokenInput.type = 'hidden';
tokenInput.name = 'idToken';
tokenInput.value = response.credential;
const courseInput = document.createElement('input');
courseInput.type = 'hidden';
courseInput.name = 'course';
courseInput.value = courseKey;
form.appendChild(tokenInput);
form.appendChild(courseInput);
document.body.appendChild(form);
form.submit();
}
window.onload = renderLoginPage;
</script>
</body>
</html>