blob: 1eb1aad3a4707fc82f1c8ea0d1ff8d699cdb98f5 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001<script type="text/javascript" nonce="[nonce]">
2runOnLoad(function() {
3
4 [# Pass the list of column names from HTML to JS ]
5 window._allColumnNames = [
6 [for column_values]'[column_values.column_name]'[if-index column_values last][else], [end][end]
7 ];
8
9 [# Update the issue link hrefs on-load and whenever the column-spec changes.]
10 _ctxCan = [can];
11 _ctxQuery = "[format "js"][query][end]";
12 _ctxSortspec = "[format "js"][sortspec][end]";
13 _ctxGroupBy = "[format "js"][groupby][end]";
14 _ctxDefaultColspec = "[format "js"][default_colspec][end]";
15 _ctxStart = [start];
16 _ctxNum = [num];
17 _ctxResultsPerPage = [default_results_per_page];
18 _ctxHotlistID = "[hotlist_id]";
19 _ctxArgs = _formatContextQueryArgs();
20
21 function _goIssue(issueIndex, newWindow) {
22 var url = _makeIssueLink(issueRefs[[]issueIndex]);
23 _go(url, newWindow);
24 }
25 // Added to enable calling from TKR_openArtifactAtCursor
26 window._goIssue = _goIssue;
27
28 window.issueRefs = [[]
29 [for table_data]
30 {project_name: "[format "js"][table_data.project_name][end]",
31 id: [table_data.local_id]}[if-index table_data last][else],[end][end]
32 ];
33
34 function _handleResultsClick(event) {
35 var target = event.target;
36 if (event.button >= 3)
37 return;
38 if (target.classList.contains("label"))
39 return;
40 if (target.classList.contains("rowwidgets") || target.parentNode.classList.contains("rowwidgets"))
41 return;
42 while (target && target.tagName != "TR") target = target.parentNode;
43 if ('[is_hotlist]') {
44 if (!target.attributes[[]"issue-context-url"]) return;
45 _go(target.attributes[[]"issue-context-url"].value, (event.metaKey || event.ctrlKey || event.button == 1));
46 }
47 else {
48 if (!target.attributes[[]"data-idx"]) return;
49 _goIssue(target.attributes[[]"data-idx"].value,
50 (event.metaKey || event.ctrlKey || event.button == 1));
51 }
52 };
53 [if-any table_data]
54 _addClickListener($("resultstable"), _handleResultsClick);
55 [end]
56
57 var issueCheckboxes = document.getElementsByClassName("checkRangeSelect");
58 for (var i = 0; i < issueCheckboxes.length; ++i) {
59 var el = issueCheckboxes[[]i];
60 el.addEventListener("click", function (event) {
61 _checkRangeSelect(event, event.target);
62 _highlightRow(event.target);
63 });
64 }
65
66 function _handleHeaderClick(event) {
67 var target = event.target;
68 while (target && target.tagName != "TH") target = target.parentNode;
69 var colIndex = target.getAttribute("data-col-index");
70 if (colIndex) {
71 _showBelow("pop_" + colIndex, target);
72 }
73 event.preventDefault();
74 }
75 var resultsTableHead = $("resultstablehead");
76 if (resultsTableHead) {
77 resultsTableHead.addEventListener("click", _handleHeaderClick);
78 }
79
80 if (typeof(ClientLogger) == "function") {
81 let cl = new ClientLogger("issues");
82 if (cl.started("issue-search")) {
83 cl.logPause("issue-search", "computer-time");
84 cl.logResume("issue-search", "user-time");
85
86 // Now we want to listen for clicks on any issue search result.
87 let logResultClick = function() {
88 cl.logPause("issue-search", "user-time");
89 cl.logResume("issue-search", "computer-time");
90 }
91
92 let links = document.querySelectorAll("#resultstable tbody .id a");
93 for (let i = 0; i < links.length; i++) {
94 links[[]i].addEventListener("click", logResultClick);
95 }
96 }
97 }
98});
99</script>
100
101<script type="text/javascript" defer src="/static/third_party/js/keys.js?version=[app_version]" nonce="[nonce]"></script>
102<script type="text/javascript" defer src="/static/third_party/js/skipper.js?version=[app_version]" nonce="[nonce]"></script>
103<script type="text/javascript" nonce="[nonce]">
104runOnLoad(function() {
105 _setupKibblesOnListPage(
106 [is arg0 "issuelist"]'[project_home_url]/issues/list'[else]'[currentPageURLEncoded]'[end],
107 '[project_home_url]/issues/entry',
108 '[projectname]', [is arg0 "issuelist"]1[else]5[end], 0);
109});
110</script>