Index: trunk/extensions/SignupAPI/SignupAPI.i18n.php |
— | — | @@ -10,6 +10,11 @@ |
11 | 11 | |
12 | 12 | $messages['en'] = array( |
13 | 13 | 'signupapi-desc' => 'Cleans up the [[Special:UserLogin|login page]] from signup related stuff and adds an API for signup', |
| 14 | + 'signupapi-enterpassword' => 'You must enter a password', |
| 15 | + 'signupapi-weak' => 'Weak', |
| 16 | + 'signupapi-medium' => 'Medium', |
| 17 | + 'signupapi-strong' => 'Strong', |
| 18 | + 'signupapi-passwordsmatch' => 'Passwords Match', |
14 | 19 | ); |
15 | 20 | |
16 | 21 | /** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца)) |
Index: trunk/extensions/SignupAPI/SignupAPI.php |
— | — | @@ -1,7 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | 4 | * Setup for SignupAPI extension, a special page that cleans up SpecialUserLogin |
5 | | - * from signup related stuff & adds an API for signup |
| 5 | + * from signup related stuff, adds an API for signup, adds sourcetracking for |
| 6 | + *account creation & AJAX-ifies the signup form |
6 | 7 | * |
7 | 8 | * @file |
8 | 9 | * @ingroup Extensions |
— | — | @@ -24,6 +25,9 @@ |
25 | 26 | 'descriptionmsg' => 'signupapi-desc', |
26 | 27 | ); |
27 | 28 | |
| 29 | +$wgSignupAPIUseAjax = true; |
| 30 | +$wgSignupAPISourceTracking = true; |
| 31 | + |
28 | 32 | $dir = dirname(__FILE__); |
29 | 33 | $wgExtensionMessagesFiles['SignupAPI'] = $dir . '/SignupAPI.i18n.php'; |
30 | 34 | $wgMyExtensionIncludes = $dir . '/includes'; |
— | — | @@ -36,95 +40,117 @@ |
37 | 41 | = $wgMyExtensionIncludes . '/APISignup.php'; |
38 | 42 | $wgSpecialPages['UserSignup'] = 'SignupForm'; |
39 | 43 | |
40 | | -$wgAPIModules['signup'] = 'ApiSignup'; |
| 44 | +if ( $wgSignupAPIUseAjax ) { |
| 45 | + $wgAutoloadClasses['validateSignup'] |
| 46 | + = $wgMyExtensionIncludes . '/validateSignup.php'; |
41 | 47 | |
42 | | -# Schema updates for update.php |
43 | | -$wgHooks['LoadExtensionSchemaUpdates'][] = 'fnMyHook'; |
44 | | -function fnMyHook() { |
45 | | - global $wgExtNewTables; |
46 | | - $wgExtNewTables[] = array( |
47 | | - 'sourcetracking', |
48 | | - dirname( __FILE__ ) . '/sourcetracking.sql' ); |
49 | | - return true; |
50 | | -} |
| 48 | + $wgAPIModules['signup'] = 'ApiSignup'; |
| 49 | + $wgAPIModules['validatesignup'] = 'validateSignup'; |
51 | 50 | |
52 | | -# Add source tracking to personal URL's |
53 | | -$wgHooks['PersonalUrls'][] = 'addSourceTracking'; |
| 51 | + # Requires jquery.ui.progressbar for password strength validation |
| 52 | + $wgResourceModules['ext.SignupAPI'] = array( |
54 | 53 | |
55 | | -function addSourceTracking( &$personal_urls, &$title ) |
56 | | -{ |
57 | | - global $wgRequest,$wgUser; |
58 | | - |
59 | | - #generate source tracking parameters |
60 | | - $sourceAction = $wgRequest->getVal( 'action' ); |
61 | | - $sourceNS = $title->getNamespace(); |
62 | | - $sourceArticle = $title->getArticleID(); |
63 | | - $loggedin = $wgUser->isLoggedIn(); |
64 | | - $thispage = $title->getPrefixedDBkey(); |
65 | | - $thisurl = $title->getPrefixedURL(); |
66 | | - $query = array(); |
67 | | - if ( !$wgRequest->wasPosted() ) { |
68 | | - $query = $wgRequest->getValues(); |
69 | | - unset( $query['title'] ); |
70 | | - unset( $query['returnto'] ); |
71 | | - unset( $query['returntoquery'] ); |
72 | | - } |
73 | | - $thisquery = wfUrlencode( wfArrayToCGI( $query ) ); |
| 54 | + 'scripts' => array( 'includes/verification.js' ), |
| 55 | + 'messages' => array( 'ok', 'signupapi-enterpassword', 'passwordtooshort', 'signupapi-weak', 'signupapi-medium', 'signupapi-strong', 'badretype', 'signupapi-passwordsmatch' ), |
| 56 | + 'dependencies' => array( 'jquery.ui.progressbar' ), |
| 57 | + 'localBasePath' => dirname( __FILE__ ), |
| 58 | + 'remoteExtPath' => 'SignupAPI' |
| 59 | + ); |
74 | 60 | |
75 | | - // Get the returnto and returntoquery parameters from the query string |
76 | | - // or fall back on $this->thisurl or $this->thisquery |
77 | | - // We can't use getVal()'s default value feature here because |
78 | | - // stuff from $wgRequest needs to be escaped, but thisurl and thisquery |
79 | | - // are already escaped. |
80 | | - $page = $wgRequest->getVal( 'returnto' ); |
81 | | - if ( !is_null( $page ) ) { |
82 | | - $page = wfUrlencode( $page ); |
83 | | - } else { |
84 | | - $page = $thisurl; |
85 | | - } |
86 | | - $query = $wgRequest->getVal( 'returntoquery' ); |
87 | | - if ( !is_null( $query ) ) { |
88 | | - $query = wfUrlencode( $query ); |
89 | | - } else { |
90 | | - $query = $thisquery; |
91 | | - } |
92 | | - $returnto = "returnto=$page"; |
93 | | - if ( $query != '' ) { |
94 | | - $returnto .= "&returntoquery=$query"; |
95 | | - } |
| 61 | +} |
96 | 62 | |
97 | | - if (isset ( $personal_urls['login'] ) ) { |
98 | | - $login_url = $personal_urls['login']; |
99 | | - $login_url['href'] = $login_url['href']."&source_action=$sourceAction&source_ns=$sourceNS&source_article=$sourceArticle"; |
100 | | - $personal_urls['login'] = $login_url; |
| 63 | +if ( $wgSignupAPISourceTracking ) { |
| 64 | + # Schema updates for update.php |
| 65 | + $wgHooks['LoadExtensionSchemaUpdates'][] = 'onSourceTracking'; |
| 66 | + function onSourceTracking() { |
| 67 | + global $wgExtNewTables; |
| 68 | + $wgExtNewTables[] = array( |
| 69 | + 'sourcetracking', |
| 70 | + dirname( __FILE__ ) . '/sourcetracking.sql' ); |
| 71 | + return true; |
101 | 72 | } |
102 | 73 | |
103 | | - if ( isset ( $personal_urls['anonlogin'] ) ) { |
104 | | - $login_url = $personal_urls['anonlogin']; |
105 | | - $login_url['href'] = $login_url['href']."&source_action=$sourceAction&source_ns=$sourceNS&source_article=$sourceArticle"; |
106 | | - $personal_urls['anonlogin'] = $login_url; |
107 | | - } |
| 74 | + # Add source tracking to personal URL's |
| 75 | + $wgHooks['PersonalUrls'][] = 'addSourceTracking'; |
108 | 76 | |
109 | | - if ( isset ( $personal_urls['createaccount'] ) ) { |
110 | | - global $wgServer, $wgSecureLogin; |
| 77 | + function addSourceTracking( &$personal_urls, &$title ) |
| 78 | + { |
| 79 | + global $wgRequest,$wgUser; |
| 80 | + |
| 81 | + #generate source tracking parameters |
| 82 | + $sourceAction = $wgRequest->getVal( 'action' ); |
| 83 | + $sourceNS = $title->getNamespace(); |
| 84 | + $sourceArticle = $title->getArticleID(); |
| 85 | + $loggedin = $wgUser->isLoggedIn(); |
| 86 | + $thispage = $title->getPrefixedDBkey(); |
| 87 | + $thisurl = $title->getPrefixedURL(); |
| 88 | + $query = array(); |
| 89 | + if ( !$wgRequest->wasPosted() ) { |
| 90 | + $query = $wgRequest->getValues(); |
| 91 | + unset( $query['title'] ); |
| 92 | + unset( $query['returnto'] ); |
| 93 | + unset( $query['returntoquery'] ); |
| 94 | + } |
| 95 | + $thisquery = wfUrlencode( wfArrayToCGI( $query ) ); |
| 96 | + |
| 97 | + // Get the returnto and returntoquery parameters from the query string |
| 98 | + // or fall back on $this->thisurl or $this->thisquery |
| 99 | + // We can't use getVal()'s default value feature here because |
| 100 | + // stuff from $wgRequest needs to be escaped, but thisurl and thisquery |
| 101 | + // are already escaped. |
111 | 102 | $page = $wgRequest->getVal( 'returnto' ); |
112 | | - $is_signup = $wgRequest->getText( 'type' ) == "signup"; |
113 | | - $createaccount_url = array( |
114 | | - 'text' => wfMsg( 'createaccount' ), |
115 | | - 'href' => SkinTemplate::makeSpecialUrl( 'Usersignup', "$returnto&type=signup&wpSourceAction=$sourceAction&wpSourceNS=$sourceNS&wpSourceArticle=$sourceArticle" ), |
116 | | - 'active' => $title->isSpecial( 'Userlogin' ) && $is_signup |
117 | | - ); |
| 103 | + if ( !is_null( $page ) ) { |
| 104 | + $page = wfUrlencode( $page ); |
| 105 | + } else { |
| 106 | + $page = $thisurl; |
| 107 | + } |
| 108 | + $query = $wgRequest->getVal( 'returntoquery' ); |
| 109 | + if ( !is_null( $query ) ) { |
| 110 | + $query = wfUrlencode( $query ); |
| 111 | + } else { |
| 112 | + $query = $thisquery; |
| 113 | + } |
| 114 | + $returnto = "returnto=$page"; |
| 115 | + if ( $query != '' ) { |
| 116 | + $returnto .= "&returntoquery=$query"; |
| 117 | + } |
118 | 118 | |
119 | | - if ( substr( $wgServer, 0, 5 ) === 'http:' && $wgSecureLogin ) { |
120 | | - $title = SpecialPage::getTitleFor( 'Usersignup' ); |
121 | | - $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL( "type=signup" ) ); |
122 | | - $createaccount_url['href'] = $https_url; |
123 | | - $createaccount_url['class'] = 'link-https'; |
124 | | - } |
125 | | - $personal_urls['createaccount'] = $createaccount_url; |
| 119 | + if (isset ( $personal_urls['login'] ) ) { |
| 120 | + $login_url = $personal_urls['login']; |
| 121 | + $login_url['href'] = $login_url['href']."&source_action=$sourceAction&source_ns=$sourceNS&source_article=$sourceArticle"; |
| 122 | + $personal_urls['login'] = $login_url; |
| 123 | + } |
| 124 | + |
| 125 | + if ( isset ( $personal_urls['anonlogin'] ) ) { |
| 126 | + $login_url = $personal_urls['anonlogin']; |
| 127 | + $login_url['href'] = $login_url['href']."&source_action=$sourceAction&source_ns=$sourceNS&source_article=$sourceArticle"; |
| 128 | + $personal_urls['anonlogin'] = $login_url; |
| 129 | + } |
| 130 | + |
| 131 | + if ( isset ( $personal_urls['createaccount'] ) ) { |
| 132 | + global $wgServer, $wgSecureLogin; |
| 133 | + $page = $wgRequest->getVal( 'returnto' ); |
| 134 | + $is_signup = $wgRequest->getText( 'type' ) == "signup"; |
| 135 | + $createaccount_url = array( |
| 136 | + 'text' => wfMsg( 'createaccount' ), |
| 137 | + 'href' => SkinTemplate::makeSpecialUrl( 'Usersignup', "$returnto&type=signup&wpSourceAction=$sourceAction&wpSourceNS=$sourceNS&wpSourceArticle=$sourceArticle" ), |
| 138 | + 'active' => $title->isSpecial( 'Userlogin' ) && $is_signup |
| 139 | + ); |
| 140 | + |
| 141 | + if ( substr( $wgServer, 0, 5 ) === 'http:' && $wgSecureLogin ) { |
| 142 | + $title = SpecialPage::getTitleFor( 'Usersignup' ); |
| 143 | + $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL( "type=signup" ) ); |
| 144 | + $createaccount_url['href'] = $https_url; |
| 145 | + $createaccount_url['class'] = 'link-https'; |
| 146 | + } |
| 147 | + $personal_urls['createaccount'] = $createaccount_url; |
| 148 | + } |
| 149 | + |
| 150 | + return true; |
126 | 151 | } |
127 | 152 | |
128 | | - return true; |
129 | 153 | } |
130 | 154 | |
131 | 155 | |
| 156 | + |
| 157 | + |
Index: trunk/extensions/SignupAPI/includes/images/MW-Icon-Warning.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/SignupAPI/includes/images/MW-Icon-Warning.png |
___________________________________________________________________ |
Added: svn:mime-type |
132 | 158 | + application/octet-stream |
Index: trunk/extensions/SignupAPI/includes/images/MW-Icon-NoMark.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/SignupAPI/includes/images/MW-Icon-NoMark.png |
___________________________________________________________________ |
Added: svn:mime-type |
133 | 159 | + application/octet-stream |
Index: trunk/extensions/SignupAPI/includes/images/MW-Icon-CheckMark.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/SignupAPI/includes/images/MW-Icon-CheckMark.png |
___________________________________________________________________ |
Added: svn:mime-type |
134 | 160 | + application/octet-stream |
Index: trunk/extensions/SignupAPI/includes/images/MW-Icon-AlertMark.png |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/SignupAPI/includes/images/MW-Icon-AlertMark.png |
___________________________________________________________________ |
Added: svn:mime-type |
135 | 161 | + application/octet-stream |
Index: trunk/extensions/SignupAPI/includes/validateSignup.php |
— | — | @@ -0,0 +1,132 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | + // Eclipse helper - will be ignored in production |
| 6 | + require_once( 'ApiBase.php' ); |
| 7 | +} |
| 8 | + |
| 9 | +/** |
| 10 | + * Unit to create accounts in the current wiki |
| 11 | + * |
| 12 | + * @ingroup API |
| 13 | + */ |
| 14 | +class validateSignup extends ApiBase { |
| 15 | + |
| 16 | + public function __construct( $main, $action ) { |
| 17 | + parent::__construct( $main, $action ); |
| 18 | + } |
| 19 | + |
| 20 | + public function execute() { |
| 21 | + $params = $this->extractRequestParams(); |
| 22 | + |
| 23 | + $result = array(); |
| 24 | + |
| 25 | + switch ( $params['field'] ) { |
| 26 | + case "username": |
| 27 | + $mUser = User::newFromName( $params['inputVal'], 'creatable' ); |
| 28 | + if ( !is_object( $mUser ) ) { |
| 29 | + $result['result'] = wfMsg( 'noname' ); |
| 30 | + $result['icon'] = 'MW-Icon-AlertMark.png'; |
| 31 | + } |
| 32 | + |
| 33 | + if ( 0 != $mUser->idForName() ) { |
| 34 | + $result['result'] = wfMsg( 'userexists' ); |
| 35 | + $result['icon'] = "MW-Icon-NoMark.png"; |
| 36 | + } |
| 37 | + |
| 38 | + else { |
| 39 | + $result['result'] = wfMsg( 'ok' ); |
| 40 | + $result['icon'] = "MW-Icon-CheckMark.png"; |
| 41 | + } |
| 42 | + break; |
| 43 | + |
| 44 | + case "email" : |
| 45 | + if ( $valid = User::isValidEmailAddr( $params['inputVal'] ) ) { |
| 46 | + $result['result']= wfMsg( 'ok' ); |
| 47 | + $result['icon'] = "MW-Icon-CheckMark.png"; |
| 48 | + } |
| 49 | + else { |
| 50 | + $result['result']= wfMsg( 'invalidemailaddress' ); |
| 51 | + $result['icon'] = "MW-Icon-NoMark.png"; |
| 52 | + } |
| 53 | + break; |
| 54 | + |
| 55 | + case "passwordlength" : |
| 56 | + global $wgMinimalPasswordLength; |
| 57 | + $result['result'] = $wgMinimalPasswordLength; |
| 58 | + break; |
| 59 | + |
| 60 | + default : |
| 61 | + ApiBase::dieDebug( __METHOD__, "Unhandled case value: {$params['field']}" ); |
| 62 | + } |
| 63 | + |
| 64 | + $this->getResult()->addValue( null, 'signup', $result ); |
| 65 | + } |
| 66 | + |
| 67 | + public function mustBePosted() { |
| 68 | + return false; |
| 69 | + } |
| 70 | + |
| 71 | + public function isReadMode() { |
| 72 | + return false; |
| 73 | + } |
| 74 | + |
| 75 | + public function getAllowedParams() { |
| 76 | + return array( |
| 77 | + 'field' => null, |
| 78 | + 'inputVal' => null, |
| 79 | + 'password' => null, |
| 80 | + 'retype' => null, |
| 81 | + 'email' => null, |
| 82 | + ); |
| 83 | + } |
| 84 | + |
| 85 | + public function getParamDescription() { |
| 86 | + return array( |
| 87 | + 'name' => 'Desired Username', |
| 88 | + 'password' => 'Password', |
| 89 | + 'retype' => 'Re-typed Password', |
| 90 | + 'email' => 'Email ID(optional)', |
| 91 | + ); |
| 92 | + } |
| 93 | + |
| 94 | + public function getDescription() { |
| 95 | + return array( |
| 96 | + 'This module validates the parameters posted by the signup form.' |
| 97 | + ); |
| 98 | + } |
| 99 | + |
| 100 | + public function getPossibleErrors() { |
| 101 | + return array_merge( parent::getPossibleErrors(), array( |
| 102 | + array( 'code' => 'WrongPassword', 'info' => 'Incorrect password entered. Please try again.' ), |
| 103 | + array( 'code' => 'ReadOnlyPage', 'info' => 'Accounts cannot be created with read-only permissions' ), |
| 104 | + array( 'code' => 'NoCookies', 'info' => 'The user account was not created, as we could not confirm its source. |
| 105 | + Ensure you have cookies enabled, reload this page and try again.' ), |
| 106 | + array( 'code' => 'NeedToken', 'info' => 'You need to resubmit your signup with the specified token' ), |
| 107 | + array( 'code' => 'WrongToken', 'info' => 'You specified an invalid token' ), |
| 108 | + array( 'code' => 'InsufficientPermission', 'info' => 'You do not have sufficient permissions to create account' ), |
| 109 | + array( 'code' => 'CreateBlocked', 'info' => 'You have been blocked from creating accounts' ), |
| 110 | + array( 'code' => 'IPBlocked', 'info' => 'Your IP is blocked from creating accounts' ), |
| 111 | + array( 'code' => 'NoName', 'info' => 'You have not set a valid name for the username parameter' ), |
| 112 | + array( 'code' => 'UserExists', 'info' => 'Username entered already in use. Please choose a different name.' ), |
| 113 | + array( 'code' => 'WrongRetype', 'info' => 'The passwords you entered do not match.' ), |
| 114 | + array( 'code' => 'InvalidPass', 'info' => 'You specified an invalid password' ), |
| 115 | + array( 'code' => 'NoEmail', 'info' => 'No e-mail address specified' ), |
| 116 | + array( 'code' => 'InvalidEmail', 'info' => 'You specified an invalid email address' ), |
| 117 | + array( 'code' => 'BlockedByHook', 'info' => 'A hook blocked account creation' ), |
| 118 | + array( 'code' => 'ExternalDBError', 'info' => 'There was either an authentication database error or you are not allowed to update your external account.' ), |
| 119 | + array( 'code' => 'Throttled', 'info' => 'You have tried creating accounts too many times in a short period' ), |
| 120 | + ) ); |
| 121 | + } |
| 122 | + |
| 123 | + protected function getExamples() { |
| 124 | + return array( |
| 125 | + 'api.php?action=validatesignup&field=username&name=username' |
| 126 | + ); |
| 127 | + } |
| 128 | + |
| 129 | + public function getVersion() { |
| 130 | + return __CLASS__ . ': $Id: validateSignup.php 91472 2011-07-05 18:43:51Z akshay $'; |
| 131 | + } |
| 132 | + |
| 133 | +} |
Property changes on: trunk/extensions/SignupAPI/includes/validateSignup.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 134 | + native |
Index: trunk/extensions/SignupAPI/includes/SpecialUserSignup.php |
— | — | @@ -129,6 +129,9 @@ |
130 | 130 | |
131 | 131 | public function execute( $par ) { |
132 | 132 | |
| 133 | + global $wgOut; |
| 134 | + $wgOut->addModules( 'mediawiki.special.usersignup' ); |
| 135 | + |
133 | 136 | if ( session_id() == '' ) { |
134 | 137 | wfSetupSession(); |
135 | 138 | } |
— | — | @@ -737,6 +740,7 @@ |
738 | 741 | |
739 | 742 | $wgOut->disallowUserJs(); // just in case... |
740 | 743 | $wgOut->addTemplate( $template ); |
| 744 | + $wgOut->addModules( 'ext.SignupAPI' ); |
741 | 745 | } |
742 | 746 | |
743 | 747 | /** |
Index: trunk/extensions/SignupAPI/includes/verification.js |
— | — | @@ -0,0 +1,84 @@ |
| 2 | +//setup verification fields on the form |
| 3 | + |
| 4 | +function validateInput( fieldtype,fieldid ) { |
| 5 | + var inputVal = document.getElementById(fieldid).value; |
| 6 | + var valresult = document.getElementById(fieldid+'val'); |
| 7 | + $.ajax({ |
| 8 | + type: "POST", |
| 9 | + url: mw.util.wikiScript('api'), |
| 10 | + data: "action=validatesignup&format=json&field="+fieldtype+"&inputVal="+inputVal, |
| 11 | + dataType: 'json', |
| 12 | + success: function( jsondata ){ |
| 13 | + var image = "<img src='"+ imagePath + jsondata.signup.icon +"'>"; |
| 14 | + var message = jsondata.signup.result; |
| 15 | + valresult.innerHTML = image+message; |
| 16 | + } |
| 17 | + }); |
| 18 | +} |
| 19 | + |
| 20 | +function passwordStrength() { |
| 21 | + |
| 22 | + var strength = document.getElementById('wpPassword2val'); |
| 23 | + var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g"); |
| 24 | + var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g"); |
| 25 | + var enoughRegex = new RegExp("(?=.{6,}).*", "g"); |
| 26 | + var pwd = document.getElementById("wpPassword2"); |
| 27 | + |
| 28 | + if (pwd.value.length==0) { |
| 29 | + strength.innerHTML = mw.message( 'signupapi-enterpassword' ); |
| 30 | + } else if (pwd.value.length<minlength) { |
| 31 | + strength.innerHTML = mw.message( 'passwordtooshort', minlength ); |
| 32 | + $("#progress").progressbar({value: 10}); |
| 33 | + $("div.ui-progressbar-value").css("background","red"); |
| 34 | + } else if (strongRegex.test(pwd.value)) { |
| 35 | + strength.innerHTML = '<span style="color:green">'+mw.message( 'signupapi-strong' )+'</span>'; |
| 36 | + $("#progress").progressbar({value: 100}); |
| 37 | + $("div.ui-progressbar-value").css("background","green"); |
| 38 | + } else if (mediumRegex.test(pwd.value)) { |
| 39 | + strength.innerHTML = '<span style="color:orange">'+mw.message( 'signupapi-medium' )+'</span>'; |
| 40 | + $("#progress").progressbar({value: 60}); |
| 41 | + $("div.ui-progressbar-value").css("background","orange"); |
| 42 | + } else { |
| 43 | + strength.innerHTML = '<span style="color:red">'+mw.message( 'signupapi-weak' )+'</span>'; |
| 44 | + $("#progress").progressbar({value: 30}); |
| 45 | + $("div.ui-progressbar-value").css("background","red"); |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | + |
| 50 | +function checkRetype( pass,retype ) { |
| 51 | + var valresult = document.getElementById('wpRetypeval'); |
| 52 | + var image = ""; |
| 53 | + var message = ""; |
| 54 | + if ( pass==retype ) { |
| 55 | + image = "<img src='"+ imagePath +"MW-Icon-CheckMark.png'>"; |
| 56 | + message = mw.message( 'signupapi-passwordsmatch' ); |
| 57 | + } |
| 58 | + else { |
| 59 | + image = "<img src='"+ imagePath +"MW-Icon-NoMark.png'>"; |
| 60 | + message = mw.message( 'badretype' ); |
| 61 | + } |
| 62 | + valresult.innerHTML = image+message; |
| 63 | +} |
| 64 | + |
| 65 | +$('#wpName2').change(function() {validateInput("username","wpName2");}); |
| 66 | +$('#wpPassword2').keyup(function() {passwordStrength();}); |
| 67 | +$('#wpRetype').change(function() {checkRetype(document.getElementById("wpPassword2").value,document.getElementById("wpRetype").value);}); |
| 68 | +$('#wpEmail').change(function() {validateInput( "email","wpEmail" );}); |
| 69 | + |
| 70 | +$('#wpName2').after('<span id="wpName2val" class="wpName2val"></span>'); |
| 71 | +$('#wpPassword2').after('<span id="wpPassword2val"></span><div id="progress" class="progress" style="width:30%; float: right;"></div>'); |
| 72 | +$('#wpRetype').after('<span id="wpRetypeval" class="wpRetypeval"></span>'); |
| 73 | +$('#wpEmail').after('<span id="wpEmailval" class="wpEmailval"></span>'); |
| 74 | + |
| 75 | +mw.loader.using( 'ext.SignupAPI', function() { |
| 76 | + $("#progress").progressbar(); |
| 77 | + } ); |
| 78 | + |
| 79 | +console.log(); |
| 80 | +$('div.ui-progressbar').css('background','#F2F5F7'); |
| 81 | + |
| 82 | +var imagePath = window.wgServer+window.wgExtensionAssetsPath + "/SignupAPI/includes/images/"; |
| 83 | +var minlength = window.wgMinimalPasswordLength; |
| 84 | + |
| 85 | + |
Property changes on: trunk/extensions/SignupAPI/includes/verification.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 86 | + native |