function getNextGroupId() { max = -1; groups = jQuery('#article_body_ifr').contents().find('.article_comments'); groups.each(function(key, value) { value = jQuery(value).attr('data-macro-group_id'); if(value>max) max = parseInt(value); }); return max+1; } function makeCommentable() { tinyMCE.activeEditor.focus(); start = jQuery(tinyMCE.activeEditor.selection.getStart()).closest('p'); end = jQuery(tinyMCE.activeEditor.selection.getEnd()).closest('p'); //text = start.parent().children(); text = jQuery('#article_body_ifr').contents().find('*'); selection = text.slice(text.index(start), text.index(end)+1); hasTag = false; selection.each(function(key, value) { commentTag = jQuery(value).closest('.article_comments'); if(commentTag.length) { commentTag.children().unwrap('
"); } } }