1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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));
|