[fix] Fixed search trouble (broadband overload) to search only if no new char in 500ms after
This commit is contained in:
parent
e0f20cdd85
commit
c9da8708ae
|
@ -2,9 +2,13 @@
|
||||||
var section = {
|
var section = {
|
||||||
view: {
|
view: {
|
||||||
text: '#CONTAINER > section[data-sublink="view"] ',
|
text: '#CONTAINER > section[data-sublink="view"] ',
|
||||||
element: document.querySelector('#CONTAINER > section[data-sublink="view"]'),
|
element: document.querySelector('#CONTAINER > section[data-sublink="view"]'),
|
||||||
searchbar: document.querySelector('#CONTAINER > section[data-sublink="view"] > .searchbar')
|
search: {
|
||||||
},
|
bar: document.querySelector('#CONTAINER > section[data-sublink="view"] > .searchbar'),
|
||||||
|
func: null,
|
||||||
|
time: null // search time manager (interval)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
details: {
|
details: {
|
||||||
text: '#CONTAINER > section[data-sublink="details"] ',
|
text: '#CONTAINER > section[data-sublink="details"] ',
|
||||||
|
@ -24,18 +28,24 @@ var section = {
|
||||||
*/
|
*/
|
||||||
if( section.view.element != null ){
|
if( section.view.element != null ){
|
||||||
|
|
||||||
|
/* (0) On gère le zoom sur un log via URL */
|
||||||
|
if( pageManager.vars.length > 1 && !isNaN(pageManager.vars[1]) ){
|
||||||
|
document.location = '#'+pageManager.vars[1];
|
||||||
|
if( document.getElementById(pageManager.vars[1]) != null )
|
||||||
|
document.getElementById(pageManager.vars[1]).addClass('selected');
|
||||||
|
}
|
||||||
|
|
||||||
/* (1) On recupere tous les liens */
|
/* (1) On recupere tous les liens */
|
||||||
section.view.link = {
|
section.view.link = {
|
||||||
details: document.querySelectorAll(section.view.text + 'button[data-details]')
|
details: document.querySelectorAll(section.view.text + 'button[data-details]')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* (2) Gestion de la recherche instantannee */
|
/* (2) Gestion de la recherche instantannee */
|
||||||
section.view.searchbar.addEventListener('keyup', function(e){
|
section.view.search.func = function(){
|
||||||
|
var search = {
|
||||||
var search = {
|
|
||||||
path: 'historyDefault/search',
|
path: 'historyDefault/search',
|
||||||
keywords: section.view.searchbar.value
|
keywords: section.view.search.bar.value
|
||||||
};
|
};
|
||||||
|
|
||||||
// On envoie la requete
|
// On envoie la requete
|
||||||
|
@ -62,10 +72,29 @@ if( section.view.element != null ){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
section.view.search.bar.addEventListener('keyup', function(e){
|
||||||
|
|
||||||
|
if( section.view.search.time != null )
|
||||||
|
clearTimeout(section.view.search.time);
|
||||||
|
|
||||||
|
section.view.search.time = setTimeout(section.view.search.func, 500);
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
|
||||||
|
/* (3) On gere la "redirection" vers les détail */
|
||||||
|
for( var i = 0 ; i < section.view.link.details.length ; i++ ){
|
||||||
|
|
||||||
|
section.view.link.details[i].addEventListener('click', function(e){
|
||||||
|
pageManager.vars = [ 'details', e.target.getData('details') ];
|
||||||
|
pageManager.refresh();
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,11 @@ var section = {
|
||||||
view: {
|
view: {
|
||||||
text: '#CONTAINER > section[data-sublink="view"] ',
|
text: '#CONTAINER > section[data-sublink="view"] ',
|
||||||
element: document.querySelector('#CONTAINER > section[data-sublink="view"]'),
|
element: document.querySelector('#CONTAINER > section[data-sublink="view"]'),
|
||||||
searchbar: document.querySelector('#CONTAINER > section[data-sublink="view"] > .searchbar')
|
search: {
|
||||||
|
bar: document.querySelector('#CONTAINER > section[data-sublink="view"] > .searchbar'),
|
||||||
|
func: null,
|
||||||
|
time: null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
create: {
|
create: {
|
||||||
|
@ -24,7 +28,11 @@ var section = {
|
||||||
groups: {
|
groups: {
|
||||||
text: '#CONTAINER > section[data-sublink="groups"] ',
|
text: '#CONTAINER > section[data-sublink="groups"] ',
|
||||||
element: document.querySelector('#CONTAINER > section[data-sublink="groups"]'),
|
element: document.querySelector('#CONTAINER > section[data-sublink="groups"]'),
|
||||||
searchbar: document.querySelector('#CONTAINER > section[data-sublink="groups"] > .searchbar')
|
search: {
|
||||||
|
bar: document.querySelector('#CONTAINER > section[data-sublink="groups"] > .searchbar'),
|
||||||
|
func: null,
|
||||||
|
time: null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -56,11 +64,11 @@ if( section.view.element != null ){
|
||||||
|
|
||||||
|
|
||||||
/* (3) Gestion de la recherche instantannee */
|
/* (3) Gestion de la recherche instantannee */
|
||||||
section.view.searchbar.addEventListener('keyup', function(e){
|
section.view.search.func = function(){
|
||||||
|
|
||||||
var search = {
|
var search = {
|
||||||
path: 'machineDefault/search',
|
path: 'machineDefault/search',
|
||||||
keywords: section.view.searchbar.value
|
keywords: section.view.search.bar.value
|
||||||
};
|
};
|
||||||
|
|
||||||
// On envoie la requete
|
// On envoie la requete
|
||||||
|
@ -87,6 +95,15 @@ if( section.view.element != null ){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
section.view.search.bar.addEventListener('keyup', function(e){
|
||||||
|
|
||||||
|
if( section.view.search.time != null )
|
||||||
|
clearTimeout(section.view.search.time);
|
||||||
|
|
||||||
|
section.view.search.time = setTimeout(section.view.search.func, 500);
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
|
||||||
|
@ -772,11 +789,11 @@ if( section.groups.element != null ){
|
||||||
|
|
||||||
|
|
||||||
/* (3) Gestion de la recherche instantannee */
|
/* (3) Gestion de la recherche instantannee */
|
||||||
section.groups.searchbar.addEventListener('keyup', function(e){
|
section.groups.search.func = function(){
|
||||||
|
|
||||||
var search = {
|
var search = {
|
||||||
path: 'clusterDefault/search',
|
path: 'clusterDefault/search',
|
||||||
keywords: section.groups.searchbar.value,
|
keywords: section.groups.search.bar.value,
|
||||||
class: 1
|
class: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -804,6 +821,15 @@ if( section.groups.element != null ){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
section.groups.search.bar.addEventListener('keyup', function(e){
|
||||||
|
|
||||||
|
if( section.groups.search.time != null )
|
||||||
|
clearTimeout(section.groups.search.time);
|
||||||
|
|
||||||
|
section.groups.search.time = setTimeout(section.groups.search.func, 500);
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
var i;
|
var i;
|
||||||
|
|
|
@ -3,7 +3,11 @@ var section = {
|
||||||
view: {
|
view: {
|
||||||
text: '#CONTAINER > section[data-sublink="view"] ',
|
text: '#CONTAINER > section[data-sublink="view"] ',
|
||||||
element: document.querySelector('#CONTAINER > section[data-sublink="view"]'),
|
element: document.querySelector('#CONTAINER > section[data-sublink="view"]'),
|
||||||
searchbar: document.querySelector('#CONTAINER > section[data-sublink="view"] > .searchbar')
|
search: {
|
||||||
|
bar: document.querySelector('#CONTAINER > section[data-sublink="view"] > .searchbar'),
|
||||||
|
func: null,
|
||||||
|
time: null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
create: {
|
create: {
|
||||||
|
@ -24,7 +28,11 @@ var section = {
|
||||||
groups: {
|
groups: {
|
||||||
text: '#CONTAINER > section[data-sublink="groups"] ',
|
text: '#CONTAINER > section[data-sublink="groups"] ',
|
||||||
element: document.querySelector('#CONTAINER > section[data-sublink="groups"]'),
|
element: document.querySelector('#CONTAINER > section[data-sublink="groups"]'),
|
||||||
searchbar: document.querySelector('#CONTAINER > section[data-sublink="groups"] > .searchbar')
|
search: {
|
||||||
|
bar: document.querySelector('#CONTAINER > section[data-sublink="groups"] > .searchbar'),
|
||||||
|
func: null,
|
||||||
|
time: null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -61,11 +69,11 @@ if( section.view.element != null ){
|
||||||
|
|
||||||
|
|
||||||
/* (3) Gestion de la recherche instantannee */
|
/* (3) Gestion de la recherche instantannee */
|
||||||
section.view.searchbar.addEventListener('keyup', function(e){
|
section.view.search.func = function(){
|
||||||
|
|
||||||
var search = {
|
var search = {
|
||||||
path: 'userDefault/search',
|
path: 'userDefault/search',
|
||||||
keywords: section.view.searchbar.value
|
keywords: section.view.search.bar.value
|
||||||
};
|
};
|
||||||
|
|
||||||
// On envoie la requete
|
// On envoie la requete
|
||||||
|
@ -95,6 +103,15 @@ if( section.view.element != null ){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
section.view.search.bar.addEventListener('keyup', function(e){
|
||||||
|
|
||||||
|
if( section.view.search.time != null )
|
||||||
|
clearTimeout(section.view.search.time);
|
||||||
|
|
||||||
|
section.view.search.time = setTimeout(section.view.search.func, 500);
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
|
||||||
|
@ -824,11 +841,11 @@ if( section.groups.element != null ){
|
||||||
|
|
||||||
|
|
||||||
/* (3) Gestion de la recherche instantannee */
|
/* (3) Gestion de la recherche instantannee */
|
||||||
section.groups.searchbar.addEventListener('keyup', function(e){
|
section.groups.search.func = function(){
|
||||||
|
|
||||||
var search = {
|
var search = {
|
||||||
path: 'clusterDefault/search',
|
path: 'clusterDefault/search',
|
||||||
keywords: section.groups.searchbar.value,
|
keywords: section.groups.search.bar.value,
|
||||||
class: 0
|
class: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -856,6 +873,15 @@ if( section.groups.element != null ){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
section.groups.search.bar.addEventListener('keyup', function(e){
|
||||||
|
|
||||||
|
if( section.groups.search.time != null )
|
||||||
|
clearTimeout(section.groups.search.time);
|
||||||
|
|
||||||
|
section.groups.search.time = setTimeout(section.groups.search.func, 500);
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
var i;
|
var i;
|
||||||
|
|
Loading…
Reference in New Issue