Move Debian sources.list generator JS into its own file (re: #21769)
Peter Palfrader

Peter Palfrader commited on 2017-03-19 18:23:54
Zeige 3 geänderte Dateien mit 163 Einfügungen und 165 Löschungen.

... ...
@@ -0,0 +1,159 @@
1
+// This code is based on the http://mozilla.debian.net sources.list
2
+// generator as originally written by Mike Hommey. It is licensed under
3
+// the terms of the GNU GPLv2, http://www.gnu.org/licenses/gpl-2.0.html.
4
+var sources = {};
5
+var software = {
6
+'tor': { '_stable': {
7
+                     'wheezy':  [ 'wheezy' ],
8
+                     'jessie':  [ 'jessie' ],
9
+                     'stretch': [ 'stretch' ],
10
+                     'sid':     [ 'sid' ],
11
+                     'precise': [ 'precise'],
12
+                     'trusty':  [ 'trusty'],
13
+                     'xenial':  [ 'xenial'],
14
+                     'yakkety': [ 'yakkety'],
15
+                     },
16
+         'experimental-0.3.0.x': {
17
+                     'wheezy':  [ 'wheezy' ],
18
+                     'jessie':  [ 'jessie' ],
19
+                     'stretch': [ 'stretch' ],
20
+                     'sid':     [ 'sid' ],
21
+                     'precise': [ 'precise'],
22
+                     'trusty':  [ 'trusty'],
23
+                     'xenial':  [ 'xenial'],
24
+                     'yakkety': [ 'yakkety'],
25
+                     },
26
+       },
27
+'tor (from source)': {
28
+         '_stable': {
29
+                     'wheezy':  [ 'wheezy' ],
30
+                     'jessie':  [ 'jessie' ],
31
+                     'stretch': [ 'stretch' ],
32
+                     'sid':     [ 'sid' ],
33
+                     'precise': [ 'precise'],
34
+                     'trusty':  [ 'trusty'],
35
+                     'xenial':  [ 'xenial'],
36
+                     'yakkety': [ 'yakkety'],
37
+                     },
38
+         'experimental-0.3.0.x': {
39
+                     'wheezy':  [ 'wheezy' ],
40
+                     'jessie':  [ 'jessie' ],
41
+                     'stretch': [ 'stretch' ],
42
+                     'sid':     [ 'sid' ],
43
+                     'precise': [ 'precise'],
44
+                     'trusty':  [ 'trusty'],
45
+                     'xenial':  [ 'xenial'],
46
+                     'yakkety': [ 'yakkety'],
47
+                     },
48
+       },
49
+};
50
+
51
+function init() {
52
+    pkg = document.getElementById('package');
53
+    for (soft in software) {
54
+        if (soft != pkg.value) {
55
+            option = document.createElement('option');
56
+            option.value = soft;
57
+            option.appendChild(document.createTextNode(soft.charAt(0).toUpperCase() + soft.slice(1)));
58
+            pkg.appendChild(option);
59
+        }
60
+    }
61
+
62
+    apt_get = document.getElementById('apt-get');
63
+    para = document.createElement('p');
64
+    para.id = 'sorry';
65
+    para.style.display = 'none';
66
+    apt_get.parentNode.insertBefore(para, apt_get);
67
+    para.appendChild(document.createTextNode("Sorry, this version is not available.\n"));
68
+
69
+    document.getElementById('selector').style.display = 'block';
70
+
71
+    update();
72
+}
73
+
74
+function replaceText(src, txt) {
75
+    while (src.firstChild)
76
+        src.removeChild(src.firstChild);
77
+    src.appendChild(document.createTextNode(txt));
78
+}
79
+
80
+function update() {
81
+    pkg = document.getElementById('package');
82
+    ver = document.getElementById('version');
83
+    package = pkg.value;
84
+    version = ver.value;
85
+    distrib = document.getElementById('distrib').value;
86
+    if (package != pkg.prev) {
87
+        while (ver.firstChild)
88
+            ver.removeChild(ver.firstChild);
89
+        var selected;
90
+        for (version in software[package]) {
91
+            option = document.createElement('option');
92
+            if (version[0] == '_') {
93
+                version = version.slice(1);
94
+                selected = version;
95
+            }
96
+            option.appendChild(document.createTextNode(version));
97
+            option.value = version = version.replace(/ \(.*\)/,'');
98
+//alert(version);
99
+            ver.appendChild(option);
100
+        }
101
+        ver.value = version = selected || version;
102
+        pkg.prev = package
103
+    }
104
+    try {
105
+        keys = software[package][version][distrib];
106
+    } catch (e) {
107
+        try {
108
+            keys = software[package]['_' + version][distrib];
109
+        } catch (e) { };
110
+    }
111
+    src = document.getElementById('sources');
112
+    txt = '';
113
+    need_signed = false;
114
+    source_install = false;
115
+    target = '';
116
+    for (i = 0; keys && (i < keys.length); i++) {
117
+//alert(keys[i]);
118
+        if (keys[i] in sources) {
119
+            txt += sources[keys[i]];
120
+            target = keys[i];
121
+        } else {
122
+            if (package.slice(-7, -1) == 'source') {
123
+                package = package.split(' ')[0];
124
+                source_install = true;
125
+            }
126
+            txt += "http://deb.torproject.org/torproject.org";
127
+            txt += " ";
128
+            txt += keys[i];
129
+            txt += " main";
130
+            need_signed = true;
131
+            target = keys[i];
132
+            txt = "deb " + txt + "\ndeb-src " + txt;
133
+            if (version != 'stable') {
134
+                txt2 = "http://deb.torproject.org/torproject.org";
135
+                txt2 += " ";
136
+                txt2 += package;
137
+                txt2 += "-";
138
+                txt2 += version;
139
+                txt2 += "-";
140
+                txt2 += keys[i];
141
+                txt2 += " main";
142
+                txt = txt + "\ndeb " + txt2 + "\ndeb-src " + txt2;
143
+            }
144
+        }
145
+        txt += "\n";
146
+    }
147
+    replaceText(src, txt);
148
+    document.getElementById('regular-install').style.display = source_install ? 'none' : 'block';
149
+    document.getElementById('source-install').style.display = source_install ? 'block' : 'none';
150
+    document.getElementById('source-install2').style.display = source_install ? 'block' : 'none';
151
+    replaceText(document.getElementById('apt-package'), package);
152
+    document.getElementById('apt-source').style.display = (keys && keys.length) ? 'block' : 'none';
153
+    document.getElementById('apt-get').style.display = keys ? 'block' : 'none';
154
+    document.getElementById('sorry').style.display = keys ? 'none' : 'block';
155
+}
156
+
157
+document.addEventListener('DOMContentLoaded', function () {
158
+  init();
159
+});
... ...
@@ -3,171 +3,9 @@
3 3
 # Translation-Priority: 3-low
4 4
 
5 5
 #include "head.wmi" TITLE="Tor Project: Debian/Ubuntu Instructions" CHARSET="UTF-8"
6
-
7
-<script>
8
-<!--
9
-// This code is based on the http://mozilla.debian.net sources.list
10
-// generator as originally written by Mike Hommey. It is licensed under
11
-// the terms of the GNU GPLv2, http://www.gnu.org/licenses/gpl-2.0.html.
12
-var sources = {};
13
-var software = {
14
-'tor': { '_stable': {
15
-                     'wheezy':  [ 'wheezy' ],
16
-                     'jessie':  [ 'jessie' ],
17
-                     'stretch': [ 'stretch' ],
18
-                     'sid':     [ 'sid' ],
19
-                     'precise': [ 'precise'],
20
-                     'trusty':  [ 'trusty'],
21
-                     'xenial':  [ 'xenial'],
22
-                     'yakkety': [ 'yakkety'],
23
-                     },
24
-         'experimental-0.3.0.x': {
25
-                     'wheezy':  [ 'wheezy' ],
26
-                     'jessie':  [ 'jessie' ],
27
-                     'stretch': [ 'stretch' ],
28
-                     'sid':     [ 'sid' ],
29
-                     'precise': [ 'precise'],
30
-                     'trusty':  [ 'trusty'],
31
-                     'xenial':  [ 'xenial'],
32
-                     'yakkety': [ 'yakkety'],
33
-                     },
34
-       },
35
-'tor (from source)': {
36
-         '_stable': {
37
-                     'wheezy':  [ 'wheezy' ],
38
-                     'jessie':  [ 'jessie' ],
39
-                     'stretch': [ 'stretch' ],
40
-                     'sid':     [ 'sid' ],
41
-                     'precise': [ 'precise'],
42
-                     'trusty':  [ 'trusty'],
43
-                     'xenial':  [ 'xenial'],
44
-                     'yakkety': [ 'yakkety'],
45
-                     },
46
-         'experimental-0.3.0.x': {
47
-                     'wheezy':  [ 'wheezy' ],
48
-                     'jessie':  [ 'jessie' ],
49
-                     'stretch': [ 'stretch' ],
50
-                     'sid':     [ 'sid' ],
51
-                     'precise': [ 'precise'],
52
-                     'trusty':  [ 'trusty'],
53
-                     'xenial':  [ 'xenial'],
54
-                     'yakkety': [ 'yakkety'],
55
-                     },
56
-       },
57
-};
58
-
59
-function init() {
60
-    pkg = document.getElementById('package');
61
-    for (soft in software) {
62
-        if (soft != pkg.value) {
63
-            option = document.createElement('option');
64
-            option.value = soft;
65
-            option.appendChild(document.createTextNode(soft.charAt(0).toUpperCase() + soft.slice(1)));
66
-            pkg.appendChild(option);
67
-        }
68
-    }
69
-
70
-    apt_get = document.getElementById('apt-get');
71
-    para = document.createElement('p');
72
-    para.id = 'sorry';
73
-    para.style.display = 'none';
74
-    apt_get.parentNode.insertBefore(para, apt_get);
75
-    para.appendChild(document.createTextNode("Sorry, this version is not available.\n"));
76
-
77
-    document.getElementById('selector').style.display = 'block';
78
-
79
-    update();
80
-}
81
-
82
-function replaceText(src, txt) {
83
-    while (src.firstChild)
84
-        src.removeChild(src.firstChild);
85
-    src.appendChild(document.createTextNode(txt));
86
-}
87
-
88
-function update() {
89
-    pkg = document.getElementById('package');
90
-    ver = document.getElementById('version');
91
-    package = pkg.value;
92
-    version = ver.value;
93
-    distrib = document.getElementById('distrib').value;
94
-    if (package != pkg.prev) {
95
-        while (ver.firstChild)
96
-            ver.removeChild(ver.firstChild);
97
-        var selected;
98
-        for (version in software[package]) {
99
-            option = document.createElement('option');
100
-            if (version[0] == '_') {
101
-                version = version.slice(1);
102
-                selected = version;
103
-            }
104
-            option.appendChild(document.createTextNode(version));
105
-            option.value = version = version.replace(/ \(.*\)/,'');
106
-//alert(version);
107
-            ver.appendChild(option);
108
-        }
109
-        ver.value = version = selected || version;
110
-        pkg.prev = package
111
-    }
112
-    try {
113
-        keys = software[package][version][distrib];
114
-    } catch (e) {
115
-        try {
116
-            keys = software[package]['_' + version][distrib];
117
-        } catch (e) { };
118
-    }
119
-    src = document.getElementById('sources');
120
-    txt = '';
121
-    need_signed = false;
122
-    source_install = false;
123
-    target = '';
124
-    for (i = 0; keys && (i < keys.length); i++) {
125
-//alert(keys[i]);
126
-        if (keys[i] in sources) {
127
-            txt += sources[keys[i]];
128
-            target = keys[i];
129
-        } else {
130
-            if (package.slice(-7, -1) == 'source') {
131
-                package = package.split(' ')[0];
132
-                source_install = true;
133
-            }
134
-            txt += "http://deb.torproject.org/torproject.org";
135
-            txt += " ";
136
-            txt += keys[i];
137
-            txt += " main";
138
-            need_signed = true;
139
-            target = keys[i];
140
-            txt = "deb " + txt + "\ndeb-src " + txt;
141
-            if (version != 'stable') {
142
-                txt2 = "http://deb.torproject.org/torproject.org";
143
-                txt2 += " ";
144
-                txt2 += package;
145
-                txt2 += "-";
146
-                txt2 += version;
147
-                txt2 += "-";
148
-                txt2 += keys[i];
149
-                txt2 += " main";
150
-                txt = txt + "\ndeb " + txt2 + "\ndeb-src " + txt2;
151
-            }
152
-        }
153
-        txt += "\n";
154
-    }
155
-    replaceText(src, txt);
156
-    document.getElementById('regular-install').style.display = source_install ? 'none' : 'block';
157
-    document.getElementById('source-install').style.display = source_install ? 'block' : 'none';
158
-    document.getElementById('source-install2').style.display = source_install ? 'block' : 'none';
159
-    replaceText(document.getElementById('apt-package'), package);
160
-    document.getElementById('apt-source').style.display = (keys && keys.length) ? 'block' : 'none';
161
-    document.getElementById('apt-get').style.display = keys ? 'block' : 'none';
162
-    document.getElementById('sorry').style.display = keys ? 'none' : 'block';
163
-}
164
-
165
-window.onload = init;
166
-
167
--->
168
-</script>
169
-
170
-
6
+{#meta#:
7
+<script type="text/javascript" src="debian-selector.js"></script>
8
+:#meta#}
171 9
 
172 10
 <div id="content" class="clearfix">
173 11
   <div id="breadcrumbs">
... ...
@@ -17,6 +17,7 @@
17 17
    <meta name="description" content="Tor is a free software that prevents people from learning your location or browsing habits by letting you communicate anonymously on the Internet. It also helps you bypass censorship online. If you can't open the website, email gettor@torproject.org for instruction on how to get Tor Browser.">
18 18
    <meta name="keywords" content="anonymity online, tor, tor project, censorship circumvention, traffic analysis, anonymous communications research">
19 19
    <meta property="og:image" content="https://www.torproject.org/images/tor-logo.jpg">
20
+{#meta#}
20 21
 
21 22
    <title>$(TITLE)</title>
22 23
 
23 24