Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 9 additions & 2 deletions modules/live-comments/js/views/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ o2.Views.LiveCommentsWidgetItemView = ( function( $ ) {
initialize: function() {
},

makeLongWordsShort: function( content, limit ) {
makeLongWordsShort: function( content, limit, stripHTML ) {
if ( stripHTML ) {
// Rendering the content in a div is safe here, as we'll add it to the DOM later anyway, and we trust WordPress to have sanitized it.
var div = document.createElement( 'div' );
div.innerHTML = content;
content = div.textContent || div.innerText || content;
}

var contentArray = content.split( ' ' );
for ( var i=0; i < contentArray.length; i++ ) {
if ( contentArray[i].length > limit ) {
Expand All @@ -29,7 +36,7 @@ o2.Views.LiveCommentsWidgetItemView = ( function( $ ) {
render: function() {
var jsonifiedModel = this.model.toJSON();

jsonifiedModel.title = this.makeLongWordsShort( jsonifiedModel.title, 15 );
jsonifiedModel.title = this.makeLongWordsShort( jsonifiedModel.title, 15, true );
jsonifiedModel.author = o2.UserCache.getUserFor( this.model.attributes, 32 );

var titleForItem = jsonifiedModel.title,
Expand Down
2 changes: 1 addition & 1 deletion modules/live-comments/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function live_item_templates() {
<# if ( 'comment' === data.type ) { #>
data-postid="{{ data.postID }}"
<# } #>
>{{{ data.title }}}</a>
>{{ data.title }}</a>
<br/>
<span class="entry-date o2-timestamp" data-unixtime="{{ data.unixtime }}" data-domref="{{ data.domRef }}"
<# if ( 'comment' === data.type ) { #>
Expand Down