source: projects/web/trunk/js/dlwin.js @ 6656

Revision 6656, 3.8 KB checked in by daisuke, 12 years ago (diff)

Vine Linux 6.1 release

Line 
1function get_radio_value(id)
2{
3        var value;
4        var index;
5        var radiogroup = document.getElementById(id);
6        var radio = radiogroup.getElementsByTagName('input');
7
8        for (index=0; index < radio.length; index++)
9        {
10                if(radio[index].checked == true)
11                {
12                        value = radio[index].value;
13                }
14        }
15
16        return  value;
17}
18
19function dl_iso(e)
20{
21        var http = new Array(
22                'http://ftp.jaist.ac.jp/pub/Linux/Vine/',
23                'http://ftp.kddilabs.jp/pub/Linux/packages/Vine/',
24                'http://ftp.vinelinux.org/pub/Vine/'
25                );
26        var ftp = new Array(
27                'ftp://ftp.jaist.ac.jp/pub/Linux/Vine/',
28                'ftp://ftp.kddilabs.jp/pub/Linux/packages/Vine/',
29                'ftp://ftp.vinelinux.org/pub/Vine/'
30                );
31        var imgprefix = 'Vine-6.1/IMAGES/Vine61-';
32        var protocol;
33        var arch;
34        var media;
35        var uri;
36
37        protocol = get_radio_value ('protocol');
38        arch = get_radio_value ('arch');
39        media = get_radio_value ('media');
40
41        var select = document.getElementById('mirror');
42        switch (protocol)
43        {
44        case 'http':
45                uri = http[select.value];
46                break;
47        case 'ftp':     
48                uri = ftp[select.value];
49        }
50
51        uri = uri + imgprefix + media + "-" + arch + ".iso";
52        closewin();
53        window.location = 'thanks.html?' + uri;
54}
55
56function closewin()
57{
58        var closebtn = document.getElementById("close");
59        removeListener(closebtn, 'click', dl_cancel, false);
60        var download = document.getElementById("downloads");
61        removeListener(download, 'click', dl_iso, false);
62        var dlwin = document.getElementById("dlwin");
63        document.getElementsByTagName("body")[0].removeChild(dlwin);
64}
65
66function openwin(e)
67{
68        if(!document.getElementById("dlwin"))
69        {
70                var dlwin = document.createElement("div");
71                dlwin.id = "dlwin";
72                dlwin.innerHTML =       '<h2>Vine Linux 6.1 CD/DVD/USB ISOイメージのダウンロード</h2>\n' +
73                                        '<form><p id="protocol">プロトコル:\n' +
74                                        '<input type="radio" name="protocol" value="http" checked="checked" />HTTP\n' +
75                                        '<input type="radio" name="protocol" value="ftp" />FTP</p>\n' +
76                                        '<p><label>ミラーサーバ:<select id="mirror">\n' +
77                                        '<option value="0">北陸先端科学技術大学院大学</option>\n' +
78                                        '<option value="1">KDDI 研究所</option>\n' +
79                                        '<option value="2">Vine Linux マスターサーバ</option></select></label></p>\n' +
80                                        '<p id="arch">対象:\n' +
81                                        '<label><input type="radio" name="arch" value="i686" />PC/AT互換機(32bit)</label>\n' +
82                                        '<label><input type="radio" name="arch" value="x86_64" checked="checked" />PC/AT互換機(64bit)</label>\n' +
83                                        '<p id="media">メディア:\n' +
84                                        '<label><input type="radio" name="media" value="DVD" checked="checked" />DVD/USB (1.4GB)</label>\n' +
85                                        '<label><input type="radio" name="media" value="CD" />CD (700MB)</label><br />\n' +
86                                        '<p class="btngroup"><input type="button" id="downloads" value="ダウンロード" />\n' +
87                                        '<input type="button" id="close" value="キャンセル" /></p></form>\n';
88                document.getElementsByTagName("body")[0].appendChild(dlwin);
89
90                var closebtn = document.getElementById("close");
91                addListener(closebtn, 'click', dl_cancel, false);
92                var download = document.getElementById("downloads");
93                addListener(download, 'click', dl_iso, false);
94        }
95       
96        if(e.preventDefault)
97        {
98                e.preventDefault();
99        }
100       
101        /*
102        if(window.event)
103        {
104                window.event.returnValue = false;
105        }
106        */
107
108        return false;
109}
110
111function dl_cancel(e)
112{
113        closewin();
114}
115
116function setListener(e)
117{
118        var dlbutton = document.getElementById("dlbutton");
119        addListener(dlbutton, 'click', openwin, false);
120}
121
122function addListener(elem, eventType, func, cap)
123{
124        if(elem.addEventListener)
125        {
126                elem.addEventListener(eventType, func, cap);
127        }
128        /*
129        else if(elem.attachEvent)
130        {
131                elem.attachEvent ('on'+eventType, func);
132        }
133        */
134}
135
136function removeListener(elem, eventType, func, cap)
137{
138        if(elem.removeEventListener)
139        {
140                elem.removeEventListener(eventType, func, cap);
141        }
142}
143
144
145addListener(window, 'load', setListener, false);
Note: See TracBrowser for help on using the repository browser.