diff options
author | Michael Gapczynski <GapczynskiM@gmail.com> | 2011-07-29 10:23:15 -0400 |
---|---|---|
committer | Michael Gapczynski <GapczynskiM@gmail.com> | 2011-07-29 10:23:15 -0400 |
commit | fcc9f506417647a5b38f3ae9398730f064177e27 (patch) | |
tree | 658f61214f712cdea354ce4f41b8260423df8c55 /core/js/js.js | |
parent | 67fe835f035e49783ba889010a005f40ed4c807d (diff) | |
parent | 46400a8124240679b7be4ae50ee932be31b18e2e (diff) | |
download | nextcloud-server-fcc9f506417647a5b38f3ae9398730f064177e27.tar.gz nextcloud-server-fcc9f506417647a5b38f3ae9398730f064177e27.zip |
Merge branch 'master' into sharing
Conflicts:
files/templates/index.php
Diffstat (limited to 'core/js/js.js')
-rw-r--r-- | core/js/js.js | 66 |
1 files changed, 57 insertions, 9 deletions
diff --git a/core/js/js.js b/core/js/js.js index 9117f08349a..407c5708701 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); }, @@ -39,6 +40,9 @@ OC={ return link; }, imagePath:function(app,file){ + if(file.indexOf('.')==-1){//if no extention is given, use png or svg depending on browser support + file+=(SVGSupport())?'.svg':'.png' + } return OC.filePath(app,'img',file); }, addScript:function(app,script,ready){ @@ -55,3 +59,47 @@ OC={ $('head').append(style); } } + +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; + } +} +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; + }; +} + +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"); +} |