Created
June 10, 2012 05:12
-
-
Save possibilities/2903905 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<title>Shuffle</title> | |
<link href='http://fonts.googleapis.com/css?family=PT+Serif' rel='stylesheet' type='text/css'> | |
</head> | |
<body> | |
<div class="wrapper"> | |
<div class="main"> | |
{{#if front}} | |
<div id="deck"> | |
{{> card}} | |
</div> | |
{{else}} | |
Loading deck... | |
{{/if}} | |
</div> | |
</div> | |
</body> | |
<template name="card"> | |
<div class="card"> | |
<div class="front">{{front}}</div> | |
<div class="back">{{back}}</div> | |
</div> | |
<button class="previous">Previous</button> | |
<button class="next">Next</button> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Decks = new Meteor.Collection("decks"); | |
if (Meteor.is_client) { | |
Session.set('deckPosition', 0); | |
Meteor.subscribe('Decks'); | |
/*counter = 0; | |
current = function(){ | |
return deck[self.counter]; | |
}; | |
next = function(){ | |
return deck[self.counter + 1]; | |
}; | |
prev = function(){ | |
return deck[self.counter - 1]; | |
};*/ | |
/*** Deck ***/ | |
/*** Card ***/ | |
Template.card.front = function () { | |
var deck = Decks.findOne(); | |
var position = Session.get('deckPosition'); | |
if (deck) | |
return _.keys(deck.translations)[position]; | |
}; | |
Template.card.back = function () { | |
var deck = Decks.findOne(); | |
var position = Session.get('deckPosition'); | |
if (deck) | |
return _.values(deck.translations)[position]; | |
}; | |
Template.card.events = { | |
'click .next': function() { | |
var position = Session.get('deckPosition'); | |
Session.set('deckPosition', (position + 1)); | |
}, | |
'click .previous': function() { | |
var position = Session.get('deckPosition'); | |
Session.set('deckPosition', (position - 1)); | |
}, | |
}; | |
} | |
if (Meteor.is_server) { | |
Meteor.startup(function () { | |
Meteor.publish('Decks',function(){ | |
return Decks.find(); | |
}); | |
if (Decks.find().count() === 0) { | |
Decks.insert({ | |
"name": "Hiragana", | |
"translations": { | |
"a": "あ", | |
"i": "い", | |
"u": "う", | |
"e": "え", | |
"o": "お", | |
"ka": "か", | |
"ki": "き", | |
"ku": "く", | |
"ke": "け", | |
"ko": "こ", | |
"ga": "が", | |
"gi": "ぎ", | |
"gu": "ぐ", | |
"ge": "げ", | |
"go": "ご", | |
"sa": "さ", | |
"si": "し", | |
"shi": "し", | |
"su": "す", | |
"se": "せ", | |
"so": "そ", | |
"za": "ざ", | |
"zi": "じ", | |
"ji": "じ", | |
"zu": "ず", | |
"ze": "ぜ", | |
"zo": "ぞ", | |
"ta": "た", | |
"ti": "ち", | |
"chi": "ち", | |
"tu": "つ", | |
"tsu": "つ", | |
"te": "て", | |
"to": "と", | |
"da": "だ", | |
"di": "ぢ", | |
"du": "づ", | |
"dzu": "づ", | |
"de": "で", | |
"do": "ど", | |
"na": "な", | |
"ni": "に", | |
"nu": "ぬ", | |
"ne": "ね", | |
"no": "の", | |
"ha": "は", | |
"hi": "ひ", | |
"hu": "ふ", | |
"fu": "ふ", | |
"he": "へ", | |
"ho": "ほ", | |
"ba": "ば", | |
"bi": "び", | |
"bu": "ぶ", | |
"be": "べ", | |
"bo": "ぼ", | |
"pa": "ぱ", | |
"pi": "ぴ", | |
"pu": "ぷ", | |
"pe": "ぺ", | |
"po": "ぽ", | |
"ma": "ま", | |
"mi": "み", | |
"mu": "む", | |
"me": "め", | |
"mo": "も", | |
"ya": "や", | |
"yu": "ゆ", | |
"yo": "よ", | |
"ra": "ら", | |
"ri": "り", | |
"ru": "る", | |
"re": "れ", | |
"ro": "ろ", | |
"la": "ら", | |
"li": "り", | |
"lu": "る", | |
"le": "れ", | |
"lo": "ろ", | |
"wa": "わ", | |
"wi": "うぃ", | |
"we": "うぇ", | |
"wo": "を", | |
"wye": "ゑ", | |
"wyi": "ゐ", | |
"-": "ー", | |
"n": "ん", | |
"nn": "ん", | |
"n'": "ん" | |
} | |
}); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment