diff options
Diffstat (limited to 'core/src/OC/util.js')
-rw-r--r-- | core/src/OC/util.js | 68 |
1 files changed, 25 insertions, 43 deletions
diff --git a/core/src/OC/util.js b/core/src/OC/util.js index 611c42d317f..c46d9a141b1 100644 --- a/core/src/OC/util.js +++ b/core/src/OC/util.js @@ -1,31 +1,17 @@ /** - * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ -import $ from 'jquery' import moment from 'moment' -import History from './util-history' -import OC from './index' +import History from './util-history.js' +import OC from './index.js' import { formatFileSize as humanFileSize } from '@nextcloud/files' +/** + * @param {any} t - + */ function chunkify(t) { // Adapted from http://my.opera.com/GreyWyvern/blog/show.dml/1671288 const tz = [] @@ -52,6 +38,7 @@ function chunkify(t) { /** * Utility functions + * * @namespace OC.Util */ export default { @@ -59,7 +46,7 @@ export default { History, /** - * @deprecated use https://nextcloud.github.io/nextcloud-files/modules/_humanfilesize_.html#formatfilesize + * @deprecated use https://nextcloud.github.io/nextcloud-files/functions/formatFileSize.html */ humanFileSize, @@ -67,8 +54,9 @@ export default { * Returns a file size in bytes from a humanly readable string * Makes 2kB to 2048. * Inspired by computerFileSize in helper.php - * @param {string} string file size in human readable format - * @returns {number} or null if string could not be parsed + * + * @param {string} string file size in human-readable format + * @return {number} or null if string could not be parsed * * */ @@ -114,11 +102,11 @@ export default { /** * @param {string|number} timestamp timestamp * @param {string} format date format, see momentjs docs - * @returns {string} timestamp formatted as requested + * @return {string} timestamp formatted as requested */ formatDate(timestamp, format) { if (window.TESTING === undefined) { - console.warn('OC.Util.formatDate is deprecated and will be removed in Nextcloud 21. See @nextcloud/moment') + OC.debug && console.warn('OC.Util.formatDate is deprecated and will be removed in Nextcloud 21. See @nextcloud/moment') } format = format || 'LLL' return moment(timestamp).format(format) @@ -126,11 +114,11 @@ export default { /** * @param {string|number} timestamp timestamp - * @returns {string} human readable difference from now + * @return {string} human readable difference from now */ relativeModifiedDate(timestamp) { if (window.TESTING === undefined) { - console.warn('OC.Util.relativeModifiedDate is deprecated and will be removed in Nextcloud 21. See @nextcloud/moment') + OC.debug && console.warn('OC.Util.relativeModifiedDate is deprecated and will be removed in Nextcloud 21. See @nextcloud/moment') } const diff = moment().diff(moment(timestamp)) if (diff >= 0 && diff < 45000) { @@ -140,18 +128,9 @@ export default { }, /** - * Returns whether this is IE - * - * @returns {bool} true if this is IE, false otherwise - */ - isIE() { - return $('html').hasClass('ie') - }, - - /** * Returns the width of a generic browser scrollbar * - * @returns {int} width of scrollbar + * @return {number} width of scrollbar */ getScrollBarWidth() { if (this._scrollBarWidth) { @@ -191,7 +170,7 @@ export default { * Remove the time component from a given date * * @param {Date} date date - * @returns {Date} date with stripped time + * @return {Date} date with stripped time */ stripTime(date) { // FIXME: likely to break when crossing DST @@ -201,9 +180,10 @@ export default { /** * Compare two strings to provide a natural sort + * * @param {string} a first string to compare * @param {string} b second string to compare - * @returns {number} -1 if b comes before a, 1 if a comes before b + * @return {number} -1 if b comes before a, 1 if a comes before b * or 0 if the strings are identical */ naturalSortCompare(a, b) { @@ -230,8 +210,9 @@ export default { /** * Calls the callback in a given interval until it returns true - * @param {function} callback function to call on success - * @param {integer} interval in milliseconds + * + * @param {Function} callback function to call on success + * @param {number} interval in milliseconds */ waitFor(callback, interval) { const internalCallback = function() { @@ -245,9 +226,10 @@ export default { /** * 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 - * @returns {boolean} true if the cookie with the given name has the given value + * @return {boolean} true if the cookie with the given name has the given value */ isCookieSetToValue(name, value) { const cookies = document.cookie.split(';') |