diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-07-07 15:16:37 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-07-07 15:16:37 +0200 |
commit | 3f5aa27d494d56217980195534ee999b5e473ca5 (patch) | |
tree | 619a559284179afbb680a6f08d8a6b3bf8855c94 /core/js/js.js | |
parent | 3d8297c25473c5496fa7e27f600f1e23053df2fc (diff) | |
download | nextcloud-server-3f5aa27d494d56217980195534ee999b5e473ca5.tar.gz nextcloud-server-3f5aa27d494d56217980195534ee999b5e473ca5.zip |
refactoring into proper methods
Diffstat (limited to 'core/js/js.js')
-rw-r--r-- | core/js/js.js | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/core/js/js.js b/core/js/js.js index e0adc3591ac..cce5a47bdd3 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1513,8 +1513,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, |