[MRM-1062] avoid applet error going into search box

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@751545 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2009-03-08 22:44:03 +00:00
parent f3b9f4f30c
commit 722e0b6682
1 changed files with 15 additions and 8 deletions

View File

@ -33,21 +33,29 @@
<div id="searchBox"> <div id="searchBox">
<s:if test="%{#application['uiOptions'].appletFindEnabled}"> <s:if test="%{#application['uiOptions'].appletFindEnabled}">
<script type="text/javascript"> <script type="text/javascript">
function generateMd5( file, defVal ) function handleChecksum( form )
{ {
if ( file ) if ( form.file.value )
{ {
var s = document.ChecksumApplet.generateMd5(file); var s = document.ChecksumApplet.generateMd5( form.file.value );
// If there is a space, it's an error message, not a checksum // If there is a space, it's an error message, not a checksum
if ( s.indexOf(" ") >= 0 ) if ( s.indexOf(" ") >= 0 )
{ {
alert(s); alert(s);
return ""; return false;
} }
else else
return s; {
form.file.disabled = true;
form.q.value = s;
}
} }
return defVal; else
{
form.file.disabled = true;
form.q.value = form.md5.value;
}
return true;
} }
</script> </script>
@ -55,8 +63,7 @@
<span class="errorMessage">JavaScript is disabled: using the file browser will not work.</span> <span class="errorMessage">JavaScript is disabled: using the file browser will not work.</span>
</noscript> </noscript>
<s:form method="POST" action="checksumSearch" namespace="/" <s:form method="POST" action="checksumSearch" namespace="/" onsubmit="return handleChecksum(this);">
onsubmit="this.q.value = generateMd5(this.file.value,this.md5.value); this.file.disabled = true;">
<s:hidden name="q"/> <s:hidden name="q"/>
<tr> <tr>
<td class="tdLabel"><label for="checksumSearch_file" class="label">Search for:</label></td> <td class="tdLabel"><label for="checksumSearch_file" class="label">Search for:</label></td>