Author: | sinchang |
---|---|
Views Total: | 163 views |
Official Page: | Go to website |
Last Update: | May 1, 2017 |
License: | MIT |
Preview:

Description:
The vanilla JavaScript version of the jQuery copyright plugin which automatically appends a reference link or copyright text to user copied content on your web page.
Install it via NPM:
$ npm install pure-copyright
How to use it:
Import the Copyright.js into your web project.
import Copyright from 'pure-copyright'
<script src="dist/pure-copyright.js"></script>
Initialize the library. This will automatically append the current page address to your text when copied.
new Copyright(document.body)
Customize the copyright text:
new Copyright(document.body, { text: "Your Copyright Text Here" })
Set the minimum length of the copied text when running.
new Copyright(document.body, { minlength: 100 })
The function to process the copied text
new Copyright(document.body, { processing: function (text) { console.log(text) } })
Event listeners.
new Copyright(document.body) .on('beforeCopy', () => { console.log(+ new Date()) }).on('afterCopy', () => { console.log(+ new Date()) })