LiveChat.class.inc in Rocket.Chat 7.2
File
src/LiveChat.class.inc
View source
<?php
namespace RocketChat;
class LiveChat {
public static function getLivechatJavascript($url = "https://default", $version = "1.0.0") {
switch ($version) {
default:
drupal_set_message("Rocket.Chat Livechat Version supplied not supported");
watchdog("Rocket.Chat", "Livechat Version supplied [%version] is not supported.", [
"%version" => $version,
], WATCHDOG_ERROR);
return null;
break;
case "1.0.0":
global $language;
$langcode = $language->language;
return <<<JAVASCRIPT
(function (\$) {
'use strict';
(function(w, d, s, u) {
w.RocketChat = function(c) { w.RocketChat._.push(c) }; w.RocketChat._ = []; w.RocketChat.url = u;
var h = d.getElementsByTagName(s)[0], j = d.createElement(s);
j.async = true; j.src = '{<span class="php-variable">$url</span>}/livechat/1.0.0/rocketchat-livechat.min.js?_=201903270000';
h.parentNode.insertBefore(j, h);
})(window, document, 'script', '{<span class="php-variable">$url</span>}/livechat?version=1.0.0');
(function(w) {
w.RocketChat(function(){
this.setLanguage('{<span class="php-variable">$langcode</span>}');
});
}(window))
})(jQuery);
JAVASCRIPT;
break;
case "legacy":
return <<<JAVASCRIPT
(function (\$) {
'use strict';
(function (w, d, s, u) {
w.RocketChat = function (c) { w.RocketChat._.push(c); }; w.RocketChat._ = []; w.RocketChat.url = u;
var h = d.getElementsByTagName(s)[0], j = d.createElement(s);
j.async = true;
j.src = '{<span class="php-variable">$url</span>}/packages/rocketchat_livechat/assets/rocket-livechat.min.js?_=201702160944';
h.parentNode.insertBefore(j, h);
})(window, document, 'script', '{<span class="php-variable">$url</span>}/livechat');
})(jQuery);
JAVASCRIPT;
break;
}
}
}