summaryrefslogtreecommitdiffstats
path: root/apps/calendar/js/settings.js
blob: 20753a7b8fef6303ed48c4a471edf66e9773f79f (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
$(document).ready(function(){
	$('#timezone').change( function(){
		var post = $( '#timezone' ).serialize();
		$.post( OC.filePath('calendar', 'ajax/settings', 'settimezone.php'), post, function(data){return;});
		return false;
	});
	$('#timezone').chosen();
	$('#timeformat').change( function(){
		var data = $('#timeformat').serialize();
		$.post( OC.filePath('calendar', 'ajax/settings', 'settimeformat.php'), data, function(data){
			if(data == 'error'){
				console.log('saving timeformat failed');
			}
		});
	});
	$('#firstday').change( function(){
		var data = $('#firstday').serialize();
		$.post( OC.filePath('calendar', 'ajax/settings', 'setfirstday.php'), data, function(data){
			if(data == 'error'){
				console.log('saving firstday failed');
			}
		});
	});
	$('#timezonedetection').change( function(){
		var post = $('#timezonedetection').serialize();
		$.post( OC.filePath('calendar', 'ajax/settings', 'timezonedetection.php'), post, function(data){
			
		});
	});
	$.getJSON(OC.filePath('calendar', 'ajax/settings', 'timeformat.php'), function(jsondata, status) {
		$('#' + jsondata.timeformat).attr('selected',true);
		$('#timeformat').chosen();
		$('#timeformat_chzn').css('width', '100px');
	});
	$.getJSON(OC.filePath('calendar', 'ajax/settings', 'gettimezonedetection.php'), function(jsondata, status){
		if(jsondata.detection == 'true'){
			$('#timezonedetection').attr('checked', 'checked');
		}
	});
	$.getJSON(OC.filePath('calendar', 'ajax/settings', 'getfirstday.php'), function(jsondata, status) {
		$('#' + jsondata.firstday).attr('selected',true);
		$('#firstday').chosen();
		$('#firstday_chzn').css('width', '100px');
	});
	$('#cleancalendarcache').click(function(){
		$.getJSON(OC.filePath('calendar', 'ajax/cache', 'rescan.php'), function(){
			calendarcachecheck();
		});
	});
	calendarcachecheck();
	
});
function calendarcachecheck(){
	$.getJSON(OC.filePath('calendar', 'ajax/cache', 'status.php'), function(jsondata, status) {
		$('#cleancalendarcache').attr('title', jsondata.l10n.text);
		if(jsondata.status == 'success'){
			$('#cleancalendarcache').css('background', '#F8F8F8');
			$('#cleancalendarcache').css('color', '#333');
			$('#cleancalendarcache').css('text-shadow', '#fff 0 1px 0');
		}else{
			$('#cleancalendarcache').css('background', '#DC143C');
			$('#cleancalendarcache').css('color', '#FFFFFF');
			$('#cleancalendarcache').css('text-shadow', '0px 0px 0px #fff, 0px 0px #fff');
		}
	});
}