@@ -17,13 +17,14 @@ document.getElementById('goToCustomImage').addEventListener('click', () => {
1717
1818
1919window . onload = ( ) => {
20- ipcRenderer . on ( 'image-loaded' , ( event , { imageUrl , videoUrl, dimmingDetailsUrl } ) => {
21- render ( imageUrl ) ;
20+ ipcRenderer . on ( 'image-loaded' , ( event , { apiUrl , videoUrl, dimmingDetailsUrl } ) => {
21+ loadlinkDetails ( apiUrl , '#moveJPEG' ) ;
2222 playVideo ( videoUrl ) ;
2323 loadDimmingDetails ( dimmingDetailsUrl , '#moveJPEG' ) ;
2424 } ) ;
2525} ;
2626
27+ /*
2728function render(imageUrl) {
2829 const resultImage = document.getElementById('resultImage');
2930
@@ -33,6 +34,7 @@ function render(imageUrl) {
3334
3435 resultImage.src = imageUrl;
3536}
37+ */
3638
3739function playVideo ( videoUrl ) {
3840 // Prepend 'file://' to the local file path
@@ -55,7 +57,97 @@ function playVideo(videoUrl) {
5557}
5658
5759
60+ let intervalId_1 ; // Variable to store the interval ID
5861
62+ function loadlinkDetails ( apiUrl ) {
63+ // Fetch HTML content from the website
64+ fetch ( apiUrl )
65+ . then ( response => response . text ( ) )
66+ . then ( html => {
67+ // Extract image information from the JavaScript code
68+ const regex = / m y _ i m a g e s \[ \d + \] \s * = \s * ' ( [ ^ ' ] + ) ' / g;
69+ const matches = html . matchAll ( regex ) ;
70+
71+ const imageUrls_1 = [ ] ;
72+ for ( const match of matches ) {
73+ // Construct complete URLs using the base URL
74+ const baseUrl = 'https://www.sidc.be/solardemon/science/' ;
75+ const completeUrl = new URL ( match [ 1 ] , baseUrl ) ;
76+ imageUrls_1 . push ( completeUrl . href ) ;
77+ }
78+
79+ if ( imageUrls_1 . length > 0 ) {
80+ // Display the image URLs (replace this with your own logic)
81+ console . log ( 'Image URLs 1:' , imageUrls_1 ) ;
82+
83+ // Clear existing interval and display the first image
84+ resetImageSequence_1 ( imageUrls_1 ) ;
85+ } else {
86+ console . error ( 'No image URLs found in the website content.' ) ;
87+ }
88+ } )
89+ . catch ( error => console . error ( 'Error loading website content:' , error ) ) ;
90+ }
91+
92+ function resetImageSequence_1 ( imageUrls_1 ) {
93+ clearInterval ( intervalId_1 ) ; // Clear existing interval
94+
95+ let currentIndex = 0 ;
96+
97+ // Display the first image
98+ displayImage_1 ( imageUrls_1 [ currentIndex ] ) ;
99+
100+ // Set interval to change the displayed image
101+ intervalId_1 = setInterval ( ( ) => {
102+ currentIndex = ( currentIndex + 1 ) % imageUrls_1 . length ;
103+ displayImage_1 ( imageUrls_1 [ currentIndex ] ) ;
104+ } , 100 ) ; // Change the interval time (in milliseconds) as needed
105+ }
106+
107+ function displayImage_1 ( imageUrl_1 ) {
108+ // Replace this with your logic to display the image
109+ console . log ( 'Displaying image:' , imageUrl_1 ) ;
110+ // Your display logic here
111+ }
112+
113+ // Event listeners for the buttons
114+ document . getElementById ( 'previousImage' ) . addEventListener ( 'click' , ( ) => {
115+ clearInterval ( intervalId_1 ) ; // Clear existing interval
116+ // Your logic for going to the previous image here
117+ } ) ;
118+
119+ document . getElementById ( 'nextImage' ) . addEventListener ( 'click' , ( ) => {
120+ clearInterval ( intervalId_1 ) ; // Clear existing interval
121+ // Your logic for going to the next image here
122+ } ) ;
123+
124+ document . getElementById ( 'goToCustomImage' ) . addEventListener ( 'click' , ( ) => {
125+ clearInterval ( intervalId_1 ) ; // Clear existing interval
126+ // Your logic for going to a custom image based on the input value here
127+ } ) ;
128+
129+
130+ function displayImage_1 ( imageUrl_1 ) {
131+ // Construct the absolute URL using the base URL of the website
132+ const baseURL_1 = new URL ( imageUrl_1 ) . origin ;
133+ const absoluteURL_1 = new URL ( imageUrl_1 , baseURL_1 ) . toString ( ) ;
134+
135+ // Find the container element where you want to display the image
136+ const resultImage = document . getElementById ( 'resultImage' ) ;
137+
138+ // Check if the container element is found
139+ if ( resultImage ) {
140+
141+
142+ resultImage . width = 600 ; // Replace with your preferred width
143+ resultImage . height = 600 ; // Replace with your preferred height
144+
145+ // Set the src attribute to trigger the image loading
146+ resultImage . src = absoluteURL_1 ;
147+ } else {
148+ console . error ( 'Image container not found.' ) ;
149+ }
150+ }
59151
60152// Your existing code...
61153
@@ -147,7 +239,7 @@ function displayImage(imageUrl) {
147239
148240 imgElement . width = 600 ; // Replace with your preferred width
149241 imgElement . height = 600 ; // Replace with your preferred height
150-
242+
151243 // Set the src attribute to trigger the image loading
152244 imgElement . src = absoluteURL ;
153245 } else {
@@ -166,7 +258,7 @@ ipcRenderer.on('image-loaded', (event, data) => {
166258function updateCsvTable ( csvRowData ) {
167259 console . log ( 'Updating table with data:' , csvRowData ) ;
168260
169- const includedProperties = [ 'cmeId' , 'cmeDate' , 'cmePa' , 'cme_width' , 'harpnum' , 'LONDTMIN' , 'LONDTMAX' , 'LATDTMIN' , 'LATDTMAX' , 'flare_id' , 'dimming_id' , 'verification_score' ] ; // Add properties to include
261+ const includedProperties = [ 'cmeId' , 'cmeDate' , 'cmePa' , 'cme_width' , 'harpnum' , 'LONDTMIN' , 'LONDTMAX' , 'LATDTMIN' , 'LATDTMAX' , 'flare_id' , 'dimming_id' , 'verification_score' ] ; // Add properties to include
170262
171263 const tbody = csvDataTable . querySelector ( 'tbody' ) ;
172264 const row = document . createElement ( 'tr' ) ;
@@ -184,14 +276,14 @@ function updateCsvTable(csvRowData) {
184276 } ) ;
185277 }
186278
187- Object . keys ( csvRowData ) . forEach ( ( key ) => {
188- if ( includedProperties . includes ( key ) ) {
189- const cell = document . createElement ( 'td' ) ;
190- const cellContent = csvRowData [ key ] !== undefined ? csvRowData [ key ] . toString ( ) : '' ;
191- cell . innerHTML = cellContent ;
192- row . appendChild ( cell ) ;
193- }
194- } ) ;
279+ Object . keys ( csvRowData ) . forEach ( ( key ) => {
280+ if ( includedProperties . includes ( key ) ) {
281+ const cell = document . createElement ( 'td' ) ;
282+ const cellContent = csvRowData [ key ] !== undefined ? csvRowData [ key ] . toString ( ) : '' ;
283+ cell . innerHTML = cellContent ;
284+ row . appendChild ( cell ) ;
285+ }
286+ } ) ;
195287
196288 // Clear existing rows and append the new row
197289 tbody . innerHTML = '' ;
@@ -206,55 +298,55 @@ let imageContainer;
206298let draggableContainers = [ ] ;
207299
208300document . addEventListener ( 'DOMContentLoaded' , ( ) => {
209- const toggleButton = document . getElementById ( 'toggleButton' ) ;
210- imageContainer = document . getElementById ( 'imageContainer' ) ;
211-
212- for ( let i = 1 ; i <= 2 ; i ++ ) {
213- const draggableContainer = document . getElementById ( `draggableContainer${ i } ` ) ;
214- draggableContainers . push ( draggableContainer ) ;
215-
216- interact ( draggableContainer )
217- . draggable ( {
218- onmove : ( event ) => dragMoveListener ( event , i ) ,
219- } )
220- . resizable ( {
221- edges : { left : true , right : true , bottom : true , top : true } ,
222- onmove : ( event ) => resizeMoveListener ( event , i ) ,
223- } ) ;
224- }
301+ const toggleButton = document . getElementById ( 'toggleButton' ) ;
302+ imageContainer = document . getElementById ( 'imageContainer' ) ;
303+
304+ for ( let i = 1 ; i <= 2 ; i ++ ) {
305+ const draggableContainer = document . getElementById ( `draggableContainer${ i } ` ) ;
306+ draggableContainers . push ( draggableContainer ) ;
307+
308+ interact ( draggableContainer )
309+ . draggable ( {
310+ onmove : ( event ) => dragMoveListener ( event , i ) ,
311+ } )
312+ . resizable ( {
313+ edges : { left : true , right : true , bottom : true , top : true } ,
314+ onmove : ( event ) => resizeMoveListener ( event , i ) ,
315+ } ) ;
316+ }
225317
226- toggleButton . addEventListener ( 'click' , toggleImage ) ;
318+ toggleButton . addEventListener ( 'click' , toggleImage ) ;
227319
228- document . addEventListener ( 'keydown' , ( event ) => {
229- if ( event . key === 'Escape' ) {
230- toggleImage ( ) ;
231- }
232- } ) ;
320+ document . addEventListener ( 'keydown' , ( event ) => {
321+ if ( event . key === 'Escape' ) {
322+ toggleImage ( ) ;
323+ }
324+ } ) ;
233325} ) ;
234326
235327function toggleImage ( ) {
236- isImageVisible = ! isImageVisible ;
237- imageContainer . classList . toggle ( 'hidden' , ! isImageVisible ) ;
328+ isImageVisible = ! isImageVisible ;
329+ imageContainer . classList . toggle ( 'hidden' , ! isImageVisible ) ;
238330}
239331
240332function dragMoveListener ( event , index ) {
241- const target = event . target ;
242- const x = ( parseFloat ( target . getAttribute ( 'data-x' ) ) || 0 ) + event . dx ;
243- const y = ( parseFloat ( target . getAttribute ( 'data-y' ) ) || 0 ) + event . dy ;
333+ const target = event . target ;
334+ const x = ( parseFloat ( target . getAttribute ( 'data-x' ) ) || 0 ) + event . dx ;
335+ const y = ( parseFloat ( target . getAttribute ( 'data-y' ) ) || 0 ) + event . dy ;
244336
245- target . style . transform = 'translate(' + x + 'px, ' + y + 'px)' ;
246- target . setAttribute ( 'data-x' , x ) ;
247- target . setAttribute ( 'data-y' , y ) ;
337+ target . style . transform = 'translate(' + x + 'px, ' + y + 'px)' ;
338+ target . setAttribute ( 'data-x' , x ) ;
339+ target . setAttribute ( 'data-y' , y ) ;
248340}
249341
250342function resizeMoveListener ( event , index ) {
251- const target = event . target ;
252- const x = ( parseFloat ( target . getAttribute ( 'data-x' ) ) || 0 ) ;
253- const y = ( parseFloat ( target . getAttribute ( 'data-y' ) ) || 0 ) ;
343+ const target = event . target ;
344+ const x = ( parseFloat ( target . getAttribute ( 'data-x' ) ) || 0 ) ;
345+ const y = ( parseFloat ( target . getAttribute ( 'data-y' ) ) || 0 ) ;
254346
255- target . style . width = event . rect . width + 'px' ;
256- target . style . height = event . rect . height + 'px' ;
347+ target . style . width = event . rect . width + 'px' ;
348+ target . style . height = event . rect . height + 'px' ;
257349
258- target . setAttribute ( 'data-x' , x ) ;
259- target . setAttribute ( 'data-y' , y ) ;
350+ target . setAttribute ( 'data-x' , x ) ;
351+ target . setAttribute ( 'data-y' , y ) ;
260352}
0 commit comments