blob: 1708e64bf7a141dc06a2306a7976775151d7a78c (
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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
function sendUserSettingsAJAX() {
var params;
var defaultDate = $('input[name=defaultDate]:checked').val();
if (defaultDate == 'today' || defaultDate == 'yesterday') {
params = 'period=day&date=' + defaultDate;
} else if (defaultDate.indexOf('last') >= 0
|| defaultDate.indexOf('previous') >= 0) {
params = 'period=range&date=' + defaultDate;
} else {
params = 'date=today&period=' + defaultDate;
}
var alias = $('#alias').val();
var email = $('#email').val();
var password = $('#password').val();
var passwordBis = $('#passwordBis').val();
var defaultReport = $('input[name=defaultReport]:checked').val();
if (defaultReport == 1) {
defaultReport = $('#defaultReportSiteSelector').attr('siteid');
}
var postParams = {};
postParams.alias = alias;
postParams.email = email;
if (password) {
postParams.password = password;
}
if (passwordBis) {
postParams.passwordBis = passwordBis;
}
postParams.defaultReport = defaultReport;
postParams.defaultDate = defaultDate;
postParams.language = $('#userSettingsTable #language').val();
postParams.timeformat = $('#userSettingsTable #timeformat').val();
var ajaxHandler = new ajaxHelper();
ajaxHandler.addParams({
module: 'UsersManager',
format: 'json',
action: 'recordUserSettings'
}, 'GET');
ajaxHandler.withTokenInUrl();
ajaxHandler.addParams(postParams, 'POST');
ajaxHandler.redirectOnSuccess(params);
ajaxHandler.setLoadingElement('#ajaxLoadingUserSettings');
ajaxHandler.setErrorElement('#ajaxErrorUserSettings');
ajaxHandler.send(true);
}
function sendAnonymousUserSettingsAJAX() {
var anonymousDefaultReport = $('input[name=anonymousDefaultReport]:checked').val();
if (anonymousDefaultReport == 1) {
anonymousDefaultReport = $('#anonymousDefaultReportWebsite').find('option:selected').val();
}
var anonymousDefaultDate = $('input[name=anonymousDefaultDate]:checked').val();
var ajaxHandler = new ajaxHelper();
ajaxHandler.addParams({
module: 'UsersManager',
format: 'json',
action: 'recordAnonymousUserSettings'
}, 'GET');
ajaxHandler.withTokenInUrl();
ajaxHandler.addParams({
anonymousDefaultReport: anonymousDefaultReport,
anonymousDefaultDate: anonymousDefaultDate
}, 'POST');
ajaxHandler.redirectOnSuccess();
ajaxHandler.setLoadingElement('#ajaxLoadingAnonymousUserSettings');
ajaxHandler.setErrorElement('#ajaxErrorAnonymousUserSettings');
ajaxHandler.send(true);
}
$(document).ready(function () {
$('#userSettingsSubmit').click(function () {
if ($('#password').length > 0 && $('#password').val() != '') {
piwikHelper.modalConfirm('#confirmPasswordChange', {yes: sendUserSettingsAJAX});
} else {
sendUserSettingsAJAX();
}
});
$('#userSettingsTable').find('input').keypress(function (e) {
var key = e.keyCode || e.which;
if (key == 13) {
$('#userSettingsSubmit').click();
}
});
$('#anonymousUserSettingsSubmit').click(function () {
sendAnonymousUserSettingsAJAX();
});
});
|