captcha-image
Advanced tools
Comparing version 1.2.0 to 1.2.1
class Captcha { | ||
constructor(font, align, baseline, width, height, bgColor, color) { | ||
let code; | ||
this.font = font; | ||
@@ -11,9 +10,5 @@ this.align = align; | ||
this.bgColor = bgColor; | ||
this.getCode = () => { | ||
return code; | ||
}; | ||
this.createImage = () => { | ||
const captcha = document.createElement('canvas'); | ||
const newImage = document.createElement('image'); | ||
newImage.id = 'canvas'; | ||
@@ -46,3 +41,2 @@ const getRandomInt = (min, max) => { | ||
const newWord = getWord(); | ||
code = getWord(); | ||
const context = captcha.getContext('2d'); | ||
@@ -59,2 +53,3 @@ context.canvas.width = this.width; | ||
newImage.setAttribute('src', context.canvas.toDataURL()); | ||
newImage.setAttribute('data-key', newWord); | ||
return newImage.outerHTML; | ||
@@ -61,0 +56,0 @@ }; |
{ | ||
"name": "captcha-image", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "A simple captcha image generator.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -35,3 +35,2 @@ # Captcha Image Generator | ||
function App() { | ||
console.log(captchaImage.getCode()); | ||
return ( | ||
@@ -62,2 +61,9 @@ <div className='App'> | ||
- createImage() method return HTML element parsed as String | ||
- getCode() method return generate code as String | ||
## Output | ||
Final outcome looks like this: | ||
```html | ||
<img src="..." data-key="..." /> | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68
3438
52