[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [webwml/master] Move Debian sources.list generator JS into its own file (re: #21769)



commit 3e230b9e6916abc036a5a99526f5c56c221e135f
Author: Peter Palfrader <peter@xxxxxxxxxxxxx>
Date:   Sun Mar 19 18:23:54 2017 +0100

    Move Debian sources.list generator JS into its own file (re: #21769)
---
 docs/debian-selector.js | 159 +++++++++++++++++++++++++++++++++++++++++++++
 docs/en/debian.wml      | 168 +-----------------------------------------------
 include/head.wmi        |   1 +
 3 files changed, 163 insertions(+), 165 deletions(-)

diff --git a/docs/debian-selector.js b/docs/debian-selector.js
new file mode 100644
index 0000000..0b89377
--- /dev/null
+++ b/docs/debian-selector.js
@@ -0,0 +1,159 @@
+// This code is based on the http://mozilla.debian.net sources.list
+// generator as originally written by Mike Hommey. It is licensed under
+// the terms of the GNU GPLv2, http://www.gnu.org/licenses/gpl-2.0.html.
+var sources = {};
+var software = {
+'tor': { '_stable': {
+                     'wheezy':  [ 'wheezy' ],
+                     'jessie':  [ 'jessie' ],
+                     'stretch': [ 'stretch' ],
+                     'sid':     [ 'sid' ],
+                     'precise': [ 'precise'],
+                     'trusty':  [ 'trusty'],
+                     'xenial':  [ 'xenial'],
+                     'yakkety': [ 'yakkety'],
+                     },
+         'experimental-0.3.0.x': {
+                     'wheezy':  [ 'wheezy' ],
+                     'jessie':  [ 'jessie' ],
+                     'stretch': [ 'stretch' ],
+                     'sid':     [ 'sid' ],
+                     'precise': [ 'precise'],
+                     'trusty':  [ 'trusty'],
+                     'xenial':  [ 'xenial'],
+                     'yakkety': [ 'yakkety'],
+                     },
+       },
+'tor (from source)': {
+         '_stable': {
+                     'wheezy':  [ 'wheezy' ],
+                     'jessie':  [ 'jessie' ],
+                     'stretch': [ 'stretch' ],
+                     'sid':     [ 'sid' ],
+                     'precise': [ 'precise'],
+                     'trusty':  [ 'trusty'],
+                     'xenial':  [ 'xenial'],
+                     'yakkety': [ 'yakkety'],
+                     },
+         'experimental-0.3.0.x': {
+                     'wheezy':  [ 'wheezy' ],
+                     'jessie':  [ 'jessie' ],
+                     'stretch': [ 'stretch' ],
+                     'sid':     [ 'sid' ],
+                     'precise': [ 'precise'],
+                     'trusty':  [ 'trusty'],
+                     'xenial':  [ 'xenial'],
+                     'yakkety': [ 'yakkety'],
+                     },
+       },
+};
+
+function init() {
+    pkg = document.getElementById('package');
+    for (soft in software) {
+        if (soft != pkg.value) {
+            option = document.createElement('option');
+            option.value = soft;
+            option.appendChild(document.createTextNode(soft.charAt(0).toUpperCase() + soft.slice(1)));
+            pkg.appendChild(option);
+        }
+    }
+
+    apt_get = document.getElementById('apt-get');
+    para = document.createElement('p');
+    para.id = 'sorry';
+    para.style.display = 'none';
+    apt_get.parentNode.insertBefore(para, apt_get);
+    para.appendChild(document.createTextNode("Sorry, this version is not available.\n"));
+
+    document.getElementById('selector').style.display = 'block';
+
+    update();
+}
+
+function replaceText(src, txt) {
+    while (src.firstChild)
+        src.removeChild(src.firstChild);
+    src.appendChild(document.createTextNode(txt));
+}
+
+function update() {
+    pkg = document.getElementById('package');
+    ver = document.getElementById('version');
+    package = pkg.value;
+    version = ver.value;
+    distrib = document.getElementById('distrib').value;
+    if (package != pkg.prev) {
+        while (ver.firstChild)
+            ver.removeChild(ver.firstChild);
+        var selected;
+        for (version in software[package]) {
+            option = document.createElement('option');
+            if (version[0] == '_') {
+                version = version.slice(1);
+                selected = version;
+            }
+            option.appendChild(document.createTextNode(version));
+            option.value = version = version.replace(/ \(.*\)/,'');
+//alert(version);
+            ver.appendChild(option);
+        }
+        ver.value = version = selected || version;
+        pkg.prev = package
+    }
+    try {
+        keys = software[package][version][distrib];
+    } catch (e) {
+        try {
+            keys = software[package]['_' + version][distrib];
+        } catch (e) { };
+    }
+    src = document.getElementById('sources');
+    txt = '';
+    need_signed = false;
+    source_install = false;
+    target = '';
+    for (i = 0; keys && (i < keys.length); i++) {
+//alert(keys[i]);
+        if (keys[i] in sources) {
+            txt += sources[keys[i]];
+            target = keys[i];
+        } else {
+            if (package.slice(-7, -1) == 'source') {
+                package = package.split(' ')[0];
+                source_install = true;
+            }
+            txt += "http://deb.torproject.org/torproject.org";;
+            txt += " ";
+            txt += keys[i];
+            txt += " main";
+            need_signed = true;
+            target = keys[i];
+            txt = "deb " + txt + "\ndeb-src " + txt;
+            if (version != 'stable') {
+                txt2 = "http://deb.torproject.org/torproject.org";;
+                txt2 += " ";
+                txt2 += package;
+                txt2 += "-";
+                txt2 += version;
+                txt2 += "-";
+                txt2 += keys[i];
+                txt2 += " main";
+                txt = txt + "\ndeb " + txt2 + "\ndeb-src " + txt2;
+            }
+        }
+        txt += "\n";
+    }
+    replaceText(src, txt);
+    document.getElementById('regular-install').style.display = source_install ? 'none' : 'block';
+    document.getElementById('source-install').style.display = source_install ? 'block' : 'none';
+    document.getElementById('source-install2').style.display = source_install ? 'block' : 'none';
+    replaceText(document.getElementById('apt-package'), package);
+    document.getElementById('apt-source').style.display = (keys && keys.length) ? 'block' : 'none';
+    document.getElementById('apt-get').style.display = keys ? 'block' : 'none';
+    document.getElementById('sorry').style.display = keys ? 'none' : 'block';
+}
+
+document.addEventListener('DOMContentLoaded', function () {
+  init();
+});
diff --git a/docs/en/debian.wml b/docs/en/debian.wml
index 83486f3..e19af4f 100644
--- a/docs/en/debian.wml
+++ b/docs/en/debian.wml
@@ -3,171 +3,9 @@
 # Translation-Priority: 3-low
 
 #include "head.wmi" TITLE="Tor Project: Debian/Ubuntu Instructions" CHARSET="UTF-8"
-
-<script>
-<!--
-// This code is based on the http://mozilla.debian.net sources.list
-// generator as originally written by Mike Hommey. It is licensed under
-// the terms of the GNU GPLv2, http://www.gnu.org/licenses/gpl-2.0.html.
-var sources = {};
-var software = {
-'tor': { '_stable': {
-                     'wheezy':  [ 'wheezy' ],
-                     'jessie':  [ 'jessie' ],
-                     'stretch': [ 'stretch' ],
-                     'sid':     [ 'sid' ],
-                     'precise': [ 'precise'],
-                     'trusty':  [ 'trusty'],
-                     'xenial':  [ 'xenial'],
-                     'yakkety': [ 'yakkety'],
-                     },
-         'experimental-0.3.0.x': {
-                     'wheezy':  [ 'wheezy' ],
-                     'jessie':  [ 'jessie' ],
-                     'stretch': [ 'stretch' ],
-                     'sid':     [ 'sid' ],
-                     'precise': [ 'precise'],
-                     'trusty':  [ 'trusty'],
-                     'xenial':  [ 'xenial'],
-                     'yakkety': [ 'yakkety'],
-                     },
-       },
-'tor (from source)': {
-         '_stable': {
-                     'wheezy':  [ 'wheezy' ],
-                     'jessie':  [ 'jessie' ],
-                     'stretch': [ 'stretch' ],
-                     'sid':     [ 'sid' ],
-                     'precise': [ 'precise'],
-                     'trusty':  [ 'trusty'],
-                     'xenial':  [ 'xenial'],
-                     'yakkety': [ 'yakkety'],
-                     },
-         'experimental-0.3.0.x': {
-                     'wheezy':  [ 'wheezy' ],
-                     'jessie':  [ 'jessie' ],
-                     'stretch': [ 'stretch' ],
-                     'sid':     [ 'sid' ],
-                     'precise': [ 'precise'],
-                     'trusty':  [ 'trusty'],
-                     'xenial':  [ 'xenial'],
-                     'yakkety': [ 'yakkety'],
-                     },
-       },
-};
-
-function init() {
-    pkg = document.getElementById('package');
-    for (soft in software) {
-        if (soft != pkg.value) {
-            option = document.createElement('option');
-            option.value = soft;
-            option.appendChild(document.createTextNode(soft.charAt(0).toUpperCase() + soft.slice(1)));
-            pkg.appendChild(option);
-        }
-    }
-
-    apt_get = document.getElementById('apt-get');
-    para = document.createElement('p');
-    para.id = 'sorry';
-    para.style.display = 'none';
-    apt_get.parentNode.insertBefore(para, apt_get);
-    para.appendChild(document.createTextNode("Sorry, this version is not available.\n"));
-
-    document.getElementById('selector').style.display = 'block';
-
-    update();
-}
-
-function replaceText(src, txt) {
-    while (src.firstChild)
-        src.removeChild(src.firstChild);
-    src.appendChild(document.createTextNode(txt));
-}
-
-function update() {
-    pkg = document.getElementById('package');
-    ver = document.getElementById('version');
-    package = pkg.value;
-    version = ver.value;
-    distrib = document.getElementById('distrib').value;
-    if (package != pkg.prev) {
-        while (ver.firstChild)
-            ver.removeChild(ver.firstChild);
-        var selected;
-        for (version in software[package]) {
-            option = document.createElement('option');
-            if (version[0] == '_') {
-                version = version.slice(1);
-                selected = version;
-            }
-            option.appendChild(document.createTextNode(version));
-            option.value = version = version.replace(/ \(.*\)/,'');
-//alert(version);
-            ver.appendChild(option);
-        }
-        ver.value = version = selected || version;
-        pkg.prev = package
-    }
-    try {
-        keys = software[package][version][distrib];
-    } catch (e) {
-        try {
-            keys = software[package]['_' + version][distrib];
-        } catch (e) { };
-    }
-    src = document.getElementById('sources');
-    txt = '';
-    need_signed = false;
-    source_install = false;
-    target = '';
-    for (i = 0; keys && (i < keys.length); i++) {
-//alert(keys[i]);
-        if (keys[i] in sources) {
-            txt += sources[keys[i]];
-            target = keys[i];
-        } else {
-            if (package.slice(-7, -1) == 'source') {
-                package = package.split(' ')[0];
-                source_install = true;
-            }
-            txt += "http://deb.torproject.org/torproject.org";;
-            txt += " ";
-            txt += keys[i];
-            txt += " main";
-            need_signed = true;
-            target = keys[i];
-            txt = "deb " + txt + "\ndeb-src " + txt;
-            if (version != 'stable') {
-                txt2 = "http://deb.torproject.org/torproject.org";;
-                txt2 += " ";
-                txt2 += package;
-                txt2 += "-";
-                txt2 += version;
-                txt2 += "-";
-                txt2 += keys[i];
-                txt2 += " main";
-                txt = txt + "\ndeb " + txt2 + "\ndeb-src " + txt2;
-            }
-        }
-        txt += "\n";
-    }
-    replaceText(src, txt);
-    document.getElementById('regular-install').style.display = source_install ? 'none' : 'block';
-    document.getElementById('source-install').style.display = source_install ? 'block' : 'none';
-    document.getElementById('source-install2').style.display = source_install ? 'block' : 'none';
-    replaceText(document.getElementById('apt-package'), package);
-    document.getElementById('apt-source').style.display = (keys && keys.length) ? 'block' : 'none';
-    document.getElementById('apt-get').style.display = keys ? 'block' : 'none';
-    document.getElementById('sorry').style.display = keys ? 'none' : 'block';
-}
-
-window.onload = init;
-
--->
-</script>
-
-
+{#meta#:
+<script type="text/javascript" src="debian-selector.js"></script>
+:#meta#}
 
 <div id="content" class="clearfix">
   <div id="breadcrumbs">
diff --git a/include/head.wmi b/include/head.wmi
index 091fda8..1fb416b 100644
--- a/include/head.wmi
+++ b/include/head.wmi
@@ -17,6 +17,7 @@
    <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@xxxxxxxxxxxxxx for instruction on how to get Tor Browser.">
    <meta name="keywords" content="anonymity online, tor, tor project, censorship circumvention, traffic analysis, anonymous communications research">
    <meta property="og:image" content="https://www.torproject.org/images/tor-logo.jpg";>
+{#meta#}
 
    <title>$(TITLE)</title>
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits