Runs server and client simultaneously in the development mode.
Open http://localhost:3000 to view it in the browser.
Launches the test runner in the interactive watch mode.
Builds production image to the output
folder.
We're using Accounts-base package to authorize and register users. This package implements the basic functions necessary for user accounts.
Accounts.createUser({username,password},function (err) {}
Meteor.loginWithPassword(username, password, function (error) {}
Meteor.logout()
Accounts-base package throws Meteor.Error but only in English. We're using errorHandler.js to translate error messages and return them to user.
switch (reason) {
case 'Incorrect password':
return 'Неверный пароль.';
Coin toss must be implemented on server side so we're are calling coin.toss Meteor Method that returns and insert in database coin state.
Math.random() returns float value from 0 to 1, so we compare Math.random() < 0.5
to obtain 50% chance of getting heads.
CoinCollection.insert({
coin: (true / false),
createdAt: new Date(),
userId: this.userId,
});
In Coin component we have 2 images one of which is visible to the user.
If coinState changes display:none is added to styles of one picture, display: block to styles of another. Both of them have animation: tosscoin 0.2s property.
@keyframes tosscoin {
from { transform: rotateY(180deg); }
to { transform: rotateY(0); }
}
To show the list of tossings we request 2 types of data from the database.
- List of tosses limited to 20 pieces.
- Number of tosses by user.
We display tosses list only if there's at least 1 record in DB and simply .map the array.
Display only if there's at least 20 records in DB.
- Previous page check:
tossesSkipCount - 20 < 0
- Next page check:
Math.abs(tossesCount - tossesSkipCount) < 20
If one of the fail checks, the corresponding button acquires className: pagination-inactive and changes its appearance.