Luke Childs
6 years ago
1 changed files with 34 additions and 33 deletions
@ -1,52 +1,53 @@ |
|||
/* eslint-env browser */ |
|||
import 'babel-polyfill'; |
|||
import whenDomReady from 'when-dom-ready'; |
|||
import dogeSeed from '../'; |
|||
import noUiSlider from 'nouislider'; |
|||
import {version} from '../package.json'; |
|||
import dogeSeed from '..'; |
|||
import {version} from '../package'; |
|||
|
|||
const bitsToWords = { |
|||
128: 12, |
|||
160: 15, |
|||
192: 18, |
|||
224: 21, |
|||
256: 24 |
|||
128: 12, |
|||
160: 15, |
|||
192: 18, |
|||
224: 21, |
|||
256: 24 |
|||
}; |
|||
|
|||
const main = async () => { |
|||
await whenDomReady(); |
|||
await whenDomReady(); |
|||
|
|||
document.querySelector('.version').innerText = `v${version}`; |
|||
document.querySelector('.version').innerText = `v${version}`; |
|||
|
|||
const seedText = document.querySelector('.seed-text'); |
|||
const regenerateSeedButton = document.querySelector('.regenerate-seed'); |
|||
const seedText = document.querySelector('.seed-text'); |
|||
const regenerateSeedButton = document.querySelector('.regenerate-seed'); |
|||
|
|||
const bitSlider = noUiSlider.create(document.querySelector('.bit-slider'), { |
|||
range: {min: 128, max: 256}, |
|||
step: 32, |
|||
start: 256, |
|||
pips: { |
|||
mode: 'steps', |
|||
density: 1, |
|||
format: {to: bits => bitsToWords[bits]}, |
|||
filter: (value, step) => step === 0 ? -1 : 1 |
|||
} |
|||
}); |
|||
const bitSlider = noUiSlider.create(document.querySelector('.bit-slider'), { |
|||
range: {min: 128, max: 256}, |
|||
step: 32, |
|||
start: 256, |
|||
pips: { |
|||
mode: 'steps', |
|||
density: 1, |
|||
format: {to: bits => bitsToWords[bits]}, |
|||
filter: (value, step) => step === 0 ? -1 : 1 |
|||
} |
|||
}); |
|||
|
|||
const generateSeed = () => { |
|||
const bits = Number(bitSlider.get()); |
|||
const seedPhraseWords = dogeSeed(bits).split(' '); |
|||
const generateSeed = () => { |
|||
const bits = Number(bitSlider.get()); |
|||
const seedPhraseWords = dogeSeed(bits).split(' '); |
|||
|
|||
const wrappedSeedPhrase = seedPhraseWords.map(word => `<span>${word}</span>`).join(' '); |
|||
const wordCount = seedPhraseWords.length; |
|||
const wrappedSeedPhrase = seedPhraseWords.map(word => `<span>${word}</span>`).join(' '); |
|||
const wordCount = seedPhraseWords.length; |
|||
|
|||
seedText.dataset.wordCount = wordCount; |
|||
seedText.innerHTML = wrappedSeedPhrase; |
|||
}; |
|||
seedText.dataset.wordCount = wordCount; |
|||
seedText.innerHTML = wrappedSeedPhrase; |
|||
}; |
|||
|
|||
regenerateSeedButton.addEventListener('click', generateSeed); |
|||
bitSlider.on('update', generateSeed); |
|||
regenerateSeedButton.addEventListener('click', generateSeed); |
|||
bitSlider.on('update', generateSeed); |
|||
|
|||
generateSeed(); |
|||
generateSeed(); |
|||
}; |
|||
|
|||
main(); |
|||
|
Loading…
Reference in new issue