diff --git a/README.org b/README.org
index 6d686c0..389d319 100644
--- a/README.org
+++ b/README.org
@@ -17,6 +17,12 @@
directory). This should open Aard2 web UI page
(http://localhost:8013) in the default system browser.
+ To make the web server available for the LAN network add /-Dslobber.host=0.0.0.0/, e.g:
+
+ #+BEGIN_SRC sh
+ java -Dslobber.browse=true -Dslobber.host=0.0.0.0 -jar aard2-web-0.8.jar ~/Downloads/*.slob
+ #+END_SRC
+
To start the web server on a different port, set system
property /slobber.port/. For example, to start on port 8014:
diff --git a/src/script.js b/src/script.js
index 39474f3..50d4938 100644
--- a/src/script.js
+++ b/src/script.js
@@ -16,6 +16,12 @@ $(function () {
if (contentLocation.href === "about:blank") {
$contentHeader.hide();
} else {
+ var url = new URL(contentLocation.href);
+ if ($word.val()) {
+ url.searchParams.set('q', $word.val());
+ }
+ window.top.location.hash = url.pathname + url.search;
+ history.pushState("", "", window.top.location.href);
var i,
slobId,
lookupKey,
@@ -43,6 +49,16 @@ $(function () {
$("#header-title").text(contentLocation.href);
}
$contentHeader.show();
+ $content.contents().find('body').dblclick(function(e) {
+ var selectedWord = $content.contents()[0].getSelection().toString().trim();
+ if (selectedWord) {
+ var $link = $("").attr("href", selectedWord);
+ $(e.target).append($link);
+ $link[0].click();
+ $word.val(selectedWord);
+ doLookup(true);
+ }
+ });
}
} catch (x) {
console.warn(x);
@@ -105,16 +121,29 @@ $(function () {
var $a = $("")
.append($label)
.append($dictLabel)
- .attr("href", item.url)
+ .attr("href", item.url.slice(0,-1) + "&q=" + item.label)
.attr("target", "content");
$li.append($a);
$ul.append($li);
return true;
});
$lookupResult.append($ul);
+ if (!$content.attr('src')) {
+ $content.attr('src', $ul.find('li:first-child a').attr('href'));
+ }
});
};
+ if (window.top.location.hash) {
+ var itemUrl = window.top.location.hash.slice(1);
+ var q = new URLSearchParams(new URL(itemUrl, 'http://_').search).get('q');
+ if (q) {
+ $word.val(q);
+ doLookup();
+ }
+ $("#content").attr("src", itemUrl);
+ }
+
var onInputChange = function () {
if (scheduledLookupID) {
clearTimeout(scheduledLookupID);