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

Side by Side Diff: options.js

Issue 29335794: Proof-of-concept: Link version to corresponding announcement (Closed)
Patch Set: Send request on demand, always link for release builds, falling back to releases overview Created Feb. 5, 2016, 2:09 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « options.html ('k') | skin/options.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 getKey.keys = { 639 getKey.keys = {
640 9: "Tab", 640 9: "Tab",
641 13: "Enter", 641 13: "Enter",
642 27: "Escape" 642 27: "Escape"
643 }; 643 };
644 644
645 // Initialize navigation sidebar 645 // Initialize navigation sidebar
646 ext.backgroundPage.sendMessage( 646 ext.backgroundPage.sendMessage(
647 { 647 {
648 type: "app.get", 648 type: "app.get",
649 what: "addonVersion" 649 what: "info"
650 }, 650 },
651 function(addonVersion) 651 function(info)
652 { 652 {
653 E("abp-version").textContent = addonVersion; 653 E("abp-version").textContent = info.addonVersion;
654 }); 654
655 getDocLink("releases", function(link) 655 // Don't link version for development builds
656 { 656 if (info.addonVersion.split(".").length > 3)
657 E("link-version").setAttribute("href", link); 657 return;
658
659 E("version").setAttribute("href", "#");
660 E("version").addEventListener("click", function(event)
661 {
662 event.preventDefault();
663
664 fetch("https://adblockplus.org/atom/?section=releases&limit=100").then(f unction(response)
665 {
666 return repsonse.ok ? response.text() : "";
667 }).then(
668 function(text)
669 {
670 var doc = new DOMParser().parseFromString(text, "application/xml");
671 var entries = doc.getElementsByTagName("entry");
672 for (var i = 0; i < entries.length; i++)
673 {
674 var entry = entries[i];
675 var title = entry.getElementsByTagName("title")[0];
676 if (!title)
677 continue;
678
679 var lowerCaseTitleText = title.textContent.toLowerCase();
680 if (lowerCaseTitleText.split(/\W+/).indexOf(info.application) == - 1)
681 continue;
682 if (lowerCaseTitleText.split(/\s+/).indexOf(info.addonVersion) == -1)
683 continue;
684
685 var links = entry.getElementsByTagName("link");
686 for (var j = 0; j < links.length; j++)
687 {
688 var link = links[j];
689 var href = link.getAttribute("href");
690
691 if (link.getAttribute("rel") == "alternate" && href)
692 return href;
693 }
694 }
695 },
696 function()
697 {
698 return null;
699 }
700 ).then(function(url)
701 {
702 if (url)
703 document.location.href = url;
704 else
705 getDocLink("releases", function(link)
706 {
707 document.location.href = link;
708 });
709 });
658 }); 710 });
659 711
660 getDocLink("contribute", function(link) 712 getDocLink("contribute", function(link)
661 { 713 {
662 document.querySelector("#tab-contribute a").setAttribute("href", link); 714 document.querySelector("#tab-contribute a").setAttribute("href", link);
663 }); 715 });
664 716
665 updateShareLink(); 717 updateShareLink();
666 718
667 // Initialize interactive UI elements 719 // Initialize interactive UI elements
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 filter: ["added", "loaded", "removed"] 1070 filter: ["added", "loaded", "removed"]
1019 }); 1071 });
1020 ext.backgroundPage.sendMessage( 1072 ext.backgroundPage.sendMessage(
1021 { 1073 {
1022 type: "subscriptions.listen", 1074 type: "subscriptions.listen",
1023 filter: ["added", "disabled", "homepage", "lastDownload", "removed", "title" ] 1075 filter: ["added", "disabled", "homepage", "lastDownload", "removed", "title" ]
1024 }); 1076 });
1025 1077
1026 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1078 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1027 })(); 1079 })();
OLDNEW
« no previous file with comments | « options.html ('k') | skin/options.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld