choosable time format

This commit is contained in:
Georg Ehrke 2011-10-01 10:39:07 +02:00
parent 0514a1925b
commit bf6414d3ad
5 changed files with 52 additions and 30 deletions

View File

@ -0,0 +1,17 @@
<?php
/**
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
if(isset($_POST["timeformat"])){
OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]);
OC_JSON::success();
}else{
OC_JSON::error();
}
?>

View File

@ -0,0 +1,12 @@
<?php
/**
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
$timeformat = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24");
OC_JSON::encodedPrint(array("timeformat" => $timeformat));
?>

View File

@ -34,6 +34,18 @@ $(document).ready(function(){
minWidth:'auto',
});
});
$("#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();
});
$("#weekend").change( function(){
var data = $("#weekend").serialize();
$.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){

View File

@ -1,32 +1,4 @@
<?php
$hours = array(
'allday' => $l->t('All day'),
0 => '0',
1 => '1',
2 => '2',
3 => '3',
4 => '4',
5 => '5',
6 => '6',
7 => '7',
8 => '8',
9 => '9',
10 => '10',
11 => '11',
12 => '12',
13 => '13',
14 => '14',
15 => '15',
16 => '16',
17 => '17',
18 => '18',
19 => '19',
20 => '20',
21 => '21',
22 => '22',
23 => '23',
);
/*
$hours24 = array(
'allday' => $l->t('All day'),
0 => '0',
@ -81,7 +53,11 @@ $hoursampm = array(
22 => '10 p.m.',
23 => '11 p.m.',
);
*/
if(OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24") == "24"){
$hours = $hours24;
}else{
$hours = $hoursampm;
}
$weekdaynames = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
$dayforgenerator = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1");
$weekdays = array();

View File

@ -38,13 +38,18 @@ OC_UTIL::addStyle('', 'jquery.multiselect');
?>
</select>&nbsp;&nbsp;
<label for="weekend"><strong><?php echo $l->t('Days of weekend');?></strong></label>
<select id="weekend" name="weekend[]" multiple="multiple" title="<?php echo "Wochenende"; ?>">
<select id="weekend" name="weekend[]" multiple="multiple" title="<?php echo $l->t("Weekend"); ?>">
<?php
$weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
for($i = 0;$i <= 6;$i++){
echo '<option value="'.$weekdays[$i].'" id="selectweekend_' . $weekdays[$i] . '">' . $l->t($weekdays[$i]) . '</option>';
}
?>
</select>&nbsp;&nbsp;
<label for="timeformat"><strong><?php echo $l->t('Timeformat');?></strong></label>
<select style="display: none;" id="timeformat" title="<?php echo "timeformat"; ?>" name="timeformat">
<option value="24" id="24h"><?php echo $l->t("24 h"); ?></option>
<option value="ampm" id="ampm"><?php echo $l->t("am/pm"); ?></option>
</select>
<br />
Calendar CalDAV syncing address: