From d2d77b2a481a63cb5b7346ab26565edefdc7f901 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 30 Jul 2011 18:05:20 +0200 Subject: [PATCH] initial work on instant search --- core/js/js.js | 66 ++++++++++++++++++++++++++++--- core/templates/part.searchbox.php | 2 +- 2 files changed, 61 insertions(+), 7 deletions(-) diff --git a/core/js/js.js b/core/js/js.js index db96a1adb3e..fbc014006b0 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -47,18 +47,63 @@ OC={ }, addScript:function(app,script,ready){ var path=OC.filePath(app,'js',script+'.js'); - if(ready){ - $.getScript(path,ready); - }else{ - $.getScript(path); + if(OC.addStyle.loaded.indexOf(path)==-1){ + OC.addStyle.loaded.push(path); + if(ready){ + $.getScript(path,ready); + }else{ + $.getScript(path); + } } }, addStyle:function(app,style){ var path=OC.filePath(app,'css',style+'.css'); - var style=$(''); - $('head').append(style); + if(OC.addScript.loaded.indexOf(path)==-1){ + OC.addScript.loaded.push(path); + var style=$(''); + $('head').append(style); + } + }, + search:function(query){ + if(query){ + OC.addStyle('search','results'); + $.getJSON(OC.filePath('search','ajax','search.php')+'?query='+encodeURIComponent(query), OC.search.showResults); + } } } +OC.addStyle.loaded=[]; +OC.addScript.loaded=[]; + +OC.search.catagorizeResults=function(results){ + var types={}; + for(var i=0;i