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

Delta Between Two Patch Sets: options.js

Issue 29335794: Proof-of-concept: Link version to corresponding announcement (Closed)
Left Patch Set: Always send request, no link if no release post found Created Feb. 5, 2016, 1:44 p.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « options.html ('k') | skin/options.css » ('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 /* 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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
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: "info" 649 what: "info"
650 }, 650 },
651 function(info) 651 function(info)
652 { 652 {
653 E("abp-version").textContent = info.addonVersion; 653 E("abp-version").textContent = info.addonVersion;
654 654
655 fetch("https://adblockplus.org/atom/?section=releases&limit=100").then(fun ction(response) 655 // Don't link version for development builds
Thomas Greiner 2016/02/05 14:24:37 We shouldn't ping our servers everytime someone op
Wladimir Palant 2016/02/05 14:29:44 Indeed. If we need this feature we need to set up
Sebastian Noack 2016/02/05 14:37:18 Please note the alternative approach in patch set
656 { 656 if (info.addonVersion.split(".").length > 3)
657 return repsonse.ok ? response.text() : ""; 657 return;
658 }).then( 658
659 function(text) 659 E("version").setAttribute("href", "#");
660 { 660 E("version").addEventListener("click", function(event)
661 var doc = new DOMParser().parseFromString(text, "application/xml"); 661 {
662 var entries = doc.getElementsByTagName("entry"); 662 event.preventDefault();
663 for (var i = 0; i < entries.length; i++) 663
664 { 664 fetch("https://adblockplus.org/atom/?section=releases&limit=100").then(f unction(response)
665 var entry = entries[i]; 665 {
666 var title = entry.getElementsByTagName("title")[0]; 666 return repsonse.ok ? response.text() : "";
667 if (!title) 667 }).then(
668 continue; 668 function(text)
669 669 {
670 var lowerCaseTitleText = title.textContent.toLowerCase(); 670 var doc = new DOMParser().parseFromString(text, "application/xml");
671 if (lowerCaseTitleText.split(/\W+/).indexOf(info.application) == -1) 671 var entries = doc.getElementsByTagName("entry");
Thomas Greiner 2016/02/05 14:24:37 That doesn't seem too reliable because it's more o
Sebastian Noack 2016/02/05 14:37:18 I guess we could omit that check as well. Not sure
672 continue; 672 for (var i = 0; i < entries.length; i++)
673 if (lowerCaseTitleText.split(/\s+/).indexOf(info.addonVersion) == -1)
674 continue;
675
676 var links = entry.getElementsByTagName("link");
677 for (var j = 0; j < links.length; j++)
678 {
679 var link = links[j];
680 var href = link.getAttribute("href");
681
682 if (link.getAttribute("rel") == "alternate" && href)
683 { 673 {
684 E("version").setAttribute("href", href); 674 var entry = entries[i];
685 return; 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 }
686 } 694 }
687 } 695 },
688 } 696 function()
689 }).catch(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 });
690 }); 710 });
691 711
692 getDocLink("contribute", function(link) 712 getDocLink("contribute", function(link)
693 { 713 {
694 document.querySelector("#tab-contribute a").setAttribute("href", link); 714 document.querySelector("#tab-contribute a").setAttribute("href", link);
695 }); 715 });
696 716
697 updateShareLink(); 717 updateShareLink();
698 718
699 // Initialize interactive UI elements 719 // Initialize interactive UI elements
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 filter: ["added", "loaded", "removed"] 1070 filter: ["added", "loaded", "removed"]
1051 }); 1071 });
1052 ext.backgroundPage.sendMessage( 1072 ext.backgroundPage.sendMessage(
1053 { 1073 {
1054 type: "subscriptions.listen", 1074 type: "subscriptions.listen",
1055 filter: ["added", "disabled", "homepage", "lastDownload", "removed", "title" ] 1075 filter: ["added", "disabled", "homepage", "lastDownload", "removed", "title" ]
1056 }); 1076 });
1057 1077
1058 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1078 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1059 })(); 1079 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld