diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-10-09 02:08:17 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-10-09 02:08:17 +0200 |
| commit | d74b4518052066446e2a1975a91ce53c745ca75a (patch) | |
| tree | c08180f88a512d15e37fbec628931f02b3825f65 /addons/website/static/src/js/visitor_timezone.js | |
| parent | ec162dd0cb5622ab6e56db1a63dab5f531a96f4a (diff) | |
| parent | f4105eb9c7010f8693e5d2fd20c0bd9d9cc2e483 (diff) | |
[MERGE] forward port branch 13.0 up to f4105eb9c70
Diffstat (limited to 'addons/website/static/src/js/visitor_timezone.js')
| -rw-r--r-- | addons/website/static/src/js/visitor_timezone.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/addons/website/static/src/js/visitor_timezone.js b/addons/website/static/src/js/visitor_timezone.js new file mode 100644 index 00000000000..b8cd2e06cbd --- /dev/null +++ b/addons/website/static/src/js/visitor_timezone.js @@ -0,0 +1,36 @@ +// +// This file is meant to determine the timezone of a website visitor +// If the visitor already exists, no need to keep the timezone cookie +// as the timezone is set on the visitor. +// +odoo.define('website.visitor_timezone', function (require) { +'use strict'; + +var ajax = require('web.ajax'); +var utils = require('web.utils'); +var publicWidget = require('web.public.widget'); + +publicWidget.registry.visitorTimezone = publicWidget.Widget.extend({ + selector: '#wrapwrap', + + start: function () { + if (!localStorage.getItem('website.found_visitor_timezone')) { + var timezone = jstz.determine().name(); + this._rpc({ + route: '/website/update_visitor_timezone', + params: { + 'timezone': timezone, + }, + }).then(function (result) { + if (result) { + localStorage.setItem('website.found_visitor_timezone', true); + } + }); + } + return this._super.apply(this, arguments); + }, +}); + +return publicWidget.registry.visitorTimezone; + +}); |
