Browse Source

change download button logic, remove request to github

Signed-off-by: R4SAS <r4sas@i2pmail.org>
master
R4SAS 3 years ago
parent
commit
3ceb6fe707
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 15
      index.html
  2. 44
      js/app.js
  3. 8
      locales/data.ini

15
index.html

@ -25,10 +25,20 @@ @@ -25,10 +25,20 @@
<a href="https://github.com/PurpleI2P/i2pd/releases/latest"
id="dl-btn" target="_blank">Downloads</a>
</div>
<div id="all-dls" style="display: none;">
<p class="header-links">
<a href="https://github.com/PurpleI2P/i2pd/releases/latest" id="all-dls"
data-l10n-id="header-dl-all" style="display: none;" target="_blank">
<a href="https://github.com/PurpleI2P/i2pd/releases/latest"
data-l10n-id="header-dl-all" target="_blank">
All downloads</a>
<a href="https://github.com/PurpleI2P/i2pd-android/releases/latest"
data-l10n-id="header-dl-android" target="_blank">
Android app</a>
<a href="https://github.com/PurpleI2P/i2pdbrowser/releases/latest"
data-l10n-id="header-dl-browser" target="_blank">
I2PdBrowser bundle</a>
</p>
</div>
<p class="header-links">
<a href="https://i2pd.readthedocs.io/en/latest/" target="_blank"
data-l10n-id="header-docs">Documentation</a>
</p>
@ -66,7 +76,6 @@ @@ -66,7 +76,6 @@
<a href="https://github.com/PurpleI2P/i2pd" target="_blank"><img alt="@GitHub" src="images/github.png"></a>
<a href="https://en.wikipedia.org/wiki/I2P" target="_blank"><img alt="@Wikipedia" src="images/wikipedia.png"></a>
<a href="https://twitter.com/hashtag/i2pd" target="_blank"><img alt="@Twitter" src="images/twitter.png"></a>
<!-- <a href="http://purplete.ch" target="_blank"><img alt="Purple Tech" src="images/purpletech.png"></a> -->
<a href="https://i2p.net/" target="_blank"><img alt="Vanilla I2P" src="images/itoopie.png"></a>
</p>
</div>

44
js/app.js

@ -1,49 +1,21 @@ @@ -1,49 +1,21 @@
var url = "https://api.github.com/repos/PurpleI2P/i2pdbrowser/releases/latest";
//var url = "http://127.0.0.1:9889/latest.json";
function renderReleaseInfo(data) {
if (!data) return;
var release = JSON.parse(data);
function renderDownloadButton() {
var downloadCount = 0, dl_btn = document.getElementById("dl-btn"), all_dls = document.getElementById("all-dls");
for (var i = 0; i < release.assets.length; i++)
downloadCount += release.assets[i].download_count;
console.log(release.name+" downloaded "+downloadCount.toLocaleString()+" times.");
if (window.navigator.platform.toUpperCase().startsWith("WIN")) {
var win_asset = release.assets.filter(function(a) {
if (a.name.startsWith("I2PdBrowser") && a.name.endsWith("exe"))
return true;
});
if (win_asset.length > 0) {
dl_btn.innerText = document.webL10n.get("header-dl-btn-windows", null, "Download for Windows");
dl_btn.setAttribute("href", win_asset[0].browser_download_url);
dl_btn.innerText = document.webL10n.get("header-dl-btn-bundle", null, "Download I2PdBrowser");
dl_btn.setAttribute("href", "https://github.com/PurpleI2P/i2pdbrowser/releases/latest");
all_dls.style.display = "block";
}
/*
} else if (window.navigator.userAgent.toUpperCase().indexOf("ANDROID") !== -1) {
var droid_asset = release.assets.filter(function(a) {
if (a.name.toUpperCase().indexOf("ANDROID") !== -1) return true;
});
if (droid_asset.length > 0) {
dl_btn.text(document.webL10n.get("header.dl-btn-android"));
} else if (window.navigator.userAgent.toUpperCase().indexOf("ANDROID") !== -1) {
dl_btn.innerText = document.webL10n.get("header.dl-btn-android", null, "Download for Android");
dl_btn.setAttribute("href", droid_asset[0].browser_download_url);
all_dls.show();
}
*/
all_dls.style.display = "block";
} else {
dl_btn.innerText = document.webL10n.get("header-dl-btn", null, "Downloads");
}
}
window.addEventListener('localized', function() {
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function(){
if (httpRequest.readyState == XMLHttpRequest.DONE)
renderReleaseInfo(httpRequest.responseText);
}
httpRequest.open('GET', url);
httpRequest.send();
renderDownloadButton();
}, false);

8
locales/data.ini

@ -4,9 +4,11 @@ header-slogan = Network without borders @@ -4,9 +4,11 @@ header-slogan = Network without borders
header-p1 = We are building network which helps people to communicate and share information without restrictions.
header-p2 = Free from censorship. Free from privacy violations.
header-dl-btn = Download
header-dl-btn-windows = Download for Windows
header-dl-btn-bundle = Download I2PdBrowser
header-dl-btn-android = Download for Android
header-dl-all = All downloads
header-dl-android = Android app
header-dl-browser = I2PdBrowser bundle
header-docs = Documentation
content-how-title = i2pd (I2P Daemon) is a full-featured C++ implementation of I2P client
content-how-p1 = I2P (Invisible Internet Protocol) is a universal anonymous network layer. All communications over I2P are anonymous and end-to-end encrypted, participants don't reveal their real IP addresses.
@ -26,9 +28,11 @@ header-slogan = Сеть без границ @@ -26,9 +28,11 @@ header-slogan = Сеть без границ
header-p1 = Мы строим сеть, которая позволяет людям общаться и обмениваться информацией без искусственных преград.
header-p2 = Без цензуры. Без нарушений права на частную жизнь.
header-dl-btn = Скачать
header-dl-btn-windows = Скачать для Windows
header-dl-btn-bundle = Скачать I2PdBrowser
header-dl-btn-android = Скачать для Android
header-dl-all = Все загрузки
header-dl-android = Android приложение
header-dl-browser = Комплект I2PdBrowser
header-docs = Документация
content-how-title = i2pd (I2P Daemon) это полнофункциональная реализация I2P клиента на языке C++
content-how-p1 = I2P (Невидимый Интернет Протокол) это универсальный анонимный сетевой уровень. Все соединения через I2P анонимны и используют сквозное (end-to-end) шифрование, участники не раскрывают свои настоящие IP адреса.

Loading…
Cancel
Save