htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 2: htmlArea 2 & 3 archive (read only): htmlArea v2.0 - Add-Ons:
automatic save


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


esthera
User

Mar 12, 2004, 12:43 AM

Post #1 of 14 (5067 views)
Shortcut
automatic save Can't Post

Has anyone yet added an automatic save button.

Sometimes it could take someone a while to write something in html editor and I was thinking of automatically saving it to a file or db every 2 minutes in case the system went down they would not lose the work.

Has anyone done this? Any ideas?


Techie
Novice

Mar 12, 2004, 8:26 PM

Post #2 of 14 (5055 views)
Shortcut
Re: [esthera] automatic save [In reply to] Can't Post

You could use cookies to periodically save the value of the editor. For example you could use setInterval(setcookiecommand, time); to have it save every amount of time, in your case 2 minutes. Or you can use the setInterval command to send the editor html to a database, as you also mentioned. I recommend using cookies since they are not dependant on the server because you mentioned that this was in case of a failure. To use the cookies you must first write a set_cookie funciton. Here is a working example:

<script>

function Get_Cookie(name) {
var start = document.cookie.indexOf(name+"=");
var len = start+name.length+1;
if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
if (start == -1) return null;
var end = document.cookie.indexOf(";",len);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure){
document.cookie = name + "=" +escape(value) +
( (expires) ? ";expires=" + expires.toGMTString() : "") +
( (path) ? ";path=" + path : "") +
( (domain) ? ";domain=" + domain : "") +
( (secure) ? ";secure" : "");
}

var today = new Date();
var expires = new Date(today.getTime() + (56 * 86400000));

</script>

NOTE: You can add var expired = new Date(today.getTime() + (56 * 86400000)); to this script to allow for deleting files. Just do Set_Cookie(name,value,expired,path,domain,secure) instead when calling it.

Anyway, next you need to grab the text of the editor via editor_getHTML(editorname) and set it to a variable. Then you can do Set_Cookie(name,variable just set,expires,path,domain,secure). This should work. I was writing one for the Hale Middle School Website (HaleMS.tk) until I came across a better editor version of htmlarea (Luis's version @ webstationone.com/test/htmlarea). It has saving functions built in and you can add the code described above easily into the editor.js file.

Hope This Helps

-Hale Middle School Tech Club
President


esthera
User

Mar 13, 2004, 11:46 AM

Post #3 of 14 (5039 views)
Shortcut
Re: [mkaplan] automatic save [In reply to] Can't Post

I am using Luis's version.

what do you mean by it has automatic save built in? I didn't notice it.

How do I activate it?


Techie
Novice

Mar 13, 2004, 2:14 PM

Post #4 of 14 (5037 views)
Shortcut
Re: [esthera] automatic save [In reply to] Can't Post

I said that it has save functions built in - not automatic save. (The disk icon) Since we are both using the same editor, I can guide you more specifically. This is what you must do:

1) Set a cookie every 2 minutes with the editors value using Set_Cookie, editor_getHTML('editorname'); , and SetInterval(Thingtodo, timeinmilliseconds); .

2) Then you must have the onload command get the stored cookie value with Get_Cookie, assign it a variable, and set it to the editor with editor_setHTML('editorname',cookievalueasvariable) .

This should do it.

-Hale Middle School Tech Club
President

(This post was edited by mkaplan on Mar 13, 2004, 2:15 PM)


Luis
Veteran

Mar 13, 2004, 2:17 PM

Post #5 of 14 (5035 views)
Shortcut
Re: [esthera] automatic save [In reply to] Can't Post

Hi esthera:

mkaplan said:

It has saving functions built in and you can add the code described above easily into the editor.js file, not automatic save built in.

I've never tried it but my guess is that you can automatize the function relatively easy. The only possible obstacle I see is in how to emulate by script the action of the ok button. May be it can be done using the SendKeys method. I don't know, but you could try it yourself. Unfortunatelly, I'm plenty of work and I've not had too much spare time to devote to HTMLArea and (I'll remain busy for a while.)


Don't give up!!
http://webstationone.com/test/htmlarea


Techie
Novice

Mar 13, 2004, 2:27 PM

Post #6 of 14 (5027 views)
Shortcut
Re: [Luis] automatic save [In reply to] Can't Post


Quote
The only possible obstacle I see is in how to emulate by script the action of the ok button.



One important thing, if the function is automatic, the user should not need to click an ok button for a reason other than to submit the form

-Hale Middle School Tech Club
President

(This post was edited by Techie on Mar 13, 2004, 2:35 PM)


Luis
Veteran

Mar 13, 2004, 11:13 PM

Post #7 of 14 (5019 views)
Shortcut
Re: [Techie] automatic save [In reply to] Can't Post

Hi Techie:

What I really mean is the save button in the SaveAs dialog in the Save To Local Disk Function. I can make the saveAs dialog open automatically but I've not been able yet to make it execute the final action (save) and close the dialog automatically. Maybe the easier solution is to open a confirm box every 2 minutes and let the user decide if he/she wants to save the file manually.

Greetings


Don't give up!!
http://webstationone.com/test/htmlarea


Techie
Novice

Mar 14, 2004, 12:48 AM

Post #8 of 14 (5012 views)
Shortcut
Re: [Luis] automatic save [In reply to] Can't Post

Well, I guess that it will depend on esthera's willingness to customize the javascript.

-Hale Middle School Tech Club
President


esthera
User

Mar 15, 2004, 2:32 AM

Post #9 of 14 (4999 views)
Shortcut
Re: [Techie] automatic save [In reply to] Can't Post

Maybe you can help me a bit further. I am really an asp programmer but trying to change the javascript to make some additions to this.

I am trying your cookie method.

First where do I put the code of set cookie that it will happen every 2 minutes automatically?

Second when calling this function

Set_Cookie(name,value,expired,path,domain,secure)

what do I put for path?

Is domain just the domain .com (or including the directory my editor is located in)

What is secure?



thanks for you help.

Esther


Techie
Novice

Mar 15, 2004, 6:34 PM

Post #10 of 14 (4982 views)
Shortcut
Re: [esthera] automatic save [In reply to] Can't Post


Quote
Second when calling this function

Set_Cookie(name,value,expired,path,domain,secure)

what do I put for path?



First of all, that will delete the cookie, not set it since you have the value set to expired.You do not need to address all possible values. For exaple, Set_Cookie(code,document.formname.fieldname.value,expire) will work just fine.




Quote


First where do I put the code of set cookie that it will happen every 2 minutes automatically?



Really it is your choice depending on how you wish to implement htmlArea. You can put it in editor.js and cause the autosave to function automatically in all editors or put it in a document if you would only like select forms to autosave. IMPORTANT NOTE: With cookies you can only save the value of one editor at a time UNLESS you change the cookie name to a unique value for each form.



One final note, since your preferred programming language is asp you could use javascript to send the value of the editor to an asp script every two minutes to save the data into a database.

-Hale Middle School Tech Club
President

(This post was edited by Techie on Mar 15, 2004, 6:34 PM)


esthera
User

Mar 16, 2004, 12:04 AM

Post #11 of 14 (4972 views)
Shortcut
Re: [Techie] automatic save [In reply to] Can't Post

thanks. I will probably try the cookie thing.

How could I do javascript to send it to an asp file without the user being aware? (You are right -- it would be much easier for me to do the programming in asp)?

Would this use a lot more server resources happening every 2 minutes?


Techie
Novice

Mar 19, 2004, 8:50 PM

Post #12 of 14 (4920 views)
Shortcut
Re: [esthera] automatic save [In reply to] Can't Post

I think it would use quite a bit more server resources, so I would still recommend going with cookies. I THINK (I am not an ASP Programmer) that ASP can write cookies, but I am not sure.

-Hale Middle School Tech Club
President


esthera
User

Mar 21, 2004, 12:41 PM

Post #13 of 14 (4894 views)
Shortcut
Re: [Techie] automatic save [In reply to] Can't Post

I basically did this server side.

How do I run a javascript function (in editor.js) every 2 minutes?

I tried setinterval and settimeout and it didn't happen.

Please help?


Techie
Novice

Mar 21, 2004, 9:07 PM

Post #14 of 14 (4887 views)
Shortcut
Re: [esthera] automatic save [In reply to] Can't Post

Here is a working example. Dowload the file and place it in the directory containing the htmlArea files. You can set the variables at the top of the script located in the body.

NOTE: The file is called autosave.htm

-Hale Middle School Tech Club
President
Attachments: autosave.htm (4.83 KB)

 
 
 


Search for (options)