make javascript language independent again
[opensuse:software-o-o.git] / app / views / main / download.erb
1 var mymedium = "<%= @medium %>";
2
3 var mylink = '';
4 var myiso = '';
5 var directory = "<%= @directory %>";
6 var isos = new Array();
7 <% @isos.each { |key, value| %>
8   <%= "isos['#{key}'] = '#{value}';" %>
9 <% } %>
10
11 function changeiso () {
12   mylink = mymedium;
13   var arch_suffix = "-64";
14   if ($('#i686').attr('checked')) {
15     arch_suffix = "-32";
16   }
17   myiso = directory + "/iso/openSUSE-" + isos[mylink + arch_suffix] + ".iso";
18   mylink = myiso;
19   var download_suffix = '';
20   if ($('#p_torrent').attr('checked')) {
21     download_suffix = ".torrent";
22   }
23   if ($('#p_metalink').attr('checked')) {
24     download_suffix = ".metalink";
25   }
26   if ($('#p_mirror').attr('checked')) {
27     download_suffix = "?mirrorlist";
28   }
29   $('#sig_gpg').attr("href", myiso + ".asc");
30   $('#sig_md5').attr("href", myiso + ".md5");
31   $('#sig_sha1').attr("href", myiso + ".sha1");
32   mylink += download_suffix;
33
34   var langiso = directory + "/iso/openSUSE-" + isos['lang' + arch_suffix] + ".iso";
35   $('#md5_lang').attr('href', langiso + ".md5");
36   $('#sha1_lang').attr('href', langiso + ".sha1");
37   $('#gpg_lang').attr('href', langiso + ".asc");
38   $('#iso_lang').attr('href', langiso + download_suffix);
39   $('#iso_nonoss').attr('href', directory + "/iso/openSUSE-" + isos['nonoss'] + ".iso" + download_suffix);
40
41   $('#icon_' + mymedium).addClass('icon_selected').removeClass('icon_unselected');
42
43   $('#download_button').html( $('#download_' + mymedium).html());
44 }
45
46 function unselectOld() {
47   $('#icon_' + mymedium).removeClass('icon_selected').addClass('icon_unselected');
48 }
49
50 function resizeBoxes() {
51   var curmax = $('#ci_gnome').height();
52   curmax = Math.max(curmax, $('#ci_kde').height());
53   curmax = Math.max(curmax, $('#ci_net').height());
54   curmax = Math.max(curmax, $('#ci_dvd').height());
55   var curwidth = $('#ci_gnome').width();
56   $('#ci_gnome').height(curmax).width(curwidth);
57   $('#ci_kde').height(curmax).width(curwidth);
58   $('#ci_net').height(curmax).width(curwidth);
59   $('#ci_dvd').height(curmax).width(curwidth);
60 }
61
62 $(function() {
63     changeiso();
64     $('.helplink').show();
65     $('.script_only').show();
66     $('.noscript').hide();
67
68     $('.changeiso').click(function(){
69                             changeiso();
70                             return true; 
71                           });
72     $('div.changeiso').click(function(){
73                                   unselectOld();
74                                   mymedium = this.id.substr(3);
75                                   changeiso();
76                                   return false; 
77                                 });
78     $('button.changeiso').click(function(){
79                                   unselectOld();
80                                   mymedium = this.id.substr(3);
81                                   changeiso();
82                                   return false; 
83                                 });
84     $('#download_button').click(function() {
85                            window.location = mylink;
86                            return false;
87                          });
88     $('#help_64').click(function() { 
89                           $("#arch_64").fadeIn("slow"); 
90                           $("#link_64").hide();
91                         });
92     $('#help_32').click(function() { 
93                           $("#arch_32").fadeIn("slow"); 
94                           $("#link_32").hide();
95                         });
96     $("#help_arch").hover(function(){
97                             $("#arch_64").fadeIn();  // Other effects can be used to show the Tooltip
98                             $("#arch_32").fadeIn();  // Other effects can be used to show the Tooltip
99                           },
100                           function() {
101                             $("#arch_64").fadeOut();
102                             $("#arch_32").fadeOut();
103                           });
104
105     var resizeTimer = null;
106     
107     $(window).bind('resize', function() {
108                      if (resizeTimer) clearTimeout(resizeTimer);
109                      resizeTimer = setTimeout(resizeBoxes, 100);
110                    });
111
112     resizeBoxes();
113
114   });