From: Robin Appelman Date: Wed, 27 Jul 2011 14:39:44 +0000 (+0200) Subject: some minor changes in the javascript translation function X-Git-Tag: v3.0~267^2~364^2~31 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=606dec8da026d3aceb75abb64c936a09a3bd9133;p=nextcloud-server.git some minor changes in the javascript translation function also provide Array.prototype.indexOf for browser that don't support it nativale (IE) --- diff --git a/core/js/js.js b/core/js/js.js index 9117f08349a..593a637137c 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1,26 +1,27 @@ -var _l10ncache = {}; function t(app,text){ - if( !( app in _l10ncache )){ - $.post( oc_webroot+'/core/ajax/translations.php', {'app': app}, function(jsondata){ - _l10ncache[app] = jsondata.data; + if( !( app in t.cache )){ + + $.post( OC.filePath('core','ajax','translations.php'), {'app': app}, function(jsondata){ + t.cache[app] = jsondata.data; }); // Bad answer ... - if( !( app in _l10ncache )){ - _l10ncache[app] = []; + if( !( app in t.cache )){ + t.cache[app] = []; } } - if( typeof( _l10ncache[app][text] ) !== 'undefined' ){ - return _l10ncache[app][text]; + if( typeof( t.cache[app][text] ) !== 'undefined' ){ + return t.cache[app][text]; } else{ return text; } } +t.cache={}; OC={ webroot:oc_webroot, - coreApps:['files','admin','log','search','settings'], + coreApps:['files','admin','log','search','settings','core'], linkTo:function(app,file){ return OC.filePath(app,'',file); }, @@ -55,3 +56,25 @@ OC={ $('head').append(style); } } + +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; + }; +} \ No newline at end of file