MCPcopy Index your code
hub / github.com/braziljs/eloquente-javascript / parseFragment

Method parseFragment

src/client/code.mjs:182–204  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

180 }
181
182 parseFragment() {
183 let hash = document.location.hash.slice(1)
184 let valid = /^(\d+)(?:\.(\d+.*))?$/.exec(hash)
185 let chapter, exercise
186 if (valid) {
187 chapter = getChapter(Number(valid[1]))
188 exercise = chapter && valid[2] && findExercise(hash, chapter)
189 if (!chapter || valid[2] && !exercise) valid = null
190 }
191 if (valid) {
192 let perValue = exercise ? hash : "box", setPer = false
193 if (this.chapters.value != valid[1]) {
194 this.chapters.value = valid[1]
195 this.selectChapter(Number(valid[1]), perValue)
196 setPer = true
197 }
198 if (this.per.value != perValue) {
199 this.per.value = perValue
200 if (!setPer) this.selectContext(perValue)
201 }
202 return true
203 }
204 }
205}
206
207function hasIncludes(code, include) {

Callers 1

constructorMethod · 0.95

Calls 5

selectChapterMethod · 0.95
selectContextMethod · 0.95
getChapterFunction · 0.85
findExerciseFunction · 0.85
sliceMethod · 0.45

Tested by

no test coverage detected