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

Side by Side Diff: stats.js

Issue 29460566: Noissue - Remove DOMContentLoaded listeners after they've fired (Closed)
Patch Set: Created June 9, 2017, 1:25 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 | « popup.js ('k') | no next file » | 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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // Update stats 87 // Update stats
88 ext.pages.query({active: true, lastFocusedWindow: true}, pages => 88 ext.pages.query({active: true, lastFocusedWindow: true}, pages =>
89 { 89 {
90 currentPage = pages[0]; 90 currentPage = pages[0];
91 updateStats(); 91 updateStats();
92 92
93 FilterNotifier.on("filter.hitCount", updateStats); 93 FilterNotifier.on("filter.hitCount", updateStats);
94 94
95 document.getElementById("stats-container").removeAttribute("hidden"); 95 document.getElementById("stats-container").removeAttribute("hidden");
96 }); 96 });
97
98 document.removeEventListener("DOMContentLoaded", onLoad);
97 } 99 }
98 100
99 function onUnload() 101 function onUnload()
100 { 102 {
101 FilterNotifier.off("filter.hitCount", updateStats); 103 FilterNotifier.off("filter.hitCount", updateStats);
102 } 104 }
103 105
104 function updateStats() 106 function updateStats()
105 { 107 {
106 let statsPage = document.getElementById("stats-page"); 108 let statsPage = document.getElementById("stats-page");
(...skipping 21 matching lines...) Expand all
128 { 130 {
129 Prefs.show_statsinicon = !Prefs.show_statsinicon; 131 Prefs.show_statsinicon = !Prefs.show_statsinicon;
130 document.getElementById("show-iconnumber").setAttribute( 132 document.getElementById("show-iconnumber").setAttribute(
131 "aria-checked", Prefs.show_statsinicon 133 "aria-checked", Prefs.show_statsinicon
132 ); 134 );
133 } 135 }
134 136
135 document.addEventListener("DOMContentLoaded", onLoad, false); 137 document.addEventListener("DOMContentLoaded", onLoad, false);
136 window.addEventListener("unload", onUnload, false); 138 window.addEventListener("unload", onUnload, false);
137 }()); 139 }());
OLDNEW
« no previous file with comments | « popup.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld