aboutsummaryrefslogtreecommitdiffstats
path: root/core/js/js.js
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-10-17 16:38:11 +0200
committerBart Visscher <bartv@thisnet.nl>2012-10-17 16:38:11 +0200
commit6081bfa2bcbe121e373486273ecce58a49e6fa97 (patch)
treef2504800c66919a53eff9323724b493079569495 /core/js/js.js
parentc2b4e534534e083147bbad9b564179832cfa2912 (diff)
parent44287d680bd0e8799724a7595db43c0fafcaff40 (diff)
downloadnextcloud-server-6081bfa2bcbe121e373486273ecce58a49e6fa97.tar.gz
nextcloud-server-6081bfa2bcbe121e373486273ecce58a49e6fa97.zip
Merge branch 'master' into routing
Conflicts: lib/search/provider/file.php settings/ajax/changepassword.php settings/settings.php
Diffstat (limited to 'core/js/js.js')
-rw-r--r--core/js/js.js33
1 files changed, 29 insertions, 4 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 8f3b5a6af1e..285fb38086b 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -5,7 +5,7 @@
* @return string
*/
-function t(app,text){
+function t(app,text, vars){
if( !( t.cache[app] )){
$.ajax(OC.filePath('core','ajax','translations.php'),{
async:false,//todo a proper sollution for this without sync ajax calls
@@ -21,15 +21,40 @@ function t(app,text){
t.cache[app] = [];
}
}
+ var _build = function(text, vars) {
+ return text.replace(/{([^{}]*)}/g,
+ function (a, b) {
+ var r = vars[b];
+ return typeof r === 'string' || typeof r === 'number' ? r : a;
+ }
+ );
+ }
if( typeof( t.cache[app][text] ) !== 'undefined' ){
- return t.cache[app][text];
+ if(typeof vars === 'object') {
+ return _build(t.cache[app][text], vars);
+ } else {
+ return t.cache[app][text];
+ }
}
else{
- return text;
+ if(typeof vars === 'object') {
+ return _build(text, vars);
+ } else {
+ return text;
+ }
}
}
t.cache={};
+/*
+* Sanitizes a HTML string
+* @param string
+* @return Sanitized string
+*/
+function escapeHTML(s) {
+ return s.toString().split('&').join('&amp;').split('<').join('&lt;').split('"').join('&quot;');
+}
+
/**
* Get the path to download a file
* @param file The filename
@@ -37,7 +62,7 @@ t.cache={};
* @return string
*/
function fileDownloadPath(dir, file) {
- return OC.filePath('files', 'ajax', 'download.php')+encodeURIComponent('?files='+encodeURIComponent(file)+'&dir='+encodeURIComponent(dir));
+ return OC.filePath('files', 'ajax', 'download.php')+'&files='+encodeURIComponent(file)+'&dir='+encodeURIComponent(dir);
}
var OC={