1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+ < title > Photo Gallery</ title >
7
+ < link rel ="stylesheet " href ="JS_final_gallery.css ">
8
+ < script >
9
+ function upDate ( previewPic ) {
10
+ previewPic . style . opacity = 1.0 ;
11
+ console . log ( 'upDate function encountered' ) ;
12
+ const x = document . getElementById ( "image" ) ;
13
+ x . innerHTML = previewPic . alt ;
14
+ x . style . backgroundImage = 'url("' + previewPic . src + '")' ;
15
+ x . style . backgroundColor = "#25efbc"
16
+ console . log ( previewPic . src ) ;
17
+ x . style . backgroundRepeat = "no-repeat" ;
18
+ x . style . backgroundSize = "100% 100%" ;
19
+ }
20
+
21
+ function unDo ( previewPic ) {
22
+ previewPic . style . opacity = 0.5 ;
23
+ console . log ( 'unDo function encountered' ) ;
24
+ const x = document . getElementById ( "image" ) ;
25
+ x . style . backgroundImage = "url('')" ;
26
+ x . style . backgroundRepeat = "no-repeat" ;
27
+ x . style . backgroundColor = "#8e68ff"
28
+ x . innerHTML = "Hover over an image below to display here." ;
29
+ }
30
+
31
+ function focus_func ( previewPic ) {
32
+ previewPic . style . opacity = 1.0 ;
33
+ console . log ( "onfocus event encountered" ) ;
34
+ const x = document . getElementById ( "image" ) ;
35
+ x . innerHTML = previewPic . alt ;
36
+ x . style . backgroundImage = 'url("' + previewPic . src + '")' ;
37
+ x . style . backgroundColor = "#25efbc" ;
38
+ console . log ( previewPic . src ) ;
39
+ x . style . backgroundRepeat = "no-repeat" ;
40
+ x . style . backgroundSize = "100% 100%" ;
41
+ }
42
+
43
+ function blur_func ( previewPic ) {
44
+ previewPic . style . opacity = 0.5 ;
45
+ console . log ( "onblur event encountered" ) ;
46
+ const x = document . getElementById ( "image" ) ;
47
+ x . style . backgroundImage = "url('')" ;
48
+ x . style . backgroundRepeat = "no-repeat" ;
49
+ x . style . backgroundColor = "#8e68ff"
50
+ x . innerHTML = "Hover over an image below to display here." ;
51
+ }
52
+
53
+ function setTabIndex ( ) {
54
+ console . log ( "onload event encountered" ) ;
55
+ images = document . querySelectorAll ( ".preview" ) ;
56
+ for ( let i = 0 ; i < images . length ; i ++ ) {
57
+ console . log ( "Image" + ( i + 1 ) )
58
+ images [ i ] . setAttribute ( "tabindex" , i + 1 ) ;
59
+ }
60
+ }
61
+ </ script >
62
+ </ head >
63
+ < body onload ="setTabIndex() ">
64
+ < div id ="image ">
65
+ Hover over an image below to display here.
66
+ </ div >
67
+
68
+ < img class ="preview " src ="mount_fuji.jpg " alt ="Picture of Mount Fuji, Japan "
69
+ onmouseover ="upDate(this) " onmouseout ="unDo(this) " onfocus ="focus_func(this) " onblur ="blur_func(this) ">
70
+
71
+ < img class ="preview " src ="Cherry_blossoms.jpeg " alt ="Picture of Cherry Blossoms "
72
+ onmouseover ="upDate(this) " onmouseout ="unDo(this) " onfocus ="focus_func(this) " onblur ="blur_func(this) ">
73
+
74
+ < img class ="preview " src ="kyoto.jpg " alt ="Picture of Kyoto, Japan "
75
+ onmouseover ="upDate(this) " onmouseout ="unDo(this) " onfocus ="focus_func(this) " onblur ="blur_func(this) ">
76
+
77
+ < img class ="preview " src ="Switzerland.jpg " alt ="Picture of Switzerland "
78
+ onmouseover ="upDate(this) " onmouseout ="unDo(this) " onfocus ="focus_func(this) " onblur ="blur_func(this) ">
79
+
80
+ < img class ="preview " src ="Victoria_Falls.jpg " alt ="Picture of Victoria Falls "
81
+ onmouseover ="upDate(this) " onmouseout ="unDo(this) " onfocus ="focus_func(this) " onblur ="blur_func(this) ">
82
+
83
+ < img class ="preview " src ="River_Ganga.jpg " alt ="Picture of River Ganga, India "
84
+ onmouseover ="upDate(this) " onmouseout ="unDo(this) " onfocus ="focus_func(this) " onblur ="blur_func(this) ">
85
+ </ body >
86
+ </ html >
0 commit comments