Skip to content

Commit

Permalink
fix(contact): Improve paste from linkedin
Browse files Browse the repository at this point in the history
Fill form contact name
  • Loading branch information
gnovaro committed Mar 20, 2024
1 parent a7dc8f0 commit 885c9ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions resources/views/contact/contact_form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ class="form-control form-control-lg">
<input type="url" name="contact_linkedin" id="contact_linkedin"
placeholder="https://linkedin.com/in/"
value="{{ !empty($contact->linkedin) ? $contact->linkedin : '' }}"
class="form-control form-control-lg">
class="form-control form-control-lg"
onblur="updateNameFromLinkedIn(this.value)"
>
</div>
</div>
<div class="col">
Expand Down Expand Up @@ -113,13 +115,9 @@ function isEmpty(str) {
return (!str || str.trim().length === 0);
}
function removeLastWord(str) {
return str.replace(/\s\S*$/, '');
}
function updateNameFromLinkedIn(url) {
if (url) {
let matches = url.match(/linkedin\.com\/in\/([^\/]+)\//);
let matches = url.match(/linkedin\.com\/in\/([^\/?#]+)/);
if (matches && matches[1]) {
let fullName = matches[1].replace(/-/g, ' '); // Reemplazar guiones con espacios
Expand All @@ -142,7 +140,7 @@ function updateNameFromLinkedIn(url) {
});
// Eliminar espacio adicional al final del apellido, remueve la ultima palabra si contiene un numero
lastName = removeLastWord(lastName.trim());
lastName = lastName.trim();
// Asignar valores a los campos de nombre y apellido
document.getElementById('contact_first_name').value = firstName;
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

const APP_VERSION = '3.9.5';
const APP_VERSION = '3.9.6';

0 comments on commit 885c9ba

Please sign in to comment.