You are not logged in.
@bernarcher: looking forward to seeing JumNav 1.0
would there be a way to use vimprobable2's/vimperator's hints instead?
Currently using this:
var elements = [];
var active_arr = [];
var hints;
var overlays;
var active;
var lastpos = 0;
var last_input = "";
var last_strings = [];
focus_color = "#00ff00";
normal_color = "#ffff99";
opacity = 0.3;
border = "1px dotted #000000";
hint_foreground = "#000000";
hint_background = "#b1ba29";
hint_border = "2px dashed #000000";
hint_opacity = 0.4;
hint_font = "11px monospace bold";
vertical_offset = 0;
horizontal_offset = -10;
function Hint(element) {
this.element = element;
this.rect = element.getBoundingClientRect();
function create_span(element, h, v) {
var span = document.createElement("span");
var leftpos = Math.max((element.rect.left + document.defaultView.scrollX), document.defaultView.scrollX) + h;
var toppos = Math.max((element.rect.top + document.defaultView.scrollY), document.defaultView.scrollY) + v;
span.style.position = "absolute";
span.style.left = leftpos + "px";
span.style.top = toppos + "px";
return span;
}
function create_hint(element) {
var hint = create_span(element, horizontal_offset, vertical_offset - element.rect.height/2);
hint.style.font = hint_font;
hint.style.color = hint_foreground;
hint.style.background = hint_background;
hint.style.opacity = hint_opacity;
hint.style.border = hint_border;
hint.style.zIndex = 10001;
hint.style.visibility = 'visible';
return hint;
}
function create_overlay(element) {
var overlay = create_span(element, 0, 0);
overlay.style.width = element.rect.width + "px";
overlay.style.height = element.rect.height + "px";
overlay.style.opacity = opacity;
overlay.style.backgroundColor = normal_color;
overlay.style.border = border;
overlay.style.zIndex = 10000;
overlay.style.visibility = 'visible';
overlay.addEventListener( 'click', function() { click_element(element); }, false );
return overlay;
}
this.hint = create_hint(this);
this.overlay = create_overlay(this);
}
function reload_hints(array, input, keep) {
var length = array.length;
var start = length < 10 ? 1 : length < 100 ? 10 : 100;
var bestposition = 37;
for (var i=0; i<length; i++) {
var e = array[i];
e.overlay.style.backgroundColor = normal_color;
if (!e.hint.parentNode && !e.hint.firstchild) {
var content = document.createTextNode(start + i);
e.hint.appendChild(content);
hints.appendChild(e.hint);
}
else if (!keep) {
e.hint.textContent = start + i;
}
if (!e.overlay.parentNode && !e.overlay.firstchild) {
overlays.appendChild(e.overlay);
}
if (input && bestposition != 0) {
// match word beginnings
var content = e.element.textContent.toLowerCase().split(" ");
for (var cl=0; cl<content.length; cl++) {
if (content[cl].toLowerCase().indexOf(input) == 0) {
if (cl < bestposition) {
lastpos = i;
bestposition = cl;
break;
}
}
}
}
}
active = array[lastpos];
active.overlay.style.backgroundColor = focus_color;
}
function click_element(e) {
var mouseEvent = document.createEvent("MouseEvent");
mouseEvent.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
e.element.dispatchEvent(mouseEvent);
clear();
}
function show_hints() {
document.activeElement.blur();
if ( elements ) {
var res = document.body.querySelectorAll('a, area, textarea, select, link, input:not([type=hidden]), button, frame, iframe');
hints = document.createElement("div");
overlays = document.createElement("div");
for (var i=0; i<res.length; i++) {
var e = new Hint(res[i]);
var rects = e.element.getClientRects()[0];
var r = e.rect;
if (!r || r.top > window.innerHeight || r.bottom < 0 || r.left > window.innerWidth || r < 0 || !rects ) {
continue;
}
var style = document.defaultView.getComputedStyle(e.element, null);
if (style.getPropertyValue("visibility") != "visible" || style.getPropertyValue("display") == "none") {
continue;
}
elements.push(e);
};
elements.sort( function(a,b) { return a.rect.top - b.rect.top; });
active_arr = elements;
reload_hints(elements);
document.body.appendChild(hints);
document.body.appendChild(overlays);
}
}
function is_input(element) {
var e = element.element;
var type = e.type.toLowerCase();
if (e.tagName == "INPUT" || e.tagName == "TEXTAREA" ) {
if (type == "radio" || type == "checkbox") {
e.checked = !e.checked;
}
else if (type == "submit" || type == "reset" || type == "button") {
click_element(element);
}
else {
e.focus();
}
return true;
}
return false;
}
function update_hints(input) {
var array = [];
var text_content;
var keep = false;
if (input) {
input = input.toLowerCase();
}
for (var i=0; i<active_arr.length; i++) {
var e = active_arr[i];
if (parseInt(input) == input) {
text_content = e.hint.textContent;
keep = true;
}
else {
text_content = e.element.textContent.toLowerCase();
}
if (text_content.match(input)) {
array.push(e);
}
else {
e.hint.style.visibility = 'hidden';
e.overlay.style.visibility = 'hidden';
}
}
active_arr = array;
if (array.length == 0) {
clear();
return;
}
if (array.length == 1) {
if (evaluate(array[0])) {
// return "__HINT_EVALUATED__"
return evaluate(array[0]);
}
else {
clear();
return;
}
}
reload_hints(array, input, keep);
}
function clear() {
if (overlays && overlays.parentNode) {
overlays.parentNode.removeChild(overlays);
}
if (hints && hints.parentNode) {
hints.parentNode.removeChild(hints);
}
elements = [];
active_arr = [];
active = undefined;
}
function evaluate(element) {
var ret = false;
var e = element.element;
if (!is_input(element) && e.href) {
if (e.href.match(/javascript:/) || (e.type.toLowerCase() == "button")) {
click_element(element);
// ret = true;
ret = e.href;
}
else {
// document.location = e.href;
// ret = true;
ret = e.href;
}
}
clear();
return ret;
}
function get_active() {
return evaluate(active);
}
function focus(newpos) {
active_arr[lastpos].overlay.style.backgroundColor = normal_color;
active_arr[newpos].overlay.style.backgroundColor = focus_color;
active = active_arr[newpos];
lastpos = newpos;
}
function focus_next() {
var newpos = lastpos == active_arr.length-1 ? 0 : lastpos + 1;
focus(newpos);
}
function focus_prev() {
var newpos = lastpos == 0 ? active_arr.length-1 : lastpos - 1;
focus(newpos);
}
function update(input) {
input = input.replace(/(\d+)$/, " $1");
strings = input.split(" ");
if (input.length < last_input.length || strings.length < last_strings.length) {
// user removed a char
clear();
show_hints();
for (var i = 0; i < strings.length; i += 1) {
update_hints(strings[i]);
}
} else {
update_hints(strings[strings.length-1]);
}
last_input = input;
last_strings = strings;
}
It's luakit's hinting script, which has been slightly modified. A couple of bugs need to be worked through, but still quite usable.
Offline
Just wanted to say thanks alot for this awesome browser! I've just changed from Firefox/Vimperator to Jumanji! Thanks again!
Btw, untill the annoying bug with JumNav.js v0.4 is fixed(pressing 'f' goes to the top of the page even though you're longer down ,or at the bottom), then portix's hints file(dwb2_hints.js) works great!
Latest version:
wget http://bitbucket.org/portix/stuff/raw/1b8fe0282f20/jumanji/dwb2_hints.js
Last edited by mhertz (2010-08-26 00:34:11)
Offline
There is also a newer version available:
http://bitbucket.org/portix/stuff/raw/2 … 2_hints.js
Offline
thanks portix for your work, i've been using your script since you've posted it here. just two remarks, when i first hit 'f', there's a green selection of the first link, i guess hitting 'enter' should go to that link but it doesn't, you still have to use the assigned letters. second and last remark, your latest revision seems to be way slower than the previous one (on my machine at least)...
edit/ for the speed, i should check a bit more sites but it /feels/ slower on full of links pages.
Last edited by bangkok_manouel (2010-08-26 08:25:07)
Offline
thanks portix for your work, i've been using your script since you've posted it here. just two remarks, when i first hit 'f', there's a green selection of the first link, i guess hitting 'enter' should go to that link but it doesn't, you still have to use the assigned letters.
Fixed, check the latest revision.
Offline
Btw, untill the annoying bug with JumNav.js v0.4 is fixed(pressing 'f' goes to the top of the page even though you're longer down ,or at the bottom), then portix's hints file(dwb2_hints.js) works great!
It is fixable already. You need to change a few lines. See this post.
Again apologies. This bug really is annoying.
To know or not to know ...
... the questions remain forever.
Offline
bangkok_manouel wrote:thanks portix for your work, i've been using your script since you've posted it here. just two remarks, when i first hit 'f', there's a green selection of the first link, i guess hitting 'enter' should go to that link but it doesn't, you still have to use the assigned letters.
Fixed, check the latest revision.
works great, thanks !
Offline
Inxsible wrote:Just pulled in the latest git and now the bookmark access doesn't work. Hit o (for :open),then I type in bbs and then hit Tab (to get access to the bookmarks.
I experience the same since august 22nd. As soon as I hit Tab on an :open command the input line seemingly becomes unresponsive, even to Esc.
Yeah, same here.
Offline
hi,neldoreth, i've seen your project home,http://pwmt.org/projects/jumanji
but i do not know how to compile, can you add a wiki to teach how to compile, or add a script to automate compile.thanks
if compile by myself, can you write some detail about compile?
# and can i compile jumanji under ubuntu?
Last edited by numbchild (2010-08-26 13:12:37)
Hack
Like computer , code , linux , hack .
Offline
i find i can not compile under ubuntu10.04,it come out a lot of words. i want to install Requirements gtk2 (2.18.6) libsoup (2.30.2) libwebkit (1.2.1) libunique (1.1.6) first, but i do not how to install it, can somebody help me?
Hack
Like computer , code , linux , hack .
Offline
There is also a newer version available:
http://bitbucket.org/portix/stuff/raw/2 … 2_hints.js
Thanks mate!
Btw, sorry for really stupid question, but i'm getting ready for a reinstall of Arch and hence, am polishing up my post-install script which installs apps and sets everything up right unattended, and so the script just wget's your hints file, but as I do not know anything about bitbucket and such, then does the url change upon each new revision(i'm hoping not ) ?
It is fixable already. You need to change a few lines. See this post.
Again apologies. This bug really is annoying.
Thanks mate! Also, I aplogize for posting about issues allready posted as fixable(I haden't read the whole thread before posting, but i'm gonna do that now so as to not make this kinda error again!)
Thanks again!
Offline
you would be better off asking in the ubuntu forums. Their package names might be different. Try to see which packages provide the required dependencies for jumanji.
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
@numbchild
Type this in a terminal:
sudo apt-get install libunique-dev libwebkit-dev libsoup-dev libgtk2.0-dev
cd /path/to/jumanji
make
Last edited by hut (2010-08-26 15:51:30)
"hut_" or "h00th00t" in irc.freenode.net #archlinux
Ranger Mailing List: https://lists.nongnu.org/mailman/listinfo/ranger-users
Offline
bernarcher wrote:Inxsible wrote:Just pulled in the latest git and now the bookmark access doesn't work. Hit o (for :open),then I type in bbs and then hit Tab (to get access to the bookmarks.
I experience the same since august 22nd. As soon as I hit Tab on an :open command the input line seemingly becomes unresponsive, even to Esc.
Yeah, same here.
Last time cc_open was change is "Jun 29" ...
Try to clean a little your history file, if it's too long completion function can take time.
new version add an "history_limit" parameter that limit the history file length.
Offline
Since upgrade to kde4.5, jumanji autostart runs at boot-up desktop but does not display the selected URL's...no window appears after 30 second download of eight url's.
This action is contrary to the response before kde4.5 wherein the window was opened and jumanji could be utilized for browsing.
Assume that kde4.5 has changed its response to jumanji.
Prediction...This year will be a very odd year!
Hard work does not kill people but why risk it: Charlie Mccarthy
A man is not complete until he is married..then..he is finished.
When ALL is lost, what can be found? Even bytes get lonely for a little bit! X-ray confirms Iam spineless!
Offline
a new version have been release : 2 new feature :
* ability to add tags to bookmark
* ability to map shortcut and/or buffer to user defined command (use sc_spawn and bcmd_spawn) :
example :
{"^gfv$", bcmd_spawn, { 0, "xterm -e sh -c 'cd ~/tempo/flash ; get_flash_videos -p \"%s\"'" } },
+ some bugfix
Offline
portix wrote:There is also a newer version available:
http://bitbucket.org/portix/stuff/raw/2 … 2_hints.jsThanks mate!
Btw, sorry for really stupid question, but i'm getting ready for a reinstall of Arch and hence, am polishing up my post-install script which installs apps and sets everything up right unattended, and so the script just wget's your hints file, but as I do not know anything about bitbucket and such, then does the url change upon each new revision(i'm hoping not ) ?
The latest revision can always be found under http://bitbucket.org/portix/stuff/raw/t … 2_hints.js.
Offline
I'd like to reiterate a feature request: session support.
I know absolutely no C, but I'd like to poke around tonight with the following approach:
Just before exit, write out open URLs to .config/jumanji/session
Right at open, just before processing commandline args, open any urls found in this file
Is anyone else working on a different approach?
//github/
Offline
I'd like to reiterate a feature request: session support.
I know absolutely no C, but I'd like to poke around tonight with the following approach:
Just before exit, write out open URLs to .config/jumanji/session
Right at open, just before processing commandline args, open any urls found in this fileIs anyone else working on a different approach?
good
Important function for you : init_data, main, cb_destroy (take example at cmd_write).
You should add a variable to enable/disable your feature.
(you can contact me by mail if you want help)
Offline
I'd like to reiterate a feature request: session support.
I know absolutely no C, but I'd like to poke around tonight with the following approach:
Just before exit, write out open URLs to .config/jumanji/session
Right at open, just before processing commandline args, open any urls found in this fileIs anyone else working on a different approach?
I implemented session support for dwb, and could try to adapt it to jumanji.
Offline
brisbin33 wrote:I'd like to reiterate a feature request: session support.
I know absolutely no C, but I'd like to poke around tonight with the following approach:
Just before exit, write out open URLs to .config/jumanji/session
Right at open, just before processing commandline args, open any urls found in this fileIs anyone else working on a different approach?
I implemented session support for dwb, and could try to adapt it to jumanji.
that'd might be better -- i'm looking at jumanji.c right now and it's over my head to say the least.
//github/
Offline
gorky wrote:bernarcher wrote:I experience the same since august 22nd. As soon as I hit Tab on an :open command the input line seemingly becomes unresponsive, even to Esc.
Yeah, same here.
Last time cc_open was change is "Jun 29" ...
Try to clean a little your history file, if it's too long completion function can take time.new version add an "history_limit" parameter that limit the history file length.
i have the same problem.
i tried everything but its still the same. deleted the bookmark/history/cookies files, completely removed jumanji and reinstalled it, set a history_limit but nothing helps.
Offline
I made some error (cherry pick a former commit git without checking what it as done ...) I last version ... so I fix a bug and remade it in the following patch.
I just send 2 new patch to neldoreth to correct 2 completion bug :
default search engine : truc
another search engine : much
:open muchmuch
-> it should search with "truc"
-> currently it take "much"
if you search for "machin chose", currently it only record "machin" in the history
i tried everything but its still the same. deleted the bookmark/history/cookies files, completely removed jumanji and reinstalled it, set a history_limit but nothing helps.
Can you open a bug report and give configuration, history, bookmark file (just a sample that allow me to reproduce the bug)
Offline
I created a patch for really simple session support:
diff -up jumanji.orig//config.def.h jumanji.session//config.def.h
--- jumanji.orig//config.def.h 2010-08-26 23:55:33.000000000 +0200
+++ jumanji.session//config.def.h 2010-08-27 00:02:51.000000000 +0200
@@ -15,6 +15,7 @@ static const char JUMANJI_RC[] =
static const char JUMANJI_BOOKMARKS[] = "bookmarks";
static const char JUMANJI_HISTORY[] = "history";
static const char JUMANJI_COOKIES[] = "cookies";
+static const char JUMANJI_SESSION[] = "session";
/* browser specific settings */
char* user_agent = "jumanji/0.1";
@@ -194,7 +195,7 @@ BufferCommand buffer_commands[] = {
{"^gP$", bcmd_paste, { NEW_TAB, NULL } },
{"^[0-9]+gt$", bcmd_nav_tabs, { SPECIFIC, NULL } },
{"^[0-9]+gT$", bcmd_nav_tabs, { SPECIFIC, NULL } },
- {"^ZZ$", bcmd_quit, { 0, NULL } },
+ {"^ZZ$", bcmd_save_session, { 0, NULL } },
{"^ZQ$", bcmd_quit, { 0, NULL } },
{"^[0-9]+%$", bcmd_scroll, { 0, NULL } },
{"^[0-9]+G$", bcmd_scroll, { 0, NULL } },
diff -up jumanji.orig//jumanji.c jumanji.session//jumanji.c
--- jumanji.orig//jumanji.c 2010-08-26 23:55:33.000000000 +0200
+++ jumanji.session//jumanji.c 2010-08-27 00:04:17.000000000 +0200
@@ -446,6 +446,7 @@ void bcmd_scroll(char*, Argument*);
void bcmd_spawn(char*, Argument*);
void bcmd_toggle_sourcecode(char*, Argument*);
void bcmd_zoom(char*, Argument*);
+void bcmd_save_session(char*, Argument*);
/* special command delcarations */
gboolean scmd_search(char*, Argument*);
@@ -3943,6 +3944,46 @@ cb_wv_window_object_cleared(WebKitWebVie
return TRUE;
}
+gboolean
+restore_session(void) {
+ char *content;
+ char *path = g_build_filename(g_get_home_dir(), JUMANJI_DIR, JUMANJI_SESSION, NULL);
+ gboolean ret = FALSE;
+
+ if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
+ g_file_get_contents(path, &content, NULL, NULL);
+ if (content && strlen(content)) {
+ char **lines = g_strsplit(content, "\n", -1);
+ for (int i=0; i<g_strv_length(lines) - 1; i++) {
+ create_tab(lines[i], FALSE);
+ }
+ g_free(content);
+ g_strfreev(lines);
+ ret = TRUE;
+ }
+ }
+ g_free(path);
+ return ret;
+}
+
+void
+bcmd_save_session(char* UNUSED(buffer), Argument* UNUSED(argument)) {
+ GString *buffer = g_string_new(NULL);
+
+ for (int i=0; i<gtk_notebook_get_n_pages(Jumanji.UI.view); i++) {
+ WebKitWebView *web = GET_NTH_TAB(i);
+ const char *uri = webkit_web_view_get_uri(web);
+ char *newuri = g_strconcat(uri, "\n", NULL);
+ g_string_append_printf(buffer, newuri);
+ }
+ gchar *path = g_build_filename(g_get_home_dir(), JUMANJI_DIR, JUMANJI_SESSION, NULL);
+ g_file_set_contents(path, buffer->str, -1, NULL);
+ g_free(path);
+ g_string_free(buffer, true);
+
+ cmd_quitall(0, NULL);
+}
+
/* main function */
int main(int argc, char* argv[])
{
@@ -3954,6 +3995,7 @@ int main(int argc, char* argv[])
Jumanji.UI.embed = 0;
Jumanji.UI.winid = 0;
Jumanji.Global.arguments = argv;
+ int restore = 0;
int i;
for(i = 1; i < argc && argv[i][0] == '-' && argv[i][1] != '\0'; i++)
@@ -3967,6 +4009,9 @@ int main(int argc, char* argv[])
Jumanji.UI.winid = argv[i];
}
break;
+ case 'r':
+ restore = 1;
+ break;
}
}
@@ -4009,7 +4054,11 @@ int main(int argc, char* argv[])
g_timeout_add(auto_save_interval * 1000, auto_save, NULL);
/* create tab */
- if(argc < 2)
+ if(restore) {
+ if (!restore_session())
+ create_tab(home_page, FALSE);
+ }
+ else if(argc < 2)
create_tab(home_page, FALSE);
else
for(; i < argc; i++)
I was not successfull in adapting the dwb-session support without heavy changes, so only the currently loaded url in
each tab willl be saved, not the history of each tab. I also noticed, that there is a bug when loading more than one
url at startup which also affects the patch: jumanji will not have keyboard focus before clicking somewhere on the
webpage.
Offline
@portix : I send a patch inspired by yours to neldoreth
Offline