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: Addressed comments #10 Created April 6, 2018, 1:21 p.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,49 @@
+"use strict";
+
+(function()
+{
+ var supportedPlatforms = {
+
+ // Desktop browsers
+ "chrome": "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpkdaibdccddilifddb",
+ "opera": "https://addons.opera.com/extensions/details/opera-adblock/?display=en-US",
+ "yandexbrowser": "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpkdaibdccddilifddb",
+ "msie": "https://update.adblockplus.org/latest/adblockplusie.exe",
+ "msedge": "https://www.microsoft.com/store/p/adblock-plus/9nblggh4r9nz",
+ "firefox": "https://update.adblockplus.org/latest/adblockplusfirefox.xpi",
+ "safari": "https://update.adblockplus.org/latest/adblockplussafari.safariextz",
+ "maxthon": "",
+
+ // Mobile platforms
+ "ios": "https://eyeo.to/adblockbrowser/ios/abp-website",
+ "android": "https://eyeo.to/adblockbrowser/android/abp-website"
+ };
+
+ function setupHeroDownloadButton()
+ {
+ var detectedPlatform = Object.keys(supportedPlatforms)
+ .find(hasOwnProperty.bind(bowser));
juliandoucette 2018/04/06 16:29:16 Detail/TOL: I'm a little uncomfortable using `wind
ire 2018/04/09 09:24:01 Done.
+
+ if (!detectedPlatform) return;
+
+ document.body.classList.add(detectedPlatform);
+
+ if (detectedPlatform == "maxthon") return;
+
+ var heroDownloadButton = document.getElementById("hero-download-button");
+ heroDownloadButton.href = supportedPlatforms[detectedPlatform];
+ heroDownloadButton.innerHTML = document
+ .getElementById("hero-download-button-template")
+ .innerHTML;
+
+ heroDownloadButton.addEventListener("click", function(event)
+ {
+ if (!chrome || !chrome.webstore) return;
juliandoucette 2018/04/06 16:29:17 This will cause a reference error if `chrome` is n
ire 2018/04/09 09:24:02 Done.
+ event.preventDefault();
+ chrome.webstore.install();
+ });
+ }
+
+ if (bowser) setupHeroDownloadButton();
juliandoucette 2018/04/06 16:29:17 I think that this may also cause a reference error
ire 2018/04/09 09:24:02 Done.
+
+}());
« includes/index.tmpl ('K') | « static/css/index.css ('k') | static/js/vendor/bowser.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld