mirror of
https://github.com/skishore/makemeahanzi.git
synced 2025-11-01 20:27:44 +08:00
Add methods to increment only complete glyphs
This commit is contained in:
@ -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),
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user