forum.coppermine-gallery.net

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Miscellaneous => Topic started by: LATH on February 17, 2005, 08:07:08 am

Title: Javascript Error
Post by: LATH on February 17, 2005, 08:07:08 am
I ran a search and found a thread like this started but there was no resolution...here is the other thread: http://forum.coppermine-gallery.net/index.php?topic=12561.0

Like the other thread I'm getting the following java script error when I attempt to change the description:

A Runtime Error has occurred.
Do you wish to Debug

Line: 258
Error: Object expected

When I drop into the debugger and inspect I see that textCounter is undefined according to the debugger.  The HTML includes a reference to scripts.js and the file does exist.  However, scripts.js doesn't include textCounter().  Instead textCounter is included in the body of the document as follows:

<script type="JavaScript">
function textCounter(field, maxlimit) {
        if (field.value.length > maxlimit) // if too long...trim it!
        field.value = field.value.substring(0, maxlimit);
}
</script>

The same error occurs on several themes including "classic".

Here is the url to the site: http://www.johnlathrop.com/gallery/
Title: Re: Javascript Error
Post by: LATH on February 17, 2005, 08:23:38 am
I think I found a solution...  :o

I copied the HTML into a test page at http://www.johnlathrop.com/gallery/test_bad.htm.  You can attempt to make a change to description ... any onkeydown should produce the error.

One little correction placed in http://www.johnlathrop.com/gallery/test_good.htm doesn't produce the error.

This is the corrected script in the HTML running on my client...I don't know how to affect the same fix in your dynamic code:

<script type="text/javascript">
function textCounter(field, maxlimit) {
        if (field.value.length > maxlimit) // if too long...trim it!
        field.value = field.value.substring(0, maxlimit);
}
Title: Re: Javascript Error
Post by: donnoman on February 17, 2005, 08:32:26 am
I'm pretty sure I don't recall seeing any code like that in the default themes that come with Coppermine.

What theme is it?
Title: Re: Javascript Error
Post by: donnoman on February 17, 2005, 08:46:51 am
Ahh, because its not part of the templates.

In stable it appears 3 times.

editOnePic.php around line 187
editpics.php around line 484
upload.php around line 306

in devel it appears 4 times
editOnePic.php
editpics.php
reviewcom.php
upload.php

It does appear that "text/javascript" is the correct W3C accepted content type, as it is used directly in an  example (http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1) on thier site.

There are probably more occurances than I found.

If another dev can confirm, I'll go through both stable and devel tomarrow to clean these up.

Title: Re: Javascript Error
Post by: LATH on February 18, 2005, 04:03:07 am
For what its worth I made the change to editOnePic.php, editpics.php and upload.php.  This solved my problem.   :)