22*/
33/* global alert */
44
5- const { findProfileImage } = require ( '../signin' )
6-
75module . exports = { }
86
97var buttons = { }
@@ -25,6 +23,9 @@ const dragAndDrop = require('./dragAndDrop')
2523const cancelIconURI = UI . icons . iconBase + 'noun_1180156.svg' // black X
2624const checkIconURI = UI . icons . iconBase + 'noun_1180158.svg' // green checkmark; Continue
2725
26+ const ns = UI . ns
27+ const kb = UI . store
28+
2829function getStatusArea ( context ) {
2930 var box = context . statusArea || context . div || null
3031 if ( box ) return box
@@ -221,15 +222,29 @@ buttons.findImageByClass = function findImageByClass (x) {
221222 return iconDir + 'noun_10636_grey.svg' // Grey Circle - some thing
222223}
223224
225+ buttons . findImage = ( thing ) => {
226+ const iconDir = UI . icons . iconBase
227+ if ( thing . sameTerm ( ns . foaf ( 'Agent' ) ) || thing . sameTerm ( ns . rdf ( 'Resource' ) ) ) {
228+ return iconDir + 'noun_98053.svg' // Globe
229+ }
230+ const image = kb . any ( thing , ns . sioc ( 'avatar' ) ) ||
231+ kb . any ( thing , ns . foaf ( 'img' ) ) ||
232+ kb . any ( thing , ns . vcard ( 'logo' ) ) ||
233+ kb . any ( thing , ns . vcard ( 'hasPhoto' ) ) ||
234+ kb . any ( thing , ns . vcard ( 'photo' ) ) ||
235+ kb . any ( thing , ns . foaf ( 'depiction' ) )
236+ return image ? image . uri : null
237+ }
238+
224239// @@ Also add icons for *properties* like home, work, email, range, domain, comment,
225240
226241buttons . setImage = function ( element , profile ) {
227242 const kb = UI . store
228- const uri = findProfileImage ( profile )
243+ const uri = buttons . findImage ( profile )
229244 element . setAttribute ( 'src' , uri || buttons . findImageByClass ( profile ) )
230245 if ( ! uri && profile . uri ) {
231246 kb . fetcher . nowOrWhenFetched ( profile . doc ( ) , undefined , ( ) => {
232- element . setAttribute ( 'src' , findProfileImage ( profile ) || buttons . findImageByClass ( profile ) )
247+ element . setAttribute ( 'src' , buttons . findImage ( profile ) || buttons . findImageByClass ( profile ) )
233248 } )
234249 }
235250}
0 commit comments