Skip to content

Commit

Permalink
pref: 优化搜索时错误提示
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Dec 1, 2022
1 parent 09cd161 commit 37b977c
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,21 @@ <h4>相关替代</h4>
baseParams.source = $('#search_source_val').val();
$.getJSON('/', baseParams)
.success(function (data) {
let subjects = data.data;
gen_help.html(subjects.reduce((accumulator, currentValue) => {
return accumulator += "<tr><td>" + currentValue.year + "</td><td>" + currentValue.subtype + "</td><td>" + currentValue.title + (currentValue.subtitle && currentValue.subtitle !== currentValue.title ? ('<br>' + currentValue.subtitle) : '') + "</td><td><a href='" + currentValue.link + "' target='_blank'>" + currentValue.link + "</a></td><td><a href='javascript:void(0);' class='gen-search-choose' data-url='" + currentValue.link + "'>选择</a></td></tr>";
}, "<table id='gen_help_table' class='table table-striped table-hover'><thead><tr><th>年代</th><th>类别</th><th>标题</th><th>资源链接</th><th>行为</th></tr></thead><tbody>"));
$("a.gen-search-choose").click(function () {
let tag = $(this);
input_btn.val(tag.attr("data-url"));
search_source.hideBtn();
query_btn.click();
});
if (data["success"] === false) {
alert(data["error"]);
} else {
let subjects = data.data;
gen_help.html(subjects.reduce((accumulator, currentValue) => {
return accumulator += "<tr><td>" + currentValue.year + "</td><td>" + currentValue.subtype + "</td><td>" + currentValue.title + (currentValue.subtitle && currentValue.subtitle !== currentValue.title ? ('<br>' + currentValue.subtitle) : '') + "</td><td><a href='" + currentValue.link + "' target='_blank'>" + currentValue.link + "</a></td><td><a href='javascript:void(0);' class='gen-search-choose' data-url='" + currentValue.link + "'>选择</a></td></tr>";
}, "<table id='gen_help_table' class='table table-striped table-hover'><thead><tr><th>年代</th><th>类别</th><th>标题</th><th>资源链接</th><th>行为</th></tr></thead><tbody>"));
$("a.gen-search-choose").click(function () {
let tag = $(this);
input_btn.val(tag.attr("data-url"));
search_source.hideBtn();
query_btn.click();
});
}

})
.fail(failedFunc)
.complete(completeFunc);
Expand Down

0 comments on commit 37b977c

Please sign in to comment.