eric7/DebugClients/Python/coverage/htmlfiles/coverage_html.js

branch
eric7
changeset 9099
0e511e0e94a3
parent 8775
0802ae193343
equal deleted inserted replaced
9098:fb9351497cea 9099:0e511e0e94a3
21 function checkVisible(element) { 21 function checkVisible(element) {
22 const rect = element.getBoundingClientRect(); 22 const rect = element.getBoundingClientRect();
23 const viewBottom = Math.max(document.documentElement.clientHeight, window.innerHeight); 23 const viewBottom = Math.max(document.documentElement.clientHeight, window.innerHeight);
24 const viewTop = 30; 24 const viewTop = 30;
25 return !(rect.bottom < viewTop || rect.top >= viewBottom); 25 return !(rect.bottom < viewTop || rect.top >= viewBottom);
26 }
27
28 function on_click(sel, fn) {
29 const elt = document.querySelector(sel);
30 if (elt) {
31 elt.addEventListener("click", fn);
32 }
26 } 33 }
27 34
28 // Helpers for table sorting 35 // Helpers for table sorting
29 function getCellValue(row, column = 0) { 36 function getCellValue(row, column = 0) {
30 const cell = row.cells[column] 37 const cell = row.cells[column]
191 localStorage.setItem(coverage.INDEX_SORT_STORAGE, JSON.stringify({ 198 localStorage.setItem(coverage.INDEX_SORT_STORAGE, JSON.stringify({
192 column: [...th.parentElement.cells].indexOf(th), 199 column: [...th.parentElement.cells].indexOf(th),
193 direction: th.getAttribute("aria-sort"), 200 direction: th.getAttribute("aria-sort"),
194 })); 201 }));
195 }); 202 });
203
204 on_click(".button_prev_file", coverage.to_prev_file);
205 on_click(".button_next_file", coverage.to_next_file);
206
207 on_click(".button_show_hide_help", coverage.show_hide_help);
196 }; 208 };
197 209
198 // -- pyfile stuff -- 210 // -- pyfile stuff --
199 211
200 coverage.LINE_FILTERS_STORAGE = "COVERAGE_LINE_FILTERS"; 212 coverage.LINE_FILTERS_STORAGE = "COVERAGE_LINE_FILTERS";
207 coverage.set_sel(parseInt(frag.substr(2), 10)); 219 coverage.set_sel(parseInt(frag.substr(2), 10));
208 } else { 220 } else {
209 coverage.set_sel(0); 221 coverage.set_sel(0);
210 } 222 }
211 223
212 const on_click = function(sel, fn) {
213 const elt = document.querySelector(sel);
214 if (elt) {
215 elt.addEventListener("click", fn);
216 }
217 }
218 on_click(".button_toggle_run", coverage.toggle_lines); 224 on_click(".button_toggle_run", coverage.toggle_lines);
219 on_click(".button_toggle_mis", coverage.toggle_lines); 225 on_click(".button_toggle_mis", coverage.toggle_lines);
220 on_click(".button_toggle_exc", coverage.toggle_lines); 226 on_click(".button_toggle_exc", coverage.toggle_lines);
221 on_click(".button_toggle_par", coverage.toggle_lines); 227 on_click(".button_toggle_par", coverage.toggle_lines);
222 228
223 on_click(".button_next_chunk", coverage.to_next_chunk_nicely); 229 on_click(".button_next_chunk", coverage.to_next_chunk_nicely);
224 on_click(".button_prev_chunk", coverage.to_prev_chunk_nicely); 230 on_click(".button_prev_chunk", coverage.to_prev_chunk_nicely);
225 on_click(".button_top_of_page", coverage.to_top); 231 on_click(".button_top_of_page", coverage.to_top);
226 on_click(".button_first_chunk", coverage.to_first_chunk); 232 on_click(".button_first_chunk", coverage.to_first_chunk);
233
234 on_click(".button_prev_file", coverage.to_prev_file);
235 on_click(".button_next_file", coverage.to_next_file);
236 on_click(".button_to_index", coverage.to_index);
237
238 on_click(".button_show_hide_help", coverage.show_hide_help);
227 239
228 coverage.filters = undefined; 240 coverage.filters = undefined;
229 try { 241 try {
230 coverage.filters = localStorage.getItem(coverage.LINE_FILTERS_STORAGE); 242 coverage.filters = localStorage.getItem(coverage.LINE_FILTERS_STORAGE);
231 } catch(err) {} 243 } catch(err) {}
296 308
297 coverage.to_first_chunk = function () { 309 coverage.to_first_chunk = function () {
298 coverage.set_sel(0, 1); 310 coverage.set_sel(0, 1);
299 coverage.to_next_chunk(); 311 coverage.to_next_chunk();
300 }; 312 };
313
314 coverage.to_prev_file = function () {
315 window.location = document.getElementById("prevFileLink").href;
316 }
317
318 coverage.to_next_file = function () {
319 window.location = document.getElementById("nextFileLink").href;
320 }
321
322 coverage.to_index = function () {
323 location.href = document.getElementById("indexLink").href;
324 }
325
326 coverage.show_hide_help = function () {
327 const helpCheck = document.getElementById("help_panel_state")
328 helpCheck.checked = !helpCheck.checked;
329 }
301 330
302 // Return a string indicating what kind of chunk this line belongs to, 331 // Return a string indicating what kind of chunk this line belongs to,
303 // or null if not a chunk. 332 // or null if not a chunk.
304 coverage.chunk_indicator = function (line_elt) { 333 coverage.chunk_indicator = function (line_elt) {
305 const classes = line_elt?.className; 334 const classes = line_elt?.className;

eric ide

mercurial