aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--hovercard.js19
2 files changed, 17 insertions, 5 deletions
diff --git a/README.md b/README.md
index 806ac4a..45c8d4a 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,8 @@ Substitute the path of the script in the example above with the location of the
## Roadmap
-[ ] Customized hovercards for H-Cards.
+[x] Customized hovercards for H-Cards.
+[ ] Show more information for H-Cards.
## License
diff --git a/hovercard.js b/hovercard.js
index a7f2c6d..c20220f 100644
--- a/hovercard.js
+++ b/hovercard.js
@@ -13,15 +13,23 @@ var hovercards = {
if (hovercard_data) {
var new_box = document.createElement("div");
new_box.classList.add("hovercard");
- if (hovercard_data["title"]) {
- new_box.innerHTML = "<strong>" + hovercard_data["title"] + "</strong>"
+ if (hovercard_data["pname"]) {
+ new_box.innerHTML = "<strong>" + hovercard_data["pname"] + "</strong>"
+ } else {
+ if (hovercard_data["title"]) {
+ new_box.innerHTML = "<strong>" + hovercard_data["title"] + "</strong>"
+ }
}
if (hovercard_data["description"]) {
new_box.innerHTML = new_box.innerHTML + "<p>" + hovercard_data["description"] + "</p>";
}
// if image available, add it
- if (hovercard_data["image"]) {
- new_box.innerHTML = "<img src='" + hovercard_data["image"] + "' alt='" + hovercard_data["title"] + "' /><br>" + new_box.innerHTML;
+ if (hovercard_data["uphoto"]) {
+ new_box.innerHTML = "<img src='" + hovercard_data["uphoto"] + "' alt='" + hovercard_data["pname"] + "' /><br>" + new_box.innerHTML;
+ } else {
+ if (hovercard_data["image"]) {
+ new_box.innerHTML = "<img src='" + hovercard_data["image"] + "' alt='" + hovercard_data["title"] + "' /><br>" + new_box.innerHTML;
+ }
}
new_box.style.top = window.scrollY + target_link.getBoundingClientRect().top + "px";
new_box.style.left = window.scrollX + target_link.getBoundingClientRect().left + "px";
@@ -67,6 +75,9 @@ var hovercards = {
}
} else {
let req = 'https://indieweb-glue.evgenykuznetsov.org/api/pageinfo?url=';
+ if (Boolean(links[i].closest('.h-card'))) {
+ req = 'https://indieweb-glue.evgenykuznetsov.org/api/hcard?url=';
+ };
req += url;
const r = encodeURI(req);
var xmlhttp = new XMLHttpRequest();