add userArray in script tag in profile cards, to be used by e.g. plugins

This commit is contained in:
Hannes Mannerheim 2016-03-05 14:50:30 +01:00
parent 68b3d377e8
commit afb3c6450d
2 changed files with 7 additions and 6 deletions

View File

@ -419,8 +419,9 @@ function buildProfileCard(data) {
} }
// full card html // full card html
data.profileCardHtml = '\ var profileCardHtml = '\
<div class="profile-card' + is_me + logged_in + is_muted + '">\ <div class="profile-card' + is_me + logged_in + is_muted + '">\
<script class="profile-json" type="application/json">' + JSON.stringify(data) + '</script>\
<div class="profile-header-inner' + is_silenced + is_sandboxed + '" style="' + coverPhotoHtml + '" data-user-id="' + data.id + '" data-screen-name="' + data.screen_name + '">\ <div class="profile-header-inner' + is_silenced + is_sandboxed + '" style="' + coverPhotoHtml + '" data-user-id="' + data.id + '" data-screen-name="' + data.screen_name + '">\
<div class="profile-header-inner-overlay"></div>\ <div class="profile-header-inner-overlay"></div>\
<a class="profile-picture" href="' + data.profile_image_url_original + '">\ <a class="profile-picture" href="' + data.profile_image_url_original + '">\
@ -458,7 +459,7 @@ function buildProfileCard(data) {
</div>\ </div>\
'; ';
return data; return { userArray: data, profileCardHtml: profileCardHtml };
} }
@ -551,7 +552,7 @@ function buildExternalProfileCard(data) {
var serverUrl = guessInstanceUrlWithoutProtocolFromProfileUrlAndNickname(data.statusnet_profile_url, data.screen_name); var serverUrl = guessInstanceUrlWithoutProtocolFromProfileUrlAndNickname(data.statusnet_profile_url, data.screen_name);
data.screenNameWithServer = '@' + data.screen_name + '@' + serverUrl; data.screenNameWithServer = '@' + data.screen_name + '@' + serverUrl;
data.profileCardHtml = '\ var profileCardHtml = '\
<div class="profile-card' + is_me + logged_in + is_muted + '">\ <div class="profile-card' + is_me + logged_in + is_muted + '">\
<div class="profile-header-inner' + is_silenced + is_sandboxed + '" style="background-image:url(\'' + cover_photo + '\')" data-user-id="' + localUserId + '" data-screen-name="' + localUserScreenName + '">\ <div class="profile-header-inner' + is_silenced + is_sandboxed + '" style="background-image:url(\'' + cover_photo + '\')" data-user-id="' + localUserId + '" data-screen-name="' + localUserScreenName + '">\
<div class="profile-header-inner-overlay"></div>\ <div class="profile-header-inner-overlay"></div>\
@ -590,7 +591,7 @@ function buildExternalProfileCard(data) {
</div>\ </div>\
<div class="clearfix"></div>'; <div class="clearfix"></div>';
return data; return { userArray: data, profileCardHtml: profileCardHtml };
} }
@ -608,7 +609,7 @@ function addProfileCardToDOM(data) {
// change design // change design
changeDesign({backgroundimage:data.background_image, backgroundcolor:data.backgroundcolor, linkcolor:data.linkcolor}); changeDesign({backgroundimage:data.userArray.background_image, backgroundcolor:data.userArray.backgroundcolor, linkcolor:data.userArray.linkcolor});
// remove any old profile card and show profile card // remove any old profile card and show profile card
$('#feed').siblings('.profile-card').remove(); $('#feed').siblings('.profile-card').remove();

View File

@ -847,7 +847,7 @@ function cacheSyntaxHighlightingGroups() {
/* · /* ·
· ·
· User array cache · User array cache (called array because it's an array in php)
· ·
· Stored in window.userArrayCache with unique key like instance_url/nickname · Stored in window.userArrayCache with unique key like instance_url/nickname
· with protocol (http:// or https://) trimmed off, e.g. "quitter.se/hannes2peer" · with protocol (http:// or https://) trimmed off, e.g. "quitter.se/hannes2peer"