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