blob: 5d5746654cbaeff387f026465e5bfcc820ed176b (
plain)
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
|
/*
* Copyright (c) 2017
*
* This file is licensed under the Affero General Public License version 3
* or later.
*
* See the COPYING-README file.
*
*/
(function() {
if (!OCA.Weather) {
/**
* Namespace for the files app
* @namespace OCA.Weather
*/
OCA.Weather = {};
}
/**
* @namespace OCA.Weather.Admin
*/
OCA.Weather.Admin = {
initialize: function() {
$('#submitOWMApiKey').on('click', _.bind(this._onClickSubmitOWMApiKey, this));
},
_onClickSubmitOWMApiKey: function () {
OC.msg.startSaving('#OWMApiKeySettingsMsg');
var request = $.ajax({
url: OC.generateUrl('/apps/weather/settings/apikey'),
type: 'POST',
data: {
apikey: $('#openweathermap-api-key').val()
}
});
request.done(function (data) {
$('#openweathermap-api-key').val(data.apikey);
OC.msg.finishedSuccess('#OWMApiKeySettingsMsg', 'Saved');
});
request.fail(function () {
OC.msg.finishedError('#OWMApiKeySettingsMsg', 'Error');
});
}
}
})();
window.addEventListener('DOMContentLoaded', function () {
OCA.Weather.Admin.initialize();
});
|