[interchange-cvs] interchange - jon modified code/UserTag/button.tag

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Fri Oct 25 17:51:01 2002


User:      jon
Date:      2002-10-25 21:50:10 GMT
Modified:  code/UserTag button.tag
Log:
Make sure that the current button being pressed is the only one whose
mv_click_map_* variable gets set.

This works around the problem of a user clicking one button, using the
browser's Back button, then clicking on a different button, and both
mv_clicks execute instead of just the most recent one.

Revision  Changes    Path
1.3       +20 -2     interchange/code/UserTag/button.tag


rev 1.3, prev_rev 1.2
Index: button.tag
===================================================================
RCS file: /var/cvs/interchange/code/UserTag/button.tag,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -u -r1.2 -r1.3
--- button.tag	28 Jul 2002 15:13:51 -0000	1.2
+++ button.tag	25 Oct 2002 21:50:10 -0000	1.3
@@ -194,17 +194,35 @@
 
 	$out .= <<EOF;
 <A HREF="javascript:void 0"$opt->{extra} onMouseOver="window.status='$wstatus'"
-	onClick="$confirm ($opt->{form}.$clickname.value='$text') && $opt->{form}.submit(); return(false);"
+	onClick="$confirm mv_click_map_unique(document.$opt->{form}, '$clickname', '$text') && $opt->{form}.submit(); return(false);"
 	ALT="$wstatus"><IMG ALT="$wstatus" SRC="$src" border=$opt->{border}$position>$a_before$anchor$a_after
 EOF
 
+	my $function = '';
+	unless ($::Instance->{js_functions}{mv_do_click}++) {
+		$function = "\n" . <<'EOJS';
+function mv_click_map_unique(myform, clickname, clicktext) {
+	for (var i = 0; i < myform.length; i++) {
+		var widget = myform.elements[i];
+		if (
+			(widget.type == 'hidden')
+			&& (widget.name != 'mv_click_map')
+			&& (widget.name.indexOf('mv_click_') == 0)
+		)
+			widget.value = (widget.name == clickname) ? clicktext : '';
+	}
+	return true;
+}
+EOJS
+	}
+
 	# Must escape backslashes and single quotes for JavaScript write function.
 	# Also must get rid of newlines and carriage returns.
 	$out =~ s/(['\\])/\\$1/g;
 	$out =~ s/[\n\r]+/ /g;
 	$out = <<EOV;
 <script language="javascript1.2">
-<!--
+<!--$function
 document.write('$out');
 // -->
 </script>