![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
wikipedia-preview
Advanced tools
Wikipedia preview allows you to provide context from Wikipedia about words or phrases on any website. It lets you show a popup card with a short summary from Wikipedia when a reader hovers over a link.
It is a small Javascript component that does not have any dependencies and should be compatible with most browsers.
<script src="wikipedia-preview.production.js"></script>
<script type="text/javascript">
wikipediaPreview.init()
</script>
You can serve the file yourself or include it from unpkg.
$ npm install wikipedia-preview --save
const wikipediaPreview = require('wikipedia-preview')
wikipediaPreview.init()
The init
function accepts the following options:
Name | Type | Default | Description |
---|---|---|---|
root | DOM Element | document | Where to look for elements that should have the popup |
selector | string | '[data-wikipedia-preview]' | How nodes that should have the popup are identified |
lang | string | 'en' | Default Wikipedia language |
popupContainer | DOM Element | document.body | Where to put the popup in the DOM |
Example
<p class="content">
You can learn about <span class="wiki">Chat</span> and <span class="wiki">Chien</span> from Wikipedia.
</p>
<div class="popup-container"></div>
wikipediaPreview.init({
root: document.querySelector('.content'),
selector: '.wiki',
popupContainer: '.popup-container',
lang: 'fr'
});
To indicate that a word or expression should bring up the article preview popup, mark it with the data-wikipedia-preview
attribute (or anything else as long as you're using the selector
option described above).
By default, nodes with the data-wikipedia-preview
attribute don't have any special visual treatment. You should style them in a way that makes sense for your context.
Example
[data-wikipedia-preview] {
background-color: yellow;
}
When the article title is not the same as the node's textContent
property, use the data-wp-title
attribute to specify the article title.
To use a language different than the language specified in the options, use the data-wp-lang
attribute.
This is heavily inspired by jquery.wikilookup and Page Previews.
FAQs
Shows Wikipedia article preview in a popup
The npm package wikipedia-preview receives a total of 335 weekly downloads. As such, wikipedia-preview popularity was classified as not popular.
We found that wikipedia-preview demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.