From 29106b7e0454ff43c83c39a3e458265d9c52ad9c Mon Sep 17 00:00:00 2001 From: Franzz Date: Sat, 19 Oct 2019 21:04:22 +0200 Subject: [PATCH] Convert all time to browser timezone --- inc/spot.php | 8 +++----- index.php | 3 ++- languages/en.lang | 2 +- masks/project.html | 6 +++--- readme.md | 1 - script/spot.js | 5 +++-- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/inc/spot.php b/inc/spot.php index 255c5df..07688a5 100755 --- a/inc/spot.php +++ b/inc/spot.php @@ -33,7 +33,7 @@ class Spot extends Main */ private $oMedia; - public function __construct($oClassManagement, $sProcessPage) + public function __construct($oClassManagement, $sProcessPage, $sTimezone) { $asClasses = array( array('name'=>'feed', 'project'=>true), @@ -41,7 +41,7 @@ class Spot extends Main array('name'=>'media', 'project'=>true), array('name'=>'converter', 'project'=>true) ); - parent::__construct($oClassManagement, $sProcessPage, $asClasses); + parent::__construct($oClassManagement, $sProcessPage, $asClasses, true, $sTimezone); $this->oClassManagement->incClass('translator'); $this->oLang = new Translator('', 'en'); @@ -123,9 +123,7 @@ class Spot extends Main ), 'consts' => array( 'geo_server' => Settings::GEO_SERVER, - 'modes' => Project::MODES, - 'site_timezone' => Settings::TIMEZONE - ) + 'modes' => Project::MODES ) ), 'index', array( diff --git a/index.php b/index.php index fc66996..c82809c 100755 --- a/index.php +++ b/index.php @@ -13,6 +13,7 @@ ToolBox::fixGlobalVars(isset($argv)?$argv:array()); //Available variables $sAction = isset($_REQUEST['a'])?$_REQUEST['a']:''; +$sTimezone = isset($_REQUEST['t'])?$_REQUEST['t']:''; $sName = isset($_GET['name'])?$_GET['name']:''; $sContent = isset($_GET['content'])?$_GET['content']:''; $iChunk = isset($_GET['chunk'])?$_GET['chunk']:0; @@ -21,7 +22,7 @@ $sField = isset($_REQUEST['field'])?$_REQUEST['field']:''; $oValue = isset($_REQUEST['value'])?$_REQUEST['value']:''; //Initiate class -$oSpot = new Spot($oClassManagement, __FILE__); +$oSpot = new Spot($oClassManagement, __FILE__, $sTimezone); $oSpot->setProjectId($iProjectId); $sResult = ''; diff --git a/languages/en.lang b/languages/en.lang index 91bfaa1..070686f 100644 --- a/languages/en.lang +++ b/languages/en.lang @@ -35,7 +35,7 @@ click_watch = Click to watch video click_zoom = Click to zoom media_count = Media $0 / $1 -city_time = $0 time +city_time = $0 Time project = Project mode = Mode diff --git a/masks/project.html b/masks/project.html index 4049636..408c633 100755 --- a/masks/project.html +++ b/masks/project.html @@ -127,9 +127,9 @@ function initProject(sProjectCodeName){ self.setPageTitle(oSpot.vars(['project', 'name'])); //Timezone difference notice - var bSameTZ = (oSpot.consts.site_timezone == oSpot.vars(['project', 'timezone'])); - self.tmp('site_tz_notice', bSameTZ?'':' ('+getTimeZoneDesc(oSpot.consts.site_timezone)+')'); - self.tmp('proj_tz_notice', bSameTZ?'':' ('+getTimeZoneDesc(self.vars(['project', 'timezone']))+')'); + var bSameTime = ((new Date()).toLocaleString([], {timeZone: oSpot.consts.timezone}) == (new Date()).toLocaleString([], {timeZone: oSpot.vars(['project', 'timezone'])})); + self.tmp('site_tz_notice', bSameTime?'':' ('+getTimeZoneDesc(oSpot.consts.timezone)+')'); + self.tmp('proj_tz_notice', bSameTime?'':' ('+getTimeZoneDesc(self.vars(['project', 'timezone']))+')'); $.when( //Markers: Spot Messages & Medias diff --git a/readme.md b/readme.md index 8b83b09..77fcd11 100644 --- a/readme.md +++ b/readme.md @@ -6,7 +6,6 @@ * ffprobe (ffmpeg) ## To Do List * import/export -* Convert all time to browser timezone * Reset zoom on image closing (lightbox) * Optimize mobile image size (lightbox) * Link pic & post \ No newline at end of file diff --git a/script/spot.js b/script/spot.js index 9830f04..30adc09 100755 --- a/script/spot.js +++ b/script/spot.js @@ -5,7 +5,7 @@ function Spot(asGlobals) this.consts.hash_sep = '-'; this.consts.title = 'Spotty'; this.consts.default_page = 'project'; - //this.consts.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; + this.consts.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; /* Initialization */ @@ -69,7 +69,8 @@ function Spot(asGlobals) bProcessIcon = bProcessIcon || false; //if(bProcessIcon) self.addBufferIcon(); - oVars['a'] = sAction; + oVars['a'] = sAction; + oVars['t'] = self.consts.timezone; return $.ajax( { url: self.consts.process_page,