2011-06-19 21:33:34 +00:00
|
|
|
function t(app,text){
|
2011-07-27 14:39:44 +00:00
|
|
|
if( !( app in t.cache )){
|
|
|
|
|
|
|
|
$.post( OC.filePath('core','ajax','translations.php'), {'app': app}, function(jsondata){
|
|
|
|
t.cache[app] = jsondata.data;
|
2011-06-19 21:33:34 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Bad answer ...
|
2011-07-27 14:39:44 +00:00
|
|
|
if( !( app in t.cache )){
|
|
|
|
t.cache[app] = [];
|
2011-06-19 21:33:34 +00:00
|
|
|
}
|
2011-05-17 20:34:31 +00:00
|
|
|
}
|
2011-07-27 14:39:44 +00:00
|
|
|
if( typeof( t.cache[app][text] ) !== 'undefined' ){
|
|
|
|
return t.cache[app][text];
|
2011-05-19 19:19:37 +00:00
|
|
|
}
|
2011-06-19 21:33:34 +00:00
|
|
|
else{
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
}
|
2011-07-27 14:39:44 +00:00
|
|
|
t.cache={};
|
2011-06-19 21:33:34 +00:00
|
|
|
|
2011-07-25 20:30:55 +00:00
|
|
|
OC={
|
|
|
|
webroot:oc_webroot,
|
2011-07-27 14:39:44 +00:00
|
|
|
coreApps:['files','admin','log','search','settings','core'],
|
2011-07-25 20:30:55 +00:00
|
|
|
linkTo:function(app,file){
|
|
|
|
return OC.filePath(app,'',file);
|
|
|
|
},
|
|
|
|
filePath:function(app,type,file){
|
|
|
|
var isCore=OC.coreApps.indexOf(app)!=-1;
|
|
|
|
app+='/';
|
|
|
|
var link=OC.webroot+'/';
|
|
|
|
if(!isCore){
|
|
|
|
link+='apps/';
|
|
|
|
}
|
|
|
|
link+=app;
|
|
|
|
if(type){
|
|
|
|
link+=type+'/'
|
|
|
|
}
|
|
|
|
link+=file;
|
|
|
|
return link;
|
|
|
|
},
|
|
|
|
imagePath:function(app,file){
|
2011-07-28 02:28:04 +00:00
|
|
|
if(file.indexOf('.')==-1){//if no extention is given, use png or svg depending on browser support
|
|
|
|
file+=(SVGSupport())?'.svg':'.png'
|
|
|
|
}
|
2011-07-25 20:30:55 +00:00
|
|
|
return OC.filePath(app,'img',file);
|
|
|
|
},
|
|
|
|
addScript:function(app,script,ready){
|
|
|
|
var path=OC.filePath(app,'js',script+'.js');
|
2011-07-30 16:05:20 +00:00
|
|
|
if(OC.addStyle.loaded.indexOf(path)==-1){
|
|
|
|
OC.addStyle.loaded.push(path);
|
|
|
|
if(ready){
|
|
|
|
$.getScript(path,ready);
|
|
|
|
}else{
|
|
|
|
$.getScript(path);
|
|
|
|
}
|
2011-07-30 19:18:54 +00:00
|
|
|
}else{
|
|
|
|
if(ready){
|
|
|
|
ready();
|
|
|
|
}
|
2011-07-25 20:30:55 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
addStyle:function(app,style){
|
|
|
|
var path=OC.filePath(app,'css',style+'.css');
|
2011-07-30 16:05:20 +00:00
|
|
|
if(OC.addScript.loaded.indexOf(path)==-1){
|
|
|
|
OC.addScript.loaded.push(path);
|
|
|
|
var style=$('<link rel="stylesheet" type="text/css" href="'+path+'"/>');
|
|
|
|
$('head').append(style);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
search:function(query){
|
|
|
|
if(query){
|
2011-07-30 19:18:54 +00:00
|
|
|
OC.addScript('search','result',function(){
|
|
|
|
OC.addStyle('search','results');
|
|
|
|
$.getJSON(OC.filePath('search','ajax','search.php')+'?query='+encodeURIComponent(query), OC.search.showResults);
|
|
|
|
});
|
2011-07-30 16:05:20 +00:00
|
|
|
}
|
2011-07-25 20:30:55 +00:00
|
|
|
}
|
|
|
|
}
|
2011-07-30 16:05:20 +00:00
|
|
|
OC.addStyle.loaded=[];
|
|
|
|
OC.addScript.loaded=[];
|
|
|
|
|
2011-07-26 14:43:12 +00:00
|
|
|
if (!Array.prototype.filter) {
|
|
|
|
Array.prototype.filter = function(fun /*, thisp*/) {
|
|
|
|
var len = this.length >>> 0;
|
|
|
|
if (typeof fun != "function")
|
|
|
|
throw new TypeError();
|
|
|
|
|
|
|
|
var res = [];
|
|
|
|
var thisp = arguments[1];
|
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
|
if (i in this) {
|
|
|
|
var val = this[i]; // in case fun mutates this
|
|
|
|
if (fun.call(thisp, val, i, this))
|
|
|
|
res.push(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
2011-07-27 14:57:49 +00:00
|
|
|
}
|
|
|
|
}
|
2011-07-27 14:39:44 +00:00
|
|
|
if (!Array.prototype.indexOf){
|
|
|
|
Array.prototype.indexOf = function(elt /*, from*/)
|
|
|
|
{
|
|
|
|
var len = this.length;
|
|
|
|
|
|
|
|
var from = Number(arguments[1]) || 0;
|
|
|
|
from = (from < 0)
|
|
|
|
? Math.ceil(from)
|
|
|
|
: Math.floor(from);
|
|
|
|
if (from < 0)
|
|
|
|
from += len;
|
|
|
|
|
|
|
|
for (; from < len; from++)
|
|
|
|
{
|
|
|
|
if (from in this &&
|
|
|
|
this[from] === elt)
|
|
|
|
return from;
|
|
|
|
}
|
|
|
|
return -1;
|
2011-07-26 14:43:12 +00:00
|
|
|
};
|
2011-07-28 02:28:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function SVGSupport() {
|
|
|
|
return document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") || document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Shape", "1.0");
|
|
|
|
}
|
2011-07-29 14:52:09 +00:00
|
|
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
if(!SVGSupport()){//replace all svg images with png images for browser that dont support svg
|
|
|
|
$('img.svg').each(function(index,element){
|
|
|
|
element=$(element);
|
|
|
|
var src=element.attr('src');
|
|
|
|
element.attr('src',src.substr(0,src.length-3)+'png');
|
|
|
|
});
|
|
|
|
};
|
2011-07-30 16:05:20 +00:00
|
|
|
$('#searchbox').keyup(function(){
|
|
|
|
var query=$('#searchbox').val();
|
|
|
|
if(query.length>2){
|
|
|
|
OC.search(query);
|
|
|
|
}else{
|
2011-07-30 19:18:54 +00:00
|
|
|
if(OC.search.hide){
|
|
|
|
OC.search.hide();
|
|
|
|
}
|
2011-07-30 16:05:20 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$('#searchbox').click(function(){$('#searchbox').trigger('keyup')});
|
2011-07-29 14:52:09 +00:00
|
|
|
});
|