@@ -4,7 +4,7 @@ var globalLoginRef;
44mendix . widget . declare ( "SimpleLogin.SimpleLogin" , {
55 addons : [ dijit . _Templated ] ,
66
7- templateString : '<div class="mobileLogin"><div class="loginContainer"><div id="errormessages" style="display: none;"></div><div id="fulllogin" style="display: none;"><label id="usernamelabel" style="display:block;"></label><input id="username" autocapitalize="off" autocorrect="off" type="text" style="width:100%" /><label id="passwordlabel" style="display:block;"></label><input id="password" autocapitalize="off" autocorrect="off" type="password" style="width:100%" /><label id="chooseshortcode" style="display:block;"></label><div class="shortcode"><input id="inlog5" type="number" pattern="[0-9]*" maxlength="5" onkeyup="if(this.value.length >= 5) { dojo.hitch(globalLoginRef, globalLoginRef.submitFullLogin)(); };" onfocus="this.value = \'\'" /></div></div><div id="quicklogin" style="display: none"><label id="givelogincode" style="display:block;"></label><div class="shortcode"><input id="qinlog5" type="number" pattern="[0-9]*" maxlength="5" onkeyup="if(this.value.length >= 5) { dojo.hitch(globalLoginRef, globalLoginRef.submitQuickLogin)(); };" onfocus="this.value = \'\'" /> </div><input type="button" onclick="dojo.hitch(globalLoginRef, globalLoginRef.reset)();" id="rechoose" class="button" /></div></div></div>' ,
7+ templateString : '<div class="mobileLogin"><div class="loginContainer"><div id="errormessages" class="alert alert-danger" style="display: none;">.</div><div id="fulllogin" style="display: none;"><label id="usernamelabel" style="display:block;">.</label><input id="username" class="textinput form-control" autocapitalize="off" autocorrect="off" type="text" style="width:100%" /><label id="passwordlabel" style="display:block;">.</label><input id="password" class="textinput form-control" autocapitalize="off" autocorrect="off" type="password" style="width:100%" /><label id="chooseshortcode" style="display:block;">.</label><div class="shortcode" style="width:100%;position:relative;"><div class="position" id="position1">.</div><div class="position" id="position2">.</div><div class="position" id="position3">.</div><div class="position" id="position4">.</div><div class="position" id="position5">.</div><input id="inlog5" type="number" class="shortcodeinput" pattern="[0-9]*" maxlength="5" style="background-color:transparent; border:0px;" onkeyup="dojo.hitch(globalLoginRef, globalLoginRef.submitFullLogin)();" onfocus="this.value = \'\'; dojo.hitch(globalLoginRef, globalLoginRef.inputChecker)(\'\');" /><div style="clear:both;visibility:hidden;height:0px;">.</div></div></div><div id="quicklogin" style="display: none"><label id="givelogincode" style="display:block;">.</label><div class="shortcode" style="width:100%;position:relative;"><div class="position" id="qposition1">.</div><div class="position" id="qposition2">.</div><div class="position" id="qposition3">.</div><div class="position" id="qposition4">.</div><div class="position" id="qposition5">.</div><input id="qinlog5" type="number" class="shortcodeinput" pattern="[0-9]*" maxlength="5" style="background-color:transparent; border:0px;" onkeyup="dojo.hitch(globalLoginRef, globalLoginRef.submitQuickLogin)();" onfocus="this.value = \'\'; dojo.hitch(globalLoginRef, globalLoginRef.inputChecker)(\'q\');" /><div style="clear:both;visibility:hidden;height:0px;">.</div></div><input type="button" style="display:block; clear:both;" onclick="dojo.hitch(globalLoginRef, globalLoginRef.reset)();" id="rechoose" class="btn btn-primary loginButton" /></div></div></div>' ,
88
99 inputargs : {
1010 urlMf : '' ,
@@ -52,8 +52,6 @@ mendix.widget.declare("SimpleLogin.SimpleLogin", {
5252
5353 this . guid = window . localStorage . getItem ( "devicecode" ) ;
5454
55- this . resetFieldValues ( ) ;
56-
5755 if ( this . guid != null ) {
5856 // show quick login
5957 dojo . byId ( "quicklogin" ) . style . display = "block" ;
@@ -70,43 +68,71 @@ mendix.widget.declare("SimpleLogin.SimpleLogin", {
7068 blocker : function ( ) {
7169 this . indicator . start ( ) ;
7270 } ,
73- submitFullLogin : function ( ) {
74- this . blocker ( ) ;
75-
76- this . removeError ( ) ;
77-
78- var username = dojo . byId ( "username" ) . value ;
79- var password = dojo . byId ( "password" ) . value ;
80- var shortcode = dojo . byId ( "inlog5" ) . value ;
81-
82- var xhrArgs = {
83- url : this . hostname + "/registerAppDevice/" ,
84- postData : "username=" + username + "&password=" + password + "&shortcode=" + shortcode ,
85- handleAs : "text" ,
86- load : dojo . hitch ( this , this . succesHandler ) ,
87- error : dojo . hitch ( this , this . errorHandler )
88- } ;
71+ inputChecker : function ( q ) {
72+ if ( typeof q == 'undefined' ) {
73+ q = "" ;
74+ }
75+ var shortcode = dojo . byId ( q + "inlog5" ) . value ;
76+ var position = shortcode . length + 1 ;
8977
90- dojo . xhrPost ( xhrArgs ) ;
91- this . resetFieldValues ( ) ;
78+ for ( var i = 1 ; i <= 5 ; i ++ ) {
79+ var el = dojo . byId ( q + "position" + i ) ;
80+ if ( position == i ) {
81+ dojo . removeClass ( el , "positionfilled" ) ;
82+ dojo . addClass ( el , "positionselected" ) ;
83+ }
84+ else if ( position < i ) {
85+ dojo . removeClass ( el , "positionfilled" ) ;
86+ dojo . removeClass ( el , "positionselected" ) ;
87+ }
88+ else {
89+ dojo . addClass ( el , "positionfilled" ) ;
90+ dojo . addClass ( el , "positionselected" ) ;
91+ }
92+
93+ }
94+ return position == 6 ;
95+ } ,
96+
97+ submitFullLogin : function ( ) {
98+ if ( this . inputChecker ( "" ) ) {
99+ this . blocker ( ) ;
100+
101+ this . removeError ( ) ;
102+
103+ var username = dojo . byId ( "username" ) . value ;
104+ var password = dojo . byId ( "password" ) . value ;
105+ var shortcode = dojo . byId ( "inlog5" ) . value ;
106+
107+ var xhrArgs = {
108+ url : this . hostname + "/registerAppDevice/" ,
109+ postData : "username=" + username + "&password=" + password + "&shortcode=" + shortcode ,
110+ handleAs : "text" ,
111+ load : dojo . hitch ( this , this . succesHandler ) ,
112+ error : dojo . hitch ( this , this . errorHandler )
113+ } ;
114+
115+ dojo . xhrPost ( xhrArgs ) ;
116+ }
92117 } ,
93118
94119 submitQuickLogin : function ( ) {
95- this . blocker ( ) ;
96-
97- this . removeError ( ) ;
98- var shortcode = dojo . byId ( "qinlog5" ) . value ;
99-
100- var xhrArgs = {
101- url : this . hostname + "/loginAppDevice/" ,
102- postData : "device=" + this . guid + "&shortcode=" + shortcode ,
103- handleAs : "text" ,
104- load : dojo . hitch ( this , this . succesHandlerQuickLogin ) ,
105- error : dojo . hitch ( this , this . errorHandler )
106- } ;
107-
108- dojo . xhrPost ( xhrArgs ) ;
109- this . resetFieldValues ( ) ;
120+ if ( this . inputChecker ( "q" ) ) {
121+ this . blocker ( ) ;
122+
123+ this . removeError ( ) ;
124+ var shortcode = dojo . byId ( "qinlog5" ) . value ;
125+
126+ var xhrArgs = {
127+ url : this . hostname + "/loginAppDevice/" ,
128+ postData : "device=" + this . guid + "&shortcode=" + shortcode ,
129+ handleAs : "text" ,
130+ load : dojo . hitch ( this , this . succesHandlerQuickLogin ) ,
131+ error : dojo . hitch ( this , this . errorHandler )
132+ } ;
133+
134+ dojo . xhrPost ( xhrArgs ) ;
135+ }
110136 } ,
111137
112138
@@ -121,11 +147,14 @@ mendix.widget.declare("SimpleLogin.SimpleLogin", {
121147 resetFieldValues : function ( ) {
122148 dojo . byId ( "inlog5" ) . value = "" ;
123149 dojo . byId ( "qinlog5" ) . value = "" ;
150+ this . inputChecker ( ) ;
124151
125152 } ,
126153 errorHandler : function ( ) {
127154 dojo . byId ( "errormessages" ) . innerHTML = this . loginFailed ;
128155 dojo . byId ( "errormessages" ) . style . display = "block" ;
156+
157+ this . resetFieldValues ( ) ;
129158 this . indicator . stop ( ) ;
130159 } ,
131160 removeError : function ( ) {
0 commit comments