|
2 | 2 | */ |
3 | 3 | /* global alert */ |
4 | 4 |
|
| 5 | +const { findProfileImage } = require('../signin') |
| 6 | + |
5 | 7 | module.exports = {} |
6 | 8 |
|
7 | 9 | var buttons = {} |
@@ -221,28 +223,13 @@ buttons.findImageByClass = function findImageByClass (x) { |
221 | 223 |
|
222 | 224 | // @@ Also add icons for *properties* like home, work, email, range, domain, comment, |
223 | 225 |
|
224 | | -buttons.setImage = function (element, x) { |
| 226 | +buttons.setImage = function (element, profile) { |
225 | 227 | const kb = UI.store |
226 | | - const ns = UI.ns |
227 | | - const iconDir = UI.icons.iconBase |
228 | | - var findImage = function (x) { |
229 | | - if (x.sameTerm(ns.foaf('Agent')) || x.sameTerm(ns.rdf('Resource'))) { |
230 | | - return iconDir + 'noun_98053.svg' // Globe |
231 | | - } |
232 | | - var image = kb.any(x, ns.sioc('avatar')) || |
233 | | - kb.any(x, ns.foaf('img')) || |
234 | | - kb.any(x, ns.vcard('logo')) || |
235 | | - kb.any(x, ns.vcard('hasPhoto')) || |
236 | | - kb.any(x, ns.vcard('photo')) || |
237 | | - kb.any(x, ns.foaf('depiction')) |
238 | | - return image ? image.uri : null |
239 | | - } |
240 | | - |
241 | | - var uri = findImage(x) |
242 | | - element.setAttribute('src', uri || buttons.findImageByClass(x)) |
243 | | - if (!uri && x.uri) { |
244 | | - kb.fetcher.nowOrWhenFetched(x.doc(), undefined, function (ok) { |
245 | | - element.setAttribute('src', findImage(x) || buttons.findImageByClass(x)) |
| 228 | + const uri = findProfileImage(profile) |
| 229 | + element.setAttribute('src', uri || buttons.findImageByClass(profile)) |
| 230 | + if (!uri && profile.uri) { |
| 231 | + kb.fetcher.nowOrWhenFetched(profile.doc(), undefined, () => { |
| 232 | + element.setAttribute('src', findProfileImage(profile) || buttons.findImageByClass(profile)) |
246 | 233 | }) |
247 | 234 | } |
248 | 235 | } |
|
0 commit comments