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

Revision 2239, 4.0 KB checked in by daisuke, 13 years ago (diff)

Vine Linux 5.2 released.

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