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

Delta Between Two Patch Sets: 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
Left Patch Set: Addressed comments #10 Created April 6, 2018, 1:21 p.m.
Right Patch Set: Addressed comments #21 Created April 16, 2018, 4 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « static/css/index.css ('k') | static/js/vendor/bowser.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 "use strict"; 1 "use strict";
2 2
3 (function() 3 (function()
4 { 4 {
5 var supportedPlatforms = { 5 var supportedPlatforms = {
6 6
7 // Desktop browsers 7 // Desktop browsers
8 "chrome": "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpkdaibdcc ddilifddb", 8 "chrome": "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpkdaibdcc ddilifddb",
9 "opera": "https://addons.opera.com/extensions/details/opera-adblock/?display =en-US", 9 "opera": "https://addons.opera.com/extensions/details/opera-adblock/?display =en-US",
10 "yandexbrowser": "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpk daibdccddilifddb", 10 "yandexbrowser": "https://chrome.google.com/webstore/detail/cfhdojbkjhnklbpk daibdccddilifddb",
11 "msie": "https://update.adblockplus.org/latest/adblockplusie.exe", 11 "msie": "https://update.adblockplus.org/latest/adblockplusie.exe",
12 "msedge": "https://www.microsoft.com/store/p/adblock-plus/9nblggh4r9nz", 12 "msedge": "https://www.microsoft.com/store/p/adblock-plus/9nblggh4r9nz",
13 "firefox": "https://update.adblockplus.org/latest/adblockplusfirefox.xpi", 13 "firefox": "https://update.adblockplus.org/latest/adblockplusfirefox.xpi",
14 "safari": "https://update.adblockplus.org/latest/adblockplussafari.safariext z", 14 "safari": "https://update.adblockplus.org/latest/adblockplussafari.safariext z",
15 "maxthon": "", 15 "maxthon": "",
16 16
17 // Mobile platforms 17 // Mobile platforms
18 "ios": "https://eyeo.to/adblockbrowser/ios/abp-website", 18 "ios": "https://eyeo.to/adblockbrowser/ios/abp-website",
19 "android": "https://eyeo.to/adblockbrowser/android/abp-website" 19 "android": "https://eyeo.to/adblockbrowser/android/abp-website"
20 }; 20 };
21 21
22 function setupHeroDownloadButton() 22 function setupHeroDownloadButton()
23 { 23 {
24 var detectedPlatform = Object.keys(supportedPlatforms) 24 var detectedPlatform = Object.keys(supportedPlatforms)
25 .find(hasOwnProperty.bind(bowser)); 25 .find(bowser.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.
26 26
27 if (!detectedPlatform) return; 27 if (!detectedPlatform) return;
28 28
29 document.body.classList.add(detectedPlatform); 29 document.body.classList.add(detectedPlatform);
30 30
31 if (detectedPlatform == "maxthon") return; 31 if (detectedPlatform == "maxthon") return;
32 32
33 var heroDownloadButton = document.getElementById("hero-download-button"); 33 var heroDownloadButton = document.getElementById("hero-download-button");
34 heroDownloadButton.href = supportedPlatforms[detectedPlatform]; 34 heroDownloadButton.href = supportedPlatforms[detectedPlatform];
35 heroDownloadButton.innerHTML = document 35 heroDownloadButton.textContent = document
36 .getElementById("hero-download-button-template") 36 .getElementById("download-label-" + detectedPlatform)
37 .innerHTML; 37 .textContent;
38 38
39 heroDownloadButton.addEventListener("click", function(event) 39 heroDownloadButton.addEventListener("click", function(event)
40 { 40 {
41 if (!chrome || !chrome.webstore) return; 41 if (typeof chrome == "undefined") 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.
42 event.preventDefault(); 42 event.preventDefault();
43 chrome.webstore.install(); 43
44 try
45 {
46 chrome.webstore.install();
47 }
48 catch(error)
49 {
50 window.location = "/" + this.hreflang + "/download";
51 }
44 }); 52 });
45 } 53 }
46 54
47 if (bowser) setupHeroDownloadButton(); 55 if (typeof bowser != "undefined") 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.
48 56
49 }()); 57 }());
LEFTRIGHT

Powered by Google App Engine
This is Rietveld