Add methods to increment only complete glyphs

This commit is contained in:
Shaunak Kishore
2015-11-03 01:40:27 -05:00
parent 512128af90
commit a646d34f3c
2 changed files with 13 additions and 2 deletions

View File

@ -84,8 +84,10 @@ const resetStage = () => {
const bindings = {
a: () => changeGlyph('getPreviousGlyph'),
A: () => changeGlyph('getPreviousUnverifiedGlyph'),
q: () => changeGlyph('getPreviousVerifiedGlyph'),
d: () => changeGlyph('getNextGlyph'),
D: () => changeGlyph('getNextUnverifiedGlyph'),
e: () => changeGlyph('getNextVerifiedGlyph'),
r: resetStage,
s: () => incrementStage(1),
w: () => incrementStage(-1),

View File

@ -53,6 +53,10 @@ Glyphs.getNextUnverified = (glyph) => {
return Glyphs.getNext(glyph, {'stages.verified': null});
}
Glyphs.getNextVerified = (glyph) => {
return Glyphs.getNext(glyph, {'stages.verified': {$ne: null}});
}
Glyphs.getPrevious = (glyph, clause) => {
clause = clause || {};
const codepoint = glyph ? glyph.codepoint : undefined;
@ -65,6 +69,10 @@ Glyphs.getPreviousUnverified = (glyph) => {
return Glyphs.getPrevious(glyph, {'stages.verified': null});
}
Glyphs.getPreviousVerified = (glyph) => {
return Glyphs.getPrevious(glyph, {'stages.verified': {$ne: null}});
}
Glyphs.save = (glyph) => {
check(glyph.character, String);
assert(glyph.character.length === 1);
@ -97,8 +105,9 @@ if (Meteor.isServer) {
// Register the methods above so they are available to the client.
const methods = {};
const method_names = ['get', 'getNext', 'getNextUnverified',
'getPrevious', 'getPreviousUnverified', 'save'];
const method_names = [
'get', 'getNext', 'getNextUnverified', 'getNextVerified',
'getPrevious', 'getPreviousUnverified', 'getPreviousVerified', 'save'];
method_names.map((name) => methods[`${name}Glyph`] = Glyphs[name]);
methods.saveGlyphs = (glyphs) => glyphs.map(Glyphs.save);
Meteor.methods(methods);