kcrca/jog — Issue #1: Bug in scriptDir()
Author: rdingwall
Created: 2011-12-14 22:22:33+00:00
State: open

Hi, bit of a novice JS guy here - I've been enjoying jog.js but just found a bug when I had a `` block at the end of my page.

```javascript
// The popup handler needs the location of this jog.js file so it can find the
// companion logPopup.html file. The following code is borrowed from
// http://stackoverflow.com/questions/984510/what-is-my-script-src-url/3865126#3865126
var scriptDir = (function() {
var scripts = document.getElementsByTagName('script'),
script = scripts[scripts.length - 1];

return script.getAttribute('src', 2).replace(/\/+[^/]*\/*$/, '/'); //jog.js:115 Uncaught TypeError: Cannot call method 'replace' of null
````

It blows up because there is no `src` attribute (the script text is inline, not loaded from a file). So jog needs another way to achieve this.

(A quick and dirty fix (I am using) is to query for `