Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
31 changes: 30 additions & 1 deletion src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = $("<a>").attr("href", selectedWord);
$(e.target).append($link);
$link[0].click();
$word.val(selectedWord);
doLookup(true);
}
});
}
} catch (x) {
console.warn(x);
Expand Down Expand Up @@ -105,16 +121,29 @@ $(function () {
var $a = $("<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);
Expand Down