| Index: static/js/index.js |
| =================================================================== |
| new file mode 100644 |
| --- /dev/null |
| +++ b/static/js/index.js |
| @@ -0,0 +1,77 @@ |
| +"use strict"; |
|
juliandoucette
2018/04/04 10:18:23
Why is this necessary?
ire
2018/04/05 14:32:43
I originally added it because it was in the main.j
juliandoucette
2018/04/06 12:35:22
Ack.
I don't really think it's necessary. Therefo
ire
2018/04/06 13:21:48
Acknowledged.
|
| + |
| +(function() |
| +{ |
| + var supportedPlatforms = { |
| + // Desktop browsers |
|
juliandoucette
2018/04/04 10:18:23
NIT: Please put one blank line above to make this
ire
2018/04/05 14:32:44
Done.
|
| + "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; |
|
juliandoucette
2018/04/04 10:18:23
NITs
- It took me a minute to figure out what you
ire
2018/04/05 14:32:43
I'll go with your implementation.
Done.
|
| + |
| + 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); |
|
juliandoucette
2018/04/04 10:18:23
"browser" is not fixed in the include. Therefore,
juliandoucette
2018/04/04 10:18:23
I think the browser name itself is translated in s
ire
2018/04/05 14:32:43
Done.
ire
2018/04/05 14:32:43
Done.
|
| + |
| + heroDownloadButton.addEventListener("click", function(event) |
|
juliandoucette
2018/04/04 10:18:23
I think chrome.webstore.install works on other chr
ire
2018/04/05 14:32:43
You're right. I switch to checking for the "chrome
|
| + { |
| + if (detectedPlatform !== "chrome") return; |
| + event.preventDefault(); |
| + chrome.webstore.install(); |
| + }); |
| + } |
| + |
| + if (bowser) setupHeroDownloadButton(); |
| + |
| +}()); |