inherit
24252
0
Aug 1, 2023 15:01:24 GMT -8
coolcoolcool
When the world says, "Give up," Hope whispers, "Try it one more time."
2,148
May 2004
coolcoolcool
|
Post by coolcoolcool on Apr 11, 2015 16:31:34 GMT -8
Hi guys.
I'm making a quick plugin for my forum. Is there an easy way to modify the text of all thread titles? Right now I have $("a.thread-link, a.thread-recent-link"), but then there's also the title bars and then the navigation links to worry about.
Of course, I can also match for those, but I'm wondering if there might be something built into the new plugin system that might make it easier.
Thanks!
Edit
Currently using $('a.thread-link, a.thread-recent-link, div.title-bar h1, .nav-tree-branch div a span'), but I think div.title-bar h1 is far from ideal.
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Apr 11, 2015 18:57:46 GMT -8
This does sound like something that would be easier to do via the templates. What is it exactly you're trying to do?
|
|
inherit
24252
0
Aug 1, 2023 15:01:24 GMT -8
coolcoolcool
When the world says, "Give up," Hope whispers, "Try it one more time."
2,148
May 2004
coolcoolcool
|
Post by coolcoolcool on Apr 11, 2015 19:05:16 GMT -8
Well, I technically already have it working.
As you can see in the code below, I am adding latex to the post area of my forum, but I do not want it to show up in any of the thread titles. To avoid this I manually remove dollar signs unless they are escaped by a backslash.
I don't understand how the template system works, as I have never experimented with it. Would I have to manually change the html of every page that would show the thread title?
<script> $('a.thread-link, a.thread-recent-link, div.title-bar h1, .nav-tree-branch div a span').text(function(){ for(var i = 1; i < $(this).text().length; ++i) { if ($(this).text().charAt(i) == '$' && $(this).text().charAt(i-1) != '\\') { $(this).text($(this).text().substring(0,i) + $(this).text().substring(i+1)); i = i-1; } } return $(this).text().replace(/^\$+/g, ""); }); </script> <script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'> MathJax.Hub.Config({ "HTML-CSS": { scale: 150, linebreaks: { automatic: true } }, SVG: { linebreaks: { automatic:true } }, displayAlign: "center", tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']], processEscapes: true } }); </script>
Although, now that I think about it, it might be better to just find a way to localize the latex to the post area.
Edit
Actually, that's what I'm going to do. I'll just configure the latex to only modify the body of the posts.
Thanks for your help!
Edit 2
Just checked out the template system and it was exactly what I needed.
|
|