Revision c483ae19
Added by koszko about 2 years ago
html/display-panel.js | ||
---|---|---|
144 | 144 |
} |
145 | 145 |
|
146 | 146 |
const connected_chbx = by_id("connected_chbx"); |
147 |
const query_pattern_but = by_id("query_pattern"); |
|
147 | 148 |
|
148 | 149 |
function try_to_connect(tab_id) |
149 | 150 |
{ |
... | ... | |
151 | 152 |
const connect_info = {name: CONNECTION_TYPE.ACTIVITY_INFO, frameId: 0}; |
152 | 153 |
const port = browser.tabs.connect(tab_id, connect_info); |
153 | 154 |
|
154 |
port.onDisconnect.addListener(port => handle_disconnect(tab_id)); |
|
155 |
const button_cb = (e) => start_querying_repos(port); |
|
156 |
|
|
157 |
port.onDisconnect.addListener(port => handle_disconnect(tab_id, button_cb)); |
|
155 | 158 |
port.onMessage.addListener(handle_activity_report); |
156 | 159 |
|
160 |
query_pattern_but.addEventListener("click", button_cb); |
|
161 |
|
|
157 | 162 |
if (is_mozilla) |
158 | 163 |
setTimeout(() => monitor_connecting(port, tab_id), 1000); |
159 | 164 |
} |
160 | 165 |
|
166 |
const query_started_chbx = by_id("query_started_chbx"); |
|
167 |
|
|
168 |
function start_querying_repos(port) |
|
169 |
{ |
|
170 |
port.postMessage("dummy (trigger repo querying)"); |
|
171 |
query_started_chbx.checked = true; |
|
172 |
} |
|
173 |
|
|
161 | 174 |
const loading_chbx = by_id("loading_chbx"); |
162 | 175 |
|
163 |
function handle_disconnect(tab_id) |
|
176 |
function handle_disconnect(tab_id, button_cb)
|
|
164 | 177 |
{ |
178 |
query_pattern_but.removeEventListener("click", button_cb); |
|
179 |
|
|
165 | 180 |
if (is_chrome && !browser.runtime.lastError) |
166 | 181 |
return; |
167 | 182 |
|
168 |
/* return if there was no connection initialization failure */
|
|
183 |
/* return if error was not during connection initialization */
|
|
169 | 184 |
if (connected_chbx.checked) |
170 | 185 |
return; |
171 | 186 |
|
... | ... | |
189 | 204 |
const payload_span = by_id("payload"); |
190 | 205 |
const view_payload_but = by_id("view_payload"); |
191 | 206 |
const container_for_injected = by_id("container_for_injected"); |
207 |
const container_for_repo_responses = by_id("container_for_repo_responses"); |
|
192 | 208 |
|
193 | 209 |
function handle_activity_report(message) |
194 | 210 |
{ |
... | ... | |
197 | 213 |
const [type, data] = message; |
198 | 214 |
|
199 | 215 |
if (type === "settings") { |
200 |
let [pattern, settings] = data; |
|
216 |
let [pattern, settings, repos] = data;
|
|
201 | 217 |
|
202 | 218 |
settings = settings || {}; |
203 | 219 |
blocked_span.textContent = settings.allow ? "no" : "yes"; |
... | ... | |
231 | 247 |
container_for_injected.appendChild(h4); |
232 | 248 |
container_for_injected.appendChild(pre); |
233 | 249 |
} |
250 |
if (type === "repo_query_result") { |
|
251 |
const [repo_url, response_text] = data; |
|
252 |
|
|
253 |
const h4 = document.createElement("h4"); |
|
254 |
const pre = document.createElement("pre"); |
|
255 |
h4.textContent = repo_url; |
|
256 |
pre.textContent = response_text; |
|
257 |
|
|
258 |
container_for_repo_responses.appendChild(h4); |
|
259 |
container_for_repo_responses.appendChild(pre); |
|
260 |
} |
|
234 | 261 |
} |
235 | 262 |
|
236 | 263 |
by_id("settings_but") |
Also available in: Unified diff
add ability to query page content from repo and display it in the popup