Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加查询app自动完成功能 #405

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions disconf-web/html/assets/js/mainList.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
+ '</a></li>';
});
$("#applist").html(html);
doAutoComplete();
}
});
$("#applist").on('click', 'li a', function (e) {
Expand Down Expand Up @@ -408,4 +409,59 @@
fetchZkDeploy();
});

/*
添加自动完成查询功能
*/
function doAutoComplete() {

var txtList = [];
var relList = {};
lst = $("a[rel]");

var j = 0;
var myUi;
for (var i = 0; i < lst.length; i++) {

var ele = lst[i];
var rel = ele.rel;
var text = ele.text;
if (rel) {
var t = text.replace("APP: ", "");
txtList[j] = t;
relList[t] = rel;
j++;
}
}


$("#appAutoList").autocomplete({
minLength:0,
source: txtList,
select: function (event, ui) {
myUi = ui;
if (ui.item) {
var stext = ui.item.label;
//console.log("data=" + stext);
var relId = relList[stext];
if (relId) {
//console.log("relId=" + relId);
appId = relId;
$("#app_info").html(", " + stext);
$("#appDropdownMenuTitle").text(stext);
version = "#";
fetchVersion(appId, envId);
}
}

}
});

$("#appAutoList").dblclick(function () {
$("#appAutoList").val("");
});

}



})(jQuery);
3 changes: 3 additions & 0 deletions disconf-web/html/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
<div class="row-fluid" style="min-height:400px;">
<div class="sidebar span2" style="float:left;overflow:visible;">

<label style="color: red"> 请输入查询:</label><br/>
<input type="text" id="appAutoList" style="width: 120px;height: 36px;" /> <br/>

<div class="dropdown" style="margin-top:20px;width:100%">
<button class="btn btn-default dropdown-toggle" type="button" id="appDropdownMenu" data-toggle="dropdown" style="width:100%;">
<span id="appDropdownMenuTitle">Apps</span>
Expand Down