Definitely possible to wrap the entire post with a predetermined colour tag on submit.
The only limitation would be if a post was close to hitting the character limit. As long as there was room for the colour tag it would work without any issues.
I'll have a look at adding something like that soon
07-Jan-2015 14:45:14
- Last edited on
07-Jan-2015 14:46:16
by
Indecent Act
Indecent Act
said
:
The only limitation would be if a post was close to hitting the character limit. As long as there was room for the colour tag it would work without any issues.
Will you be able to access the character remaining in the post, to determine if you have enough space to add color tags?
Or a quick and hacky way is to just count the number of characters in the post being written (since you can restore posts.)
Lifer
said
:
Will you be able to access the character remaining in the post, to determine if you have enough space to add color tags?
Or a quick and hacky way is to just count the number of characters in the post being written (since you can restore posts.)
I can do it either way, but counting the characters is actually more efficient than reading the value from characters remaining. This may not be the case if the max characters was huge, but counting 2000 characters or less is better than looking at the DOM for a value (DOM operations are slow, numeric and simple string operations are lightening fast). But it doesn't actually matter in this case (see 2nd last paragraph).
I used to modify the character limit and reduce it accordingly for those using avatar codes, since the code is added on submit. This meant there was always room for the avatar code. I'm actually not sure if I'm still doing that (I need to check), there has been many changes to how custom avatars work and I can't remember if that method is still in place.
Assuming I'm still using that method, I could do the same thing and make the character limit 2000 minus the length of the colour tag. That means there is no string operations, and you'll always have room for the desired colour tag.
Though tbh it doesn't really matter what way I go. I actually like these kind of features because it all takes place well after the page has loaded. So it in no way adds more work during page load since all the processing occurs when the submit button is clicked.
Edit:
Two limitations I can think of.
- If someone uses text selection quoting on your coloured post, the colour wont be honoured. That's just the nature of that feature, all text selections are treated as plain text. I think we can live with that though.
- If you include a quote in your post, the entire post including the quote gets recoloured. But I think I have a sneaky solution for that
07-Jan-2015 16:49:06
- Last edited on
07-Jan-2015 17:13:16
by
Indecent Act
Indecent Act
said
:
- If you include a quote in your post, the entire post including the quote gets recoloured. But I think I have a sneaky solution for that
That's why I just use a colour code in my signature box
Suppose that's not an option if people actually have a signature though