- support derivates (patch from Samyak Bhuta)
[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').parent('div').addClass("medium_selected").removeClass('medium_unselected');
42   // $('#icon_' + mymedium).addClass('icon_selected').removeClass('icon_unselected');
43
44   // $('#download_button').html($('#download_' + mymedium).html());
45   $('#download_button').html($('#download_' + mymedium).html());
46
47   if (mymedium == 'net') {
48      $('#l_torrent').addClass('notavailable');
49      $('#p_torrent').attr('disabled', 'disabled');
50      if ($('#p_torrent').attr('checked')) {
51         $('#p_torrent').attr('checked', '');
52         $('#p_http').attr('checked', 'checked');
53      }
54   } else {
55      $('#l_torrent').removeClass('notavailable');
56      $('#p_torrent').attr('disabled', '');
57   }
58
59   if ( mymedium == "derivatives"){
60     //mylink="http://www.opensuse-education.org/download/ISOs/openSUSE-Edu-li-f-e-11.2-latest-i686.iso";
61     mylink = "http://en.opensuse.org/Derivatives";
62
63 //      $('#l_x86_64').addClass('notavailable');
64 //    $('#x86_64').attr('disabled', 'disabled');
65 //   if ($('#x86_64').attr('checked')) {
66 //              $('#x86_64').attr('checked', '');
67 //              $('#i686').attr('checked', 'checked');
68 //    }
69 //  }
70 //  else {
71 //     $('#l_x86_64').removeClass('notavailable');
72 //     $('#x86_64').attr('disabled', '');
73   }
74 }
75
76
77 function unselectOld() {
78   // $('#icon_' + mymedium).removeClass('icon_selected').addClass('icon_unselected');
79   $('#icon_' + mymedium).removeClass('icon_selected').addClass('icon_unselected').parent('div').addClass("medium_unselected").removeClass('medium_selected');
80 }
81
82 function resizeBoxes() {
83   var curmax = $('#ci_gnome').height();
84   curmax = Math.max(curmax, $('#ci_kde').height());
85   curmax = Math.max(curmax, $('#ci_net').height());
86   curmax = Math.max(curmax, $('#ci_dvd').height());
87   curmax = Math.max(curmax, $('#ci_edu').height());
88   var curwidth = $('#ci_gnome').width();
89   $('#ci_gnome').height(curmax).width(curwidth);
90   $('#ci_kde').height(curmax).width(curwidth);
91   $('#ci_net').height(curmax).width(curwidth);
92   $('#ci_dvd').height(curmax).width(curwidth);
93   $('#ci_edu').height(curmax).width(curwidth);
94 }
95
96 $(function() {
97     changeiso();
98     $('.helplink').show();
99     $('.script_only').show();
100     $('.noscript').hide();
101
102     $('.changeiso').click(function(){
103                             changeiso();
104                             return true; 
105                           });
106     $('div.changeiso').click(function(){
107                                   unselectOld();
108                                   mymedium = this.id.substr(3);
109                                   changeiso();
110                               $(this).parent().trigger('click');
111                                   if ( mymedium == "derivatives"){
112                                       $(this).parent().next().append($('#derivativesDiv'));
113                                   }
114                                   else {
115                                       $(this).parent().next().append($('#downloadForm'));
116                                   }
117                                   return false; 
118                                 });
119     $('button.changeiso').click(function(){
120                                   unselectOld();
121                                   mymedium = this.id.substr(3);
122                                   changeiso();
123                                   return false; 
124                                 });
125     $('#download_button').click(function() {
126                            window.location = mylink;
127                            return false;
128                          });
129
130     var resizeTimer = null;
131     
132     $(window).bind('resize', function() {
133                      if (resizeTimer) clearTimeout(resizeTimer);
134                      resizeTimer = setTimeout(resizeBoxes, 100);
135                    });
136
137     resizeBoxes();
138         $("#downloaderAccordion").accordion();
139         $("#help_method_content").dialog({
140                                 bgiframe: true,
141                                 autoOpen:false,
142                                 width: "80%",
143                                 draggable: false,
144                                 resizable: false,
145                                 title: 'openSUSE Download Help',
146                                 modal: true,
147                                 buttons: {
148                                         Ok: function() {
149                                                 $(this).dialog('close');
150                                         }
151                                 }
152                         });
153         $("#help_arch_content").dialog({
154                                 bgiframe: true,
155                                 autoOpen:false,
156                                 width: "80%",
157                                 draggable: false,
158                                 resizable: false,
159                                 title: 'openSUSE Download Help',
160                                 modal: true,
161                                 buttons: {
162                                         Ok: function() {
163                                                 $(this).dialog('close');
164                                         }
165                                 }
166                         });                     
167
168         $("#downloadMethodHelpPopup").click( function (){
169                 $("#help_method_content").dialog('open');
170         });                     
171
172         $("#architectureTypeHelpPopup").click( function (){
173                 $("#help_arch_content").dialog('open');
174         });                             
175 });