Improve AboutPage layout
[quandoparte] / www / screenshot-generator.js
1 var screenshots = {
2         "@1" : "Version 0.6.0 for Sailfish OS",
3         "sailfishos-screenshot-stationlist.png" : "The Station List View",
4         "sailfishos-screenshot-stationview.png" : "The Station Departures View",
5         "@2" : "Version 0.5.0 for Meego Harmattan N9/N950",
6         "harmattan-screenshot-stationlist.png" : "The Station List View",
7         "harmattan-screenshot-stationview.png" : "The Station Departures View",
8         "@3" : "Version 0.4.3 for Maemo 5 N900",
9         "screenshot-stationlist.png" : "The Station List View",
10         "screenshot-stationview.png" : "The Station Departures View",
11         "screenshot-stationlist-menu.png" : "The Station List Menu",
12         "screenshot-stationview-menu.png" : "The Station Departures Menu",
13 };
14
15 function dismiss_picture()
16 {
17         var parent = this.parentNode;
18         parent.style.opacity = 0.0;
19         parent.style.visibility = 'hidden';
20         parent.display = 'none';
21 }
22
23 function present_picture()
24 {
25         var display = document.getElementById('picture-display');
26         parent.display = 'block';
27         display.style.visibility = 'visible';
28         display.style.opacity = 1.0;
29         display.style.left = (window.width  - display.width) / 2;
30         display.style.top = (window.height  - display.height) / 2;
31         var picture = document.getElementById('picture-display-picture');
32         picture.setAttribute('src', this.getAttribute('src'));
33 }
34
35 function generate_div(value, index, array)
36 {
37         var screenshots = document.getElementById('screenshot-list');
38         var screenshotDiv = document.createElement('div');
39         screenshotDiv.setAttribute('class', 'screenshot');
40         
41         var p1Element = document.createElement('div');
42         var p2Element = p1Element.cloneNode(true);
43         
44         var aElement = document.createElement('img');
45         aElement.setAttribute('src', index);
46         if (aElement.addEventListener) {
47                 aElement.addEventListener('click', present_picture, true);
48         } else if (aElement.attachEvent) {
49                 aElement.attachEvent('onclick', show_picture);
50         }
51
52         var imgElement = document.createElement('img');
53         imgElement.setAttribute('src', index);
54
55         var captionElement = document.createTextNode(value);
56
57         p1Element.appendChild(aElement);
58         aElement.appendChild(imgElement);
59         p2Element.appendChild(captionElement);
60
61         screenshotDiv.appendChild(p1Element);
62         screenshotDiv.appendChild(p2Element);
63         screenshots.appendChild(screenshotDiv);
64 }
65
66 function generate_section(value, index, array)
67 {
68         var screenshots = document.getElementById('screenshot-list');
69         var sectionElement = document.createElement('h3');
70         var captionElement = document.createTextNode(value);
71         
72         sectionElement.appendChild(captionElement);
73         screenshots.appendChild(sectionElement);
74 }
75
76 function build_screenshot_list()
77 {
78         for (var key in screenshots) {
79                 if (key.match(/^@.*/)) 
80                         generate_section(screenshots[key], key, screenshots);
81                 else
82                         generate_div(screenshots[key], key, screenshots);
83         }
84
85         var element = document.getElementById('picture-display-picture');
86         if (element.addEventListener) {
87                 element.addEventListener('click', dismiss_picture, false);
88         } else if (element.attachEvent) {
89                 window.attachEvent('onclick', dismiss_picture);
90         }
91 }
92
93 if (window.addEventListener) {
94         window.addEventListener('load', build_screenshot_list, false);
95 } else if (window.attachEvent) {
96         window.attachEvent('onload', build_screenshot_list);
97 }