]> source.dussan.org Git - nextcloud-server.git/commitdiff
some minor changes in the javascript translation function
authorRobin Appelman <icewind1991@gmail.com>
Wed, 27 Jul 2011 14:39:44 +0000 (16:39 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Wed, 27 Jul 2011 14:40:26 +0000 (16:40 +0200)
also provide Array.prototype.indexOf for browser that don't support it nativale (IE)

core/js/js.js

index 9117f08349a2470c891bcb94bf08ea96f9929271..593a637137c37fa76b107de24d3463679503b4f6 100644 (file)
@@ -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