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 = { const bindings = {
a: () => changeGlyph('getPreviousGlyph'), a: () => changeGlyph('getPreviousGlyph'),
A: () => changeGlyph('getPreviousUnverifiedGlyph'), A: () => changeGlyph('getPreviousUnverifiedGlyph'),
q: () => changeGlyph('getPreviousVerifiedGlyph'),
d: () => changeGlyph('getNextGlyph'), d: () => changeGlyph('getNextGlyph'),
D: () => changeGlyph('getNextUnverifiedGlyph'), D: () => changeGlyph('getNextUnverifiedGlyph'),
e: () => changeGlyph('getNextVerifiedGlyph'),
r: resetStage, r: resetStage,
s: () => incrementStage(1), s: () => incrementStage(1),
w: () => incrementStage(-1), w: () => incrementStage(-1),

View File

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