soroban-simulators
v2.0.3
Published
Soroban simulators for training
Downloads
1
Maintainers
Readme
Soroban training
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')
})
});