|
Purpose: This applet reads a bookmarks file (in Netscape format) and displays the corresponding menu, like the one in Netscape's toolbar. Click here to open a new small window with the bookmark menu applet
Author: Zoran Lazarevic
Get the applet BookmarkMenuApplet.jar
Sources: Download latest sources in a ZIP package
Sources: get the zip file with the latest date (YYYY-MM-DD) from the list of all files.
Put onto your web page
Insert this code into your web page:
<applet code="BookmarkMenuApplet.class" archive="BookmarkMenuApplet.jar" name="BookmarkMenuApplet" height=20 width=80 MAYSCRIPT > <param name=filename value="bookmark.html"> <param name=label value="Bookmarks"> <param name=target value="mytarget"> </applet> |
Change the value of "filename" parameter to fit your
bookmark file name ("bookmark.html" in the example above)
Note:The filename can be a URL (e.g.
"http://my.site.com/bookmark.html").
The bookmark file MUST be on the same server as applet. JAVA security
lets an applet read only the files from the same site.
Change "label" string if you want some other text on the button.
Purpose: This applet reads a bookmarks file (in Netscape format) and displays the corresponding menu, like the one in Netscape's toolbar.
Click here for the list of all files
The applet BookmarkMenuApplet.java gets the parameters, displays a button and starts the menu loader.
MenuLoader runs in a new thread, adding to the menu items, submenus or separators to the menu. If the bookmark file (~64KB) is downloaded over the modem, clicking on the button will show the menu "growing".
BookmarkParser uses a TagGetter to retrieve tags between <brackets>, or inter-tag strings. Based on the fixed Netscape bookmark format, items, folders and separators are recognized. This code is not flexible, just enough to get the job done.
TagGetter reads one by one char from a Reader. Initially I wanted to use a StreamTokenizer for getting tags. But, like many of the early java library classes, it is quite useless, except for parsing Java code.
In order for the applet to be usefull, it can be located in a small window which can be kept in the corner of the screen. Click here to open the new small window with the bookmark menu applet
I could not figure out how to open a new browser window smaller than 100x100 pixels. In order to use the window real estate, a small form is added. It allows searching at alltheweb.com and looking up words in Miriam-Webster dictionary.
A snippet of JavaScript code in opener.html browser window opens a small bookmarks window without toolbars or menus, containing only the applet. The bookmark window will then give opener's name to the applet, so a click on a menu item will open the corresponding web page in the opener window. A JavaScript in the opener names itself if it is an anonymous window.
The bookmark window (bookmarkWindow.html) interacts with the applet. So the <applet> tag has MAYSCRIPT property.
<applet code="BookmarkMenuApplet.class" ... MAYSCRIPT>
The form in the bookmark window is submitted by hyperlinks instead of buttons (links take less space). JavaScript onClick() modifies the form to customize it to the target web site. For instance:
function goSearch() { document.fastForm.method="GET"; document.fastForm.action="http://www.alltheweb.com/cgi-bin/search"; document.fastForm.target=opener.name; document.fastForm.submit(); opener.focus(); }
The file with bookmarks is opened and converted to a stream using
new InputStreamReader( new URL(getDocumentBase(), filename) .openStream()
After adding the button to the panel, BookmarkMenuApplet calls validate() to paint itself, so it appears on the screen quite fast (<10 sec. over 56K modem, including opening a new window). All the other classes will start loading after the repainting.
The browser window is opened by hitting the form button on the opener page. At first, I wanted it to be opened automatically on load, but that would be too annoying. I prefer one more click than windows popping up when someone does not expect them.
Adding new bookmarks. Suggestions on how to modify the server-side bookmarks file (cgi-bin, perl, python) are welcome.
Bookmark editing applet.
Basic functionality done right
Added "About this applet" at the top of the menu.
Eliminated anonymous inner classes because the resulting files (e.g. BookmarkMenuApplet$1.class) contain '$' sign. Some web hosts (e.g. Geocities) do not allow filenames with non-alphanumerics.
Added "label" parameter to set button label (default is still "Bookmarks")
[2001-11-11] JARred up all classes.
[2002-02-01] Closing bookmark file stream after reading it.