Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Update Algorithm to create default Avatar for Pàdé #253

Open
gjaekel opened this issue Jan 6, 2021 · 6 comments
Open

Enhancement: Update Algorithm to create default Avatar for Pàdé #253

gjaekel opened this issue Jan 6, 2021 · 6 comments

Comments

@gjaekel
Copy link
Contributor

gjaekel commented Jan 6, 2021

Update the algorithm for choosing the Initials for the default avatar introduced in "OFMeet". This will respect the common European syntax for display names ("lastname, firstname" -> "FL")

@gjaekel
Copy link
Contributor Author

gjaekel commented Jan 6, 2021

@deleolajide

As a copy of the changes for "meetings", I made a verified patch for plugins/pade/classes/docs7inverse/index.js for function _createAvatar(), but I can't locate this file in the sources?!

# diff index.js.20210104-081414 index.js
1762,1764c1762,1764
<         if (!width) width = 32;
<         if (!height) height = 32;
<         if (!font) font = "16px Arial";
---
>         if (!width) width = 128;
>         if (!height) height = 128;
>         if (!font) font = "64px Arial";
1780,1783c1780,1784
<         var name = nickname.split(" ");
<         if (name.length == 1) name = nickname.split(".");
<         if (name.length == 1) name = nickname.split("-");
<         var l = name.length - 1;
---
> 	console.debug("_createAvatar: " + nickname );
>         // try to split nickname into words at different symbols with preference
>         let words = nickname.split(/[, ]/); // "John W. Doe" -> "John "W." "Doe"  or  "Doe,John W." -> "Doe" "John" "W."
>         if (words.length == 1) words = nickname.split("."); // "John.Doe" -> "John" "Doe"  or  "John.W.Doe" -> "John" "W" "Doe"
>         if (words.length == 1) words = nickname.split("-"); // "John-Doe" -> "John" "Doe"  or  "John-W-Doe" -> "John" "W" "Doe"
1785c1786
<         if (name && name[0] && name.first != '')
---
>         if (words && words[0] && words.first != '')
1787,1788d1787
<             first = name[0][0];
<             last = name[l] && name[l] != '' && l > 0 ? name[l][0] : null;
1790,1792c1789,1802
<             if (last) {
<                 var initials = first + last;
<                 context.fillText(initials.toUpperCase(), 3, 23);
---
>             const firstInitial = words[0][0]; // first letter of first word
>             var lastInitial = null; // first letter of last word, if any
> 
>             const lastWordIdx = words.length - 1; // index of last word
>             if (lastWordIdx > 0 && words[lastWordIdx] && words[lastWordIdx] != '')
>             {
>                 lastInitial = words[lastWordIdx][0]; // first letter of last word
>             }
> 
>             // if nickname consist of more than one words, compose the initials as two letter
>             if (lastInitial) {
>                 // if any comma is in the nickname, treat it to have the lastname in front, i.e. compose reversed
>                 const initials = nickname.indexOf(",") == -1 ? firstInitial + lastInitial : lastInitial + firstInitial;
>                 context.fillText(initials.toUpperCase(), 20, 88);
1794,1795c1804
<                 var initials = first;
<                 context.fillText(initials.toUpperCase(), 10, 23);
---
>                 context.fillText(firstInitial.toUpperCase(), 44, 88);
1796a1806,1807
> 
>                                             

@deleolajide deleolajide transferred this issue from igniterealtime/openfire-pade-plugin Jan 6, 2021
@deleolajide
Copy link
Member

See

function _createAvatar(nickname, width, height, font)

@gjaekel
Copy link
Contributor Author

gjaekel commented Jan 6, 2021

I see, source for Pàdé is at this repo. 😄

gjaekel added a commit to gjaekel/pade that referenced this issue Jan 6, 2021
Update the algorithm for choosing the Initials for the default avatar introduced in "OFMeet". This will respect the common European syntax for display names ("lastname, firstname" -> "FL")

Update is taken from https://github.com/igniterealtime/openfire-pade-plugin/blob/3230d0f5b4319bee233eaa6b4913d872ec37ca4a/web/src/main/webapp/custom_ofmeet.js#L599

Support igniterealtime#253
@gjaekel gjaekel mentioned this issue Jan 6, 2021
@gjaekel
Copy link
Contributor Author

gjaekel commented Jan 6, 2021

I found the identical code at

function createAvatar(nickname, width, height, font, force)
?!? Is this used or is it an artefact?

@deleolajide
Copy link
Member

deleolajide commented Jan 6, 2021

@gjaekel
Copy link
Contributor Author

gjaekel commented Jan 6, 2021

But I don't change js/background.js::createAvatar(), just inverse/index.js::_createAvatar() to see the expected results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants