Skip to content

Commit 524ad29

Browse files
committed
FEATURE: Add some kind of fallback to not display undefined
1 parent 24831fb commit 524ad29

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

iv_script.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ function create_issue(issue_url, domain_name, author_name, creator_name, comment
1414
return html;
1515
}
1616

17+
function get_domain_from_url(issue) {
18+
var regExp = /https:\/\/instantview\.telegram\.org\/contest\/(.*?)\/template[0-9]+\/issue[0-9]+\/?/g;
19+
var domain_name = regExp.exec(issue.url)[1];
20+
return domain_name;
21+
}
22+
1723
function filter() {
1824
// Get all filters
1925
self_made_cb = document.getElementById("self-made-cb");
@@ -90,7 +96,12 @@ function filter() {
9096
if (domain_search != "") {
9197
tmp_result_set = [];
9298
ret_result_set.forEach(issue => {
93-
if (issue.domain.toLowerCase().includes(String(domain_search).toLowerCase())) {
99+
domain = issue.domain;
100+
if (domain == undefined) {
101+
domain=get_domain_from_url(issue);
102+
}
103+
104+
if (domain.toLowerCase().includes(String(domain_search).toLowerCase())) {
94105
tmp_result_set.push(issue);
95106
}
96107
});
@@ -161,8 +172,13 @@ function draw_result_set() {
161172
let html = "";
162173

163174
result_set.forEach(issue => {
175+
domain = issue.domain;
176+
if (domain == undefined) {
177+
domain=get_domain_from_url(issue);
178+
}
179+
164180
if (issue.author.includes(String(name)) || issue.template_creator.includes(String(name))) {
165-
html += create_issue(issue.url, issue.domain, issue.author, issue.template_creator, issue.comment, issue.creator_comment);
181+
html += create_issue(issue.url, domain, issue.author, issue.template_creator, issue.comment, issue.creator_comment);
166182
}
167183
});
168184
list.innerHTML = html;

0 commit comments

Comments
 (0)