Improvement requests :  K-Meleon Web Browser Forum
Use this forum to talk about a feature you're missing. 
A session plugin!
Posted by: MonkeeSage
Date: January 18, 2003 01:31AM

Got 5 windows open? Want to go to them again when K-meleon starts next?

...make a plugin to save a session to file (plain text would be easy enough with a url-per-line format) then have the plugin open new layers (or windows if layers plugin not loaded or not present) with the urls as listed from a session file, on startup!!

Mozilla 1.3a has something like this built in where you can save all current tabs to a new booksmarks folder, and open whole bookmarks folders in tabs next start...anything like that, made to work with the layers plugin, that would be better than manually saving and reopening them!!!!

The lack of session support is one of the biggest drawbacks for me to making K-Meleon my main browser (right now I mostly use MyIE2, even with its horribly bloated IE core, for that simple reason--session ability).


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 18, 2003 01:51AM

Looks like Ismo already provided half the solution in another thread, where he gave this javascript for opening multiple startup pages:

<HEAD><TITLE>MyStartupPages</TITLE></HEAD>
<BODY>
<script language="JavaScript">
<!--hide from old browsers
window.open('http://www.google.com');
window.open('http://cnn.com');
window.open('http://www.dilbert.com');
window.close()
// -->
</script>
</BODY>

So, if there was a plugin that will write out the values to a startup file like that, for the url of all your open layers / windows on exit.... grinning smiley


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 18, 2003 02:18AM

Actually, I was wrong, that isn't really a solution, because:

1. There is no standard (or non-standard, Mozilla) javascript function to open a new tab (so there is no way to open a new layer by java, either, I wouldn't imagine):

http://bugzilla.mozilla.org/show_bug.cgi?id=105409

2. You have to have "Disable popup windows on page load/unload" _unchecked_ (which means popups enabled) under Edit -> Preferences -> Privacy in K-Meleon. No one likes popups! (Well some people do, but they are wierd and smell funny winking smiley ).


:\

I guess someone would have to do a bit more coding in that case, if a plugin were ever to be produced that could handle sessions...


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: Hugo
Date: January 18, 2003 06:48AM

I think it might soon be possible to accomplish this with a few macros - now with the new event based macro stuff: OnInit, OnCreate, OnQuit
http://kmeleon.freewebsites.com/

Especially, if there was an OnLoad handler and an OnUnload handler (which I believe there isn't yet), you could perhaps keep track of all the currently open $URL:s (by storing them in a global variable or as a user_pref)... I guess.

Then, whenever you would want to "bookmark this session", you can call a macro that saves those $URL:s (as a long string) into another user_pref..

setpref(STRING, "mySession1", "www.google.com>>>www.cnn.com>>>www.dilbert.com");

It shouldn't be to hard to write a macro that can open the urls contained in a string like that (with pluginmsg(layers, "OpenURLBg", url) or openbg( URL ) ). This goes for the current macro implementation as well, no need for OnLoad etc. Just do
$mySession = getpref(STRING, "mySession1");
and then parse the string.

Also, if a macro can call itself, recursively, so that a "while-loop" can be simulated, the url-string can contain any number of urls. (In each recursive call, chop off the first url from the string and open the url.. and if the string is empty, just don't do any more recursive calls).

Well, all this is totally untested.. it's just that I don't think a plug-in should be necessary for doing this.

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 18, 2003 09:18AM

Yay!

Looks promising, Hugo! I just downloaded the latest macros.dll and it includes OnInit and OnQuit!

I'm having trouble finding out how to implement these event macros, though. I understand the macro structure and how the normal macros are implemented (as per the .7 guide), but I assume that the "On..." + event macros have a different syntax since there is no way for the user to cause them to be parsed (well...yeah, that _is_ the point of making them event driven...I just need to know the syntax).

Did I miss a page or is there no documentation for these new macros yet? If there is none, I would be much obliged if someone would show me how to implement them. Thanks!


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 19, 2003 02:24AM

I just got the latrst macros.dll and the On + event macros work perfectly now (they are auto-implemented on the event,,who'd have thunk it winking smiley ). For example:

OnStartup {
pluginmsg(layers, "OpenURLBg", "http://kmeleonbrowser.org/forum/read.php?f=4&i=3234&t=3234"winking smiley;
}

^ works on startup

I'm still not sure of exactly how to store the urls, because there doesn't seem to be a way to loop (unless I missed something).

...I'm thinking that I could use the OnOpenWindow macro to write $sess1 (2, 3, etc.) with the url for the current window, and then the use OnQuit macro to tally how many $sess variables are stored, and then use the OnStartup macro to load tally number of $sess variables as new layers.

I'm not sure if that is possible either, though, without some type of recursing function like 'while'...

In any case, it seems that the event macros are the way to go, even if a helper plugin is necessary to pass variables recursively to them.

Something like that anyways... any suggestions?


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: Ismo
Date: January 19, 2003 03:27AM

I have used these two macros to save the current url and later open
the saved url to a new layer. I used the old dll. Of course if you use the
new dll you can autoload the saved url if you want and create a very
simple session history. Now you have to use the keyboard shortcut
after startup.

save_URL {
setpref(STRING,"kmeleon.savedURL", $URL);
statusbar("Url saved. Open later with Alt-O");
}

open_savedURL {
$tmp = getpref(STRING, "kmeleon.savedURL");
pluginmsg(layers, "OpenURL", $tmp);
statusbar("Saved Url opened. Save new Url with Alt-S");
}

in accel.cfg I have

ALT S = macros(save_URL)
ALT O = macros(open_savedURL)

This is good for just one url but you could enhance
this to ask the user via prompt the save/open name for the url.
IT just worries me to write too many strings to prefs.js. As far as I
know prefs.js is the only file you can write to with macros. A pity than
you can't choose another file name.

I have also macro which saves four urls. If I save more times
the oldest urls is replaced by the newest (some kind of url ring).

I don't know how to loop inside macro. I haven't tried recursion.
I hope there were (at least there should be) some kind of looping
mechanism. Also I would like to know how javascript and macro
variables can interact (visibility/scope?).

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 19, 2003 05:33AM

Very interesting... and helpful!

Here is what I did so far...

In menus.cfg:

Under:

Main {
}

Added:

:&Session


Then added:

&Session {
macros(session_save_url, Save to session...)
macros(session_load_url, Load from session...)
}


In macros.cfg:

Added:

session_save_url {
menu = "Save to session..."
$sess = prompt("Session prompt:", "Save to Session", "kmeleon.session.1");
setpref(STRING, $sess, $URL);
statusbar("Url saved to session, use Session menu to restore.");
}

session_load_url {
menu = "Load from session..."
$islayer = getpref(BOOL,"kmeleon.plugins.layers.load");
$sess = prompt("Session prompt:", "Load from Session", "kmeleon.session.1");
$sessval = getpref(STRING, $sess)
$islayer ? pluginmsg(layers, "OpenURLBg",$sessval) : openbg($sessval);
statusbar("Url loaded from session.");
}

--------

Works well.

Now I am wondering if there is any way to list out the values from "kmeleon.session.1", "kmeleon.session.2", &c., in the &Session menu?

Mabye something like...

&Session {
macros(session_save_url, Save to session...)
macros(session_load_url, Load from session...)
macros(getpref(STRING, "kmeleon.session.1"))
macros(getpref(STRING, "kmeleon.session.2"))
macros(getpref(STRING, "kmeleon.session.3"))
}


Something like that? But that doesn't seem to work...

Suggestions?


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 19, 2003 05:59AM

Here is what I have now...

In menus.cfg:

&Session {
macros(session_save_url, Save to session...)
macros(session_load_url, Load from session...)
macros(session_load_url_1, 1)
macros(session_load_url_2, 2)
macros(session_load_url_3, 3)
macros(session_load_url_4, 4)
macros(session_load_url_5, 5)
}


In macros.cfg:

$islayer = getpref(BOOL,"kmeleon.plugins.layers.load");

session_save_url {
menu = "Save to session..."
$sess = prompt("Session prompt:", "Save to Session", "kmeleon.session.1");
setpref(STRING, $sess, $URL);
statusbar("Url saved to session, use Session menu to restore.");
}

session_load_url {
menu = "Load from session..."
$sess = prompt("Session prompt:", "Load from Session", "kmeleon.session.1");
$sess = getpref(STRING, $sess)
$islayer ? pluginmsg(layers, "OpenURLBg",$sess) : openbg($sess);
statusbar("Url loaded from session.");
}

session_load_url_1 {
$sess = getpref(STRING, "kmeleon.session.1")
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
statusbar("Url loaded from session.");
}

session_load_url_2 {
$sess = getpref(STRING, "kmeleon.session.2")
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
statusbar("Url loaded from session.");
}

session_load_url_3 {
$sess = getpref(STRING, "kmeleon.session.3")
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
statusbar("Url loaded from session.");
}

session_load_url_4 {
$sess = getpref(STRING, "kmeleon.session.4")
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
statusbar("Url loaded from session.");
}

session_load_url_5 {
$sess = getpref(STRING, "kmeleon.session.5")
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
statusbar("Url loaded from session.");
}


========

It is quick and ugly... anybody can improve it, please do!


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 19, 2003 07:13AM

Ok...here is a little bit better...

In Accel.cfg:

Added:

CTRL 1 = macros(session_load_url_1)
CTRL 2 = macros(session_load_url_2)
CTRL 3 = macros(session_load_url_3)
CTRL 4 = macros(session_load_url_4)
CTRL 5 = macros(session_load_url_5)

ALT 1 = macros(session_save_url_1)
ALT 2 = macros(session_save_url_2)
ALT 3 = macros(session_save_url_3)
ALT 4 = macros(session_save_url_4)
ALT 5 = macros(session_save_url_5)


========


In Menus.cfg:

In entry:

Main {

}

Added:

:&Session


Then added entry:

&Session {
macros(session_save_url, Save to session...)
macros(session_save_url_1, Save 1)
macros(session_save_url_2, Save 2)
macros(session_save_url_3, Save 3)
macros(session_save_url_4, Save 4)
macros(session_save_url_5, Save 5)
-
macros(session_load_url, Load from session...)
macros(session_load_url_1, Load 1)
macros(session_load_url_2, Load 2)
macros(session_load_url_3, Load 3)
macros(session_load_url_4, Load 4)
macros(session_load_url_5, Load 5)
}


========


In Macros.cfg:

Added:

$islayer = getpref(BOOL,"kmeleon.plugins.layers.load");

session_save_url {
menu = "Save to session..."
$sess = prompt("Session prompt:", "Save to Session", "kmeleon.session.");
setpref(STRING, $sess, $URL);
statusbar("Url saved to session, use Session menu to restore.");
}

session_load_url {
menu = "Load from session..."
$sess = prompt("Session prompt:", "Load from Session", "kmeleon.session.");
$sess = getpref(STRING, $sess)
$islayer ? pluginmsg(layers, "OpenURLBg",$sess) : openbg($sess);
statusbar("Url loaded from session.");
}

session_load_url_1 {
$sess = getpref(STRING, "kmeleon.session.1")
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
statusbar("Url loaded from session.");
}

session_load_url_2 {
$sess = getpref(STRING, "kmeleon.session.2")
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
statusbar("Url loaded from session.");
}

session_load_url_3 {
$sess = getpref(STRING, "kmeleon.session.3")
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
statusbar("Url loaded from session.");
}

session_load_url_4 {
$sess = getpref(STRING, "kmeleon.session.4")
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
statusbar("Url loaded from session.");
}

session_load_url_5 {
$sess = getpref(STRING, "kmeleon.session.5")
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
statusbar("Url loaded from session.");
}

session_save_url_1 {
setpref(STRING, "kmeleon.session.1", $URL);
statusbar("Url saved to session.");
}

session_save_url_2 {
setpref(STRING, "kmeleon.session.2", $URL);
statusbar("Url saved to session.");
}

session_save_url_3 {
setpref(STRING, "kmeleon.session.3", $URL);
statusbar("Url saved to session.");
}

session_save_url_4 {
setpref(STRING, "kmeleon.session.4", $URL);
statusbar("Url saved to session.");
}

session_save_url_5 {
setpref(STRING, "kmeleon.session.5", $URL);
statusbar("Url saved to session.");
}


========

Still wish I knew how list the value of kmeleon.session.1, 2, 3, &c., as menu elements under the &Session menu though, so I could see the stored url instead of 1, 2 ,3...


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 19, 2003 07:58AM

In Menus.cfg:

In entry:

&Session {
}

Added:

-
macros(session_load_entire, Load entire session...)

========

In Macros.cfg:

Added:

session_load_entire {
$sess = getpref(STRING, "kmeleon.session.1");
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
$sess = getpref(STRING, "kmeleon.session.2");
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
$sess = getpref(STRING, "kmeleon.session.3");
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
$sess = getpref(STRING, "kmeleon.session.4");
$islayer ? pluginmsg(layers, "OpenURLBg", $sess) : openbg($sess);
$sess = getpref(STRING, "kmeleon.session.5");
statusbar("Loading entire session.");
}

========

You could also make the macro an event macro, i.e., OnStartup, and leave out the menu element.

Note: If there is no pref set for, let's say, "kmeleon.session.5", an empty layer is loaded in the bg... I don't know how to get around this, mabye some else knows....


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 19, 2003 08:05AM

In Accel.cfg:

Added:

CTRL 9 = macros(session_load_entire)

Options: ReplyQuote
Re: A session plugin!
Posted by: Hugo
Date: January 20, 2003 04:16PM

Note: If there is no pref set for, let's say, "kmeleon.session.5", an empty layer is loaded in the bg... I don't know how to get around this, mabye some else knows....

Yeah.. this is where you would want to simulate a while loop by means of some recursion:

Assume that you have some prefs (in Prefs.js) like e.g:
user_pref("kmeleon.session.1.1", "www.google.com");
user_pref("kmeleon.session.1.2", "www.yahoo.com");
user_pref("kmeleon.session.1.3", "www.altavista.com");
user_pref("kmeleon.session.1.title", "Search");
user_pref("kmeleon.session.2.1", "www.dn.se");
user_pref("kmeleon.session.2.2", "www.aftonbladet.se");
user_pref("kmeleon.session.2.3", "www.expressen.se");
user_pref("kmeleon.session.2.4", "www.svd.se");
user_pref("kmeleon.session.2.title", "News in Sweden");

- you can store several (any number of) sessions, all of them having a session title...and each containing several (any number of) urls..

Simplest case: you could open e.g some favorite session - say session number 1.. with:
############# Open Session Stuff ###############
$url_num = 1;
$sess_num = 1;
$one_more = true;
open_if_more{
$sess = getpref( STRING, "kmeleon.session.".$sess_num.".".$url_num );
$sess == "" ? $one_more=false : $one_more=true;
$islayer = getpref(BOOL,"kmeleon.plugins.layers.load");
$one_more? ( islayer ? pluginmsg(layers,"OpenURLBg",$sess) : openbg($sessval)) : "";
$one_more ? $url_num = $url_num+1 : $url_num = 1;
#Recursive conditional call to simulate "while":
$one_more ? macros(open_if_more) : $one_more = true;
}

open_my_favorite_sess{
menu = "My favorite session"
$sess_num = 1;
macros(open_if_more);
}
#############################################
# Also, one could throw a prompt to the user - showing all the
# session titles.. asking what session to open.. by adding the
# following to the open session stuff:
$titles = "";
$titl_num = 1;
get_titles{
$tmp = getpref( STRING, "kmeleon.session.".$titl_num.".title" );
$tmp != "" ? $titles = $titles.$titl_num.". ".$tmp." " : "" ;
$tmp != "" ? $titl_num = $titl_num + 1 : "";
$tmp != "" ? macros(get_titles) : "";
}
prompt_open_sess{
menu = "Open Session";
macros(get_titles);
$sess_num = prompt($titles, "Enter a session number ", "1");
macros(open_if_more);
}
###############################################

This works well for me.

A problem though is to find a neat way to "save current session".. As Ismo pointed out somewhere, it is difficult to have control of what urls are currently open in the different layers.

I can't even get this to work as expected:
test_layers{
plugin(layers, 0);
alert($URL);
plugin(layers, "next");
alert($URL);
}
..so I think I'll just have to give up on "save current session" thingy.

Options: ReplyQuote
Re: A session plugin!
Posted by: Hugo
Date: January 20, 2003 04:47PM

oops..
In the open_if_more macro, the line
$one_more? ( islayer ? pluginmsg(layers,"OpenURLBg",$sess) : openbg($sessval)) : "";
is wrong.. it should be
$one_more?($islayer?pluginmsg(layers,"OpenURLBg",$sess)yawning smileypenbg($sess)):"";

Options: ReplyQuote
Re: A session plugin!
Posted by: Hugo
Date: January 20, 2003 06:30PM

I don't know how to loop inside macro. I haven't tried recursion.
I hope there were (at least there should be) some kind of looping
mechanism. Also I would like to know how javascript and macro
variables can interact (visibility/scope?).


About the loop thing.. I did use loops in the prev posts, but here is some cleaner macro code that uses recursion to simulate a while loop:

$num;
$max;
$do_it_again;
doit{
alert($num);
$num != $max ? $do_it_again =true :$do_it_again = false ;
$do_it_again ? $num = $num + 1 :"" ;
$do_it_again ? macros(doit) : "" ;
}

looptest{
$max = 5;
$num = 0;
macros(doit);
}



About javascript: I've thought about that.. but no luck really. The only kind of interaction I can come up with is stuff like:

test{
$str = "Ismo";
#or
$str = $URL;
#or whatever.
open ("javascript: alert( ' Hello, ".$str ." ' ); ");
}

i.e you can textually "insert" stuff into the JavaScript when calling it with a macro.

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 20, 2003 11:31PM

Whoohoo! Thanks Hugo!! Works well. smiling smiley I haven't got to multiple sessions yet, maninly because of what you mentioned, you can't save all windows to a session at once...so for now I'm sticking with one session with 8 slots (5 wasn't enough hehe). Here is how I implemented your macro:

========

&Session {
[...]
macros(session_open_if_more, Load entire session)
}

========

$islayer = getpref(BOOL,"kmeleon.plugins.layers.load");
$sess_num = 1;
$one_more = true;

session_open_if_more {
$sess = getpref( STRING, "kmeleon.session.".$sess_num);
$sess == "" ? $one_more=false : $one_more=true;
$one_more? ( islayer ? pluginmsg(layers,"OpenURLBg",$sess) : openbg($sess)) : "";
$one_more ? $sess_num = $sess_num+1 : $sess_num = 1;
$one_more ? macros(session_open_if_more) : $one_more = true;
statusbar("Loading entire session.");
}

========


Thanks again!

Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 20, 2003 11:58PM

Also, is there a function to call from a macro that will _erase_ a user_pref string... I know you can 'set' one and 'get' one...but is there any way erase one without manually removing the line?

If there is not a specific function, shouldn't it be possible, using the clipboard macro mabye, to replace the pref you want gone with a null string ""? Or to add comment marks // to the beginning of that line?

I know...its a dumb question (ther obviously is a way, and its prolly really easy too)...but I was born this way winking smiley Any help is much appeciated!


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: Hugo
Date: January 21, 2003 09:24AM

MonkeeSage,

Glad to hear it worked! smiling smiley

is there a function to call from a macro that will _erase_ a user_pref string...
What do you want to do this for? ..I can't figure out a way to do it (I was born like this too..), the only thing would be to just
setpref( STRING, "my.little.pref.that.I.would.want.to.remove", "" );
- set an empty string to the preference.

By the way, I am starting to think that some plugin coding might actually be needed to do some reasonable session handling.. Without "Save current session", I find sessions a bit pointless :-)

Ismo,
Also I would like to know how javascript and macro
variables can interact (visibility/scope?).


I guess you could set a user_pref in JavaScript, and then read it later within a macro.. :-)

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 21, 2003 09:27PM

Hugo:

I don't usually shift sessions that often, because I'm a message board junky, I'm on like 3 e-z boards 4+ misc. others, at a time. I use accels to set the "framework" of which sites I'm going to be navigating, then try to have a good memory about the layout. winking smiley

I was thinking that it would work better that storing in Prefs.js, to create a K-Meleon native bookmarks folder with the editor (or as part of a modified macro), for sessions, then have as many sub folders as you like within that folder--then use a modified open_if_more that grabs its urls from the bookmarks plugin, looking in the "default" session subfolder. This way we'd have the ability to save and organize multiple sets of sessions (albeit I still don't have a clue on how to do it all at once); and would provide a menu access to individual session urls, and a dynamic title for them in the menu and everything. grinning smiley

I'm about to die from sleep depravation though, so my brain is about silly-putty at this point. I was up all night learning realscripting for my realplayer thing... I'll post the updated host file and info and a cap to the usergroup tomorrow, er later today. It is sweet! Much better though javascript technology winking smiley Now has open URL button that acccepts all four real protocols (http, rtsp, pnm, file)--this is for dynamic playback of content so you don't have to always edit the playlist file, and when you exit, it doesn't overwite your old playlist! previous track and next track in playlist buttons, aspect ratio toggle, fullscreen, &etc. &etc. Even though Realplayer is a bloatmonster, I can run it from a frame of the best browser on the planet...which makes it all worth it! (And nope, it doesn't slow down vrowsing other layers / windows at all, even when displaying video cotent. (E.g., I'm watching a movie right now in another layer). Tomorrow I'm going to figure out how to pass it the URI for dvdnav, because RealOne can play DVDs too! grinning smiley ...Ok, sorry...I'm way off topic.

Oh yeah, the only reason I wanted to know about the pref thing was for reference and a few ideas that I've since decided against, so its not a biggie. In the interest of less destroyed Prefs.jf files from forgetting to add that one little "." to your macro, I can see why there is not one implemented in the macros plugin. winking smiley

One more thing...about javascript in Prefs.js, can you use whole js functions like

function myfunc() { document.location.reload() }

???

If this is possible, then it seems like there is no end to the madness we can wreak! You could define your own K-meleon (pseudo)mime-handlers, for example, by a macro in the LinkPopup that calls a js function from Prefs.js, handles the links, and then determines which external programs to call with what arguments based on file extensions. winking smiley Am I pipe-dreaming?


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 21, 2003 09:49PM

Edit***

--------
Much better though javascript technology winking smiley
--------


^ Much better thRough javascript technology winking smiley

Options: ReplyQuote
Re: A session plugin!
Posted by: Hugo
Date: January 24, 2003 11:29AM

One more thing...about javascript in Prefs.js, can you use whole js functions like

function myfunc() { document.location.reload() }


MonkeeSage,

You can always put your JavaScript function definitions and/or function calls in a macro (like a bookmarklet):

a_macro{
menu = "A cool JS based macro";
open(" function myfunc() { document.location.reload() } void(myfunc()); ");
}

To make it more general and distributable, extend it to:

a_macro{
menu = "A cool JS based macro";
$javascript_enabled = getpref(BOOL, "javascript.enabled") ;
setpref(BOOL, "javascript.enabled", true) ;

open(" function myfunc() { document.location.reload() } void(myfunc()); ");
setpref(BOOL, "javascript.enabled", $javascript_enabled ) ;
}

Is this what you're looking for?

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 24, 2003 02:56PM

Wow!! That is SO COOL!! **falls over from utter glee**

Thanks alot for the info Hugo!

Thanks alot for this awsome broswer and macros, programmers!

Yayaya, I'm going to go play. smiling smiley


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 24, 2003 03:51PM

Hugo,

I tried that exact code, both ways, and got the Malformed URL error screen with:

function myfunc() { document.location.reload() } void(myfunc());

in the entry box...I don't have any extra returns....did I mess something up?


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: Hugo
Date: January 24, 2003 03:56PM

Ooooooooooooooops, I forgot:

a_macro{
menu = "A cool JS based macro";
$javascript_enabled = getpref(BOOL, "javascript.enabled") ;
setpref(BOOL, "javascript.enabled", true) ;
open("javascript: function myfunc(){document.location.reload()}void(myfunc());");
setpref(BOOL, "javascript.enabled", $javascript_enabled ) ;
}

You have to tell what uri scheme to use;
javascript: function myfunc(){document.location.reload()}void(myfunc());
should be a well formed url (try entering it into the url field!), while
function myfunc(){document.location.reload()}void(myfunc());
is definitely not..

So sorry! :-p

Options: ReplyQuote
Re: A session plugin!
Posted by: Hugo
Date: January 24, 2003 03:57PM

Note: There must be no line breaks in the
open("javascript: .... ");
line!

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 24, 2003 03:59PM

Ahhhhh sweet! I was worried I borke something with all the tinkering ^^*


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: Hugo
Date: January 26, 2003 12:57PM

I myself wrote:
...I can't even get this to work as expected:
test_layers{
plugin(layers, 0);
alert($URL);
plugin(layers, "next");
alert($URL);
}
..so I think I'll just have to give up on "save current session" thingy.


I filed two bug reports (#331 and #332) for this now.. (but as with all my bug reports, it is probably just a misunderstanding on my part)
http://kmeleon.sourceforge.net/bugs/viewbug.php?bugid=331
http://kmeleon.sourceforge.net/bugs/viewbug.php?bugid=332

Options: ReplyQuote
Re: A session plugin!
Posted by: MonkeeSage
Date: January 26, 2003 07:16PM

Either way, I'm either misunderstanding as well, or infested with the bug, cause I have tried an even simpler version of the same macro:

test {
plugin(layers, 0);
plugin(layers, "next");
plugin(layers, "next");
plugin(layers, "next");
}


With three windows ("layers") open, the only thing it did was change to the next layer _once_ and exit. I also tried putting 0 to 1 and 2, and I also tried using just the "next"s and manually starting on the first layer, same result for all--changed _once_ and exited...


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: A session plugin!
Posted by: Hugo
Date: January 27, 2003 08:09AM

Thanx for telling me, I hadn't tested that. I'll file a link to your post in the BTS.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.