summaryrefslogtreecommitdiffstats
path: root/core/js/js.js
diff options
context:
space:
mode:
Diffstat (limited to 'core/js/js.js')
-rw-r--r--core/js/js.js62
1 files changed, 56 insertions, 6 deletions
diff --git a/core/js/js.js b/core/js/js.js
index ec890be4541..77aadd23e03 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -194,6 +194,30 @@ var OC={
linkToRemoteBase:function(service) {
return OC.webroot + '/remote.php/' + service;
},
+
+ /**
+ * Generates the absolute url for the given relative url, which can contain parameters.
+ *
+ * @returns {string}
+ * @param {string} url
+ * @param params
+ */
+ generateUrl: function(url, params) {
+ 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 (url.charAt(0) !== '/') {
+ url = '/' + url;
+
+ }
+ return OC.webroot + '/index.php' + _build(url, params);
+ },
+
/**
* @brief Creates an absolute url for remote use
* @param string $service id
@@ -467,6 +491,34 @@ OC.search.lastResults={};
OC.addStyle.loaded=[];
OC.addScript.loaded=[];
+OC.msg={
+ startSaving:function(selector){
+ OC.msg.startAction(selector, t('core', 'Saving...'));
+ },
+ finishedSaving:function(selector, data){
+ OC.msg.finishedAction(selector, data);
+ },
+ startAction:function(selector, message){
+ $(selector)
+ .html( message )
+ .removeClass('success')
+ .removeClass('error')
+ .stop(true, true)
+ .show();
+ },
+ finishedAction:function(selector, data){
+ if( data.status === "success" ){
+ $(selector).html( data.data.message )
+ .addClass('success')
+ .stop(true, true)
+ .delay(3000)
+ .fadeOut(900);
+ }else{
+ $(selector).html( data.data.message ).addClass('error');
+ }
+ }
+};
+
OC.Notification={
queuedNotifications: [],
getDefaultNotificationFunction: null,
@@ -763,12 +815,10 @@ function initCore() {
if (interval < 60) {
interval = 60;
}
- OC.Router.registerLoadedCallback(function(){
- var url = OC.Router.generate('heartbeat');
- setInterval(function(){
- $.post(url);
- }, interval * 1000);
- });
+ var url = OC.generateUrl('/heartbeat');
+ setInterval(function(){
+ $.post(url);
+ }, interval * 1000);
}
// session heartbeat (defaults to enabled)