Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: static/js/index.js

Issue 29727563: Fixes #35 - Progressively enhance install button with appropriate links and text (Closed) Base URL: https://hg.adblockplus.org/web.adblockplus.org
Patch Set: Rebase Created March 21, 2018, 9:16 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: static/js/index.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/static/js/index.js
@@ -0,0 +1,70 @@
+"use strict";
+
+(function()
+{
+ var supportedPlatforms = {
saroyanm 2018/03/23 19:08:37 I wonder what SEO implications this can introduce,
ire 2018/03/26 10:23:01 This is a good point. As I wasn't part of the init
+ // Desktop browsers
+ "chrome": {
+ installer: "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpkdaibdccddilifddb",
saroyanm 2018/03/23 19:08:37 Seems like here we also don't have inline installa
ire 2018/03/26 10:23:01 Done.
+ label: "Chrome"
+ },
+ "opera": {
+ installer: "https://addons.opera.com/extensions/details/opera-adblock/?display=en-US",
+ label: "Opera"
+ },
+ "yandexbrowser": {
+ installer: "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpkdaibdccddilifddb",
+ label: "Yandex Browser"
+ },
+ "msie": {
+ installer: "https://update.adblockplus.org/latest/adblockplusie.exe",
+ label: "Internet Explorer"
+ },
+ "msedge": {
+ installer: "https://www.microsoft.com/store/p/adblock-plus/9nblggh4r9nz",
+ label: "Micrsoft Edge"
+ },
+ "firefox": {
+ installer: "https://update.adblockplus.org/latest/adblockplusfirefox.xpi",
+ label: "Firefox"
+ },
+ "safari": {
+ installer: "https://update.adblockplus.org/latest/adblockplussafari.safariextz",
+ label: "Safari"
+ },
+ "maxthon": "",
+
+ // Mobile platforms
+ "ios": {
+ installer: "https://eyeo.to/adblockbrowser/ios/abp-website",
saroyanm 2018/03/23 19:08:37 We might want to use this or similar redirection l
ire 2018/03/26 10:23:01 Ack.
+ label: "iOS",
+ },
+ "android": {
+ installer: "https://eyeo.to/adblockbrowser/android/abp-website",
+ label: "Android"
+ }
+ };
+
+ function setupHeroDownloadButton()
+ {
+ var heroDownloadButton = document.getElementById("hero-download-button");
+ var detectedPlatform;
+
+ for (var key in supportedPlatforms) if (bowser[key]) detectedPlatform = key;
+
+ if (!detectedPlatform) return;
+
+ document.body.classList.add(detectedPlatform);
+
+ if (detectedPlatform === "maxthon") return;
+
+ heroDownloadButton.href = supportedPlatforms[detectedPlatform].installer;
+ heroDownloadButton.textContent = document
+ .getElementById("hero-download-button-template")
+ .innerHTML
+ .replace("browser", supportedPlatforms[detectedPlatform].label);
+ }
+
+ if (bowser) setupHeroDownloadButton();
+
+}());

Powered by Google App Engine
This is Rietveld