[init]
This commit is contained in:
commit
aae4e3df8d
11 changed files with 1289 additions and 0 deletions
45
public/js/app.js
Normal file
45
public/js/app.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/* global initData */
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @type type
|
||||
*/
|
||||
const serviceContainer = {};
|
||||
|
||||
|
||||
function updatePage(data){
|
||||
|
||||
var content = "";
|
||||
$.each(data.hits.hits, (k,v)=>{
|
||||
var item = v._source;
|
||||
content += `
|
||||
|
||||
<div class="log row-fluid">
|
||||
<div class="span9">
|
||||
<p>${item.created_at} ${item.author} ${item.server}
|
||||
<h4> ${item.content}</h4>
|
||||
</span>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
$("#content").html(content);
|
||||
|
||||
}
|
||||
|
||||
$("input").on("keydown",function(e){
|
||||
const el = $(e.target);
|
||||
const val = el.val();
|
||||
if( val.length < 3 ){ return; }
|
||||
$.ajax("/search",{
|
||||
data: {q:val}
|
||||
})
|
||||
.done(function(data) {
|
||||
updatePage(data);
|
||||
})
|
||||
.fail(function() {
|
||||
alert( "error" );
|
||||
});
|
||||
});
|
||||
|
||||
updatePage( initData );
|
||||
Loading…
Add table
Add a link
Reference in a new issue