MCPcopy Index your code
hub / github.com/marijnh/Eloquent-JavaScript / selectChapter

Method selectChapter

src/client/code.mjs:157–180  ·  view source on GitHub ↗
(number, context)

Source from the content-addressed store, hash-verified

155 }
156
157 selectChapter(number, context) {
158 this.per.textContent = ""
159 let chapter = getChapter(number)
160 if (chapter.exercises.length) {
161 this.per.appendChild(opt("box", "Select an exercise"))
162 chapter.exercises.forEach(exercise => {
163 let num = chapter.number + "." + exercise.number
164 this.per.appendChild(opt(num, num + " " + exercise.name))
165 })
166 } else {
167 this.per.appendChild(opt("box", "This chapter has no exercises"))
168 }
169 this.fileInfo.style.display = this.runLocally.style.display = "none"
170 this.fileList.textContent = this.localFileList.textContent = ""
171 if (chapter.links) chapter.links.forEach((file, i) => {
172 if (!i) this.runLocally.style.display = ""
173 addItem(this.localFileList, file)
174 })
175 if (chapter.include) chapter.include.forEach((file, i) => {
176 if (!i) this.fileInfo.style.display = ""
177 if (!/(^|\/)_/.test(file)) addItem(this.fileList, file)
178 })
179 this.selectContext(context || "box")
180 }
181
182 parseFragment() {
183 let hash = document.location.hash.slice(1)

Callers 2

constructorMethod · 0.95
parseFragmentMethod · 0.95

Calls 4

selectContextMethod · 0.95
getChapterFunction · 0.85
optFunction · 0.85
addItemFunction · 0.85

Tested by

no test coverage detected