Simplify search result js code

This commit is contained in:
Bart Visscher 2012-06-22 17:43:57 +02:00
parent 618a3c1d94
commit f4b937c6fe
1 changed files with 4 additions and 14 deletions

View File

@ -41,23 +41,13 @@ OC.search.showResults=function(results){
for(var name in types){ for(var name in types){
var type=types[name]; var type=types[name];
if(type.length>0){ if(type.length>0){
for(var i=0;i<type.length;i++){
var row=$('#searchresults tr.template').clone(); var row=$('#searchresults tr.template').clone();
row.removeClass('template'); row.removeClass('template');
row.addClass('result'); row.addClass('result');
if (index == 0){
row.children('td.type').text(name); row.children('td.type').text(name);
row.find('td.result a').attr('href',type[0].link);
row.find('td.result div.name').text(type[0].name);
row.find('td.result div.text').text(type[0].text);
row.data('index',index);
index++;
if(OC.search.customResults[name]){//give plugins the ability to customize the entries in here
OC.search.customResults[name](row,type[0]);
} }
$('#searchresults tbody').append(row);
for(var i=1;i<type.length;i++){
var row=$('#searchresults tr.template').clone();
row.removeClass('template');
row.addClass('result');
row.find('td.result a').attr('href',type[i].link); row.find('td.result a').attr('href',type[i].link);
row.find('td.result div.name').text(type[i].name); row.find('td.result div.name').text(type[i].name);
row.find('td.result div.text').text(type[i].text); row.find('td.result div.text').text(type[i].text);