";
}
var titleArea = document.getElementById("tutnav_title_area");
var cardEl = grid.querySelector('.tutnav-card[data-name="' + t.name + '"]');
// Show the "MORE TUTORIALS" heading when displaying specific tutorial topics
var sectionHeading = document.querySelector("#nav_tutorials .tutnav-section-heading");
if (sectionHeading) {
sectionHeading.style.display = "";
sectionHeading.textContent = "More Tutorials:";
}
// Remove filter-only class when heading is shown
var tutHeader = document.querySelector("#nav_tutorials .tutnav-header");
if (tutHeader) tutHeader.classList.remove("filter-only");
var iconHtml = (cardEl ? cardEl.querySelector(".tutnav-icon-wrap").innerHTML : "") || window.iconSvgs[t.name] || '';
titleArea.innerHTML = "";
var ct = document.getElementById("tutnav_current_topic");
ct.style.display = "";
var quizUrl = quizUrls[t.name] || "";
var html = '
";
ct.innerHTML = html;
// Update active highlight
var allCards = grid.querySelectorAll(".tutnav-card");
for (var j = 0; j < allCards.length; j++) {
allCards[j].classList.remove("tutnav-card-active");
}
if (cardEl) cardEl.classList.add("tutnav-card-active");
// Scroll to top so user sees the updated section
var scrollEl = document.getElementById("tutorials_list");
if (scrollEl) scrollEl.scrollTop = 0;
}
var pathParts = window.location.pathname.split("/").filter(Boolean);
var seg1 = (pathParts[0] || "").toLowerCase();
var seg2 = (pathParts[1] || "").toLowerCase();
var activeName = pathToName[seg2] || pathToName[seg1] || "";
// Special handling for Bootstrap 3 (bootstrap/default.asp should map to bootstrap3)
if (seg1 === "bootstrap" && seg2 === "default" && !activeName) {
activeName = "bootstrap3";
}
if (activeName) {
var activeTopic = null;
for (var i = 0; i < topics.length; i++) {
if (topics[i].name === activeName) {
activeTopic = topics[i];
break;
}
}
if (activeTopic) {
updateTopSection(activeTopic);
}
} else {
// Show default tutorial heading for folders not in tutorial list
var mainHeading = document.getElementById("tutnav_main_heading");
var titleArea = document.getElementById("tutnav_title_area");
var currentTopic = document.getElementById("tutnav_current_topic");
if (mainHeading) mainHeading.style.display = "none";
if (titleArea) titleArea.innerHTML = "";
// Build certification card for tutorials default state
(function () {
var certUrl = "https://campus.w3schools.com/collections/course-catalog";
var w3Svg = '';
var previewSvg = '";
var cardHtml = '
' + '
Become W3Schools Certified
' + '
Get certified, and earn a credential that proves your skills.
' + '
From $95
' + '
Includes exam, course materials, exercises, and one year of the Hero plan.
';
var sectionHeading = document.querySelector(".refnav-section-heading");
if (sectionHeading) sectionHeading.style.display = "";
var refHeader = document.querySelector(".refnav-header");
if (refHeader) refHeader.classList.remove("filter-only");
container.innerHTML = cardHtml;
} else {
if (mainHeading) mainHeading.style.display = "none";
var w3Svg = '';
var certUrl2 = "https://campus.w3schools.com/collections/course-catalog";
var previewSvg2 = '";
var cardHtml = '
' + '
Become W3Schools Certified
' + '
Get certified, and earn a credential that proves your skills.
' + '
From $95
' + '
Includes exam, course materials, exercises, and one year of the Hero plan.
";
container.innerHTML = cardHtml;
var prev = document.querySelector("#nav_references .refnav-card-active");
if (prev) prev.classList.remove("refnav-card-active");
if (card) card.classList.add("refnav-card-active");
var scrollEl = document.querySelector("#nav_references .refnav-topics-scroll");
if (scrollEl) scrollEl.scrollTop = 0;
}
// Clone icons from Exercises cards (lazy � runs on first open)
var iconsCloned = false;
function cloneExerciseIcons() {
if (iconsCloned) return;
var refCards = document.querySelectorAll("#nav_references .refnav-card");
var anyCloned = false;
for (var i = 0; i < refCards.length; i++) {
var rc = refCards[i];
var dn = rc.getAttribute("data-name");
if (!dn) continue;
var exCard = document.querySelector('#nav_exercises .exnav-card[data-name="' + dn + '"]');
if (!exCard) continue;
var exIcon = exCard.querySelector(".exnav-icon-wrap svg");
if (!exIcon) continue;
var clonedSvg = exIcon.cloneNode(true);
var grads = clonedSvg.querySelectorAll("[id]");
for (var g = 0; g < grads.length; g++) {
grads[g].id = "ref-" + grads[g].id;
}
var fills = clonedSvg.querySelectorAll('[fill^="url("]');
for (var f = 0; f < fills.length; f++) {
var fv = fills[f].getAttribute("fill");
fills[f].setAttribute("fill", fv.replace("url(#", "url(#ref-"));
}
var iconWrap = rc.querySelector(".refnav-icon-wrap");
if (iconWrap) {
iconWrap.innerHTML = "";
iconWrap.appendChild(clonedSvg);
anyCloned = true;
}
}
if (anyCloned) {
iconsCloned = true;
if (activeRefTopic) showRefTopicCard(activeRefTopic);
else showDefaultRefCard();
}
}
if (activeRefTopic) showRefTopicCard(activeRefTopic);
else showDefaultRefCard();
var nav = document.getElementById("nav_references");
if (nav) {
// Clone icons when modal becomes visible
var observer = new MutationObserver(function () {
if (nav.style.display === "block") cloneExerciseIcons();
});
observer.observe(nav, { attributes: true, attributeFilter: ["style"] });
nav.addEventListener("click", function (e) {
var card = e.target.closest(".refnav-card");
if (!card) return;
var name = card.getAttribute("data-name");
if (!name) return;
var url = refUrlMap[name];
if (url) {
window.location.href = url;
}
});
}
// Populate references card icons from shared iconSvgs library
var refCards = document.querySelectorAll("#nav_references .refnav-card");
refCards.forEach(function (card) {
var topicName = card.getAttribute("data-name");
var iconWrap = card.querySelector(".refnav-icon-wrap");
if (iconWrap && window.iconSvgs && window.iconSvgs[topicName]) {
iconWrap.innerHTML = window.iconSvgs[topicName];
}
});
})();
";
// Show the "SELECT ANOTHER TOPIC:" heading when displaying specific exercise topics
var sectionHeading = document.querySelector("#nav_exercises .exnav-section-heading");
if (sectionHeading) sectionHeading.style.display = "";
// Remove filter-only class when heading is shown
var exHeader = document.querySelector("#nav_exercises .exnav-header");
if (exHeader) exHeader.classList.remove("filter-only");
var qaHtml = '
";
qaContainer.innerHTML = qaHtml;
var qaTip = document.getElementById("exnav_quick_tip");
if (qaTip) qaTip.style.display = "flex";
if (currentHighlight) currentHighlight.style.background = "";
var prevActive = document.querySelector("#nav_exercises .exnav-card-active");
if (prevActive) prevActive.classList.remove("exnav-card-active");
if (qaCard) {
qaCard.classList.add("exnav-card-active");
currentHighlight = qaCard;
}
var scrollEl = document.querySelector("#nav_exercises .exnav-topics-scroll");
if (scrollEl) scrollEl.scrollTop = 0;
var listEl = document.getElementById("exercises_list");
if (listEl) listEl.scrollTop = 0;
}
if (activeTopic) {
showTopicQuickActions(activeTopic);
} else {
// Show default exercises heading for folders not in exercise list
var mainHeading = document.getElementById("exnav_main_heading");
var quickActions = document.getElementById("exnav_quick_actions");
var sectionHeading = document.querySelector("#nav_exercises .exnav-section-heading");
if (mainHeading) mainHeading.innerHTML = '
W3SCHOOLS EXERCISES
';
if (sectionHeading) {
sectionHeading.style.display = "";
sectionHeading.textContent = "Select a topic:";
}
var exHeader = document.querySelector("#nav_exercises .exnav-header");
if (exHeader) exHeader.classList.remove("filter-only");
// Build multi-icon SVG: 2x2 grid of small topic icons
var pyIcon = (window.iconSvgs["python"] || "")
.replace(/id="tut-py-b"/g, 'id="def-py-b"')
.replace(/id="tut-py-y"/g, 'id="def-py-y"')
.replace(/url\(#tut-py-b\)/g, "url(#def-py-b)")
.replace(/url\(#tut-py-y\)/g, "url(#def-py-y)");
var defaultCards = [
{ title: "Exercises", desc: "Practice with interactive exercises", url: "/exercises/index.php", icon: qaIcons.exercises, btnText: "Browse Exercises", subtitle: "What is an Exercise?", subtitleUrl: "/exercises/index.php" },
{ title: "Quizzes", desc: "Test your knowledge", url: "/quiztest/default.asp", icon: qaIcons.quiz, btnText: "Browse Quizzes", subtitle: "What is a Quiz?", subtitleUrl: "/quiztest/default.asp" },
{ title: "Challenges", desc: "Solve coding challenges", url: "/challenges/index.php", icon: qaIcons.challenges, btnText: "Browse Challenges", subtitle: "What is a Challenge?", subtitleUrl: "/challenges/index.php" },
{ title: "Practice Problems", desc: "Solve real-life coding problems", url: "/practice/index.php", icon: qaIcons.problems, btnText: "Browse Problems", subtitle: "What is a Practice Problem?", subtitleUrl: "/practice/index.php" },
];
var defHtml = '
';
for (var d = 0; d < defaultCards.length; d++) {
var dc = defaultCards[d];
defHtml += '
Just like a while loop, a for loop may also never run.
If the condition is false right from the start, the code inside the loop will be skipped entirely:
Example
for (int i = 10; i < 5; i++) {
System.out.println("This will never be printed");
}