From: Anthony Talarico Date: Mon, 18 Jan 2016 20:15:47 +0000 (-0500) Subject: removing ellipses from posts with < 225 chars X-Git-Tag: v1.0.0^2~35 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=1077f993959012223601a92d5a622d50c8bad020;p=WP-Themes%2Fotsego.git removing ellipses from posts with < 225 chars --- diff --git a/js/app.js b/js/app.js index d28a8f9..c7af6d9 100644 --- a/js/app.js +++ b/js/app.js @@ -113,14 +113,16 @@ $(document).ready(function () { // remove link from posts with less than 225 characters for (var i = 0; i < $('div[class*="excerpt"]').length; i++){ -// var words = $(".excerpt" + i).text().split(' '); - var words = $(".excerpt" + i).text(); - if(words.length < 225){ - + var chars= $(".excerpt" + i).text(); + + if(chars.length < 225){ + chars = chars.substr(0,chars.length - 2); + // disable link if excerpt is < 225 characters $(".excerpt" + i).parent().find("a").replaceWith(function(){ return $("

", {html: $(this).html()}); }); + $('.excerpt' + i).text(chars); } } /* get number of elements in DOM console.log($("*").length); diff --git a/js/custom/pageSetup.js b/js/custom/pageSetup.js index d361547..40ea86d 100644 --- a/js/custom/pageSetup.js +++ b/js/custom/pageSetup.js @@ -104,14 +104,16 @@ $(document).ready(function () { // remove link from posts with less than 225 characters for (var i = 0; i < $('div[class*="excerpt"]').length; i++){ -// var words = $(".excerpt" + i).text().split(' '); - var words = $(".excerpt" + i).text(); - if(words.length < 225){ - + var chars= $(".excerpt" + i).text(); + + if(chars.length < 225){ + chars = chars.substr(0,chars.length - 2); + // disable link if excerpt is < 225 characters $(".excerpt" + i).parent().find("a").replaceWith(function(){ return $("

", {html: $(this).html()}); }); + $('.excerpt' + i).text(chars); } } /* get number of elements in DOM console.log($("*").length);