diff --git a/core/js/dist/main.js b/core/js/dist/main.js index e05334ce5853de08241bfdba9bb38cdf6db3ec5f..eff69c9fedd6340ba8fecaab7323913d2fabd0eb 100644 Binary files a/core/js/dist/main.js and b/core/js/dist/main.js differ diff --git a/core/js/dist/main.js.map b/core/js/dist/main.js.map index 82734ae0cb82659c526fa3abd9b39053f8e8a472..58ad7e166a343d18430ea0a93e85b217498fd4c6 100644 Binary files a/core/js/dist/main.js.map and b/core/js/dist/main.js.map differ diff --git a/core/js/js.js b/core/js/js.js index 0959528b31ade3fff970b21220ae179a65b2768a..76b0ecda492c89e685c5d943cee9b1a0737692f0 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1113,41 +1113,4 @@ if (window.history.pushState) { else { $(window).on('hashchange', _.bind(OC.Util.History._onPopState, OC.Util.History)); } - -/** - * Get a variable by name - * @param {string} name - * @return {*} - */ -OC.get=function(name) { - var namespaces = name.split("."); - var tail = namespaces.pop(); - var context=window; - - for(var i = 0; i < namespaces.length; i++) { - context = context[namespaces[i]]; - if(!context){ - return false; - } - } - return context[tail]; -}; - -/** - * Set a variable by name - * @param {string} name - * @param {*} value */ -OC.set=function(name, value) { - var namespaces = name.split("."); - var tail = namespaces.pop(); - var context=window; - - for(var i = 0; i < namespaces.length; i++) { - if(!context[namespaces[i]]){ - context[namespaces[i]]={}; - } - context = context[namespaces[i]]; - } - context[tail]=value; -}; diff --git a/core/src/OC/get_set.js b/core/src/OC/get_set.js new file mode 100644 index 0000000000000000000000000000000000000000..9fafe12138719c21097f381f3cdc754dd75d4fe3 --- /dev/null +++ b/core/src/OC/get_set.js @@ -0,0 +1,56 @@ +/* + * @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/>. + */ + +/** + * Get a variable by name + * @param {string} name + * @return {*} + */ +export const get = context => name => { + const namespaces = name.split('.') + const tail = namespaces.pop() + + for (var i = 0; i < namespaces.length; i++) { + context = context[namespaces[i]] + if (!context) { + return false + } + } + return context[tail] +} + +/** + * Set a variable by name + * @param {string} name + * @param {*} value + */ +export const set = context => (name, value) => { + const namespaces = name.split(".") + const tail = namespaces.pop() + + for (let i = 0; i < namespaces.length; i++) { + if (!context[namespaces[i]]) { + context[namespaces[i]] = {} + } + context = context[namespaces[i]] + } + context[tail] = value +} diff --git a/core/src/OC/index.js b/core/src/OC/index.js index ab5552c8e57ea7f0eedfa2d208d8e232d3443999..548d6f544c8f940bb18349c60828f9a6779100e4 100644 --- a/core/src/OC/index.js +++ b/core/src/OC/index.js @@ -26,6 +26,7 @@ import Config from './config' import ContactsMenu from './contactsmenu' import Dialogs from './dialogs' import EventSource from './eventsource' +import {get, set} from './get_set' import {isUserAdmin} from './admin' import L10N from './l10n' import { @@ -67,6 +68,8 @@ export default { Util, debug, generateUrl, + get: get(window), + set: set(window), getRootPath, filePath, redirect,