javascript - Telegram messenger colored box filled with the initials of the contacts -


i developing chat website similar telegram(http://zhukov.github.io/webogram/#/im?p=u67212536_13900205441461158827) . can see in contacts section first letter of contact name taken , placed in colored box. attaching screenshot of question. have tried code, failing implement it. here code have written. using bootstrap make happen. know have add code li tag.enter image description here

    sortedarray = eliminateduplicates(removedups);     console.log(sortedarray);     sortedarray.sort();     sortedarray = sortedarray.filter(emptyelement);     for(r=0;r<sortedarray.length;r++){     var contact = $('#contact');     var display = $('#display');     var newcontact= $('<li><a href="#">' + sortedarray[r] + '</a></li>');     contact.append(newcontact);     } 

you can see in image below initials of names displayed in colored circle.

i have solution it.         var contact = $('#contact');         var display = $('#display');         initial = sortedarray[r].slice(0,1)+" "+sortedarray[r].slice(1,2);         var newcontact= $('<div><span class="peer_initials im_dialog_photo   user_bgcolor_8">'+initial+'</span><li><a> ' + sortedarray[r] + '</a></li>   </div>');         contact.append(newcontact);         }         div.im_dialog_photo .peer_initials {          line-height: 48px;          font-size: 18px;          }       .im_dialog_photo {   width: 48px;         height: 48px;         line-height: 48px;          border-radius: 50%;        overflow: hidden;         } .peer_initials {   display: block;   color: #fff;   text-align: center;   text-transform: uppercase; } .user_bgcolor_8 {   background: #fba76f; 

Comments

Popular posts from this blog

c# - ItextSharp font color issue in ver 5.5.4+ -

jquery - Multiple issues with pushstate: history, loading, calling functions -

ios - retrievePeripherals deprecated in IOS7 how to substitude it with retrievePeripheralsWithIdentifiers -