diff --git a/README.md b/README.md index 0f49ed7..dd88e47 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,9 @@ No server side code is required - it's all just static files - and all modern web servers support Range (tested lighttpd, cherokee, apache). Tested (briefly) in IE, FF, Chrome. -Usage: symlink the log to /log, or alter the url in logtail.js. Other settings -available in logtail.js including poll frequency. Then browse to index.html +Usage: symlink the log to /log, provide ?url=http://my.custom.path/log, or alter +the url in logtail.js. Other settings available in logtail.js including poll +frequency. Then browse to index.html License is GNU GPL 3; see http://www.gnu.org/licenses/ diff --git a/logtail.js b/logtail.js index 6506b9b..3ae5b52 100644 --- a/logtail.js +++ b/logtail.js @@ -7,7 +7,10 @@ var dataelem = "#data"; var pausetoggle = "#pause"; var scrollelems = ["html", "body"]; -var url = "log"; +var urlString = window.location.href; +var urlObject = new URL(urlString); +var urlParam = urlObject.searchParams.get("url"); +var url = urlParam ?? "log" var fix_rn = true; var load = 30 * 1024; /* 30KB */ var poll = 1000; /* 1s */ @@ -146,7 +149,7 @@ function show_log() { if (reverse) { var t_a = t.split(/\n/g); t_a.reverse(); - if (t_a[0] == "") + if (t_a[0] == "") t_a.shift(); t = t_a.join("\n"); } @@ -163,7 +166,7 @@ function error(what) { kill = true; $(dataelem).text("An error occured :-(.\r\n" + - "Reloading may help; no promises.\r\n" + + "Reloading may help; no promises.\r\n" + what); scroll(0);