I was tinkering around today with a google applet I cooked up in
Javascript (and I don't profess to be a javascript programmer), and decided
to take a shot at making a Plucker "bookmarklet".

        After about 4 hours of tinkering and testing, I've come up with this
so far. If you take both of these parts, and stick them in your bookmarks
somewhere, call one "Get" and the other one "Set", you'll see what they do.

        In a nutshell, when you're viewing a webpage in your browser window,
you can select the "Set"  bookmark (mine sits on my Netscape toolbar, easy
access) and it will then walk you through a brief "wizard" asking you a few
questions about the page in question. I added some flashy things to it, like
the ability to count the links in the page shown, and so on. It then sets a
few local cookies on your system with these parameters, which are then read
by the "Get" bookmarklet.  The "Get" bookmarklet will read these cookies,
and then pop up a window with the proper plucker-build syntax in it. Since
this is client-side, this can all be used offline also for local files.

        I stopped after URL, Maxdepth, and BPP, but you can see how easy it
is to cut and paste to make them all work. I offer this up in the "Release
Early, Release Often" phase of open source. I'll be adding a bit more to
this, and adding the ability to walk through a full-blown Javascript-based
form (checkboxes, dropdowns), and then writing out to a file. Since
Javascript does not allow me to launch any client-side app (such as
plucker-build), I have to resort to the user initiating that part.

        Hey, I was bored =)

        Here they are, attached to this message. In order to use these, you
have to cut and paste the FULL code shown for each one into the Location
field of your Bookmarks for both "Set" and "Get" (two separate bookmarks).
Treat the full code as a URL and paste it all in.

        If anyone has fixes, additions, whatever, send them back to the list
for everyone else to enjoy!

        Hope everyone had a great weekend. The idea for this goes out to Ben
Chess, since he got me thinking about how to handle this in a more portable
fashion.


/d

############################################################################
#
# Plucker Bookmarklets, "Set" and "Get"
#
# (c) 2001, David A. Desrosiers, <[EMAIL PROTECTED]>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc., 59
# Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
############################################################################

# Each of these, in their entirety, must be pasted into the Location field
# of your bookmark. They must be separate bookmarks for now. 

#########################################################
#
# "Set" will walk the user through a small "wizard"
# and gather the parameters for the url in their 
# browser, and set cookies corresponding to the values
# that are given
#
#########################################################
javascript:URL=prompt('This webpage has ' + document.links.length + ' links.\n\n
Below is the URL of the current webpage. We can now store this value in a\n
local cookie on your machine. Once your selected Plucker parameters are set,\n
we can then create a home.html file for you with these parameters.\n',location.href);

if(URL!=null) {EXP=86400000*prompt('Expires in...(days)','1');
MAXD=prompt('How deep would you like to gather' + location.href,'1');
BPP=prompt('What bitdepth would you like the images stored in?','4');

dT9v=new Date;dT9v.setTime(dT9v.getTime()+EXP);

void(document.cookie='PluckerURL='+escape(URL)+';
expires='+dT9v.toGMTString());

void(document.cookie='PluckerMax='+escape(MAXD)+';
expires='+dT9v.toGMTString());

void(document.cookie='PluckerBPP='+escape(BPP)+';
expires='+dT9v.toGMTString());
} else {void(null)} 


#########################################################
#
# "Get" will read those values, and allow you to pop up
# a browser window with the results formatted in a 
# proper 'plucker-build' syntax line. Javascript 
# restricts us from launching plucker-build ourselves
#
#########################################################
javascript:dL8=document.cookie.indexOf('PluckerURL');
if(dL8!=-1) {d7n=document.cookie.substring(dL8+11,document.cookie.length);
uHm1=d7n.indexOf(';');dUP1=(uHm1==-1)?d7n.length:uHm1;
void(prompt('The value of the URL parameter is:\n\n', 
unescape(d7n.substring(0,dUP1))))
} else {alert('No values found!')}

dL8=document.cookie.indexOf('PluckerMax');
if(dL8!=-1) {d8n=document.cookie.substring(dL8+11,document.cookie.length);
uHm2=d8n.indexOf(';');dUP2=(uHm2==-1)?d8n.length:uHm2;
void(prompt('The value of the maxdepth parameter is:\n\n', 
unescape(d8n.substring(0,dUP2))))
} else {alert('No values found!')}

dL9=document.cookie.indexOf('PluckerBPP');
if(dL9!=-1) {d9n=document.cookie.substring(dL9+11,document.cookie.length);
uHm3=d9n.indexOf(';');dUP3=(uHm3==-1)?d8n.length:uHm3;
void(prompt('The value of the bitdepth parameter is:\n\n', 
unescape(d9n.substring(0,dUP3))))
} else {alert('No values found!')}

WIN=window.open('','w','innerWidth=400,innerHeight=300,titlebar=no,scrollbars,menubar');

WIN.document.write('plucker-build -H "', unescape(d7n.substring(0, dUP1)) + '"');
WIN.document.write(' --maxdepth="', unescape(d8n.substring(0, dUP2)) + '"');
WIN.document.write(' --bpp="', unescape(d9n.substring(0, dUP3)) + '"');
void(WIN.document.close())

Reply via email to