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

Revision 10983, 3.7 KB checked in by daisuke, 7 years ago (diff)

update dlwin.js

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.5/IMAGES/Vine65-';
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.5 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 (2.2GB)</label>\n' +
85                                        '<p class="btngroup"><input type="button" id="downloads" value="ダウンロード" />\n' +
86                                        '<input type="button" id="close" value="キャンセル" /></p></form>\n';
87                document.getElementsByTagName("body")[0].appendChild(dlwin);
88
89                var closebtn = document.getElementById("close");
90                addListener(closebtn, 'click', dl_cancel, false);
91                var download = document.getElementById("downloads");
92                addListener(download, 'click', dl_iso, false);
93        }
94       
95        if(e.preventDefault)
96        {
97                e.preventDefault();
98        }
99       
100        /*
101        if(window.event)
102        {
103                window.event.returnValue = false;
104        }
105        */
106
107        return false;
108}
109
110function dl_cancel(e)
111{
112        closewin();
113}
114
115function setListener(e)
116{
117        var dlbutton = document.getElementById("dlbutton");
118        addListener(dlbutton, 'click', openwin, false);
119}
120
121function addListener(elem, eventType, func, cap)
122{
123        if(elem.addEventListener)
124        {
125                elem.addEventListener(eventType, func, cap);
126        }
127        /*
128        else if(elem.attachEvent)
129        {
130                elem.attachEvent ('on'+eventType, func);
131        }
132        */
133}
134
135function removeListener(elem, eventType, func, cap)
136{
137        if(elem.removeEventListener)
138        {
139                elem.removeEventListener(eventType, func, cap);
140        }
141}
142
143
144addListener(window, 'load', setListener, false);
Note: See TracBrowser for help on using the repository browser.