diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-10-21 15:14:19 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-10-21 15:14:19 +0200 |
commit | fbad651ebd31d09406ef141e61ea396ad1eda710 (patch) | |
tree | b57b142031c4e291856cc607fb3697b537b48b49 /js/admin | |
parent | b02f22f86b6e89483948e5bf9605558a78046efd (diff) |
Make config.ini editable in the admin interface
Diffstat (limited to 'js/admin')
-rw-r--r-- | js/admin/Admin.js | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/js/admin/Admin.js b/js/admin/Admin.js new file mode 100644 index 000000000..61af46461 --- /dev/null +++ b/js/admin/Admin.js @@ -0,0 +1,83 @@ +/** + * ownCloud - News + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @copyright Bernhard Posselt 2014 + */ + +/** + * Used to update the admin settings + */ +(function (window, document, $) { + 'use strict'; + + $(document).ready(function () { + var useCronUpdatesInput = + $('#news input[name="news-use-cron-updates"]'); + var autoPurgeMinimumIntervalInput = + $('#news input[name="news-auto-purge-minimum-interval"]'); + var autoPurgeCountInput = + $('#news input[name="news-auto-purge-count"]'); + var cacheDurationInput = + $('#news input[name="news-cache-duration"]'); + var feedFetcherTimeoutInput = + $('#news input[name="news-feed-fetcher-timeout"]'); + var savedMessage = $('#news-saved-message'); + + var saved = function () { + if (savedMessage.is(':visible')) { + savedMessage.hide(); + } + + savedMessage.fadeIn(function () { + setTimeout(function () { + savedMessage.fadeOut(); + }, 5000); + }); + }; + + var submit = function () { + var autoPurgeMinimumInterval = autoPurgeMinimumIntervalInput.val(); + var autoPurgeCount = autoPurgeCountInput.val(); + var cacheDuration = cacheDurationInput.val(); + var feedFetcherTimeout = feedFetcherTimeoutInput.val(); + var useCronUpdates = useCronUpdatesInput.is(':checked'); + + var data = { + autoPurgeMinimumInterval: + parseInt(autoPurgeMinimumInterval, 10), + autoPurgeCount: parseInt(autoPurgeCount, 10), + cacheDuration: parseInt(cacheDuration, 10), + feedFetcherTimeout: parseInt(feedFetcherTimeout, 10), + useCronUpdates: useCronUpdates + }; + + var url = OC.generateUrl('/apps/news/admin'); + + $.ajax({ + type: 'PUT', + contentType: 'application/json; charset=utf-8', + url: url, + data: JSON.stringify(data), + dataType: 'json' + }).success(function (data) { + saved(); + autoPurgeMinimumIntervalInput + .val(data.autoPurgeMinimumInterval); + autoPurgeCountInput.val(data.autoPurgeCount); + cacheDurationInput.val(data.cacheDuration); + feedFetcherTimeoutInput.val(data.feedFetcherTimeout); + useCronUpdatesInput.prop('checked', data.useCronUpdates); + }); + + } + + $('#news input[type="text"]').blur(submit); + $('#news input[type="checkbox"]').change(submit); + }); + + +}(window, document, jQuery));
\ No newline at end of file |