Jump to content
xisto Community
Sign in to follow this  
threehappypenguins

Autolink And Tooltip Combo

Recommended Posts

I was wondering if I could get some help in something. I am working on my church's website, and I previously implemented something called "Reftagger" onto the new website: https://www.logos.com/reftagger?ssi=0

It "converts" any bible verse into a hyperlink as well as a tooltip. I thought that this was a neat idea, and wanted to do the same with the Westminster Larger (and Shorter) Catechism as well. Anytime it says "WLC Q58" (for example) I want it to automatically display that specific question and answer. So far, I simply have a basic tooltip and a hyperlink inserted for every WLC Q: http://forums.xisto.com/no_longer_exists/ (just look at the page source and you'll see what I did). Then I have the tooltip.js file: http://forums.xisto.com/no_longer_exists/

What I want to do is create some sort of definition library or glossary. One where it tells the webpage that every time the webpage says "WLC 58" it will be automatically converted into a hyperlink and tooltip, just like Reftagger.

Share this post


Link to post
Share on other sites

I too plan on using Reftagger on my site. But to do what you want, the only way i know how is to replace the content of the document through innerHTML.

<script type="text/javascript">
function wlc()
{
var reg = /\b(WLC Q?\d{1,})\b/g;
var iHtml = document.body.innerHTML;
iHtml = iHtml.replace(reg, "<a href=\"#\">$1</a>");
document.body.innerHTML = iHtml;
}

window.onload = wlc();
</script>

Just make sure this is at the end of page (right before the ending of the body element). Just replace <a href=\"#\">$1</a> with whatever you want. Note, though, that this assumes that WLC Q# won't be within title or alt attributes.

Share this post


Link to post
Share on other sites

This seems like a hell of a good idea and looks like it can be applied to alot more things not just for you church website. This could be used on Blogs, Forums, News websites. I will pass this idea along to some of my friends they will love to here this idea.

Share this post


Link to post
Share on other sites

I too plan on using Reftagger on my site. But to do what you want, the only way i know how is to replace the content of the document through innerHTML.

<script type="text/javascript">
function wlc()
{
var reg = /\b(WLC Q?\d{1,})\b/g;
var iHtml = document.body.innerHTML;
iHtml = iHtml.replace(reg, "<a href=\"#\">$1</a>");
document.body.innerHTML = iHtml;
}

window.onload = wlc();
</script>

Just make sure this is at the end of page (right before the ending of the body element). Just replace <a href=\"#\">$1</a> with whatever you want. Note, though, that this assumes that WLC Q# won't be within title or alt attributes.

 


Truefusion, I'm not sure that I follow? I guess what I'm trying to ask is if there is some library or glossary generating program, or someone who has already written some kind of library or glossary and posted it (where I could just make appropriate changes). I don't know how to write javascript. I just copy and paste it, and then make changes. I would create a .js file or something and "call" that glossary or library from the footer of the webpage. Unfortunately, Reftagger doesn't give too many details on how they do it, so I can't "use" their files and make changes. I was hoping that someone would come across this and know what to do!!!

Share this post


Link to post
Share on other sites

Truefusion, I'm not sure that I follow? I guess what I'm trying to ask is if there is some library or glossary generating program, or someone who has already written some kind of library or glossary and posted it (where I could just make appropriate changes). I don't know how to write javascript. I just copy and paste it, and then make changes. I would create a .js file or something and "call" that glossary or library from the footer of the webpage. Unfortunately, Reftagger doesn't give too many details on how they do it, so I can't "use" their files and make changes. I was hoping that someone would come across this and know what to do!!!

I do not know of any library or glossary generating script whether they fit your needs or not. But the small script i provided does fit your needs, as far as i understand what you want. The script i have provided is far more simpler than any JavaScript library or glossary generating script and works in accordance to what you have asked for. It may take the easy route in doing things, but so long as it doesn't find the regular expression within title or alternative attributes, et cetera, it should be fine. All you have to do is edit the replacement parameter from the replace method (what i have explicitly pointed out in my previous post).

The Reftagger script does something similar to the script i have provided, it just does it better and it only looks up Biblical verses. The reason why both scripts have to be placed at the bottom of the page is because this ensures that the body element will be available to the script on page load. You could try to edit the RefTagger script to fit your needs, but if you do not understand JavaScript except to what can be understood intuitively (assuming it is possible to understand some parts of the script without previous knowledge of JavaScript or similar langauges), then trying to modify a complex JavaScript script i would not recommend to you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.