wip
This commit is contained in:
parent
1e6734567d
commit
0ffb8ba3a0
|
@ -25,7 +25,7 @@ class KagiSummarizerExtension extends Minz_Extension {
|
|||
public function addSummarizeButton(FreshRSS_Entry $entry): FreshRSS_Entry {
|
||||
$this->registerTranslates();
|
||||
|
||||
$entry->_content('<p class="kagi-summary"><a class="kagi-summary btn" data-url="' . urlencode($entry->link()) .' href="#">' . _t('ext.kagiSummarizer.ui.summarize_button') . '</a></p>' . $entry->content());
|
||||
$entry->_content('<p class="kagi-summary"><a class="btn" data-url="' . urlencode($entry->link()) .' href="#">' . _t('ext.kagiSummarizer.ui.summarize_button') . '</a></p>' . $entry->content());
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,27 @@
|
|||
if (document.readyState && document.readyState !== 'loading') {
|
||||
configureKagiButtons();
|
||||
kagiSummarizeOnLoad();
|
||||
} else {
|
||||
document.addEventListener('DOMNodeInserted', configureKagiButtons, false);
|
||||
document.addEventListener('DOMContentLoaded', kagiSummarizeOnLoad, false);
|
||||
}
|
||||
|
||||
function configureKagiButtons() {
|
||||
console.log('configuring kagi buttons');
|
||||
function kagiSummarizeOnLoad() {
|
||||
console.log('configuring kagi observer');
|
||||
var observer = new MutationObserver(function(mutations) {
|
||||
mutations.forEach(function(mutation) {
|
||||
if (mutation.addedNodes && mutation.addedNodes.length > 0) {
|
||||
var hasClass = [].some.call(mutation.addedNodes, function(el) {
|
||||
return el.classList.contains('kagi-summary');
|
||||
});
|
||||
if (hasClass) {
|
||||
console.log('kagi observer triggered');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
observer.observe(document.body, {
|
||||
attributes: true,
|
||||
childList: true,
|
||||
characterData: true
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue