Captcha And Password Strength in gwt-ext
package com.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Timer;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.logical.shared.OpenEvent;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.ui.Frame;
import com.gwtext.client.widgets.Toolbar;
import com.gwtext.client.widgets.ToolbarButton;
import com.gwtext.client.widgets.Window;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.google.gwt.user.client.ui.RichTextArea;
import com.smartgwt.client.widgets.Progressbar;
import com.smartgwt.client.widgets.layout.HLayout;
import com.gwtext.client.core.EventObject;
public class signup extends Composite{
final GreetingServiceAsync a1 = GWT.create(GreetingService.class);
RootPanel rootPanel = RootPanel.get();;
boolean flag;
AbsolutePanel absolutePanel= new AbsolutePanel();;
Image image;
TextBox fullname1 ;
TextBox Emailid;
TextBox confirmid;
Button Submitbutton;
Button changeyourpassword;
PasswordTextBox pass;
boolean f3;
int j=0,j1=0,j2=0,j3=0,j4=0;
String s5=null;
String s3=null;
String s1=null;
String s2=null;
ToolbarButton bold;
Toolbar tt;
String s4;
int k=0;
Label label;
Label captchaLabel ;
Label hBar1Label ;
Label hBar2Label ;
boolean flagprogress=false;
Label label_1;
Label label_2;
Label label_3;
Label label_4;
//com.gwtext.client.widgets.Button refreshimage;
Image captchaimg;
Image captchaimg1;
Frame frame;
Window window;
boolean flagcap=false;
Button cap;
Label caplabel;
RichTextArea richTextArea;
StringBuffer buf=null;
StringBuffer buf1=null;
TextBox captext ;
String imglen;
int colorno;
Image one;
Image two,three,four,five,six;
boolean flagone=false,flagtwo=false,flagthree=false,flagfour=false,flagsix=false;
Progressbar hBar2 ;
public signup()
{
// Window.alert("s");
//public void onModuleLoad() {
rootPanel.setStyleName("gwt-roo1");
absolutePanel.setStyleName("h1");
rootPanel.add(absolutePanel, 428, 89);
absolutePanel.setSize("600px", "528px");
image = new Image("13.jpg");
absolutePanel.add(image, 33, 10);
image.setSize("590px", "508px");
five = new Image("refimg.gif");
absolutePanel.add(five, 419, 365);
/*tt=new Toolbar();
tt.setAutoWidth(false);
absolutePanel.add(tt, 419, 365);
tt.setSize("47px", "20px");
bold=new ToolbarButton();
bold.setText("");
// bold.setTooltip("Bold");
bold.setCls("a");
bold.setToggleGroup("");
bold.setIcon("");
tt.addButton(bold);
bold.setSize("47px", "20px");*/
fullname1 = new TextBox();
absolutePanel.add(fullname1, 233, 49);
Emailid = new TextBox();
absolutePanel.add(Emailid, 233, 115);
confirmid = new TextBox();
absolutePanel.add(confirmid, 233, 175);
pass = new PasswordTextBox();
absolutePanel.add(pass, 233, 236);
Label lblFullName = new Label("Full Name");
lblFullName.setStyleName("gwt-Label-new");
absolutePanel.add(lblFullName, 47, 49);
lblFullName.setSize("90px", "21px");
Label lblPassword = new Label("Password");
lblPassword.setStyleName("gwt-Label-new");
absolutePanel.add(lblPassword, 47, 237);
Label lblConfirmPassword = new Label("Confirm Email Id");
lblConfirmPassword.setStyleName("gwt-Label-new");
absolutePanel.add(lblConfirmPassword, 47, 175);
Submitbutton = new Button("New button");
Submitbutton.setStyleName("gwt-Buttonnext");
Submitbutton.setText("Next");
absolutePanel.add(Submitbutton, 312, 464);
Submitbutton.setSize("63px", "22px");
Label lblCreateYourAccount = new Label("Create Your account");
lblCreateYourAccount.setStyleName("gwt-Label-new");
absolutePanel.add(lblCreateYourAccount, 48, 22);
lblCreateYourAccount.setSize("214px", "21px");
changeyourpassword = new Button("New button");
changeyourpassword.setStyleName("gwt-Buttonnext");
changeyourpassword.setText("Change Your Password");
// absolutePanel.add(changeyourpassword, 48, 318);
changeyourpassword.setSize("214px", "34px");
Label lblUsername = new Label("Email Id");
lblUsername.setStyleName("gwt-Label-new");
absolutePanel.add(lblUsername, 47, 115);
label = new Label("");
label.setStyleName("gwt-Label-new");
absolutePanel.add(label, 233, 89);
label.setSize("147px", "21px");
label = new Label("");
label.setStyleName("gwt-new1");
absolutePanel.add(label, 233, 89);
label.setSize("147px", "21px");
label_1 = new Label("");
label_1.setStyleName("gwt-new1");
absolutePanel.add(label_1, 227, 148);
label_1.setSize("153px", "21px");
label_2 = new Label("");
label_2.setStyleName("gwt-new1");
absolutePanel.add(label_2, 233, 203);
label_2.setSize("154px", "21px");
label_3 = new Label("");
label_3.setStyleName("gwt-new1");
absolutePanel.add(label_3, 227, 264);
label_3.setSize("51px", "21px");
label_4 = new Label("");
label_4.setStyleName("gwt-new1");
absolutePanel.add(label_4, 52, 464);
label_4.setSize("127px", "21px");
/* one = new Image("qmarkcustom.gif");
absolutePanel.add(one, 100, 464);
two = new Image("qmarkcustom.gif");
absolutePanel.add(two, 52, 464);
three = new Image("qmarkcustom.gif");
absolutePanel.add(three, 150, 464);
four = new Image("qmarkcustom.gif");
absolutePanel.add(four, 125, 464);
*/
captext = new TextBox();
absolutePanel.add(captext, 233, 422);
caplabel = new Label("");
absolutePanel.add(caplabel, 47, 423);
caplabel.setSize("146px", "11px");
String base = "0123456789CDEFGHIJKLMNOPQRSTUVWXYZ";
buf = new StringBuffer(5);
while(buf.length() < 5)
{
long n = Math.round(((Math.random() * 100)) % base.length());
buf.append(base.charAt((int)n));
}
String base1 = "01234";
buf1 = new StringBuffer(1);
while(buf1.length() < 1)
{
long n1 = Math.round(((Math.random() * 100)) % base1.length());
buf1.append(base1.charAt((int)n1));
// colorno=(int)n1;
}
// signup1 up1=new signup1();
// absolutePanel.clear();
// up1.onModuleLoad();
imglen=buf.toString();
String colorno1=buf1.toString();
char cc[]=colorno1.toCharArray();
colorno=(int)cc[0] ;
System.out.println(imglen);
System.out.println("hlll"+colorno);
a1.capcha(imglen,colorno,new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(String result) {
//captchaimg = new Image("http://localhost:80/gg1.php");
captchaimg = new Image("capcha.jpg");
captchaimg.setSize("180px", "45px");
absolutePanel.add(captchaimg, 233, 361);
}
});
pass.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) {
int alphabets=0;
int numbers=0;
int alphabetcapital=0;
int sum=0;
hBar1Label.setVisible(true);
hBar2.setVisible(true);
int len=pass.getText().length();
// int lastindex= pass.getText().lastIndexOf(1);
//char lastchar=pass.getText().charAt(lastindex+1);
//System.out.println("last index"+lastindex);
//System.out.println("last index"+lastchar);
System.out.println("len"+len);
for(int i=0;i<len;i++)
{
char bad=pass.getText().charAt(i);
System.out.println("last index"+bad);
if(bad>=(char)65 && bad<(char)92)
{
alphabetcapital=1;
}
if(bad>=(char)97 && bad<(char)122)
{
alphabets=1;
}
if(bad>=(char)48 && bad<(char)57)
{
numbers=1;
}
sum=alphabetcapital+alphabets+numbers;
System.out.println("sum"+sum);
}
if(sum==1)
{
hBar1Label.setText("Password Strength: "+sum*30+"%");
hBar2.setPercentDone((sum)*30);
}
if(sum==2 || pass.getText().length()<6)
{
hBar1Label.setText("Password Strength: "+sum*30+"%");
hBar2.setPercentDone((sum)*30);
}
if(sum==3 && pass.getText().length()>=6)
{
int hun=10+sum*30;
hBar1Label.setText("Password Strength: "+hun+"%");
hBar2.setPercentDone(hun);
}
if(pass.getText()=="")
{
hBar1Label.setText("Password Strength: "+0+"%");
hBar2.setPercentDone(0);
}
new Timer() {
public void run() {
//hBar1Value += 1 + (int) (10 * Math.random());
if(flagprogress==true)
{
hBar2Label.setVisible(false);
flagprogress=false;
}
else
{
}
}
}.schedule(50);
}
});
hBar1Label = new Label("Current File Progress");
hBar1Label.setHeight("16 px");
hBar1Label.setStyleName("gwt-new1");
hBar1Label.setVisible(false);
absolutePanel.add(hBar1Label,47,280);
captchaLabel = new Label(" Captcha");
captchaLabel.setHeight("34 px");
captchaLabel.setStyleName("gwt-Label-new");
absolutePanel.add(captchaLabel,47,361);
final HLayout progressBarLayout = new HLayout ();
hBar2 = new Progressbar();
// hBar2.setVertical(false);
// hBar2.setHeight(2);
//System.out.println(hBar2.getHeight()+"height");
hBar2.setVisible(false);
hBar2.setLength(175);
hBar2.setKeepInParentRect(true);
// horizontalBars.addMember(hBar2);
absolutePanel.add(hBar2,233,280);
hBar2.setHeight (15);
// hBar2.setWidth (500);
hBar2.setVertical (false);
progressBarLayout.addMember (hBar2);
/*changeyourpassword.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if(captext.getText()==imglen)
{
System.out.println("equal");
}
else
{
caplabel.setText("Incorrect");
System.out.println("not equal");
}
//change c1=new change();
//c1.onModuleLoad();
}
});*/
five.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// bold.addListener(new ButtonListenerAdapter() {
// public void onClick(com.gwtext.client.widgets.Button btn,EventObject event) {
System.out.println("refresh image");
String base = "0123456789CDEFGHIJKLMNOPQRSTUVWXYZ";
buf = new StringBuffer(5);
while(buf.length() < 5)
{
long n = Math.round(((Math.random() * 100)) % base.length());
buf.append(base.charAt((int)n));
}
String base1 = "01234";
buf1 = new StringBuffer(1);
while(buf1.length() < 1)
{
long n1 = Math.round(((Math.random() * 100)) % base1.length());
buf1.append(base1.charAt((int)n1));
// colorno=(int)n1;
}
imglen=buf.toString();
String colorno1=buf1.toString();
char cc[]=colorno1.toCharArray();
colorno=(int)cc[0] ;
System.out.println(imglen);
System.out.println("hlll"+colorno);
a1.capcha(imglen,colorno,new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(String result) {
System.out.println("hlllaajao");
captchaimg1 = new Image("http://localhost:80/gg1.php?"+k+"");
captchaimg1.setSize("180px", "45px");
absolutePanel.add(captchaimg1, 233, 361);
k=k+1;
System.out.println(k+"value");
}
});
}
});
pass.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent event) {
hBar2.setVisible(false);
hBar1Label.setVisible(false);
if(pass.getText().length()<6)
{
four= new Image("question.png");
absolutePanel.add(four, 390, 220);
flagfour=true;
if(j2==0)
{
four.setVisible(false);
}
else
{
pass.setFocus(true);
pass.setCursorPos(pass.getText().length());
}
four.addMouseOverHandler(new MouseOverHandler(){
public void onMouseOver(MouseOverEvent e)
{
five=new Image("password.png");
absolutePanel.add(five, 420, 200);
}
});
four.addMouseOutHandler(new MouseOutHandler(){
public void onMouseOut(MouseOutEvent e)
{
five.setVisible(false);
}
});
j=0;
}
else
{
if(flagfour==true)
four.setVisible(false);
j=1;
label.setText("");
}
}
});
fullname1.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent event) {
//int curlen=0;
s1=fullname1.getText();
char a[]=new char[100];
for(int i=0;i<s1.length();i++)
{
a[i]=s1.charAt(i);
if(!((a[i] >=(char)65 && a[i]<=(char)90) || (a[i]>=(char)97 && a[i]<=(char)122 )) || s1=="")
{
fullname1.setFocus(true);
fullname1.setCursorPos(fullname1.getText().length());
Emailid.setFocus(false);
one = new Image("question.png");
absolutePanel.add(one, 390, 40);
flagone=true;
one.addMouseOverHandler(new MouseOverHandler(){
public void onMouseOver(MouseOverEvent e)
{
five=new Image("logincallout.png");
absolutePanel.add(five, 420, 1);
}
});
one.addMouseOutHandler(new MouseOutHandler(){
public void onMouseOut(MouseOutEvent e)
{
five.setVisible(false);
}
});
j=0;
break;
}
else
{
if(flagone==true)
one.setVisible(false);
Emailid.setFocus(true);
j=1;
}
}
}
});
Emailid.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent event) {
s2=Emailid.getText();
if (!(s2.matches(".+@.+\\.[a-z]+")) || s2=="")
{
two = new Image("question.png");
absolutePanel.add(two, 390, 110);
if(j==0)
{
two.setVisible(false);
}
else
{
// two.setVisible(true);
Emailid.setFocus(true);
Emailid.setCursorPos(Emailid.getText().length());
}
flagtwo=true;
two.addMouseOverHandler(new MouseOverHandler(){
public void onMouseOver(MouseOverEvent e)
{
five=new Image("mail.png");
absolutePanel.add(five, 420, 100);
}
});
two.addMouseOutHandler(new MouseOutHandler(){
public void onMouseOut(MouseOutEvent e)
{
five.setVisible(false);
}
});
j1=0;
}
else
{
if(flagtwo==true)
two.setVisible(false);
j1=1;
}
}
});
confirmid.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent event) {
s3=confirmid.getText();
if (!(s3.matches(".+@.+\\.[a-z]+")) || s3=="")
{
three = new Image("question.png");
absolutePanel.add(three, 390, 160);
if(j1==0)
{
three.setVisible(false);
}
else
{
confirmid.setFocus(true);
confirmid.setCursorPos(confirmid.getText().length());
}
flagthree=true;
three.addMouseOverHandler(new MouseOverHandler(){
public void onMouseOver(MouseOverEvent e)
{
five=new Image("mail.png");
absolutePanel.add(five, 420, 170);
}
});
three.addMouseOutHandler(new MouseOutHandler(){
public void onMouseOut(MouseOutEvent e)
{
five.setVisible(false);
}
});
j2=0;
}
else if(!(s3.equals(s2)))
{
flagsix=true;
six = new Image("question.png");
absolutePanel.add(six, 390, 160);
if(j1==0)
{
six.setVisible(false);
}
else
{
confirmid.setFocus(true);
confirmid.setCursorPos(confirmid.getText().length());
}
six.addMouseOverHandler(new MouseOverHandler(){
public void onMouseOver(MouseOverEvent e)
{
five=new Image("match.png");
absolutePanel.add(five, 420, 170);
}
});
six.addMouseOutHandler(new MouseOutHandler(){
public void onMouseOut(MouseOutEvent e)
{
five.setVisible(false);
}
});
j2=0;
}
else
{
if(flagthree==true)
three.setVisible(false);
if(flagsix==true)
six.setVisible(false);
j2=1;
label_2.setText("");
}
}
});
Submitbutton.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent e)
{
//calcaptcha
String stext=captext.getText();
if(stext.equals(imglen))
{
caplabel.setText("");
}
else
{
caplabel.setStyleName("gwt-new1");
caplabel.setText("Incorrect");
System.out.println("not equal");
System.out.println("refresh image");
String base = "0123456789CDEFGHIJKLMNOPQRSTUVWXYZ";
buf = new StringBuffer(5);
while(buf.length() < 5)
{
long n = Math.round(((Math.random() * 100)) % base.length());
buf.append(base.charAt((int)n));
}
String base1 = "01234";
buf1 = new StringBuffer(1);
while(buf1.length() < 1)
{
long n1 = Math.round(((Math.random() * 100)) % base1.length());
buf1.append(base1.charAt((int)n1));
// colorno=(int)n1;
}
imglen=buf.toString();
String colorno1=buf1.toString();
char cc[]=colorno1.toCharArray();
colorno=(int)cc[0] ;
System.out.println(imglen);
System.out.println("hlll"+colorno);
a1.capcha(imglen,colorno,new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(String result) {
System.out.println("hlllaajao");
captchaimg1 = new Image("http://localhost:80/gg1.php?"+k+"");
captchaimg1.setSize("180px", "45px");
absolutePanel.add(captchaimg1, 233, 361);
k=k+1;
System.out.println(k+"value");
}
});
//callcaptcha
}
Cookies.setCookie("fullname", s1);
String fullname=Cookies.getCookie("fullname");
Cookies.setCookie("mail", s2);
String email=Cookies.getCookie("mail");
Cookies.setCookie("pass", s3);
String word=Cookies.getCookie("pass");
Cookies.setCookie("con", s4);
String con=Cookies.getCookie("con");
a1.setSession(new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(Void result) {
}
});
a1.signup(fullname,Emailid.getText(),pass.getText(),new AsyncCallback<String>() {
@Override
public void onSuccess(String arg0) {
// TODO Auto-generated method stub
System.out.println(arg0);
}
@Override
public void onFailure(Throwable arg0) {
// TODO Auto-generated method stub
//signin.setText("asd");
}
});
//if(j==1 && j1==1 && j2==1 && j3==1)
//{
if(!(fullname1.getText()=="" && pass.getText()=="" && Emailid.getText()=="" && confirmid.getText()==""))
{
signup1 s2=new signup1();
absolutePanel.clear();
rootPanel.clear();
s2.onModuleLoad();
}
}
});
/*one.addMouseOverHandler(new MouseOverHandler(){
@Override
public void onMouseOver(MouseOverEvent event) {
// TODO Auto-generated method stub
//four=new Image("callout_box.png");
//absolutePanel.add(four, 450, 30);
}
});*/
}
}
package com.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Timer;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.logical.shared.OpenEvent;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.ui.Frame;
import com.gwtext.client.widgets.Toolbar;
import com.gwtext.client.widgets.ToolbarButton;
import com.gwtext.client.widgets.Window;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.google.gwt.user.client.ui.RichTextArea;
import com.smartgwt.client.widgets.Progressbar;
import com.smartgwt.client.widgets.layout.HLayout;
import com.gwtext.client.core.EventObject;
public class signup extends Composite{
final GreetingServiceAsync a1 = GWT.create(GreetingService.class);
RootPanel rootPanel = RootPanel.get();;
boolean flag;
AbsolutePanel absolutePanel= new AbsolutePanel();;
Image image;
TextBox fullname1 ;
TextBox Emailid;
TextBox confirmid;
Button Submitbutton;
Button changeyourpassword;
PasswordTextBox pass;
boolean f3;
int j=0,j1=0,j2=0,j3=0,j4=0;
String s5=null;
String s3=null;
String s1=null;
String s2=null;
ToolbarButton bold;
Toolbar tt;
String s4;
int k=0;
Label label;
Label captchaLabel ;
Label hBar1Label ;
Label hBar2Label ;
boolean flagprogress=false;
Label label_1;
Label label_2;
Label label_3;
Label label_4;
//com.gwtext.client.widgets.Button refreshimage;
Image captchaimg;
Image captchaimg1;
Frame frame;
Window window;
boolean flagcap=false;
Button cap;
Label caplabel;
RichTextArea richTextArea;
StringBuffer buf=null;
StringBuffer buf1=null;
TextBox captext ;
String imglen;
int colorno;
Image one;
Image two,three,four,five,six;
boolean flagone=false,flagtwo=false,flagthree=false,flagfour=false,flagsix=false;
Progressbar hBar2 ;
public signup()
{
// Window.alert("s");
//public void onModuleLoad() {
rootPanel.setStyleName("gwt-roo1");
absolutePanel.setStyleName("h1");
rootPanel.add(absolutePanel, 428, 89);
absolutePanel.setSize("600px", "528px");
image = new Image("13.jpg");
absolutePanel.add(image, 33, 10);
image.setSize("590px", "508px");
five = new Image("refimg.gif");
absolutePanel.add(five, 419, 365);
/*tt=new Toolbar();
tt.setAutoWidth(false);
absolutePanel.add(tt, 419, 365);
tt.setSize("47px", "20px");
bold=new ToolbarButton();
bold.setText("");
// bold.setTooltip("Bold");
bold.setCls("a");
bold.setToggleGroup("");
bold.setIcon("");
tt.addButton(bold);
bold.setSize("47px", "20px");*/
fullname1 = new TextBox();
absolutePanel.add(fullname1, 233, 49);
Emailid = new TextBox();
absolutePanel.add(Emailid, 233, 115);
confirmid = new TextBox();
absolutePanel.add(confirmid, 233, 175);
pass = new PasswordTextBox();
absolutePanel.add(pass, 233, 236);
Label lblFullName = new Label("Full Name");
lblFullName.setStyleName("gwt-Label-new");
absolutePanel.add(lblFullName, 47, 49);
lblFullName.setSize("90px", "21px");
Label lblPassword = new Label("Password");
lblPassword.setStyleName("gwt-Label-new");
absolutePanel.add(lblPassword, 47, 237);
Label lblConfirmPassword = new Label("Confirm Email Id");
lblConfirmPassword.setStyleName("gwt-Label-new");
absolutePanel.add(lblConfirmPassword, 47, 175);
Submitbutton = new Button("New button");
Submitbutton.setStyleName("gwt-Buttonnext");
Submitbutton.setText("Next");
absolutePanel.add(Submitbutton, 312, 464);
Submitbutton.setSize("63px", "22px");
Label lblCreateYourAccount = new Label("Create Your account");
lblCreateYourAccount.setStyleName("gwt-Label-new");
absolutePanel.add(lblCreateYourAccount, 48, 22);
lblCreateYourAccount.setSize("214px", "21px");
changeyourpassword = new Button("New button");
changeyourpassword.setStyleName("gwt-Buttonnext");
changeyourpassword.setText("Change Your Password");
// absolutePanel.add(changeyourpassword, 48, 318);
changeyourpassword.setSize("214px", "34px");
Label lblUsername = new Label("Email Id");
lblUsername.setStyleName("gwt-Label-new");
absolutePanel.add(lblUsername, 47, 115);
label = new Label("");
label.setStyleName("gwt-Label-new");
absolutePanel.add(label, 233, 89);
label.setSize("147px", "21px");
label = new Label("");
label.setStyleName("gwt-new1");
absolutePanel.add(label, 233, 89);
label.setSize("147px", "21px");
label_1 = new Label("");
label_1.setStyleName("gwt-new1");
absolutePanel.add(label_1, 227, 148);
label_1.setSize("153px", "21px");
label_2 = new Label("");
label_2.setStyleName("gwt-new1");
absolutePanel.add(label_2, 233, 203);
label_2.setSize("154px", "21px");
label_3 = new Label("");
label_3.setStyleName("gwt-new1");
absolutePanel.add(label_3, 227, 264);
label_3.setSize("51px", "21px");
label_4 = new Label("");
label_4.setStyleName("gwt-new1");
absolutePanel.add(label_4, 52, 464);
label_4.setSize("127px", "21px");
/* one = new Image("qmarkcustom.gif");
absolutePanel.add(one, 100, 464);
two = new Image("qmarkcustom.gif");
absolutePanel.add(two, 52, 464);
three = new Image("qmarkcustom.gif");
absolutePanel.add(three, 150, 464);
four = new Image("qmarkcustom.gif");
absolutePanel.add(four, 125, 464);
*/
captext = new TextBox();
absolutePanel.add(captext, 233, 422);
caplabel = new Label("");
absolutePanel.add(caplabel, 47, 423);
caplabel.setSize("146px", "11px");
String base = "0123456789CDEFGHIJKLMNOPQRSTUVWXYZ";
buf = new StringBuffer(5);
while(buf.length() < 5)
{
long n = Math.round(((Math.random() * 100)) % base.length());
buf.append(base.charAt((int)n));
}
String base1 = "01234";
buf1 = new StringBuffer(1);
while(buf1.length() < 1)
{
long n1 = Math.round(((Math.random() * 100)) % base1.length());
buf1.append(base1.charAt((int)n1));
// colorno=(int)n1;
}
// signup1 up1=new signup1();
// absolutePanel.clear();
// up1.onModuleLoad();
imglen=buf.toString();
String colorno1=buf1.toString();
char cc[]=colorno1.toCharArray();
colorno=(int)cc[0] ;
System.out.println(imglen);
System.out.println("hlll"+colorno);
a1.capcha(imglen,colorno,new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(String result) {
//captchaimg = new Image("http://localhost:80/gg1.php");
captchaimg = new Image("capcha.jpg");
captchaimg.setSize("180px", "45px");
absolutePanel.add(captchaimg, 233, 361);
}
});
pass.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) {
int alphabets=0;
int numbers=0;
int alphabetcapital=0;
int sum=0;
hBar1Label.setVisible(true);
hBar2.setVisible(true);
int len=pass.getText().length();
// int lastindex= pass.getText().lastIndexOf(1);
//char lastchar=pass.getText().charAt(lastindex+1);
//System.out.println("last index"+lastindex);
//System.out.println("last index"+lastchar);
System.out.println("len"+len);
for(int i=0;i<len;i++)
{
char bad=pass.getText().charAt(i);
System.out.println("last index"+bad);
if(bad>=(char)65 && bad<(char)92)
{
alphabetcapital=1;
}
if(bad>=(char)97 && bad<(char)122)
{
alphabets=1;
}
if(bad>=(char)48 && bad<(char)57)
{
numbers=1;
}
sum=alphabetcapital+alphabets+numbers;
System.out.println("sum"+sum);
}
if(sum==1)
{
hBar1Label.setText("Password Strength: "+sum*30+"%");
hBar2.setPercentDone((sum)*30);
}
if(sum==2 || pass.getText().length()<6)
{
hBar1Label.setText("Password Strength: "+sum*30+"%");
hBar2.setPercentDone((sum)*30);
}
if(sum==3 && pass.getText().length()>=6)
{
int hun=10+sum*30;
hBar1Label.setText("Password Strength: "+hun+"%");
hBar2.setPercentDone(hun);
}
if(pass.getText()=="")
{
hBar1Label.setText("Password Strength: "+0+"%");
hBar2.setPercentDone(0);
}
new Timer() {
public void run() {
//hBar1Value += 1 + (int) (10 * Math.random());
if(flagprogress==true)
{
hBar2Label.setVisible(false);
flagprogress=false;
}
else
{
}
}
}.schedule(50);
}
});
hBar1Label = new Label("Current File Progress");
hBar1Label.setHeight("16 px");
hBar1Label.setStyleName("gwt-new1");
hBar1Label.setVisible(false);
absolutePanel.add(hBar1Label,47,280);
captchaLabel = new Label(" Captcha");
captchaLabel.setHeight("34 px");
captchaLabel.setStyleName("gwt-Label-new");
absolutePanel.add(captchaLabel,47,361);
final HLayout progressBarLayout = new HLayout ();
hBar2 = new Progressbar();
// hBar2.setVertical(false);
// hBar2.setHeight(2);
//System.out.println(hBar2.getHeight()+"height");
hBar2.setVisible(false);
hBar2.setLength(175);
hBar2.setKeepInParentRect(true);
// horizontalBars.addMember(hBar2);
absolutePanel.add(hBar2,233,280);
hBar2.setHeight (15);
// hBar2.setWidth (500);
hBar2.setVertical (false);
progressBarLayout.addMember (hBar2);
/*changeyourpassword.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if(captext.getText()==imglen)
{
System.out.println("equal");
}
else
{
caplabel.setText("Incorrect");
System.out.println("not equal");
}
//change c1=new change();
//c1.onModuleLoad();
}
});*/
five.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// bold.addListener(new ButtonListenerAdapter() {
// public void onClick(com.gwtext.client.widgets.Button btn,EventObject event) {
System.out.println("refresh image");
String base = "0123456789CDEFGHIJKLMNOPQRSTUVWXYZ";
buf = new StringBuffer(5);
while(buf.length() < 5)
{
long n = Math.round(((Math.random() * 100)) % base.length());
buf.append(base.charAt((int)n));
}
String base1 = "01234";
buf1 = new StringBuffer(1);
while(buf1.length() < 1)
{
long n1 = Math.round(((Math.random() * 100)) % base1.length());
buf1.append(base1.charAt((int)n1));
// colorno=(int)n1;
}
imglen=buf.toString();
String colorno1=buf1.toString();
char cc[]=colorno1.toCharArray();
colorno=(int)cc[0] ;
System.out.println(imglen);
System.out.println("hlll"+colorno);
a1.capcha(imglen,colorno,new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(String result) {
System.out.println("hlllaajao");
captchaimg1 = new Image("http://localhost:80/gg1.php?"+k+"");
captchaimg1.setSize("180px", "45px");
absolutePanel.add(captchaimg1, 233, 361);
k=k+1;
System.out.println(k+"value");
}
});
}
});
pass.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent event) {
hBar2.setVisible(false);
hBar1Label.setVisible(false);
if(pass.getText().length()<6)
{
four= new Image("question.png");
absolutePanel.add(four, 390, 220);
flagfour=true;
if(j2==0)
{
four.setVisible(false);
}
else
{
pass.setFocus(true);
pass.setCursorPos(pass.getText().length());
}
four.addMouseOverHandler(new MouseOverHandler(){
public void onMouseOver(MouseOverEvent e)
{
five=new Image("password.png");
absolutePanel.add(five, 420, 200);
}
});
four.addMouseOutHandler(new MouseOutHandler(){
public void onMouseOut(MouseOutEvent e)
{
five.setVisible(false);
}
});
j=0;
}
else
{
if(flagfour==true)
four.setVisible(false);
j=1;
label.setText("");
}
}
});
fullname1.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent event) {
//int curlen=0;
s1=fullname1.getText();
char a[]=new char[100];
for(int i=0;i<s1.length();i++)
{
a[i]=s1.charAt(i);
if(!((a[i] >=(char)65 && a[i]<=(char)90) || (a[i]>=(char)97 && a[i]<=(char)122 )) || s1=="")
{
fullname1.setFocus(true);
fullname1.setCursorPos(fullname1.getText().length());
Emailid.setFocus(false);
one = new Image("question.png");
absolutePanel.add(one, 390, 40);
flagone=true;
one.addMouseOverHandler(new MouseOverHandler(){
public void onMouseOver(MouseOverEvent e)
{
five=new Image("logincallout.png");
absolutePanel.add(five, 420, 1);
}
});
one.addMouseOutHandler(new MouseOutHandler(){
public void onMouseOut(MouseOutEvent e)
{
five.setVisible(false);
}
});
j=0;
break;
}
else
{
if(flagone==true)
one.setVisible(false);
Emailid.setFocus(true);
j=1;
}
}
}
});
Emailid.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent event) {
s2=Emailid.getText();
if (!(s2.matches(".+@.+\\.[a-z]+")) || s2=="")
{
two = new Image("question.png");
absolutePanel.add(two, 390, 110);
if(j==0)
{
two.setVisible(false);
}
else
{
// two.setVisible(true);
Emailid.setFocus(true);
Emailid.setCursorPos(Emailid.getText().length());
}
flagtwo=true;
two.addMouseOverHandler(new MouseOverHandler(){
public void onMouseOver(MouseOverEvent e)
{
five=new Image("mail.png");
absolutePanel.add(five, 420, 100);
}
});
two.addMouseOutHandler(new MouseOutHandler(){
public void onMouseOut(MouseOutEvent e)
{
five.setVisible(false);
}
});
j1=0;
}
else
{
if(flagtwo==true)
two.setVisible(false);
j1=1;
}
}
});
confirmid.addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent event) {
s3=confirmid.getText();
if (!(s3.matches(".+@.+\\.[a-z]+")) || s3=="")
{
three = new Image("question.png");
absolutePanel.add(three, 390, 160);
if(j1==0)
{
three.setVisible(false);
}
else
{
confirmid.setFocus(true);
confirmid.setCursorPos(confirmid.getText().length());
}
flagthree=true;
three.addMouseOverHandler(new MouseOverHandler(){
public void onMouseOver(MouseOverEvent e)
{
five=new Image("mail.png");
absolutePanel.add(five, 420, 170);
}
});
three.addMouseOutHandler(new MouseOutHandler(){
public void onMouseOut(MouseOutEvent e)
{
five.setVisible(false);
}
});
j2=0;
}
else if(!(s3.equals(s2)))
{
flagsix=true;
six = new Image("question.png");
absolutePanel.add(six, 390, 160);
if(j1==0)
{
six.setVisible(false);
}
else
{
confirmid.setFocus(true);
confirmid.setCursorPos(confirmid.getText().length());
}
six.addMouseOverHandler(new MouseOverHandler(){
public void onMouseOver(MouseOverEvent e)
{
five=new Image("match.png");
absolutePanel.add(five, 420, 170);
}
});
six.addMouseOutHandler(new MouseOutHandler(){
public void onMouseOut(MouseOutEvent e)
{
five.setVisible(false);
}
});
j2=0;
}
else
{
if(flagthree==true)
three.setVisible(false);
if(flagsix==true)
six.setVisible(false);
j2=1;
label_2.setText("");
}
}
});
Submitbutton.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent e)
{
//calcaptcha
String stext=captext.getText();
if(stext.equals(imglen))
{
caplabel.setText("");
}
else
{
caplabel.setStyleName("gwt-new1");
caplabel.setText("Incorrect");
System.out.println("not equal");
System.out.println("refresh image");
String base = "0123456789CDEFGHIJKLMNOPQRSTUVWXYZ";
buf = new StringBuffer(5);
while(buf.length() < 5)
{
long n = Math.round(((Math.random() * 100)) % base.length());
buf.append(base.charAt((int)n));
}
String base1 = "01234";
buf1 = new StringBuffer(1);
while(buf1.length() < 1)
{
long n1 = Math.round(((Math.random() * 100)) % base1.length());
buf1.append(base1.charAt((int)n1));
// colorno=(int)n1;
}
imglen=buf.toString();
String colorno1=buf1.toString();
char cc[]=colorno1.toCharArray();
colorno=(int)cc[0] ;
System.out.println(imglen);
System.out.println("hlll"+colorno);
a1.capcha(imglen,colorno,new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(String result) {
System.out.println("hlllaajao");
captchaimg1 = new Image("http://localhost:80/gg1.php?"+k+"");
captchaimg1.setSize("180px", "45px");
absolutePanel.add(captchaimg1, 233, 361);
k=k+1;
System.out.println(k+"value");
}
});
//callcaptcha
}
Cookies.setCookie("fullname", s1);
String fullname=Cookies.getCookie("fullname");
Cookies.setCookie("mail", s2);
String email=Cookies.getCookie("mail");
Cookies.setCookie("pass", s3);
String word=Cookies.getCookie("pass");
Cookies.setCookie("con", s4);
String con=Cookies.getCookie("con");
a1.setSession(new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(Void result) {
}
});
a1.signup(fullname,Emailid.getText(),pass.getText(),new AsyncCallback<String>() {
@Override
public void onSuccess(String arg0) {
// TODO Auto-generated method stub
System.out.println(arg0);
}
@Override
public void onFailure(Throwable arg0) {
// TODO Auto-generated method stub
//signin.setText("asd");
}
});
//if(j==1 && j1==1 && j2==1 && j3==1)
//{
if(!(fullname1.getText()=="" && pass.getText()=="" && Emailid.getText()=="" && confirmid.getText()==""))
{
signup1 s2=new signup1();
absolutePanel.clear();
rootPanel.clear();
s2.onModuleLoad();
}
}
});
/*one.addMouseOverHandler(new MouseOverHandler(){
@Override
public void onMouseOver(MouseOverEvent event) {
// TODO Auto-generated method stub
//four=new Image("callout_box.png");
//absolutePanel.add(four, 450, 30);
}
});*/
}
}