From 1077f993959012223601a92d5a622d50c8bad020 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Mon, 18 Jan 2016 15:15:47 -0500 Subject: [PATCH] removing ellipses from posts with < 225 chars --- js/app.js | 10 ++++++---- js/custom/pageSetup.js | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) 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); -- 2.17.1