1// Create the sidebar menus for each OS and Cloud Partner 2 3// For pytorch.md page: build sidebar from all h2/h3 tags in the article 4if ($('.pytorch-2').length > 0) { 5 buildSidebarMenu('.pytorch-article', '#get-started-locally-sidebar-list'); 6 $('.get-started-locally-sidebar li').show(); // Show all items for pytorch page 7} 8 9$([".macos", ".linux", ".windows"]).each(function(index, osClass) { 10 buildSidebarMenu(osClass, "#get-started-locally-sidebar-list"); 11}); 12 13$([".alibaba", ".aws", ".microsoft-azure", ".google-cloud", ".lightning-studios"]).each(function(index, cloudPartner) { 14 buildSidebarMenu(cloudPartner, "#get-started-cloud-sidebar-list"); 15}); 16 17$(["macos", "linux", "windows"]).each(function(index, osClass) { 18 $("#" + osClass).on("click", function() { 19 showSidebar(osClass, ".get-started-locally-sidebar li"); 20 }); 21}); 22 23// Show cloud partner side nav on click or hide side nav if already open 24$(["alibaba", "aws", "microsoft-azure", "google-cloud", "lightning-studios"]).each(function(index, sidebarClass) { 25 $("#" + sidebarClass).click(function() { 26 showSidebar(sidebarClass, ".get-started-cloud-sidebar li"); 27 // alibaba filter for centering cloud module 28 if (sidebarClass == "alibaba") { 29 $(".article-wrapper").parent().removeClass("col-md-8 offset-md-1").addClass("col-md-12"); 30 $(".cloud-nav").hide(); 31 } else { 32 $(".article-wrapper").parent().removeClass("col-md-12").addClass("col-md-8 offset-md-1"); 33 $(".cloud-nav").show(); 34 } 35 if ($("#" + sidebarClass).parent().hasClass("open")) { 36 $(".get-started-cloud-sidebar li").hide(); 37 $(".cloud-nav").hide(); 38 $(".article-wrapper").parent().removeClass("col-md-8 offset-md-1").addClass("col-md-12"); 39 } 40 }) 41}); 42 43function buildSidebarMenu(menuClass, menuItem) { 44 var currentH2 = null; 45 var h2Index = 0; 46 47 $(menuClass + " > h2," + menuClass + " > h3").each(function(index, element) { 48 menuClass = menuClass.replace(".", ""); 49 var tagName = $(element).get(0).tagName; 50 51 if (tagName == "H2") { 52 // H2 í목: í ê¸ ê°ë¥í ë©ì¸ ìì´í 53 h2Index++; 54 var h2Id = "sidebar-h2-" + h2Index; 55 currentH2 = h2Id; 56 57 $(menuItem).append( 58 "<li class='" + menuClass + " sidebar-h2' data-h2-id='" + h2Id + "' style='display:none'>" + 59 "<a href='#" + this.id + "' class='sidebar-h2-link'>" + 60 "<span class='toggle-icon'>â¸</span>" + 61 "<span class='menu-text'>" + this.textContent + "</span>" + 62 "</a>" + 63 "</li>" 64 ); 65 } else if (tagName == "H3" && currentH2) { 66 // H3 í목: ì¨ê²¨ì§ ìë¸ìì´í 67 $(menuItem).append( 68 "<li class='" + menuClass + " subitem sidebar-h3' data-parent='" + currentH2 + "' style='display:none'>" + 69 "<a href='#" + this.id + "'>" + this.textContent + "</a>" + 70 "</li>" 71 ); 72 } 73 }); 74} 75 76function showSidebar(selectedClass, menuItem) { 77 // Hide all of the menu items at first 78 // Then filter for the selected OS/cloud partner 79 $(menuItem) 80 .hide() 81 .filter(function() { 82 return $(this) 83 .attr("class") 84 .includes(selectedClass); 85 }) 86 .show(); 87} 88 89// H2 í ê¸ ê¸°ë¥ 90$(document).on("click", ".get-started-locally-sidebar li.sidebar-h2 .sidebar-h2-link", function(e) { 91 var $li = $(this).closest("li"); 92 var h2Id = $li.data("h2-id"); 93 var $icon = $li.find(".toggle-icon"); 94 var $children = $(".get-started-locally-sidebar li.sidebar-h3[data-parent='" + h2Id + "']"); 95 96 // í ê¸ ìì´ì½ í´ë¦ ììë§ í¼ì¹¨/ì í, í ì¤í¸ í´ë¦ ììë ì¤í¬ë¡¤ë§ 97 var isIconClick = $(e.target).hasClass("toggle-icon") || $(e.target).closest(".toggle-icon").length > 0; 98 99 if (isIconClick) { 100 e.preventDefault(); 101 102 // í ê¸ ìí ë³ê²½ 103 if ($li.hasClass("expanded")) { 104 $li.removeClass("expanded"); 105 $icon.text("â¸"); 106 $children.slideUp(200); 107 } else { 108 $li.addClass("expanded"); 109 $icon.text("â¾"); 110 $children.slideDown(200); 111 } 112 } else { 113 // í ì¤í¸ í´ë¦ ì í´ë¹ ì¹ì ì¼ë¡ ì¤í¬ë¡¤ 114 removeActiveClass(); 115 addActiveClass($li); 116 } 117}); 118 119// H3 ë§í¬ í´ë¦ ì 120$(document).on("click", ".get-started-locally-sidebar li.sidebar-h3 a", function() { 121 removeActiveClass(); 122 addActiveClass($(this).closest("li")); 123}); 124 125// ì¤í¬ë¡¤ ì íì¬ ì¹ì íì´ë¼ì´í¸ ë° ìë íì¥ 126var scrollTimeout; 127$(window).on("scroll", function() { 128 clearTimeout(scrollTimeout); 129 scrollTimeout = setTimeout(function() { 130 updateActiveSection(); 131 }, 100); 132}); 133 134function updateActiveSection() { 135 if ($('.pytorch-2').length === 0) return; 136 137 var scrollPos = $(window).scrollTop() + 100; 138 var $h2Elements = $(".pytorch-article > h2"); 139 var $h3Elements = $(".pytorch-article > h3"); 140 var currentH2 = null; 141 var currentH3 = null; 142 143 // íì¬ ë³´ê³ ìë H2 찾기 144 $h2Elements.each(function() { 145 if ($(this).offset().top <= scrollPos) { 146 currentH2 = $(this).attr("id"); 147 } 148 }); 149 150 // íì¬ ë³´ê³ ìë H3 찾기 151 $h3Elements.each(function() { 152 if ($(this).offset().top <= scrollPos) { 153 currentH3 = $(this).attr("id"); 154 } 155 }); 156 157 if (currentH2) { 158 var $activeH2 = $(".get-started-locally-sidebar li.sidebar-h2 a[href='#" + currentH2 + "']").closest("li"); 159 160 // 먼ì 모ë ì¹ì ì ì ê³ íì¬ ì¹ì ë§ íì¥ 161 if ($activeH2.length) { 162 // ë¤ë¥¸ 모ë H2 ì¹ì ì 기 163 $(".get-started-locally-sidebar li.sidebar-h2").not($activeH2).each(function() { 164 var $otherH2 = $(this); 165 if ($otherH2.hasClass("expanded")) { 166 $otherH2.removeClass("expanded"); 167 $otherH2.find(".toggle-icon").text("â¸"); 168 var otherId = $otherH2.data("h2-id");
169 $(".get-started-locally-sidebar li.sidebar-h3[data-parent='" + otherId + "']").slideUp(200); 170 } 171 }); 172 173 // íì¬ ì¹ì ìë íì¥ 174 if (!$activeH2.hasClass("expanded")) { 175 var h2Id = $activeH2.data("h2-id"); 176 $activeH2.addClass("expanded"); 177 $activeH2.find(".toggle-icon").text("â¾"); 178 $(".get-started-locally-sidebar li.sidebar-h3[data-parent='" + h2Id + "']").slideDown(200); 179 } 180 } 181 182 removeActiveClass(); 183 184 if (currentH3) { 185 var $activeH3 = $(".get-started-locally-sidebar li.sidebar-h3 a[href='#" + currentH3 + "']").closest("li"); 186 if ($activeH3.length) { 187 addActiveClass($activeH3); 188 return; 189 } 190 } 191 192 addActiveClass($activeH2); 193 } 194} 195 196// íì´ì§ ë¡ë ì ì´ê¸° ì¹ì ì ë°ì´í¸ (모ë ë©ë´ ì í ìíë¡ ìì) 197$(document).ready(function() { 198 if ($('.pytorch-2').length > 0) { 199 setTimeout(function() { 200 updateActiveSection(); 201 }, 100); 202 } 203}); 204 205function removeActiveClass() { 206 $(".get-started-locally-sidebar li a").each(function() { 207 $(this).removeClass("active"); 208 }); 209} 210 211function addActiveClass(element) { 212 $(element) 213 .find("a") 214 .addClass("active"); 215} 216 217if ($("#get-started-locally-sidebar-list").text() == "") { 218 $("#get-started-shortcuts-menu").hide(); 219}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.