Demo Discussion
Forum Config Examples Contributions Vulnerabilities
  Discussion forum about ELOG  Not logged in ELOG logo
icon1.gif   Javascript for Bookmark Link for one-click submission to elog, posted by Fred Hooper on Sat Jan 31 09:33:35 2004 elogsubmit-template.js
    icon2.gif   Re: Javascript for Bookmark Link for one-click submission to elog, posted by Stefan Ritt on Wed Feb 4 12:00:14 2004 
Message ID: 464     Entry time: Sat Jan 31 09:33:35 2004     Reply to this: 465
Icon: Entry  Author: Fred Hooper  Author Email: fhooper@sushisoft.com 
Category: Other  OS: Linux | Windows | Mac OSX | Other  ELOG Version: 2.5.0 
Subject: Javascript for Bookmark Link for one-click submission to elog 
I have created a javascript to be used as a browser link that allows a one
step cut and paste from a web browser into a elog logbook. 

The intended application is allow a user to do a text selection in a web
browser, then click on a bookmark that automagically pastes the selected
text, the current browser page url, and the current browser page title into
a pre-defined elog logbook.   I do some research where I would like to save
some text from a webpage, but also have a record of where the webpage came
from.  However, you should find that you can extend this script in a varity
of ways for your own application.  

The script is a simple one: it uses javascript in a saved bookmark to get
your selected text, title, and url, and then creates a new browser window
with a elog form, and print the document variables into the form, and then
submits the form to elog.   The key advantage to this approach is that you
can use the "post" command, rather than "get", to submit to the text section
of an elog logbook.  The only way I found now to submit to elog via a
bookmark is using the "get" command, and it doesn't allow entry of the
"text" field, only attribute fields.    

The second major advantage to using POST is that you can submit a much large
quanity of information ; However, some checking on this leads me to believe
that the limit is browser and server depended, so YMMV.  However, a great
discussion on the limits of browsers can be found here: 
http://www.squarefree.com/bookmarklets/browsers.html .

One of the major limits is that IE6.0 browsers have a maxium of 508 bytes
per bookmark - This book runs over 800 bytes, so I suspect tha IE6+ will not
allow it.  I tested the link with Mozilla and Firebird 0.7.

This script will need to edited for you to use with your elog logbook.
The script should be fairly self-explainitory, if you are used to html forms
and have some exposure to javascript.

You will need to modifiy the following fields:

1) in form action = http://<your_domain.com>/elog/<logbook>/?cmd=New
      change the link to point to your specific logbook to be used for entry.

2) the attribute fields need match up with the ones in your logbook.

     The ones listed in the template are Author, Email, Title, and URL.

     If you have fixed fields (like Author and Email), then you can
predefine these fields as shown.  

      I have the page title used as the entry for Title, and the page url is
 use as the URL attribute.

      Finally, I have the text selection used as the entry for the Text field.

      You can add additional fields by creating a new <input ...>  segment
in the script.  For those more clever than me, you can concatinate the
title, url and selection to paste into the Text area as well.  

3) once you have a edited version of the script (make sure you keep it as a
single line), you can then create a new bookmark in your browser, and then
paste the script into the properties->location field (for Mozilla/Firebird)
or the properites->url field (IE).  Give it a good name like "post to elog"

4) once saved, you can then go a web page, select some text, and then go to
your bookmarks and click on the bookmark.  It should then create a new
window in elog with a completed logbook entry.


some notes:

1) again, this may not work on IE6+ browsers due to M$ limitations.

2) You may have to be logged in already to elog for this work - I have not
tested the interaction using a password protected elog

3) You can only post to a single elog logbook - You'll need to have multiple
bookmarks for multiple logbooks.
   
Attachment 1: elogsubmit-template.js  797 Bytes  | Hide | Hide all
javascript:var t=document.title;var u=document.location.href;var s=document.getSelection();var d=window.open('','d');with(d.document){write('<form method=\'POST\' action=\'http://www.domain.com/elog/notebook/?cmd=New\' enctype=\'multipart/form-data\'><input type=\'text\' name=\'Author\' value=\'you\'>
<input type=\'text\' name=\'Email\' value=\'you@domain.com\'>
<input type=\'text\' name=\'Title\' value=\''+t+'\' size=80>
<input type=\'text\' name=\'Url\' value=\''+u+'\' size=80>
<textarea name=\'Text\' rows=30 cols=80 wrap>'+s+'</textarea>
<input type=\'hidden\' name=\'attfile\' value=\'cmd\'><input type=\'hidden\' name=\cmd\' value=\'Update\'><input type=\'submit\' name=\'cmd\' value=\'Submit\'><input type=\'reset\' name=\'cmd\' value=\'Clear\'></form>');void(close())}
ELOG V3.1.5-fe60aaf