From 4abacf5e843e32e4432209831fc8a720600f3499 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Mon, 11 May 2015 11:42:00 +0200 Subject: [PATCH] move date to the top, populate via JS --- controllers/controllers.php | 24 +---------------------- views/new-post.php | 38 +++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/controllers/controllers.php b/controllers/controllers.php index f2056ab..119fea6 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -270,31 +270,9 @@ $app->get('/options.json', function() use($app) { $options = get_entry_options($user->id, k($params,'latitude'), k($params,'longitude')); $html = partial('partials/entry-buttons', ['options'=>$options]); - $tz_offset = '+0000'; - $date_str = date('Y-m-d'); - $time_str = date('H:i:s'); - if(k($params,'latitude')) { - if($timezone=get_timezone($params['latitude'], $params['longitude'])) { - $seconds = $timezone->getOffset(new DateTime()); - $tz_offset = tz_seconds_to_offset($seconds); - - // Create a date object in the local timezone given the offset - $date = new DateTime(); - if($seconds > 0) - $date->add(new DateInterval('PT'.$seconds.'S')); - elseif($seconds < 0) - $date->sub(new DateInterval('PT'.abs($seconds).'S')); - $date_str = $date->format('Y-m-d'); - $time_str = $date->format('H:i:s'); - } - } - $app->response()['Content-type'] = 'application/json'; $app->response()->body(json_encode([ - 'buttons'=>$html, - 'tz_offset'=>$tz_offset, - 'date_str'=>$date_str, - 'time_str'=>$time_str + 'buttons'=>$html ])); } }); diff --git a/views/new-post.php b/views/new-post.php index ad32080..cce7125 100644 --- a/views/new-post.php +++ b/views/new-post.php @@ -3,6 +3,14 @@
+
+

Date

+ + + + +
+
$this->default_options]) ?>
@@ -20,13 +28,6 @@ -
-

Date

- - - - -
micropub_endpoint): ?> @@ -69,6 +70,26 @@