I am building a webrtc call button. Here is the image
enter image description here
Every button should calls the id “CallmeWidget” with a specific phone number from the table which is located in the script as “sipId”. The main fuctions work is that, when the button is pressed then the an outgoing call is occured to the specific number of the client. I dont know much of javascript. I need help is doing this.
When I tried to make duplicates of the below two scripts than the result get is this my 2nd output. The buttons are not displaying properly and not working properly
There will be lots of data in the table which will come from database, I can display that no problem. But I need to run the function properly. I would be kind if someone helps me to do this.
<div class="container">
<div class="row">
<div class="col-12">
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">SL</th>
<th scope="col">Client Name</th>
<th scope="col">Number</th>
<th scope="col">Call</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Client 1</td>
<td><?php echo $number; ?></td>
<td>
<div id="CallScripts"></div>
<div id="CallmeWidget"></div>
</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Client 2</td>
<td><?php echo $number2;?></td>
<td>
<div id="CallScripts"></div>
<div id="CallmeWidget"></div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script>
var script1 = document.createElement('script');
script1.src = 'detectWebRTC.min.js';
document.getElementById('CallScripts').appendChild(script1);
var script2 = document.createElement('script');
script2.src = 'jssip.min.js';
document.getElementById('CallScripts').appendChild(script2);
var script3 = document.createElement('script');
script3.src = 'widget.min.js?version=5';
document.getElementById('CallScripts').appendChild(script3);
var styl = document.createElement('link');
styl.setAttribute('rel', 'stylesheet');
styl.href = 'style.min.css';
document.getElementById('CallScripts').appendChild(styl);
</script>
<script>
var CallmeWidget;
var CallmeWidgetFn = function() {
CallmeWidget = new CallmeWidgetNew("CallmeWidget");
CallmeWidget.create({
"widgetId": "kkd8cVk8N21vesXKxvBfBebcUCGtaMy5cv18TT8PJ49eXrGxzt66R7S7kb96GeSmc8v9rthssgau1m3c6GT4gTg2Unesb8zz7c351bcafe4aeb79ac80e811dd16266c",
"sipId": "<?php echo $number;?>",
"domElement": "CallmeWidget"
}, {
"shape": "square",
"language": "en",
"width": "0",
"dtmf": false,
"dtmf_position": "top",
"dtmf_time_to_disappear": "20",
"font": "'Trebuchet MS','Helvetica CY',sans-serif",
"color_call": "rgb(255, 255, 255)",
"color_bg_call": "rgb(126, 211, 33)",
"color_border_call": "rgb(191, 233, 144)",
"color_connection": "rgb(255, 255, 255)",
"color_bg_connection": "rgb(33, 211, 166)",
"color_border_connection": "rgb(144, 233, 211)",
"color_calling": "rgb(255, 255, 255)",
"color_border_calling": "rgb(255, 218, 128)",
"color_bg_calling": "rgb(255, 181, 0)",
"color_ended": "rgb(255, 255, 255)",
"color_bg_ended": "rgb(164,164,164)",
"color_border_ended": "rgb(210, 210, 210)"
});
};
if (window.addEventListener) {
window.addEventListener('load', CallmeWidgetFn, false);
} else if (window.attachEvent) {
window.attachEvent('onload', CallmeWidgetFn);
}
</script>