]> ruin.nu Git - ndwebbie.git/commitdiff
Possible to edit timezone manually
authorMichael Andreen <harv@ruin.nu>
Fri, 2 Jan 2009 20:41:39 +0000 (21:41 +0100)
committerMichael Andreen <harv@ruin.nu>
Fri, 2 Jan 2009 20:41:39 +0000 (21:41 +0100)
lib/NDWeb/Controller/Settings.pm
root/src/settings/index.tt2

index d6743fb1f6afebcc985d0ac201f775cd8574a07c..4a60ebebf53354378a35390568121cc6cafcbb45 100644 (file)
@@ -92,8 +92,7 @@ sub changeTimezone : Local {
        my ( $self, $c ) = @_;
        my $dbh = $c->model;
 
-       my $timezone = $c->req->param('category');
-       $timezone .= '/' . $c->req->param('country') if $c->req->param('country');
+       my $timezone = $c->req->param('timezone');
        my $query = $dbh->prepare(q{UPDATE users SET timezone = $2 WHERE uid = $1});
        eval{
                $dbh->selectrow_array(q{SELECT NOW() AT TIME ZONE $1},undef,$timezone);
index 6291e33cddcf3684b067b4da5f943167687e9a85..c2a88ce8eb5a71ae017a91dfaf556c4ba8b2e883 100644 (file)
@@ -23,7 +23,7 @@
        </p>
 </fieldset>
 </form>
-<form action="[% c.uri_for('changeTimezone') %]" method="post"><fieldset> <legend>Timezone</legend>
+<fieldset> <legend>Timezone</legend>
        <select name="category" id="tzcategory">
 [% FOR cat IN tzcategories %]
                <option value="[% cat %]" [% IF cat == timezone.0 %]selected[% END %]>[% cat %]</option>
                <option value="[% country %]" [% IF country == timezone.1 %]selected[% END %]>[% country %]</option>
 [% END %]
        </select>
-       <br><input type="submit" value="Change">
+<form action="[% c.uri_for('changeTimezone') %]" method="post">
+       <p><input type="text" name="timezone" value="[% timezone.join("/") %]" id="timezone">
+       <input type="submit" value="Change"></p>
        <p>Remember that GMT stays the same all year, so if you're in the UK you should pick Europe/London.</p>
-</fieldset></form>
+</form></fieldset>
 [%- site.stylesheets = ['ui/ui.datepicker.css'] %]
 <script type="text/javascript" src="/static/ui/ui.core.min.js"></script>
 <script type="text/javascript" src="/static/ui/ui.datepicker.min.js"></script>
@@ -50,12 +52,22 @@ $(document).ready(function(){
                showOn: "both"
        });
        $("#tzcategory").change(function(){
-               $.get("/jsrpc/tzcountries/" + $(this).val(),function(xml){
+               if ($(this).val() == 'GMT'){
+                       $("#timezone").val($(this).val());
                        $("#tzcountry").empty();
-                       $("country",xml).each(function(i){
-                               $("#tzcountry").append('<option value="'+$(this).text()+'">'+$(this).text()+'</option>');
+               }else{
+                       $.get("/jsrpc/tzcountries/" + $(this).val(),function(xml){
+                               $("#tzcountry").empty();
+                               $("country",xml).each(function(i){
+                                       var opt = $('<option>');
+                                       $("#tzcountry").append(opt);
+                                       opt.attr('value',$(this).text()).text($(this).text());
+                               });
                        });
-               });
+               }
+       });
+       $("#tzcountry").change(function(){
+               $("#timezone").val($("#tzcategory").val() + '/' + $(this).val());
        });
 });
 </script>