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: Created March 19, 2018, 10:25 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
« no previous file with comments | « static/css/index.css ('k') | static/js/vendor/bowser.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 = {
+ // Desktop browsers
+ "chrome": {
+ installer: "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpkdaibdccddilifddb",
+ 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",
+ 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();
+
+}());
« no previous file with comments | « static/css/index.css ('k') | static/js/vendor/bowser.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld