Gossamer Forum
Home : Products : DBMan : Customization :

how to embed a javascript wsiwyg editor in dbman?

Quote Reply
how to embed a javascript wsiwyg editor in dbman?
I would like to embed a javascript-coded editor in dbman-generated pages. The editor is taken from http://sourceforge.net/projects/richtext/. Please take a look at the test page I've set up which lets you edit code (though the "post"-button in the editor is not yet functional): http://mailbox.univie.ac.at/...ellner/kelltest.html

The idea is: A user gets the value of one (and only one) field printed, say $rec{'maintext'}, from within dbman. There's an edit button printed next to the record, just like the one printed on the above test page. Clicking the button opens up the wsiwyg javascript editor with the value of $rec{'maintext'} appearing in the window. The user edits whatever they like, presses a submit button, and the modified record is added to the database. So essentially, the modify-routine of dbman is to be replaced by an embedded wsiwyg javascript editor.

I think the coding should involve the following steps:
1) dbman prints out a record (via sub html_record). the record is embedded in <form></form>-tags, the submit-button is actually an "edit"-button.
2) the edit-button calls a subroutine html_edit coded in html.pl, which prints out the necessary html-code, contains the javascript code for the editor, and prints the editor window embedded in a form with a submit-button that passes the modified data back to dbman to have it added to the database.

The tricky part is that I don't know anything about parameter handling in javascript. It seems to me that the form at stage 1) would have to pass on the field value of $rec{'maintext'} to the javascript editor called from html_edit, presumably via a hidden input field. But how does the editor access this value?

As it is, the javascript editor expects there to be a variable called "doc" to be submitted, whose value is then printed in the textarea window. This is how far my thinking gets me, and then my technical ignorance comes in ...




kellner


kellner
Quote Reply
Re: [kellner] how to embed a javascript wsiwyg editor in dbman? In reply to
Were you able to accomplish this? If so, how? I need to embed a javascript in my html.pl file!

Thanks!
Lynette
Hollister, Ca
Quote Reply
Re: [ltillner] how to embed a javascript wsiwyg editor in dbman? In reply to
But, Lynette, do you need to pass data from a js routine to the database?
-------------
David Olley
Anglo & Foreign International Limited,
http://www.firehelmets.co.uk

There are 10 types of people in the world: those who understand binary, and those who don't.
Quote Reply
Re: [davidolley] how to embed a javascript wsiwyg editor in dbman? In reply to
probably not, just store the java selection in a textbox on the form and then the form would deal with the record when it is submitted. I have two scripts that I think will accomplish what I need. I'm going to work on them today.



My question is incorporating the javascript in the html.pl. I think I just need to separate the code for one page and play with it to see what happens.

Thanks!
Lynette
Hollister, Ca
Quote Reply
Re: [ltillner] how to embed a javascript wsiwyg editor in dbman? In reply to
I am by NO means an expert, in perl or javascript, but you should be able to call the javascript as an external file in the header section of the html.pl file:

<script language="JavaScript" src="javascript-file-name.js"></script>

Or set up a subroutine that will print the javascripting, only make sure that you use a code like print qq! !; instead of the print "" command. Does that make sense? I incorporated javascript in an external cgi script that I'm using to create a quiz from a database of mine, and it works. The only problem was that there was a bit of code in the javascript that read \n and the perl didn't like that. I took it out and it works fine.

Hope this helps?
'Salem ~ http://jherusalem.com
Quote Reply
Re: [kellner] how to embed a javascript wsiwyg editor in dbman? In reply to
Me again Smile

Kellner, do you HAVE to use that javascript editor? It seems like a lot of extra work to me. Why couldn't you simply have the html_edit in a javascript pop-up window? Or create a new subroutine to call only that particular part of the field that you want to access in the pop-up, then have the edit button open an external window with a link to call that subroutine?

BTW, when I click on your "edit" button now, I get the javascript editor but I also get a syntax error in the javascript that has nothing to do (I don't think so anyway) with dbman.
'Salem ~ http://jherusalem.com