From 6bbd6346c36ab83ff43211c57cc399c4e86d3326 Mon Sep 17 00:00:00 2001 From: joethei Date: Fri, 5 Apr 2019 10:08:06 +0200 Subject: [PATCH] Orderinfo fertig --- src/main/webapp/preview/index.html | 3 +- src/main/webapp/preview/orderinfo.html | 103 ++++++++++--------------- 2 files changed, 43 insertions(+), 63 deletions(-) diff --git a/src/main/webapp/preview/index.html b/src/main/webapp/preview/index.html index 1e35b4f..e80215c 100644 --- a/src/main/webapp/preview/index.html +++ b/src/main/webapp/preview/index.html @@ -5,4 +5,5 @@ Bücherliste
Buchdetails
Bestätigung
-Warenkorb
\ No newline at end of file +Warenkorb
+Bestellinfos \ No newline at end of file diff --git a/src/main/webapp/preview/orderinfo.html b/src/main/webapp/preview/orderinfo.html index 16665f8..5c7b3db 100644 --- a/src/main/webapp/preview/orderinfo.html +++ b/src/main/webapp/preview/orderinfo.html @@ -18,17 +18,15 @@ -
-

All form fields are required.

- +
- - - - - + + + + + @@ -36,17 +34,15 @@
-
-

All form fields are required.

- +
- - - - - - + + + + + + @@ -260,7 +256,7 @@ $( function() { - var dialog, form, + var address, account, account_form, address_form, // From http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#e-mail-state-%28type=email%29 emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, @@ -270,26 +266,6 @@ allFields = $( [] ).add( name ).add( email ).add( password ), tips = $( ".validateTips" ); - function updateTips( t ) { - tips - .text( t ) - .addClass( "ui-state-highlight" ); - setTimeout(function() { - tips.removeClass( "ui-state-highlight", 1500 ); - }, 500 ); - } - - function checkLength( o, n, min, max ) { - if ( o.val().length > max || o.val().length < min ) { - o.addClass( "ui-state-error" ); - updateTips( "Length of " + n + " must be between " + - min + " and " + max + "." ); - return false; - } else { - return true; - } - } - function checkRegexp( o, regexp, n ) { if ( !( regexp.test( o.val() ) ) ) { o.addClass( "ui-state-error" ); @@ -301,35 +277,16 @@ } function addUser() { - var valid = true; - allFields.removeClass( "ui-state-error" ); - valid = valid && checkLength( name, "username", 3, 16 ); - valid = valid && checkLength( email, "email", 6, 80 ); - valid = valid && checkLength( password, "password", 5, 16 ); - - valid = valid && checkRegexp( name, /^[a-z]([0-9a-z_\s])+$/i, "Username may consist of a-z, 0-9, underscores, spaces and must begin with a letter." ); - valid = valid && checkRegexp( email, emailRegex, "eg. ui@jquery.com" ); - valid = valid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" ); - - if ( valid ) { - $( "#users tbody" ).append( "" + - "" + name.val() + "" + - "" + email.val() + "" + - "" + password.val() + "" + - "" ); - dialog.dialog( "close" ); - } - return valid; } - dialog = $( "#add-account-form" ).dialog({ + address = $( "#add-address-form" ).dialog({ autoOpen: false, height: 400, width: 350, modal: true, buttons: { - "Create an account": addUser, + "hinzufügen": addUser, Cancel: function() { dialog.dialog( "close" ); } @@ -340,16 +297,38 @@ } }); - form = dialog.find( "form" ).on( "submit", function( event ) { + account = $( "#add-account-form" ).dialog({ + autoOpen: false, + height: 400, + width: 350, + modal: true, + buttons: { + "hinzufügen": addUser, + Cancel: function() { + dialog.dialog( "close" ); + } + }, + close: function() { + form[ 0 ].reset(); + allFields.removeClass( "ui-state-error" ); + } + }); + + account_form = account.find( "form" ).on( "submit", function( event ) { + event.preventDefault(); + addUser(); + }); + + address_form = account.find( "form" ).on( "submit", function( event ) { event.preventDefault(); addUser(); }); $( "#add-account" ).button().on( "click", function() { - dialog.dialog( "open" ); + account.dialog( "open" ); }); $( "#add-address" ).button().on( "click", function() { - dialog.dialog( "open" ); + address.dialog( "open" ); }); } );