@@ -447,11 +447,17 @@ window.BaseController = class BaseController {
447447 /**
448448 * Initialize controller
449449 */
450- initialize ( targetElement ) {
451- this . targetElement = targetElement ;
452-
453- // Set up event handlers
454- this . setupPageEventHandlers ( ) ;
450+ initialize ( skipPageHandlers ) {
451+ if ( ! skipPageHandlers ) {
452+ const targetElement = document . getElementById ( "target" ) ;
453+ if ( ! targetElement ) {
454+ console . error ( 'Target element not found' ) ;
455+ return ;
456+ }
457+ this . targetElement = targetElement ;
458+ // Set up event handlers
459+ this . setupPageEventHandlers ( ) ;
460+ }
455461
456462 // Set up UI buttons
457463 this . setupButtons ( ) ;
@@ -2390,13 +2396,6 @@ window.SelectorController = class SelectorController extends BaseController {
23902396
23912397// Simple initialization on DOM ready - directly instantiates the right controller
23922398document . addEventListener ( 'DOMContentLoaded' , function ( ) {
2393-
2394- const targetElement = document . getElementById ( "target" ) ;
2395- if ( ! targetElement ) {
2396- console . error ( 'Target element not found' ) ;
2397- return ;
2398- }
2399-
24002399 // Get controller type from meta tag
24012400 const metaTag = document . querySelector ( 'meta[name="controller-type"]' ) ;
24022401 if ( ! metaTag ) {
@@ -2410,19 +2409,18 @@ document.addEventListener('DOMContentLoaded', function() {
24102409 let controller ;
24112410 if ( controllerType === 'navigator' ) {
24122411 controller = new NavigatorController ( ) ;
2412+ controller . initialize ( ) ;
24132413 } else if ( controllerType === 'selector' ) {
24142414 controller = new SelectorController ( ) ;
2415+ controller . initialize ( ) ;
24152416 } else if ( controllerType === 'inspector' ) { // ADD THIS BLOCK
24162417 controller = new InspectorController ( ) ;
2418+ controller . initialize ( true ) ;
24172419 } else {
24182420 console . error ( 'Invalid controller type: ' + controllerType ) ;
24192421 return ;
24202422 }
24212423
2422- // Initialize it directly - this sets everything up
2423- // including event handling and motion tracking
2424- controller . initialize ( targetElement ) ;
2425-
24262424 // Make controller globally accessible
24272425 window . controller = controller ;
24282426} ) ;
@@ -2431,11 +2429,13 @@ window.InspectorController = class InspectorController extends BaseController {
24312429 constructor ( ) {
24322430 super ( 'inspector' ) ; // Client type
24332431 this . jsonOutputElement = null ;
2432+ this . iFrameElement = null ;
24342433 }
24352434
24362435 setupControllerSpecificUI ( ) {
24372436 this . logEvent ( 'Init' , 'Setting up Inspector-specific UI' ) ;
24382437 this . jsonOutputElement = document . getElementById ( 'inspector-json-output' ) ;
2438+ this . iFrameElement = document . getElementById ( 'inspector-iframe' ) ;
24392439 if ( ! this . jsonOutputElement ) {
24402440 this . logEvent ( 'Error' , 'Inspector JSON output element not found!' ) ;
24412441 }
@@ -2444,9 +2444,11 @@ window.InspectorController = class InspectorController extends BaseController {
24442444 // This method will be called when the selected item data changes
24452445 selectedItemChanged ( selectedItemJSON ) {
24462446 this . logEvent ( 'Inspector' , 'Received new selected item JSON:' , selectedItemJSON ) ;
2447- if ( this . jsonOutputElement ) {
2447+ if ( this . iFrameElement ) {
24482448 if ( selectedItemJSON ) {
2449- this . jsonOutputElement . textContent = JSON . stringify ( selectedItemJSON , null , 2 ) ;
2449+ // this.jsonOutputElement.innerHTML = JSON.stringify(selectedItemJSON)
2450+ this . iFrameElement . src = `https://archive.org/details/${ selectedItemJSON [ 'id' ] } ` ;
2451+ this . jsonOutputElement . textContent = JSON . stringify ( selectedItemJSON ) ;
24502452 } else {
24512453 this . jsonOutputElement . textContent = 'No item currently selected.' ;
24522454 }
0 commit comments