Scripturizer for Javascript

Abstract

Scripturizer for Javascript finds Bible passage references in a web page, and creates links to either Good News Publisher or Bible Gateway -- all done on the web browser with no server-side programming required.

Download

About

This comment got me thinking -- whether Scripturizer, implemented in PHP or Perl on the server side, is too difficult to use for people who have no scripting language or programming background. Dean Peter's MovableType plugin version requires you to upload files to your MT plugin directory, and then modify templates to invoke it. Glen Davis' and my version for WordPress also both require uploading file(s) to WP's plugin directory, and then activate it from inside the WP -- FTP and template editing knowledge required.

What about other blogging software, like TextPattern, Blosxom or Nucleus? Well, you might be able to hack the PHP/Perl version of Scripturizer to act as a filter for these respective blog software, but coding knowledge required. Using PyBlosxom, Roller Weblogger or .Text? Too bad. You have to hack the regular expression yourself to port the Scripturizer over to the languages these blogging software use -- again coding knowledge required.

What about if your blog is hosted by a blog service, like Blogger or Xanga? What about if it is not a blog, but a couple of static pages hosted on Geocity? When you have no control on the server side software -- a server side solution is simply not feasible.

Thus the birth of this little script - Scripturizer for Javascript. You can have it loaded into any web page, and this script will search for Bible passage references inside the document and make links to websites that can display the full text. All done on the web browser, no server-side programming required.

Demo Page

Want to see how Scripturizer for Javascript works? Check out this testing page

Installation/Usage

Just include that Javascript file inside your HTML code! For example,

  1. Upload scripturizer.js to the root directory of your website.
  2. Insert the following HTML into your page/template:
    <script type="text/javascript" src="/scripturizer.js">
    </script>
    
    The URL inside the src attribute needs to be altered to point to where you have actually uploaded the file.
  3. Reload your page, and it should now be scripturized!

Customization

You can change how Scripturizer behave by using different query string parameters when you import it into your HTML document.

onload: 1|0 (default: 0)
Whether to automatically invoke the Scripturizer when the page is loaded. Default is 1, but you might want to disable it if you wish to manually call Scripturizer functions.
element: (default: content)
The element ID for the DOM element to be scripturized. If the element does not exist, then the whole document.body will be used.
new_window: 1|0 (default: 0)
Whether to open the Bible text in a new browser window, instead of inside the current window.
version: (default: esvpopup)
Bible translation version to used. If the value is "esv", then links to Good News Publisher will be used. If the value is "esvpopup", and ESV Popup has also been loaded, ESV reference inside a small pop-up window will be used. Otherwise, links to Bible Gateway will be used.

For example, if you only want to scripturize all references in "sidebar" and use New International Version in a new window, you use the following HTML to import Scripturizer:

<script type="text/javascript" 
  src="/scripturizer.js?element=sidebar&amp;new_window=1&amp;version=niv">
</script>

All links generated would have CSS class scripturized. You can change the stylesheets to make these scripturized links look differently.

Compatibility

I have tested Scripturizer for Javascript in the following web browsers:

  • Internet Explorer 6, 7 on Windows
  • Firebird 1/1.5/2 on Windows
  • Safari 1.2.x on Mac OS X
  • Opera 8.5/9 on Windows

Bookmarklet

You are not only able to hyperlink Bible references on your own website, you can now also scripturize other websites! Even been to a website where the webmaster just forgot to provide links for passages to the text (like I usually do)? The Scripturizer bookmarklet is here to provide the fix.

Scripturize It! (ESV popup)

Scripturize It! (NIV)

Installation/Usage

  1. Drag one of the above link to your browser's bookmark toolbar.
  2. Hit that "Scripturize It!" button on your toolbar, whenever you come across a site not linking Bible passage to text.
  3. There is no step 3.

Note -- if you are unfortunately an Internet Explorer user, it might not let you drag the link to your Links toolbar. You will need to (1) right click on the link to bring out context menu (2) click on "Add to Favorites..." (3) click on "Yes" in the Security Alert dialog box (4) choose "Links" folder in "Add Favorite" dialog box. A bit complicated, or else you can try Firefox or Opera.

GreaseMonkey User Script

Thanks to Glen's suggestion, I have partially ported the Scripturizer JS to GreaseMonkey user script.

I have only tested this user script under Firefox 1.5 and GreaseMonkey 0.6.4 on Windows. If you are running a different version of Mozilla, GM or operating system, then your mileage might vary.

This user script will be triggered on all documents by default, but you can re-configure it using "Manage User Script" menu item. It defaults to link Bible passages to ESV at Good News Publisher, but you can change the configuration with these steps:

  1. Type in about:config in Firefox/Mozilla's address bar.
  2. Put greasemonkey in the filter.
  3. You should see:
    greasemonkey.scriptvals.http://fucoder.com/Scripturizer.translation
    in the list, and the value is default to "esv". Change it to the Bible translation of your choice.

Currently it is not as configurable as the regular Scripturizer for Javascript, nor it supports ESVPopup due to some limitations. They will be worked on.

Support/Help

Please post your support issues to my Javascript forum detailing your situation, i.e. what is not working, what browser are you using, etc.

History

  • 2.2 (2006-01-16)
    • Fix a few regular expression bug on value replacing.
    • Skip text if it is already inside a link.
  • 2.1 (2005-10-13)
    • Fix a regular expression bug that prevents scripturizing a lengthy text node.
    • Change the onload mechanism.
  • 2.0 (2005-10-06)
    • Manipulate DOM elements instead of searching and replacing innerHTML.