@@ -23,6 +23,9 @@ const dragAndDrop = require('./dragAndDrop')
2323const cancelIconURI = UI . icons . iconBase + 'noun_1180156.svg' // black X
2424const checkIconURI = UI . icons . iconBase + 'noun_1180158.svg' // green checkmark; Continue
2525
26+ const ns = UI . ns
27+ const kb = UI . store
28+
2629function getStatusArea ( context ) {
2730 var box = context . statusArea || context . div || null
2831 if ( box ) return box
@@ -219,30 +222,29 @@ buttons.findImageByClass = function findImageByClass (x) {
219222 return iconDir + 'noun_10636_grey.svg' // Grey Circle - some thing
220223}
221224
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+
222239// @@ Also add icons for *properties* like home, work, email, range, domain, comment,
223240
224- buttons . setImage = function ( element , x ) {
241+ buttons . setImage = function ( element , profile ) {
225242 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 ) )
243+ const uri = buttons . findImage ( profile )
244+ element . setAttribute ( 'src' , uri || buttons . findImageByClass ( profile ) )
245+ if ( ! uri && profile . uri ) {
246+ kb . fetcher . nowOrWhenFetched ( profile . doc ( ) , undefined , ( ) => {
247+ element . setAttribute ( 'src' , buttons . findImage ( profile ) || buttons . findImageByClass ( profile ) )
246248 } )
247249 }
248250}
0 commit comments