2.0.3 • Published 6 years ago

soroban-simulators v2.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Soroban training

npm.io npm.io npm.io npm.io npm.io

Install

npm i -S soroban-simulators

Demo 1

Example

document.addEventListener('DOMContentLoaded', function(){
    var el = document.getElementById('app'),
        config = {
            debug: false,
            columns: 1,
            btnTextResult: 'Send Result',
            textLoading: 'Loading...',
            btnTextStart: 'Start',
            btnTextNext: 'Next start',
            timeSendResult: 15 // seconds
        },
        iter = 0,
        zones = [
            {
                example: [1, -1, 2, -2, 1, -1],
                type: 'default',
                speed: 500,
                id: 1
            },
            {
                example: [1, -1, 2, -2, 1, -1],
                type: 'random-position',
                speed: 500,
                id: 2
            }
        ],                
        s = new SorobanSimulator(config);

    s.build(el, zones)

    el.addEventListener('sendResult', (e) => {
        var sum = s.arraySum(e.detail.zone.data.example)
        iter++
        setTimeout(() => {
            s.showResult(e.detail, sum === parseInt(e.detail.value) ? 'success' : 'error')
            if (iter >= zones.length) {
                iter = 0;
                setTimeout(() => {
                    s.build(el, zones, 'next')
                }, 2000)
            }
        }, 1000)
    })

    el.addEventListener('startTraining', (e) => {
        console.log('startTraining')
    })
    el.addEventListener('endTraining', (e) => {
        console.log('endTraining')
    })
    el.addEventListener('startTimer', (e) => {
        console.log('startTimer')
    })
    el.addEventListener('endTimer', (e) => {
        console.log('endTimer')
        s.build(el, zones, 'next')
    })
});
2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago