diff options
Diffstat (limited to 'core/js/js.js')
-rw-r--r-- | core/js/js.js | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/core/js/js.js b/core/js/js.js index f1ed6070c32..c392991d456 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -4,6 +4,8 @@ * @param text the string to translate * @return string */ +var OC; + function t(app,text){ if( !( app in t.cache )){ $.ajax(OC.filePath('core','ajax','translations.php'),{ @@ -40,6 +42,11 @@ function fileDownloadPath(dir, file) { } OC={ + PERMISSION_CREATE:4, + PERMISSION_READ:1, + PERMISSION_UPDATE:2, + PERMISSION_DELETE:8, + PERMISSION_SHARE:16, webroot:oc_webroot, appswebroots:oc_appswebroots, currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false, @@ -201,7 +208,7 @@ OC={ popup.prepend('<span class="arrow '+arrowclass+'"></span><h2>'+t('core', 'Settings')+'</h2><a class="close svg"></a>').show(); popup.find('.close').bind('click', function() { popup.remove(); - }) + }); if(typeof props.loadJS !== 'undefined') { var scriptname; if(props.loadJS === true) { @@ -587,3 +594,40 @@ function formatDate(date){ t('files','July'), t('files','August'), t('files','September'), t('files','October'), t('files','November'), t('files','December') ]; return monthNames[date.getMonth()]+' '+date.getDate()+', '+date.getFullYear()+', '+((date.getHours()<10)?'0':'')+date.getHours()+':'+((date.getMinutes()<10)?'0':'')+date.getMinutes(); } + +/** + * get a variable by name + * @param string name + */ +OC.get=function(name) { + var namespaces = name.split("."); + var tail = namespaces.pop(); + var context=window; + + for(var i = 0; i < namespaces.length; i++) { + context = context[namespaces[i]]; + if(!context){ + return false; + } + } + return context[tail]; +} + +/** + * set a variable by name + * @param string name + * @param mixed value + */ +OC.set=function(name, value) { + var namespaces = name.split("."); + var tail = namespaces.pop(); + var context=window; + + for(var i = 0; i < namespaces.length; i++) { + if(!context[namespaces[i]]){ + context[namespaces[i]]={}; + } + context = context[namespaces[i]]; + } + context[tail]=value; +} |