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.js32
1 files changed, 31 insertions, 1 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 8380d56e31e..45c9c90362f 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -1609,8 +1609,38 @@ OC.Util = {
}
}
return aa.length - bb.length;
+ },
+ /**
+ * Calls the callback in a given interval until it returns true
+ * @param {function} callback
+ * @param {integer} interval in milliseconds
+ */
+ waitFor: function(callback, interval) {
+ var internalCallback = function() {
+ if(callback() !== true) {
+ setTimeout(internalCallback, interval);
+ }
+ };
+
+ internalCallback();
+ },
+ /**
+ * Checks if a cookie with the given name is present and is set to the provided value.
+ * @param {string} name name of the cookie
+ * @param {string} value value of the cookie
+ * @return {boolean} true if the cookie with the given name has the given value
+ */
+ isCookieSetToValue: function(name, value) {
+ var cookies = document.cookie.split(';');
+ for (var i=0; i < cookies.length; i++) {
+ var cookie = cookies[i].split('=');
+ if (cookie[0].trim() === name && cookie[1].trim() === value) {
+ return true;
+ }
+ }
+ return false;
}
-}
+};
/**
* Utility class for the history API,