Getting Selection-Magic to Work

Included in this set-up of WP is a javascript thing that allows the selection of regions of the text, which is convenient when you want to reference a certain passage in a blog post. I had noticed that the functionality was not actually working on my web page, so I dug into the problem. I learned a bit about javascript and a bit about Wordpress. Here are the things I had to change to get it to work:

In the single-post file, which is where the javascript thing is active, there were actually two <span>tags with the same ID, so I got rid of one of them. The big problem with the code was that this <span> tag ID must match the ID called for in the selection-magic script, and for some reason the script was not being updated to match the ID on the page. I reasoned that there is no reason that the ID should be unique for each page (it was being assigned a "shash-#" to match the post ID), it just has to be unique within the page. So I switched it to a static ID string, "sm-area", which solved the problem.

In trying to figure out why this was not working, I compared my script to the one on a page with a working version, and noticed that they included the word "selection-" in the generated address, so I added that too. I also did some minor edits to the javascript.

Next Step: I will review the standard files, and if appropriate, make a vpatch to include these changes into the tree as found on Btcbase.org.

Tags: ,

One Response to “Getting Selection-Magic to Work”

  1. [...] Blog of Peter Lambert mentis supra materia « Getting Selection-Magic to Work [...]

Leave a Reply