|
|
|
@ -18,17 +18,22 @@ export class CardModel {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function buildFileCard(filePath: string, elem: Element, append: boolean = false) {
|
|
|
|
export function buildFileCard(filePath: string, elem: Element, append: boolean = false, $: any = require('jquery')) {
|
|
|
|
let model = new CardModel(getImagePathFromDocumentName(filePath), fileNameToPrettyString(filePath));
|
|
|
|
let model = new CardModel(getImagePathFromDocumentName(filePath), fileNameToPrettyString(filePath));
|
|
|
|
loadTemplateSingle("file-card.mustache", model, (content: string, id: string) => {
|
|
|
|
loadTemplateSingle("file-card.mustache", model, (content: string, id: string) => {
|
|
|
|
|
|
|
|
let snip = $(content);
|
|
|
|
|
|
|
|
let container = $("#" + elem.id);
|
|
|
|
|
|
|
|
|
|
|
|
if (append) {
|
|
|
|
if (append) {
|
|
|
|
elem.innerHTML = elem.innerHTML + content;
|
|
|
|
container.append(snip);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
elem.innerHTML = content;
|
|
|
|
container.empty().append(snip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.querySelector("#" + id).addEventListener('click', () => {
|
|
|
|
setTimeout(() => {
|
|
|
|
launchDocument(filePath);
|
|
|
|
$(`#${id}`).on("click", () => {
|
|
|
|
})
|
|
|
|
launchDocument(filePath);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}, 1); //for some reason we have to let the dom breathe before it will let us do this?
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -77,7 +82,7 @@ export function buildWebCard(urlText: string, elem: Element, append: boolean = f
|
|
|
|
launchWebsite(url.toString());
|
|
|
|
launchWebsite(url.toString());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}).catch(reason => {
|
|
|
|
}).catch(reason => {
|
|
|
|
let card = $("<p>", {id:"come on", class: "pr-3 mb-0"});
|
|
|
|
let card = $("<p>", {id: "come on", class: "pr-3 mb-0"});
|
|
|
|
card.text(urlText);
|
|
|
|
card.text(urlText);
|
|
|
|
$(`#${id}-title`).html(card);
|
|
|
|
$(`#${id}-title`).html(card);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|