diff options
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; + +}); |
