diff --git a/public/js/account.js b/public/js/account.js deleted file mode 100644 index 59d74ae82599be37ddc79c93ec28c794e7d8840f..0000000000000000000000000000000000000000 --- a/public/js/account.js +++ /dev/null @@ -1,35 +0,0 @@ -/* -TODO: - Show list of registered services? -*/ - -// Profile Initialization -$.get( "/api/v1/profile", function(data) { - var title = data.title - var firstname = data.firstname - var lastname = data.lastname - var email = data.email - var industry = data.industry - var organisation = data.organisation - var speciality = data.speciality - - // asign to HTML - $("#fullname").text(firstname+' '+lastname); - //document.getElementById('inputFirstname').value = firstname; //JS - $("#inputTitle").val(title); // jQuery - $("#inputFirstname").val(firstname); - $("#inputLastname").val(lastname); - $("#inputEmail").val(email); - $("#inputIndustry").val(industry); - $("#inputOrganisation").val(organisation); - $("#inputSpeciality").val(speciality); -}) -.done(function() { - console.log("done"); -}) -.fail(function() { - console.log( "error" ); -}) -/*.always(function() { - alert( "finished" ); -}) */ \ No newline at end of file diff --git a/public/js/generalFunction.js b/public/js/generalFunction.js index 1347bb5e2a3da52e5482457c0887d21401ce750b..5aeafdcc39c439733b511c73af61cef5eeffe87b 100644 --- a/public/js/generalFunction.js +++ b/public/js/generalFunction.js @@ -1,30 +1,9 @@ -// check password and password confirmation input fields -$('#inputNewPwd, #inputConfirm').on('keyup', function () { - var isBest = false; - var isMatch = false; - - // password best practice - if ($('#inputNewPwd').val().length < 8) { - $('#recommendation').html('Must be at least 8 characters').css('color', 'red'); +// password requirement +function checkPasswordReq(pwd) { + if (pwd.length < 8) { isBest = false; } else { - $('#recommendation').html('').css('color', 'red'); isBest = true; } - - // match or not? - if ($('#inputNewPwd').val() == $('#inputConfirm').val()) { - $('#message').html('Matching').css('color', 'green'); - isMatch = true; - } else { - $('#message').html('Not Matching').css('color', 'red'); - isMatch = false; - } - - // enable/disable update button - if (isBest && isMatch) { - $('#updateBtn').prop('disabled', false); - } else { - $('#updateBtn').prop('disabled', true); - } -}); \ No newline at end of file + return isBest +} \ No newline at end of file diff --git a/public/js/security.js b/public/js/security.js new file mode 100644 index 0000000000000000000000000000000000000000..52b42f148943c5e1671d4141bcd3097523196132 --- /dev/null +++ b/public/js/security.js @@ -0,0 +1,26 @@ +// check password and password confirmation input fields +$('#inputNewPwd, #inputConfirm').on('keyup', function () { + var isBest, isMatch; + + isBest = checkPasswordReq($('#inputNewPwd').val()) + $('#recommendation').empty(); + if (!isBest) { + $('#recommendation').html('Must be at least 8 characters').css('color', 'red'); + } + + // match or not? + if ($('#inputNewPwd').val() == $('#inputConfirm').val()) { + $('#message').html('Matching').css('color', 'green'); + isMatch = true; + } else { + $('#message').html('Not Matching').css('color', 'red'); + isMatch = false; + } + + // enable/disable update button + if (isBest && isMatch) { + $('#updateBtn').prop('disabled', false); + } else { + $('#updateBtn').prop('disabled', true); + } +}); \ No newline at end of file diff --git a/views/profile.pug b/views/profile.pug index e2800ded16183e4cf33491a2e92e0ca41c0675a4..3d329f524ee46b7335401af160b6d88bc07b99fb 100644 --- a/views/profile.pug +++ b/views/profile.pug @@ -32,12 +32,12 @@ html(lang="en") div(class="row") div(class="col-3") h5 - span#fullname + span #{user.firstname} #{user.lastname} div(class="nav flex-column nav-pills", id="v-pills-tab", role="tablist", aria-orientation="vertical") a(class="nav-link" href="#" aria-selected="true") Profile a(class="nav-link" href="/security" aria-selected="false") Security a(class="nav-link" href="/services" aria-selected="false") Services - div(class="col-sm-9") + div(class="col-sm-8") if successes for success in successes div.alert.alert-success.alert-dismissible #{ success } @@ -47,32 +47,38 @@ html(lang="en") div.alert.alert-danger.alert-dismissible.fade.show #{ error } a(class="close", href="#", data-dismiss="alert", aria-label="close") × form#profileForm(method="POST",action="/updateProfile") - div(class="form-group row") - label(for="title") Title - select#inputTitle(name="inputTitle", class="form-control") - option(value="Frau") Frau - option(value="Herr") Herr - option(value="Frau/Herr") Frau/Herr - option(value="Dr.") Dr. - option(value="Prof. Dr.") Prof. Dr. - div(class="form-group row") - label(for="firstname") Vorname - input#inputFirstname(name="inputFirstname", type="text", class="form-control", placeholder="Vorname" required) - div(class="form-group row") - label(for="lastname") Nachname - input#inputLastname(name="inputLastname", type="text", class="form-control", placeholder="Nachname" required) - div(class="form-group row") - label(for="email") Email - input#inputEmail(name="inputEmail", type="email", class="form-control", placeholder="Email" required) - div(class="form-group row") - label(for="organisation") Unternehmen - input#inputOrganisation(name="inputOrganisation", type="text", class="form-control", placeholder="Unternehmen") - div(class="form-group row") - label(for="industry") Branche - input#inputIndustry(name="inputIndustry", type="text", class="form-control", placeholder="Branche") - div(class="form-group row") - label(for="speciality") Fachgebiete - input#inputSpeciality(name="inputSpeciality", type="text", class="form-control", placeholder="Fachgebiete") + div(class="form-row") + div(class='form-group col-md-2') + label(for="title") Title + // to read: https://stackoverflow.com/questions/39997579/pug-templates-how-to-mark-option-in-dropdown-list-as-selected + select#inputTitle(name="inputTitle", class="form-control", value=user.title) + option(value="Frau/Herr") Frau/Herr + option(value="Frau") Frau + option(value="Herr") Herr + option(value="Dr.") Dr. + option(value="Prof. Dr.") Prof. Dr. + div(class='form-group col-md-3') + label(for="firstname") Vorname + input#inputFirstname(name="inputFirstname", type="text", class="form-control", placeholder="Vorname", value=user.firstname required) + div(class='form-group col-md-3') + label(for="lastname") Nachname + input#inputLastname(name="inputLastname", type="text", class="form-control", placeholder="Nachname", value=user.lastname required) + div(class="form-row") + div(class='form-group col-md-8') + label(for="email") Email + input#inputEmail(name="inputEmail", type="email", class="form-control", placeholder="Email", value=email required) + div(class="form-row") + div(class='form-group col-md-8') + label(for="organisation") Unternehmen + input#inputOrganisation(name="inputOrganisation", type="text", class="form-control", placeholder="Unternehmen", value=user.organisation) + div(class="form-row") + div(class='form-group col-md-8') + label(for="industry") Branche + input#inputIndustry(name="inputIndustry", type="text", class="form-control", placeholder="Branche", value=user.industry) + div(class="form-row") + div(class='form-group col-md-8') + label(for="speciality") Fachgebiete + input#inputSpeciality(name="inputSpeciality", type="text", class="form-control", placeholder="Fachgebiete", value=user.speciality) input(type="submit", class="btn btn-primary", value="Update") // jQuery @@ -81,5 +87,5 @@ html(lang="en") // Bootstrap script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous") // M4_LAB - script(src="/js/account.js") + //script(src="/js/account.js") script(src="https://transfer.hft-stuttgart.de/js/headfoot.js") \ No newline at end of file diff --git a/views/security.pug b/views/security.pug index 8d2f9700f1726f98d3efb03262394dacccd6e2ce..0bdea4cf0c6d59d8da7774243390af98dca0f05d 100644 --- a/views/security.pug +++ b/views/security.pug @@ -27,12 +27,15 @@ html(lang="en") -o-transition-property: height,visibility; transition-property: height,visibility; } + .warning { + font-size: 11px; + } body div(class="container-fluid") div(class="row") div(class="col-3") h5 - span#fullname + span #{user.firstName} #{user.lastName} div(class="nav flex-column nav-pills", id="v-pills-tab", role="tablist", aria-orientation="vertical") a(class="nav-link" href="/profile" aria-selected="true") Profile a(class="nav-link" href="#" aria-selected="false") Security @@ -47,20 +50,23 @@ html(lang="en") div.alert.alert-danger.alert-dismissible.fade.show #{ error } a(class="close", href="#", data-dismiss="alert", aria-label="close") × form(class="needs-validation", method="post", action="/changePwd" novalidate) - div(class="form-group row") - label(for="currPwd") Current Password - input(id="inputCurrPwd", name="inputCurrPwd", type="password", class="form-control" required) - div(class="invalid-feedback") Please fill in this field. - div(class="form-group row") - label(for="newPwd") New Password - input#inputNewPwd(name="inputNewPwd", type="password", class="form-control" required) - span#recommendation - div(class="invalid-feedback") Please fill in this field. - div(class="form-group row") - label(for="confirm") Confirm New Password - input#inputConfirm(name="inputConfirm", type="password", class="form-control" required) - span#message - div(class="invalid-feedback") Please fill in this field. + div(class="form-row") + div(class='form-group col-md-6') + label(for="currPwd") Current Password + input(id="inputCurrPwd", name="inputCurrPwd", type="password", class="form-control" required) + div(class="invalid-feedback") Please fill in this field. + div(class="form-row") + div(class='form-group col-md-6') + label(for="newPwd") New Password + input#inputNewPwd(name="inputNewPwd", type="password", class="form-control" required) + span#recommendation(class='warning') + div(class="invalid-feedback") Please fill in this field. + div(class="form-row") + div(class='form-group col-md-6') + label(for="confirm") Confirm New Password + input#inputConfirm(name="inputConfirm", type="password", class="form-control" required) + span#message(class='warning') + div(class="invalid-feedback") Please fill in this field. input#updateBtn(type="submit", class="btn btn-primary", value="Update Password" disabled) // jQuery @@ -69,8 +75,8 @@ html(lang="en") // Bootstrap script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous") // M4_LAB - script(src="/js/account.js") script(src="/js/generalFunction.js") + script(src="/js/security.js") script(src="https://transfer.hft-stuttgart.de/js/headfoot.js") script. // check input fields