disable password field on openid detection via javascript

git-svn-id: http://yolanda.mister-muffin.de/svn@280 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
erlehmann 2008-04-09 01:10:21 +00:00
parent f779418312
commit 031a198e83
6 changed files with 89 additions and 51 deletions

View file

@ -112,10 +112,12 @@
<!-- login / register page -->
<string id="username">username</string>
<string id="password">password</string>
<string id="username_or_openid">Username or OpenID</string>
<string id="password">Password</string>
<string id="password_repeat">repeat password</string>
<string id="button_register">register</string>
<string id="button_login">login</string>
<string id="input_password_not_required">No password required.</string>
<string id="button_register">Register</string>
<string id="button_login">Login</string>
<!-- upload page -->
<string id="file">file</string>

View file

@ -29,12 +29,14 @@
<xsl:include href="./xhtml/settings.xsl" />
<xsl:include href="./xhtml/splash.xsl" />
<xsl:include href="./xhtml/searchbar.xsl" />
<xsl:include href="./xhtml/tagbar.xsl" />
<xsl:include href="./xhtml/tagcloud.xsl" />
<xsl:include href="./xhtml/upload.xsl" />
<xsl:include href="./xhtml/video.xsl" />
<xsl:include href="./xhtml/xhtml-body.xsl" />
<xsl:include href="./xhtml/xhtml-head.xsl" />
<xsl:variable name="locale">
<xsl:choose>
<xsl:when test="document(concat('../locale/', //@locale, '.xml'))">

View file

@ -8,10 +8,8 @@
>
<xsl:template name="loginbox">
<div class="loginbox">
<xsl:choose>
<xsl:when test="string-length(//@username)=0">
<div class="loginbox">
<form method="post">
<xsl:attribute name="action">
@ -19,17 +17,17 @@
</xsl:attribute>
<fieldset>
<label for="user">
<xsl:value-of select="$locale_strings[@id='username']" />:
<xsl:value-of select="$locale_strings[@id='username_or_openid']" />:
</label>
<br />
<input name="user" type="text" />
<input id="username" name="user" onkeyup="check_openid();" type="text" />
<br />
<label for="pass">
<xsl:value-of select="$locale_strings[@id='password']" />:
</label>
<br />
<input name="pass" type="password" />
<input id="password" name="pass" type="password" />
<input type="submit" name="login" >
<xsl:attribute name="value">
@ -40,24 +38,42 @@
</fieldset>
</form>
</xsl:when>
<xsl:otherwise>
</div>
<script type="text/javascript">
<!--
<xsl:value-of select="$locale_strings[@id='logged_in_as']" />
<a>
<xsl:attribute name="href">
user/<xsl:value-of select="//@username" />
</xsl:attribute>
<xsl:value-of select="//@username" />
</a>
this looks awfully ugly, but nevertheless generates javascript inside _valid_ XHTML
kudos to toby white who details the solution on http://scispace.net/tow21/weblog/718.html
-->
<xsl:text disable-output-escaping="yes">&lt;![CDATA[
<![CDATA[
</xsl:otherwise>
</xsl:choose>
function check_openid()
{
password = document.getElementById('password');
if (
document.getElementById('username').value.substring(7,0).toLowerCase() == "http://"
||
document.getElementById('username').value.substring(8,0).toLowerCase() == "https://"
)
{
password.disabled = true;
password.type = 'input';
password.value = ']]></xsl:text><xsl:value-of select="$locale_strings[@id='input_password_not_required']" /><xsl:text disable-output-escaping="yes"><![CDATA[';
}
else
{
password.disabled = false;
password.type = 'password';
password.value = '';
}
}
</div>
]]]]></xsl:text>
<xsl:text disable-output-escaping="yes">></xsl:text>
</script>
</xsl:template>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://web.resource.org/cc/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
<xsl:template name="tagbar">
</xsl:template>
</xsl:stylesheet>

View file

@ -22,7 +22,12 @@
<xsl:choose>
<xsl:when test="//frontpage">
<xsl:call-template name="searchbar" />
<xsl:if test="string-length(//@username)=0">
<xsl:call-template name="loginbox" />
</xsl:if>
<xsl:call-template name="tagcloud" />
<xsl:if test="//message">