1 /*############################################################################
3 # OpenERP, Open Source Management Solution
4 # Copyright (C) 2011 OpenERP SA (<http://openerp.com>).
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as
8 # published by the Free Software Foundation, either version 3 of the
9 # License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Affero General Public License for more details.
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 ############################################################################*/
21 var __lc_buttons = [];
23 openerp.web_livechat = function (openerp) {
25 var QWeb = openerp.web.qweb;
26 QWeb.add_template('/web_livechat/static/src/xml/web_livechat.xml');
29 // tracking code from LiveChat
30 var license = '1035052',
34 __lc_load = function (p) { if (typeof __lc_loaded != 'function')
35 if (p) { var d = document, l = d.createElement('script'), s =
36 d.getElementsByTagName('script')[0], a = unescape('%26'),
37 h = ('https:' == d.location.protocol ? 'https://' : 'http://'); l.type = 'text/javascript'; l.async = true;
38 l.src = h + 'gis' + p +'.livechatinc.com/gis.cgi?serverType=control'+a+'licenseID='+license+a+'jsonp=__lc_load';
39 if (!(typeof p['server'] !== 'string' || typeof __lc_serv === 'string')) {
40 l.src = h + (__lc_serv = p['server']) + '/licence/'+license+'/script.cgi?lang='+lang+a+'groups='+skill;
41 l.src += (params == '') ? '' : a+'params='+encodeURIComponent(encodeURIComponent(params)); s.parentNode.insertBefore(l, s);
42 } else setTimeout(__lc_load, 1000); if(typeof __lc_serv != 'string'){ s.parentNode.insertBefore(l, s);}
43 } else __lc_load(Math.ceil(Math.random()*5)); }
48 openerp.web_livechat.Livechat = openerp.web.Widget.extend({
49 template: 'Header-LiveChat',
56 var pwc = new openerp.web.Model(self.session, "publisher_warranty.contract");
57 pwc.get_func('get_default_livechat_text')().then(function(text) {
58 self.$element.html(text);
62 openerp.webclient.header.do_update.add_last(this.do_update);
65 do_update: function() {
68 self.$element.remove();
72 var lc_id = _.uniqueId('livechat_');
73 this.$element.attr('id', lc_id);
75 var pwc = new openerp.web.Model(self.session, "publisher_warranty.contract");
77 pwc.get_func('is_livechat_enable')().then(function(res) {
78 console.log('res', res);
84 elementId: lc_id, //'livechat_status',
89 online: '<img src="/web_livechat/static/src/img/available.png"/>Support',
90 offline: '<img src="/web_livechat/static/src/img/away.png"/>Support',
97 openerp.webclient.livechat = new openerp.web_livechat.Livechat(openerp.webclient);
98 openerp.webclient.livechat.prependTo('div.header_corner');