]> source.dussan.org Git - nextcloud-server.git/commitdiff
choosable time format
authorGeorg Ehrke <georg.stefan.germany@googlemail.com>
Sat, 1 Oct 2011 08:39:07 +0000 (10:39 +0200)
committerGeorg Ehrke <georg.stefan.germany@googlemail.com>
Sat, 1 Oct 2011 08:39:07 +0000 (10:39 +0200)
apps/calendar/ajax/settimeformat.php [new file with mode: 0644]
apps/calendar/ajax/timeformat.php [new file with mode: 0644]
apps/calendar/js/settings.js
apps/calendar/templates/calendar.php
apps/calendar/templates/settings.php

diff --git a/apps/calendar/ajax/settimeformat.php b/apps/calendar/ajax/settimeformat.php
new file mode 100644 (file)
index 0000000..7805120
--- /dev/null
@@ -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();
+}
+?> 
diff --git a/apps/calendar/ajax/timeformat.php b/apps/calendar/ajax/timeformat.php
new file mode 100644 (file)
index 0000000..3533adc
--- /dev/null
@@ -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));
+?> 
index 5d048b83c36597485d6475b3379059cede592a3a..fc5fc7377a6018ec39e98bd8b1945d25313dd0c4 100644 (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){
index 25d92b0c7e422cbe9290ebbaf1bbfd414dcd3afd..317bb17ddbc881892e1ddd3fd3db0d56b8639b32 100644 (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();
index 7df357099e832213108370f5c9849da17d4433d0..d3e3e3c525e19434f7f823526abf5d7f3b1fed2b 100644 (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: