Sorry to bother you. I have been really struggling understanding what is probably quite simple. I have been working on BlogSpot coding a theme. Currently, whenever a post is made, on the homepage it gets turned into a 'summary' rather than being shown as a full post. Below is the code which I have identified as handling the task. I have tried changing it and deleting it many times all resulting in the same result - The post is visible but none of the hyperlinked titles or post dates etc show, only the main content. I was hoping if someone could help me solve this so that when I post, a full article is shown on the blog rather than just a summary?
If img.length is *exactly* 1 (that is, if there is exactly 1 image within the <div>) then that code will first set imgtag to the one string and then to the other!
And there is similar insanity with the if (postCount>=1) stuff.
On top of that, the code to strip the HTML tags is braindead.
It wouldn't give me much confidence in using this software.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Just to show how UTTERLY BRAINDEAD that code is, try this:
Code:
var txt = "In math, 3 < 5 is true and 10 > 12 is false";
alert( removeHtmlTag( txt, 9999 ) );
using that removeHtmlTag code, as written.
You get an alert of In math, 3 12 is false
The stupid code thinks that "< 5 is true and 10 >" is an HTML tag!!!
*********
Anyway, aside from the code being both braindead and ugly as pig snot, if you don't want to eliminate HTML tags from the blogposts, then you *could* simply change that function to
Code:
function removeHtmlTag( strx, chop ) { return strx; }
If you do want to remove HTML tags, then do it right:
Code:
function removeHtmlTag( strx, chop ) /* ignores chop! */
{
var re = /\<\/?[a-z][^\>]*\>/ig;
return strx.replace( re, "" );
}
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Do note that arbitrarily removing HTML tags can have funny consequences! (Using either their code or mine.)
For example:
Code:
This is a nothing post. <span style="display: none;">This blog owner is a doofus</span>
As written, the stuff in the span doesn't show.
After removing the HTML tags, you get
Code:
This is a nothing post. This blog owner is a doofus
All of this is just really poorly thought out. The blog software *SHOULD* be using a WYSIWYG text editor that does *NOT* allow HTML tags and that, instead, uses pseudo-tags (as does this forum, where we can use [ b] xxx [/ b] tags--without the spaces--to create bold text).
I think I would avoid BlogSpot if it doesn't support something like that!
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Thanks for all your help, it worked perfectly! Agreed, this code is very messy and doesn't help newbies at JS like me The BlogSpot platform the gives no option, they really need to update. They only recently started to allow people to code!