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');
+ for(var name in types){
+ var type=types[name];
+ if(type.length>0){
+ ul.append($('- '+name+'
'));
+ for(var i=0;i'));
+ li.append($(''+item.name+''));
+ li.append($(''+item.text+''));
+ ul.append(li);
+ }
+ }
+ }
+ $('body').append(ul);
+}
if (!Array.prototype.filter) {
Array.prototype.filter = function(fun /*, thisp*/) {
@@ -112,4 +157,13 @@ $(document).ready(function(){
element.attr('src',src.substr(0,src.length-3)+'png');
});
};
+ $('#searchbox').keyup(function(){
+ var query=$('#searchbox').val();
+ if(query.length>2){
+ OC.search(query);
+ }else{
+ $('#searchresults').remove();
+ }
+ });
+ $('#searchbox').click(function(){$('#searchbox').trigger('keyup')});
});
diff --git a/core/templates/part.searchbox.php b/core/templates/part.searchbox.php
index efce47ecd24..ddf184ed5b6 100644
--- a/core/templates/part.searchbox.php
+++ b/core/templates/part.searchbox.php
@@ -1,3 +1,3 @@