summaryrefslogtreecommitdiffstats
path: root/apps/calendar/js/settings.js
blob: 6c00be06b3928ee9b61de301b9e89dcc385a806d (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
$(document).ready(function(){
	$("#timezone").change( function(){
		OC.msg.startSaving('#calendar .msg')
		// Serialize the data
		var post = $( "#timezone" ).serialize();
		$.post( OC.filePath('calendar', 'ajax', 'settimezone.php'), post, function(data){
			//OC.msg.finishedSaving('#calendar .msg', data);
		});
		return false;
	});
	$("#timezone").chosen();
	$("#firstdayofweek").change( function(){
		var data = $("#firstdayofweek").serialize();
		$.post( OC.filePath('calendar', 'ajax', 'setfirstdayofweek.php'), data, function(data){
			if(data == "error"){
				console.log("saving first day of week failed");
			}
		});
	});
	$.getJSON(OC.filePath('calendar', 'ajax', 'firstdayofweek.php'), function(jsondata, status) {
		$("#select_" + jsondata.firstdayofweek).attr('selected',true);
		$("#firstdayofweek").chosen();
	});
	$.getJSON(OC.filePath('calendar', 'ajax', 'daysofweekend.php'), function(jsondata, status) {
		for(day in jsondata){
			if(jsondata[day] == "true"){
				$("#selectweekend_" + day).attr('selected',true);
			}
		}
		$("#weekend").chosen();
	});
	$("#timeformat").change( function(){
		var data = $("#timeformat").serialize();
		$.post( OC.filePath('calendar', 'ajax', 'settimeformat.php'), data, function(data){
			if(data == "error"){
				console.log("saving timeformat failed");
			}
		});
	});
	$.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) {
		$("#" + jsondata.timeformat).attr('selected',true);
		$("#timeformat").chosen();
	});
	$("#duration").blur( function(){
		var data = $("#duration").val();
		$.post( OC.filePath('calendar', 'ajax', 'setduration.php'), {duration: data}, function(data){
			if(data == "error"){
				console.log("saving duration failed");
			}
		});
	});
	$.getJSON(OC.filePath('calendar', 'ajax', 'duration.php'), function(jsondata, status) {
		$("#duration").val(jsondata.duration);
	});
	$("#weekend").change( function(){
		var data = $("#weekend").serialize();
		$.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){
			if(data == "error"){
				console.log("saving days of weekend failed");
			}
		});
	});
});