minj / foxtrick

FoxTrick is a browser extension for the Hattrick online football manager game, currently available for Firefox, Google Chrome, as well as for Opera.
https://www.foxtrick.org
GNU General Public License v3.0
71 stars 49 forks source link

Is it possible? (player names abbreviated) #960

Closed minj closed 9 years ago

minj commented 9 years ago

Original issue 960 created by gantorys on 2012-06-08T17:12:30.000Z:

In the foxtrick skill-table (on players page), show the name of the player abbreviated.

Examples:

Alessandro Del Piero ---> A. Del Piero Roberto Baggio ---------> R. Baggio

(like FIFA)

I try change the code of players.js, skill-table.js... but im lost.

Sorry for my english.

minj commented 9 years ago

Comment #1 originally posted by convincedd on 2012-06-08T23:18:15.000Z:

if we make the short name default (you can do that for now):

players.js line 125. there we get the name from the chpp api files. there change the way we want (with regexp replace i guess)

player.nameLink.textContent = playerNode.getElementsByTagName("FirstName")[0].textContent

(for the pure html version, we can't do that. we won't know what the first and the last name is. there realy is no way to tell)


in skilltable.js: nothing to do

minj commented 9 years ago

Comment #2 originally posted by gantorys on 2012-06-09T00:28:44.000Z:

i have been trying change that line, but any change happened. In fact, if i erase it, skill-table shows the sames names.

minj commented 9 years ago

Comment #3 originally posted by convincedd on 2012-06-09T00:45:12.000Z:

right. reason is line 113 if(!player) .. we only add the basic info if we don't have it from the html already. hmtl is always upto date while the way we use the xml files, they can be slightly out of date. i guess we just can move the name part in there line:120-127 to the general part further bellow, so in line 193

minj commented 9 years ago

Comment #4 originally posted by gantorys on 2012-06-09T12:20:19.000Z:

Yes, that's works!

I only have to change the name to the way I want and it will be done.

Thanks!

minj commented 9 years ago

Comment #5 originally posted by gantorys on 2012-06-09T12:32:06.000Z:

That's works!

I put this:

player.nameLink.textContent = playerNode.getElementsByTagName("FirstName")[0].textContent[0] + '. ' + playerNode.getElementsByTagName("LastName")[0].textContent;

It's done! Thanks!

minj commented 9 years ago

Comment #6 originally posted by convincedd on 2012-06-09T13:15:07.000Z:

i guess that's only the very first letter then. some have two first names. then regular expressions can do more https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions in this case

player.nameLink.textContent = playerNode.getElementsByTagName("FirstName")[0].textContent .replace(/(-.)([^-\s]+)/g,"$1.") // replaces first name
.replace(/(\s.)([^-\s]+)/g,"$1.") // replace further first names .replace(/(^.)([^-\s]+)/g,"$1.") // replace names connected with "-"

minj commented 9 years ago

Comment #7 originally posted by gantorys on 2012-06-09T14:22:49.000Z:

Great.

It will be nice aplicate this on transfer search results too, i dont't know if it will possible.

minj commented 9 years ago

Comment #8 originally posted by convincedd on 2012-06-09T14:43:50.000Z:

not realy. we don't have there first and last name seperatelly. so of Stefan Frank Hansen we don't know if it should be S.F. Hansen or S. Frank Hansen

minj commented 9 years ago

Comment #9 originally posted by gantorys on 2012-06-09T14:56:12.000Z:

Ole Gunnar Solskjaer

It will be OK for me with "O. Solskjaer" instead of "O. G. Solskjaer", easier code i think.

minj commented 9 years ago

Comment #10 originally posted by convincedd on 2012-06-09T14:59:49.000Z:

that's possible naturally. i personnally don't think the displaying Raúl de Miguel as R. Miguel is that nice.

maybe R. d. Miguel still not realy nice but better

minj commented 9 years ago

Comment #11 originally posted by gantorys on 2012-06-09T15:01:23.000Z:

Ok, no problem, you help me with my the first problem, that's what i wanted.

Thanks for your time.

minj commented 9 years ago

Comment #12 originally posted by gantorys on 2012-06-09T15:24:53.000Z:

Yes you're right. Is not really nice,

for example (on transfer list i mean)

Alessandro Del Piero --> 'A. d. Piero' or 'A. D. Piero' it's not cool, because everyone knows him with 'Del Piero'

I know Hattrick players are invented but you know what I mean, lol.

However, I don't understand very well why on players.js get's the name separately and in the transferlist not. I guess because the APIs but it's weird.

minj commented 9 years ago

Comment #13 originally posted by convincedd on 2012-06-09T15:33:12.000Z:

yes, players have an api and transferlist search results naturally not. in the api there is first and last name seperatelly, but from the pure html in the transfer search we just can't tell

minj commented 9 years ago

Comment #14 originally posted by convincedd on 2012-06-09T15:36:31.000Z:

btw: no latin names might look wierd eg

李 (Li) 文隆 (Wenlong) playerId=206936537

minj commented 9 years ago

Comment #15 originally posted by convincedd on 2012-06-12T13:12:20.000Z:

<empty>

Status: Done