Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
document.getElementById('connect').onclick = function() {
new bsn.Button(document.querySelector('#connect'), 'loading');
new bsn.Button(document.querySelector('#connect-dropdown'), 'loading');
var docName = window.location.pathname.slice(1);
var username = 'the-other-user'; //TODO: prompt user for their name
console.log('Getting new conversations client');
getConnectedConversationsClientFor(username)
.then(function() {
console.log('Got conversations client');
if (activeConversation) {
// Add a video/audio participant
// activeConversation.invite(docName);
alert('Only two participants supported at this time.');
} else {
var options = {};
if (previewMedia) {
for (var i = 0; i < links.length; i++) {
links[i].addEventListener('click', function(e) {
e.preventDefault();
myself.emit('file', files[e.target.innerHTML].content);
modal.close();
});
}
document.querySelector('#gist-url').value = url;
new bsn.Button(e.target, 'reset');
} else {
var error = 'No files found in gist.';
updateModalBody(modal,
modalBody + '<h5 style="color: #aa2222;">' + error + '</h5>');
document.querySelector('#gist-url').value = url;
new bsn.Button(e.target, 'reset');
}
})
.catch(function(error) {
loadButton.addEventListener('click', function(e) {
new bsn.Button(e.target, 'loading');
var url = document.querySelector('#gist-url').value;
getGistFiles(url)
.then(function(files) {
var fileNames = Object.keys(files);
var fileCount = fileNames.length;
if (fileCount === 1) {
myself.emit('file', files[fileNames[0]].content);
modal.close();
} else if (fileCount > 1) {
var list = '';
for (var fileName in files) {
list += '<li><a href="#">' + fileName + '</a></li>';
}
updateModalBody(modal,
modalBody + '<br><br><p>Which file from the gist?</p><ul>' + list + '</ul>');
function toggleConnectButton() {
var connectButton = document.querySelector('#connect');
var connectDropdownButton = document.querySelector('#connect-dropdown');
if (connectButton.hasAttribute('disabled') && connectButton.hasAttribute('data-original-text')) {
new bsn.Button(connectButton, 'reset');
connectButton.setAttribute('disabled', 'disabled'); //TODO: change this to 'Disconnect'
connectDropdownButton.setAttribute('disabled', 'disabled');
} else if (connectButton.hasAttribute('disabled')) {
connectButton.removeAttribute('disabled');
connectDropdownButton.removeAttribute('disabled');
} else {
connectButton.setAttribute('disabled', 'disabled'); //TODO: change this to 'Disconnect'
connectDropdownButton.setAttribute('disabled', 'disabled');
}
}