[Enhancement] Add CopyToClipboard action in code component (#329)
* Add CopyToClipboard action in websiteWidgetCode component * Fix codeclimate issues
This commit is contained in:
parent
a3662091c7
commit
60e96f446e
18 changed files with 283 additions and 90 deletions
42
app/javascript/dashboard/helper/scriptGenerator.js
Normal file
42
app/javascript/dashboard/helper/scriptGenerator.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
export const createWebsiteWidgetScript = websiteToken => `
|
||||
<script>
|
||||
(function(d,t) {
|
||||
var BASE_URL = '${window.location.origin}';
|
||||
var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
||||
g.src= BASE_URL + "/packs/js/sdk.js";
|
||||
s.parentNode.insertBefore(g,s);
|
||||
g.onload=function(){
|
||||
window.chatwootSDK.run({
|
||||
websiteToken: '${websiteToken}',
|
||||
baseUrl: BASE_URL
|
||||
})
|
||||
}
|
||||
})(document,"script");
|
||||
</script>
|
||||
`;
|
||||
|
||||
export const createMessengerScript = pageId => `
|
||||
<script>
|
||||
window.fbAsyncInit = function() {
|
||||
FB.init({
|
||||
appId: "${window.chatwootConfig.fbAppId}",
|
||||
xfbml: true,
|
||||
version: "v4.0"
|
||||
});
|
||||
};
|
||||
(function(d, s, id){
|
||||
var js, fjs = d.getElementsByTagName(s)[0];
|
||||
if (d.getElementById(id)) { return; }
|
||||
js = d.createElement(s); js.id = id;
|
||||
js.src = "//connect.facebook.net/en_US/sdk.js";
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
}(document, 'script', 'facebook-jssdk'));
|
||||
|
||||
</script>
|
||||
<div class="fb-messengermessageus"
|
||||
messenger_app_id="${window.chatwootConfig.fbAppId}"
|
||||
page_id="${pageId}"
|
||||
color="blue"
|
||||
size="standard" >
|
||||
</div>
|
||||
`;
|
Loading…
Add table
Add a link
Reference in a new issue