diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-07-27 16:39:44 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-07-27 16:40:26 +0200 |
commit | 606dec8da026d3aceb75abb64c936a09a3bd9133 (patch) | |
tree | e2a027bb314ecdb6effe0d8280c6b34272f09e64 /core/js | |
parent | 6585e83037541bc2126b111b39ce867f9ec09ad3 (diff) | |
download | nextcloud-server-606dec8da026d3aceb75abb64c936a09a3bd9133.tar.gz nextcloud-server-606dec8da026d3aceb75abb64c936a09a3bd9133.zip |
some minor changes in the javascript translation function
also provide Array.prototype.indexOf for browser that don't support it nativale (IE)
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/js.js | 41 |
1 files changed, 32 insertions, 9 deletions
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 |