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