File size: 1,912 Bytes
ffd34ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Spottd micro-interactions
const year = document.getElementById('year');
if (year) year.textContent = new Date().getFullYear();

const email = document.getElementById('email');
const password = document.getElementById('password');
const pwToggle = document.querySelector('.pw-toggle');
const hint = document.getElementById('domainHint');
const form = document.getElementById('loginForm');

// Gentle campus-domain nudge (non-blocking)
const allowedDomains = [
  'utoronto.ca','torontomu.ca','yorku.ca','mcmaster.ca','uwaterloo.ca',
  'queensu.ca','uwo.ca','uottawa.ca','algonquincollege.com','sheridancollege.ca',
  'humber.ca','senecacollege.ca'
];

email?.addEventListener('input', () => {
  const v = email.value.toLowerCase().trim();
  const domain = v.split('@')[1];
  if (!domain){ hint.textContent=''; hint.className='hint'; return; }
  const ok = domain.endsWith('.edu') || allowedDomains.some(d => domain.endsWith(d));
  hint.textContent = ok
    ? 'Looks good — campus email detected.'
    : 'Tip: use your school email for the best experience (e.g., .edu, utoronto.ca, yorku.ca).';
  hint.className = 'hint ' + (ok ? 'good' : 'warn');
});

// Show/Hide password
pwToggle?.addEventListener('click', () => {
  const show = password.type === 'password';
  password.type = show ? 'text' : 'password';
  pwToggle.setAttribute('aria-label', show ? 'Hide password' : 'Show password');
});

// Demo submit (replace with real auth later)
form?.addEventListener('submit', (e) => {
  e.preventDefault();
  const vEmail = email.value.trim(), vPw = password.value.trim();
  if (!vEmail || !vPw){ alert('Please fill in both fields.'); return; }
  const btn = form.querySelector('.btn.primary');
  const prev = btn.textContent; btn.disabled = true; btn.textContent = 'Signing in…';
  setTimeout(() => { btn.disabled = false; btn.textContent = prev; alert('Demo only — connect real auth next.'); }, 900);
});