Skip to content

Issue #24 #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/assests/js/anchorme.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions public/assests/js/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,21 @@ function updateConversation(data) {
var messageText = $("<div></div>").addClass("message-text");

// Embed YouTube video if link presents in message.
var result = anchorme(data[i].message.replace(/<(?:.|\n)*?>/gm, ''), { attributes:[ { name:"target", value:"_blank" } ] });
var youtube_link = data[i].message.indexOf('https://www.youtube.com');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@forsd You need to check it for youtube short url like https://youtu.be/* and one more thing, pls put this link in <a> tag so user can opn this link directly in the new tab also

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK will do.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check it.

if(youtube_link !== -1) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather repeating the same code again and again, it would be better to make a new function and cal that function on getting link similar to http://youtube.com or http://youtu.be/ else will send message. What do you say ??

messageText.html(data[i].message + '<iframe width="100%" src="https://www.youtube.com/embed/' +
data[i].message.substring(youtube_link + 32, youtube_link + 43) + '" frameborder="0" allowfullscreen></iframe>');
messageText.html(result + '<iframe width="100%" src="https://www.youtube.com/embed/' +
data[i].message.substring(youtube_link + 32, youtube_link + 43) + '" frameborder="0" allowfullscreen></iframe>');
}
else {
messageText.text(data[i].message);
youtube_link = data[i].message.indexOf('https://youtu.be/');
if(youtube_link !== -1) {
messageText.html(result + '<iframe width="100%" src="https://www.youtube.com/embed/' +
data[i].message.substring(youtube_link + 17, youtube_link + 28) + '" frameborder="0" allowfullscreen></iframe>');
}
else {
messageText.html(result);
}
}

var spanElement = $("<span></span>").addClass("message-time pull-right").text(data[i].time);
Expand Down
Loading