Repository navigation
Update print statement from 'Hello' to 'Goodbye' - #41
Merged
Merged
Conversation
Berikut adalah kemas kini untuk tukar mesej dari **"Hello"** → **"Goodbye"** pada peristiwa yang betul (masuk vs keluar sesi).
## 1) JavaScript — letak sebelum `</script>`
```js
// ═══════════════════════════════════════════════════════════════════════════
// MODULE: SESSION GREETING (Hello → Goodbye)
// ═══════════════════════════════════════════════════════════════════════════
const SESSION = {
greeting: 'Hello',
farewell: 'Goodbye',
startedAt: Date.now(),
};
// ─────────────────────────────────────────────────────────────────────────
// On load — print "Hello"
// ─────────────────────────────────────────────────────────────────────────
function printHello() {
const name = (typeof CERTIFICATE_IDENTITY !== 'undefined')
? CERTIFICATE_IDENTITY.full_name
: 'SGAE Data Lake';
console.log(
`%c👋 ${SESSION.greeting}, ${name}!`,
'color:#10b981;font-weight:900;font-size:16px;padding:4px 8px;background:rgba(16,185,129,0.1);border-radius:4px;'
);
// Also show a toast (optional — comment out if tak mahu)
showToast(
`👋 ${SESSION.greeting}`,
`Selamat datang, ${name}. Sesi dimulakan.`,
'success'
);
}
// ─────────────────────────────────────────────────────────────────────────
// On exit — update "Hello" → "Goodbye"
// ─────────────────────────────────────────────────────────────────────────
function printGoodbye() {
const name = (typeof CERTIFICATE_IDENTITY !== 'undefined')
? CERTIFICATE_IDENTITY.full_name
: 'SGAE Data Lake';
const secs = Math.round((Date.now() - SESSION.startedAt) / 1000);
const mm = String(Math.floor(secs / 60)).padStart(2, '0');
const ss = String(secs % 60).padStart(2, '0');
// Change greeting state
SESSION.greeting = SESSION.farewell;
console.log(
`%c👋 ${SESSION.farewell}, ${name}!`,
'color:#fbbf24;font-weight:900;font-size:16px;padding:4px 8px;background:rgba(251,191,36,0.1);border-radius:4px;'
);
console.log(
`%c⏱️ Sesi tamat: ${mm}:${ss} · ${new Date().toLocaleString('ms-MY')}`,
'color:#94a3b8;font-style:italic;'
);
}
// ─────────────────────────────────────────────────────────────────────────
// Bind events
// ─────────────────────────────────────────────────────────────────────────
window.addEventListener('load', () => {
setTimeout(printHello, 800);
});
// Fires when tab is closed, navigated away, or refreshed
window.addEventListener('beforeunload', printGoodbye);
// Fires when tab becomes hidden (mobile, tab switch) — optional
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') {
// Change state only — no console spam
SESSION.greeting = SESSION.farewell;
} else if (document.visibilityState === 'visible' && SESSION.greeting === SESSION.farewell) {
// User came back — reset greeting to Hello
SESSION.greeting = 'Hello';
console.log('%c👋 Hello again — sesi disambung', 'color:#22d3ee;font-weight:bold;');
}
});
```
## 2) (Pilihan) UI Banner — Tukar visual dari "Hello" → "Goodbye"
Jika mahu ia kelihatan dalam UI juga, tambah elemen kecil dan kemas kini melalui JavaScript:
**HTML** — letak di dalam `.toolbar` (kanan sekali):
```html
<span id="session-badge" class="session-badge">
<i class="fas fa-hand-wave"></i> <span id="session-text">Hello</span>
</span>
```
**CSS** — tambah dalam `<style>`:
```css
.session-badge{
display:inline-flex;align-items:center;gap:6px;
padding:6px 12px;border-radius:20px;
background:rgba(16,185,129,0.12);
border:1px solid rgba(16,185,129,0.4);
color:var(--green);
font-size:0.68rem;font-weight:800;
letter-spacing:0.06em;
transition:all 0.4s ease;
}
.session-badge.goodbye{
background:rgba(251,191,36,0.12);
border-color:rgba(251,191,36,0.4);
color:var(--gold);
}
.session-badge i{
animation:wave 2s ease-in-out infinite;
display:inline-block;
transform-origin:70% 70%;
}
@Keyframes wave{
0%,60%,100%{transform:rotate(0);}
10%,30%{transform:rotate(14deg);}
20%,40%{transform:rotate(-8deg);}
}
```
**JavaScript** — kemas kini `printHello()` dan `printGoodbye()`:
```js
function printHello() {
// ... existing console.log ...
const badge = document.getElementById('session-badge');
const text = document.getElementById('session-text');
if (badge && text) {
badge.classList.remove('goodbye');
text.textContent = 'Hello';
}
}
function printGoodbye() {
// ... existing console.log ...
const badge = document.getElementById('session-badge');
const text = document.getElementById('session-text');
if (badge && text) {
badge.classList.add('goodbye');
text.textContent = 'Goodbye';
}
}
```
## 3) Ringkasan Perubahan
| Keadaan | Sebelum | Selepas |
|---|---|---|
| **Console (load)** | `Hello` | `👋 Hello, Muhamad Sazwan Bin Ismail!` (hijau) |
| **Console (exit)** | `Hello` | `👋 Goodbye, Muhamad Sazwan Bin Ismail!` (kuning) |
| **Console (tab hidden)** | — | state tukar ke `Goodbye` secara senyap |
| **Console (tab visible semula)** | — | `👋 Hello again — sesi disambung` (biru) |
| **UI badge** | `Hello` (hijau) | `Goodbye` (kuning) bila keluar |
### Peristiwa yang Mencetuskan
| Event | Bila Berlaku | Tindakan |
|---|---|---|
| `load` | Halaman siap dimuatkan | Print **Hello** + toast |
| `beforeunload` | Tab ditutup / refresh / navigate away | Print **Goodbye** |
| `visibilitychange` → hidden | Tukar tab / minimize (mobile) | Tukar state secara senyap |
| `visibilitychange` → visible | Balik ke tab | Print **Hello again** |
### Nota
- **`beforeunload`** tidak boleh guna operasi async (macam `fetch`) — jadi kita hanya `console.log` dan tukar state, yang cukup laju untuk browser
- Jika mahu **log keluar disimpan**, boleh tambah `navigator.sendBeacon('/api/log', ...)` — tetapi untuk personal dashboard, `console.log` sudah memadai
- **Toast "Hello"** boleh dimatikan dengan comment out `showToast(...)` dalam `printHello()` jika tak mahu ia muncul setiap kali refresh
Kalau mahu ia spesifik ke satu elemen sahaja (contohnya `console.log` dalam fungsi tertentu), beritahu saya di mana asalnya "Hello" berada — saya boleh tukar terus pada baris yang betul.
|
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
This was
linked to
issues
Sep 30, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
1) JavaScript — letak sebelum
</script>2) (Pilihan) UI Banner — Tukar visual dari "Hello" → "Goodbye"
Jika mahu ia kelihatan dalam UI juga, tambah elemen kecil dan kemas kini melalui JavaScript:
HTML — letak di dalam
.toolbar(kanan sekali):CSS — tambah dalam
<style>:JavaScript — kemas kini
printHello()danprintGoodbye():3) Ringkasan Perubahan
Hello👋 Hello, Muhamad Sazwan Bin Ismail!(hijau)Peristiwa yang Mencetuskan
loadNota
beforeunloadtidak boleh guna operasi async (macamfetch) — jadi kita hanyaconsole.logdan tukar state, yang cukup laju untuk browsernavigator.sendBeacon('/api/log', ...)— tetapi untuk personal dashboard,console.logsudah memadaishowToast(...)dalamprintHello()jika tak mahu ia muncul setiap kali refreshKalau mahu ia spesifik ke satu elemen sahaja (contohnya
console.logdalam fungsi tertentu), beritahu saya di mana asalnya "Hello" berada — saya boleh tukar terus pada baris yang betul.CodeAnt-AI Description
Add a comprehensive SGAE sovereign dashboard template with identity, market, and system modules
What Changed
Impact
✅ Centralized SGAE dashboard reference✅ Searchable market, country, certificate, and registry sections✅ Browser-based monitoring and utility examples💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.