Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Arturo Montejo Ráez
/
solid2022
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2824c794
authored
Apr 20, 2022
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Práctica 1 de solid completada
parent
5322be32
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
index.html
js/main.js
index.html
View file @
2824c794
...
...
@@ -19,6 +19,9 @@
<span
id=
"fullName"
></span>
</p>
<p
id=
"photo"
></p>
<h2>
Contactos
</h2>
<ul
id=
"friends"
></ul>
</div>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"
></script>
<script
src=
"https://solid.github.io/solid-auth-client/dist/solid-auth-client.bundle.js"
></script>
...
...
js/main.js
View file @
2824c794
...
...
@@ -32,12 +32,18 @@ const VCARD = $rdf.Namespace('http://www.w3.org/2006/vcard/ns#');
const
store
=
$rdf
.
graph
();
const
fetcher
=
new
$rdf
.
Fetcher
(
store
);
$
(
'#view'
).
click
(
async
function
()
{
$
(
'#view'
).
click
(()
=>
showProfile
());
/* --------------
Mostramos información del perfil referenciado por la WebID
*/
async
function
showProfile
()
{
// Cargamos los datos a partir del WebID
const
person
=
$
(
'#webid'
).
val
();
await
fetcher
.
load
(
person
);
showPersonalData
(
person
);
});
showFriends
(
person
);
}
// Información personal
function
showPersonalData
(
person
)
{
...
...
@@ -47,3 +53,22 @@ function showPersonalData(person) {
$
(
'#fullName'
).
text
(
fullName
&&
fullName
.
value
);
$
(
'#photo'
).
html
(
$
(
'<img>'
).
attr
(
'src'
,
photoUrl
&&
photoUrl
.
value
).
attr
(
'width'
,
'200px'
));
}
/* -------------------------
Contactos (navegable)
*/
async
function
showFriends
(
person
)
{
// Mostramos su lista de amigos
const
friends
=
store
.
each
(
$rdf
.
sym
(
person
),
FOAF
(
'knows'
));
$
(
'#friends'
).
empty
();
friends
.
forEach
(
async
(
friend
)
=>
{
await
fetcher
.
load
(
friend
);
// con cada "load", la base de conocimiento ¡crece!
const
fullName
=
store
.
any
(
friend
,
FOAF
(
'name'
));
$
(
'#friends'
).
append
(
$
(
'<li>'
).
append
(
$
(
'<a>'
).
text
((
fullName
&&
fullName
.
value
||
friend
.
value
))
.
click
(()
=>
$
(
'#webid'
).
val
(
friend
.
value
))
.
click
(()
=>
showProfile
(
friend
.
value
))));
});
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment