File tree Expand file tree Collapse file tree 2 files changed +4
-25
lines changed
Expand file tree Collapse file tree 2 files changed +4
-25
lines changed Original file line number Diff line number Diff line change 22import { loadDescription } from "./description.js" ;
33import { displayBoneImages , clearImages , showPlaceholder } from "./imageDisplay.js" ;
44import { loadAndDrawAnnotations , clearAnnotations } from "./annotationOverlay.js" ;
5+ import { fetchBoneData } from "./api.js" ;
56
67// Show the placeholder ASAP
78document . addEventListener ( "DOMContentLoaded" , ( ) => {
@@ -40,14 +41,7 @@ async function loadBoneImages(boneId, options = {}) {
4041 return ;
4142 }
4243 try {
43- const res = await fetch ( `${ API_BASE } /api/bone-data/?boneId=${ encodeURIComponent ( boneId ) } ` ) ;
44- if ( ! res . ok ) {
45- console . warn ( "bone-data API error:" , res . status , boneId ) ;
46- showPlaceholder ( ) ;
47- if ( stage ) { clearAnnotations ( stage ) ; stage . classList . remove ( "with-annotations" ) ; }
48- return ;
49- }
50- const data = await res . json ( ) ;
44+ const data = await fetchBoneData ( boneId ) ;
5145 const images = Array . isArray ( data . images ) ? data . images : [ ] ;
5246 if ( images . length === 0 ) {
5347 showPlaceholder ( ) ;
Original file line number Diff line number Diff line change 11// quiz.js - Quiz functionality for Digital Bones Box
22
3- import { fetchCombinedData } from "./api.js" ;
3+ import { fetchBoneData , fetchCombinedData } from "./api.js" ;
44
55class QuizManager {
66 constructor ( ) {
@@ -120,7 +120,6 @@ class QuizManager {
120120 itemName : correctItem . name ,
121121 correctAnswer : correctItem . name ,
122122 allAnswers : this . shuffleArray ( [ correctItem . name , ...wrongAnswers ] ) ,
123- imageUrl : this . getImageUrl ( correctItem . id )
124123 } ;
125124
126125 this . questions . push ( question ) ;
@@ -160,26 +159,12 @@ class QuizManager {
160159 return shuffled ;
161160 }
162161
163- /**
164- * Get image URL for an item....
165- */
166- getImageUrl ( itemId ) {
167- // Use the API endpoint that serves bone images
168- return `http://127.0.0.1:8000/api/bone-data/?boneId=${ encodeURIComponent ( itemId ) } ` ;
169- }
170-
171162 /**
172163 * Fetch and display bone image from API
173164 */
174165async fetchBoneImage ( itemId , container ) {
175166 try {
176- const response = await fetch ( `http://127.0.0.1:8000/api/bone-data/?boneId=${ encodeURIComponent ( itemId ) } ` ) ;
177-
178- if ( ! response . ok ) {
179- throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
180- }
181-
182- const data = await response . json ( ) ;
167+ const data = fetchBoneData ( itemId ) ;
183168
184169 console . log ( `Bone data for ${ itemId } :` , data ) ; // DEBUG
185170
You can’t perform that action at this time.
0 commit comments