"Open Sourcing" this, perhaps people will find it interesting/useful.
This commit is contained in:
commit
197dcd2ae7
18 changed files with 4339 additions and 0 deletions
520
assets/www/index.html
Executable file
520
assets/www/index.html
Executable file
|
|
@ -0,0 +1,520 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||
<title>Katanakana</title>
|
||||
<style type="text/css">
|
||||
html {
|
||||
height: 100%;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#dedede), to(#f9f9f9));
|
||||
color: #444;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: 'Droid Sans', helvetica, sans-serif;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body { padding: 0; margin: 0; height: 100%; }
|
||||
|
||||
#header {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#3d3d3d), to(#010101));
|
||||
-webkit-box-shadow: 1px 1px 5px #787878;
|
||||
}
|
||||
|
||||
#header span {
|
||||
position: absolute;
|
||||
font-size: 20px;
|
||||
top: 9px;
|
||||
left: 10px;
|
||||
font-weight: bold;
|
||||
text-shadow: 1px 1px 1px #787878;
|
||||
color: #f9f9f9;
|
||||
}
|
||||
|
||||
#right, #wrong {
|
||||
float: right;
|
||||
padding-top: 12px;
|
||||
height: 28px;
|
||||
min-width: 40px;
|
||||
text-align: center;
|
||||
color: #f9f9f9;
|
||||
text-shadow: 1px 1px 1px #121212;
|
||||
border-left: 1px solid #010101;
|
||||
}
|
||||
|
||||
#right { background: -webkit-gradient(linear, left top, left bottom, from(#6fe78c), to(#169a35)); }
|
||||
#wrong { background: -webkit-gradient(linear, left top, left bottom, from(#e92222), to(#9f1515)); }
|
||||
.right { background: -webkit-gradient(linear, left top, left bottom, from(#6fe78c), to(#169a35)) !important; border: 1px solid #169a35 !important; }
|
||||
.wrong { background: -webkit-gradient(linear, left top, left bottom, from(#e92222), to(#9f1515)) !important; border: 1px solid #9f1515 !important; }
|
||||
|
||||
#intro {
|
||||
padding: 10px;
|
||||
height: 0; /* Default, gets judged */
|
||||
text-align: left;
|
||||
-webkit-transition: opacity .25s linear;
|
||||
}
|
||||
|
||||
#intro h1 {
|
||||
font-size: 20px;
|
||||
text-shadow: 1px 1px 1px #b7b7b7;
|
||||
color: #010101;
|
||||
padding-bottom: 6px;
|
||||
margin-bottom: 10px;
|
||||
border-bottom: 1px solid #c9c9c9;
|
||||
}
|
||||
|
||||
#intro p {
|
||||
margin: 0 0 15px 0;
|
||||
font-size: 14px;
|
||||
line-height: 16px;
|
||||
text-shadow: 1px 1px 1px #b9b9b9;
|
||||
}
|
||||
|
||||
#game {
|
||||
height: 0; /* Default, gets judged */
|
||||
-webkit-transition: opacity .25s linear;
|
||||
padding: 10px;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#letter, #choices { float: left; }
|
||||
|
||||
#letter {
|
||||
font-weight: bold;
|
||||
border: 1px solid #b9b9b9;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#fafafa), to(#e7e7e7));
|
||||
-webkit-border-radius: 6px;
|
||||
-webkit-box-shadow: 1px 1px 5px #f7f7f7;
|
||||
-webkit-transition: opacity .25s linear;
|
||||
margin-bottom: 9px;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
|
||||
#choices button, #get_started {
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
text-shadow: 1px 1px 3px #121212;
|
||||
border: 1px solid #1874ca;
|
||||
-webkit-box-shadow: 1px 1px 5px #787878;
|
||||
width: 100%;
|
||||
margin: 0 auto 10px;
|
||||
padding: 7px 0;
|
||||
-webkit-border-radius: 6px;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#2792f6), to(#146abb));
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<span>Katanakana</span>
|
||||
<div id="right">0</div>
|
||||
<div id="wrong">0</div>
|
||||
</div>
|
||||
|
||||
<div id="intro">
|
||||
<h1>You Can Do This!</h1>
|
||||
<p>
|
||||
Learning any of the Japanese alphabets can seem like a daunting task because there's
|
||||
just so many characters. Thing is, this doesn't <em>have</em> to be difficult!
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The human brain works in a mysterious fashion, and everybody has their own point at which the brain commits something
|
||||
to memory. Katanakana watches how you identify characters, and will figure out when your brain has the best chance of
|
||||
storing the relations you need to read Japanese.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Once this is determined, it'll make you re-identify those characters
|
||||
at the ideal moment, and you'll be good to go!
|
||||
</p>
|
||||
|
||||
<button id="get_started">Get Started Now!</button>
|
||||
</div>
|
||||
|
||||
<div id="game" style="display: none; opacity: 0;">
|
||||
<div id="letter"></div>
|
||||
|
||||
<div id="choices">
|
||||
<button id="choice_1"></button>
|
||||
<button id="choice_2"></button>
|
||||
<button id="choice_3"></button>
|
||||
<button id="choice_4"></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="phonegap.0.9.4.js"></script>
|
||||
<script type="text/javascript">
|
||||
Array.prototype.contains = function(v) {
|
||||
for(var i = 0, x = this.length; i < x; i++) {
|
||||
if(this[i] === v) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
Array.prototype.unique = function(blacklist) {
|
||||
var newArr = [];
|
||||
for(var i = 0, l = this.length; i < l; i++) {
|
||||
if(newArr.contains(this[i]) || (typeof blacklist !== 'undefined' && this[i] === blacklist)) this.splice(i, 1);
|
||||
else newArr.push(this[i]);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/* Fisher Yates what up */
|
||||
Array.prototype.shuffle = function() {
|
||||
var i = this.length;
|
||||
if(i === 0) return false;
|
||||
while(--i) {
|
||||
var j = Math.floor(Math.random() * (i + 1)),
|
||||
tmpi = this[i],
|
||||
tmpj = this[j];
|
||||
this[i] = tmpj;
|
||||
this[j] = tmpi;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
Array.prototype.average = function() {
|
||||
var avg = 0,
|
||||
i = this.length;
|
||||
|
||||
if(i === 0) return false;
|
||||
while(--i) {
|
||||
avg = avg + this[i];
|
||||
}
|
||||
return parseInt(avg / this.length, 10);
|
||||
};
|
||||
|
||||
var kat = {
|
||||
choices: [],
|
||||
game: null,
|
||||
letter: null,
|
||||
right: null,
|
||||
wrong: null,
|
||||
rightCount: 0,
|
||||
wrongCount: 0,
|
||||
oldFontSize: null,
|
||||
orientationSwapFontFize: null,
|
||||
|
||||
/* Default to two minutes... */
|
||||
idealLearnTime: 1000*60,
|
||||
|
||||
/* Gets constructed in a bit. */
|
||||
sounds: [],
|
||||
|
||||
/* An array of ones that were chosen incorrectly. Circles back to them
|
||||
* on average every 2 minutes to start.
|
||||
*/
|
||||
loopBacks: [],
|
||||
previousLoopBackTimers: [1000*60*2],
|
||||
|
||||
/* Used for lookup of time taken to commit to memory. */
|
||||
previousLoopBacks: {},
|
||||
|
||||
/* This gets set to true after the 4 minute mark, wherein the
|
||||
* turn functions will take over until loopBacks is empty for each new
|
||||
* turn.
|
||||
*/
|
||||
runloopBacks: false,
|
||||
|
||||
/* Stored object from setTimeout, for checking. */
|
||||
loopBackTimer: null,
|
||||
|
||||
katas: {
|
||||
'ア': 'a <em>(ah)</em>',
|
||||
'カ': 'ka <em>(kah)</em>',
|
||||
'サ': 'sa <em>(sah)</em>',
|
||||
'タ': 'ta <em>(tah)</em>',
|
||||
'ナ': 'na <em>(nah)</em>',
|
||||
'ハ': 'ha <em>(hah)</em>',
|
||||
'マ': 'ma <em>(mah)</em>',
|
||||
'ヤ': 'ya <em>(yah)</em>',
|
||||
'ラ': 'ra <em>(rah)</em>',
|
||||
'ワ': 'wa <em>(wah)</em>',
|
||||
'ン': 'n',
|
||||
'ガ': 'ga <em>(gah)</em>',
|
||||
'ザ': 'za <em>(zah)</em>',
|
||||
'ダ': 'da <em>(dah)</em>',
|
||||
'バ': 'ba <em>(bah)</em>',
|
||||
'パ': 'pa <em>(pah)</em>',
|
||||
'アァ': 'fa <em>(fah)</em>',
|
||||
'キャ': 'kya <em>(kyah)</em>',
|
||||
'シャ': 'sha <em>(shah)</em>',
|
||||
'チャ': 'cha <em>(chah)</em>',
|
||||
'ニャ': 'nya <em>(nyah)</em>',
|
||||
'ヒャ': 'hya <em>(hyah)</em>',
|
||||
'ミャ': 'mya <em>(myah)</em>',
|
||||
'リャ': 'rya <em>(ryah)</em>',
|
||||
'ギャ': 'gya <em>(gyah)</em>',
|
||||
'ヅャ': 'ja <em>(jah)</em>',
|
||||
'ビャ': 'bya <em>(byah)</em>',
|
||||
'ピャ': 'pya <em>(pyah)</em>',
|
||||
'イ': 'i <em>(ee)</em>',
|
||||
'キ': 'ki <em>(kee)</em>',
|
||||
'シ': 'shi <em>(shee)</em>',
|
||||
'チ': 'chi <em>(chee)</em>',
|
||||
'ニ': 'ni <em>(nee)</em>',
|
||||
'ヒ': 'hi <em>(hee)</em>',
|
||||
'ミ': 'mi <em>(mee)</em>',
|
||||
'リ': 'ri <em>(ree)</em>',
|
||||
'ギ': 'gi <em>(gee)</em>',
|
||||
'ジ': 'ji <em>(jee)</em>',
|
||||
'ヂ': 'ji <em>(jee)</em>',
|
||||
'ビ': 'bi <em>(bee)</em>',
|
||||
'ピ': 'pi <em>(pee)</em>',
|
||||
'ワィ': 'fi <em>(fee)</em>',
|
||||
'ウ': 'u <em>(oo)</em>',
|
||||
'ク': 'ku <em>(koo)</em>',
|
||||
'ス': 'su <em>(soo)</em>',
|
||||
'ツ': 'tsu <em>(tsoo)</em>',
|
||||
'ヌ': 'nu <em>(noo)</em>',
|
||||
'フ': 'fu <em>(foo)</em>',
|
||||
'ム': 'mu <em>(moo)</em>',
|
||||
'ユ': 'yu <em>(yoo)</em>',
|
||||
'ル': 'ru <em>(roo)</em>',
|
||||
'グ': 'gu <em>(goo)</em>',
|
||||
'ズ': 'zu <em>(zoo)</em>',
|
||||
'ヅ': 'zu <em>(zoo)</em>',
|
||||
'ブ': 'bu <em>(boo)</em>',
|
||||
'プ': 'pu <em>(poo)</em>',
|
||||
'キユ': 'kyu <em>(kyoo)</em>',
|
||||
'シユ': 'shu <em>(shoo)</em>',
|
||||
'チユ': 'chu <em>(choo)</em>',
|
||||
'ニユ': 'nyu <em>(nyoo)</em>',
|
||||
'ヒユ': 'hyu <em>(hyoo)</em>',
|
||||
'ミユ': 'myu <em>(myoo)</em>',
|
||||
'リユ': 'ryu <em>(ryoo)</em>',
|
||||
'ギユ': 'gyu <em>(gyoo)</em>',
|
||||
'ジユ': 'ju <em>(joo)</em>',
|
||||
'ビユ': 'byu <em>(byoo)</em>',
|
||||
'ピユ': 'pyu <em>(pyoo)</em>',
|
||||
'エ': 'e <em>(eh)</em>',
|
||||
'ケ': 'ke <em>(keh)</em>',
|
||||
'セ': 'se <em>(seh)</em>',
|
||||
'テ': 'te <em>(teh)</em>',
|
||||
'ネ': 'ne <em>(neh)</em>',
|
||||
'ヘ': 'he <em>(heh)</em>',
|
||||
'メ': 'me <em>(meh)</em>',
|
||||
'レ': 're <em>(reh)</em>',
|
||||
'ゲ': 'ge <em>(geh)</em>',
|
||||
'ゼ': 'ze <em>(zeh)</em>',
|
||||
'デ': 'de <em>(deh)</em>',
|
||||
'ベ': 'be <em>(beh)</em>',
|
||||
'ペ': 'pe <em>(peh)</em>',
|
||||
'フエ': 'fe <em>(feh)</em>',
|
||||
'オ': 'o <em>(oh)</em>',
|
||||
'コ': 'ko <em>(koh)</em>',
|
||||
'ソ': 'so <em>(soh)</em>',
|
||||
'ト': 'to <em>(toh)</em>',
|
||||
'ノ': 'no <em>(noh)</em>',
|
||||
'ホ': 'ho <em>(hoh)</em>',
|
||||
'モ': 'mo <em>(moh)</em>',
|
||||
'ヨ': 'yo <em>(yoh)</em>',
|
||||
'ロ': 'ro <em>(roh)</em>',
|
||||
'ヲ': 'o <em>(oh)</em>',
|
||||
'ゴ': 'go <em>(goh)</em>',
|
||||
'ゾ': 'zo <em>(zoh)</em>',
|
||||
'ド': 'do <em>(doh)</em>',
|
||||
'ボ': 'bo <em>(boh)</em>',
|
||||
'ポ': 'po <em>(poh)</em>',
|
||||
'フォ': 'fo <em>(foh)</em>',
|
||||
'キヨ': 'kyo <em>(kyoh)</em>',
|
||||
'シヨ': 'sho <em>(shoh)</em>',
|
||||
'チヨ': 'cho <em>(choh)</em>',
|
||||
'ニヨ': 'nyo <em>(nyoh)</em>',
|
||||
'ヒヨ': 'hyo <em>(hyoh)</em>',
|
||||
'ミヨ': 'myo <em>(myoh)</em>',
|
||||
'リヨ': 'ryo <em>(ryoh)</em>',
|
||||
'ギヨ': 'gyo <em>(gyoh)</em>',
|
||||
'ジヨ': 'jo <em>(joh)</em>',
|
||||
'ビヨ': 'byo <em>(byoh)</em>',
|
||||
'ピヨ': 'pyo <em>(pyoh)</em>',
|
||||
},
|
||||
|
||||
/* Yeah custom layout managers because CSS wasn't meant for this. ;P */
|
||||
resolveLayout: function() {
|
||||
var w = window.innerWidth,
|
||||
h = window.innerHeight;
|
||||
|
||||
/* Minus 20 to account for left/right automagic padding. */
|
||||
kat.game.style.width = (w - 20) + 'px';
|
||||
|
||||
/* Minus 80 for (40 = header height, 20 pixels total top/bottom automagic padding) */
|
||||
kat.game.style.height = (h - 80) + 'px';
|
||||
|
||||
/* Get the letter nice and into position. */
|
||||
if(w < h) {
|
||||
var ideal = w - 22;
|
||||
kat.letter.style.cssText = "width: " + ideal + "px; height: " + ideal + "px; margin: 0 auto 10px;";
|
||||
kat.letter.style.fontSize = (kat.letter.innerHTML.length > 1 ? ideal - 150 : ideal - 30) + "px";
|
||||
kat.choicesNode.style.cssText = 'float: left; clear: left; width: ' + ideal + 'px;';
|
||||
|
||||
kat.choices.forEach(function(btn) {
|
||||
btn.style.cssText = 'padding: 7px 0; font-size: 12px;';
|
||||
});
|
||||
} else {
|
||||
var ideal = h - 60;
|
||||
kat.letter.style.cssText = "width: " + ideal + "px; height: " + ideal + "px; margin: 0 10px 0 0;";
|
||||
kat.letter.style.fontSize = (kat.letter.innerHTML.length > 1 ? ideal - 140 : ideal - 130) + "px";
|
||||
kat.choicesNode.style.cssText = 'float: right; clear: none; width: ' + ((w - 35) - ideal) + 'px;';
|
||||
|
||||
kat.choices.forEach(function(btn) {
|
||||
btn.style.cssText = 'padding: 50px 0; font-size: 40px;';
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
check: function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if(e.srcElement.nodeType !== 1) return false;
|
||||
|
||||
var ch = kat.letter.innerHTML,
|
||||
node = e.srcElement.nodeName === 'EM' ? e.srcElement.parentNode : e.srcElement,
|
||||
possibleOtherNode = null,
|
||||
answer = node.innerHTML;
|
||||
|
||||
if(kat.katas[ch] === answer) {
|
||||
node.className = 'right';
|
||||
++kat.rightCount;
|
||||
kat.right.innerHTML = kat.rightCount;
|
||||
|
||||
if(typeof kat.previousLoopBacks[ch] !== 'undefined') {
|
||||
var diff = +new Date() - kat.previousLoopBacks[ch];
|
||||
kat.previousLoopBacks[ch] = undefined;
|
||||
kat.previousLoopBackTimers.push(diff);
|
||||
kat.idealLearnTime = kat.previousLoopBackTimers.average();
|
||||
}
|
||||
} else {
|
||||
kat.loopBacks.push(ch);
|
||||
|
||||
/* If we're in loopBack mode and this is one they already got wrong
|
||||
* once, then we wanna set the idealLearnTime to be the average of all the previous
|
||||
* idealLearnTimes (set when they get one they had wrong correct).
|
||||
*/
|
||||
if(typeof kat.previousLoopBacks[ch] === 'undefined') {
|
||||
kat.previousLoopBacks[ch] = +new Date();
|
||||
}
|
||||
|
||||
/* We're gonna come back to this one down the road. */
|
||||
if(kat.loopBackTimer === null) {
|
||||
kat.loopBackTimer = setTimeout(function() {
|
||||
kat.runloopBacks = true;
|
||||
clearTimeout(kat.loopBackTimer);
|
||||
kat.loopBackTimer = null;
|
||||
}, kat.idealLearnTime);
|
||||
}
|
||||
|
||||
++kat.wrongCount;
|
||||
kat.wrong.innerHTML = kat.wrongCount;
|
||||
|
||||
var correct_answer = kat.katas[ch];
|
||||
|
||||
for(var choice in kat.choices) {
|
||||
if(kat.choices[choice].innerHTML === correct_answer) {
|
||||
possibleOtherNode = kat.choices[choice];
|
||||
node.className = 'wrong';
|
||||
possibleOtherNode.className = 'right';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
node.className = '';
|
||||
if(possibleOtherNode !== null) possibleOtherNode.className = '';
|
||||
kat.newTurn();
|
||||
}, 1500);
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
newTurn: function() {
|
||||
if(kat.loopBacks.length <= 0) kat.runloopBacks = false;
|
||||
|
||||
var kata = kat.sounds[Math.floor(Math.random() * (kat.sounds.length - 1))];
|
||||
if(kat.runloopBacks) {
|
||||
var rndm = kat.loopBacks.splice(Math.floor(Math.random() * (kat.loopBacks.length - 1)), 1)[0];
|
||||
kata = {
|
||||
ch: rndm,
|
||||
sound: kat.katas[rndm]
|
||||
};
|
||||
}
|
||||
|
||||
var answers = [kata.sound],
|
||||
extraAnswers = [],
|
||||
choices = [],
|
||||
lstRndm = null;
|
||||
|
||||
for(var i = 0; i < 10; i++) {
|
||||
extraAnswers.push(kat.sounds[Math.floor(Math.random() * (kat.sounds.length - 1))].sound);
|
||||
}
|
||||
answers = answers.concat(extraAnswers.unique(kata.sound).slice(0, 3)).shuffle();
|
||||
|
||||
if(kata.ch.length > 1) {
|
||||
if(kat.oldFontSize === null) {
|
||||
kat.oldFontSize = parseInt(window.getComputedStyle(kat.letter, '')['font-size']);
|
||||
kat.letter.style.fontSize = (kat.oldFontSize - 140) + 'px';
|
||||
}
|
||||
kat.letter.innerHTML = kata.ch;
|
||||
} else {
|
||||
if(kat.oldFontSize !== null) {
|
||||
kat.letter.style.fontSize = kat.oldFontSize + 'px';
|
||||
kat.oldFontSize = null;
|
||||
}
|
||||
kat.letter.innerHTML = kata.ch;
|
||||
}
|
||||
|
||||
for(var choice in kat.choices) {
|
||||
choices.push(kat.choices[choice]);
|
||||
}
|
||||
|
||||
for(var i = 0, j = choices.length; i < j; i++) {
|
||||
choices[i].innerHTML = answers[i];
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
};
|
||||
|
||||
document.addEventListener('deviceready', function() {
|
||||
//document.addEventListener('menuKeyDown', function(e) {
|
||||
// navigator.notification.alert(device.uuid, function(){}, '', 'Dismiss');
|
||||
//}, false);
|
||||
|
||||
/* Absense of querySelectorAll pre-Android 2.0 makes Ryan sad. ;P */
|
||||
['choice_1', 'choice_2', 'choice_3', 'choice_4'].forEach(function(choice) {
|
||||
kat.choices[choice] = document.getElementById(choice);
|
||||
kat.choices[choice].addEventListener('touchstart', kat.check, false);
|
||||
});
|
||||
|
||||
['intro', 'game', 'letter','right', 'wrong', 'get_started'].forEach(function(nodeName) {
|
||||
kat[nodeName] = document.getElementById(nodeName);
|
||||
});
|
||||
|
||||
/* Need to go ahead and get a separate Array for the sounds to pull false entries from. */
|
||||
for(var key in kat.katas) { kat.sounds.push({ch: key, sound: kat.katas[key]}); }
|
||||
|
||||
/* When they hit get started, start... */
|
||||
kat.get_started.addEventListener('touchstart', function(e) {
|
||||
e.preventDefault();
|
||||
kat.intro.style.display = 'none';
|
||||
kat.newTurn();
|
||||
kat.game.style.display = 'block';
|
||||
kat.game.style.opacity = 1;
|
||||
return false;
|
||||
}, false);
|
||||
|
||||
kat.choicesNode = document.getElementById('choices');
|
||||
|
||||
kat.resolveLayout();
|
||||
window.addEventListener('resize', kat.resolveLayout);
|
||||
}, false);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
3498
assets/www/phonegap.0.9.4.js
Executable file
3498
assets/www/phonegap.0.9.4.js
Executable file
File diff suppressed because it is too large
Load diff
22
assets/www/zepto.js
Normal file
22
assets/www/zepto.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
var Zepto=function(){function f(a){return a.filter(function(c){return c!==i&&c!==null})}function h(a){return a.reduce(function(c,d){return c.concat(d)},[])}function n(a){return a.replace(/-+(.)?/g,function(c,d){return d?d.toUpperCase():""})}function j(a,c){this.dom=a||[];this.length=this.dom.length;this.selector=c||""}function b(a,c){if(a==g)return new j;else if(c!==i)return b(c).find(a);else if(typeof a==="function")return b(g).ready(a);else{var d;if(a instanceof j)d=a.dom;else{if(a instanceof Array)d=
|
||||
f(a);else{if(a instanceof Element||a===window)d=[a];else{if(q.test(a)){e.innerHTML=(""+a).trim();d=l.call(e.childNodes);e.innerHTML="";d=d}else d=o(g,a);d=d}d=d}d=d}return new j(d,a)}}var l=[].slice,k,m,o,q,e,g=window.document,i;if(String.prototype.trim===i)String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")};q=/^\s*<.+>/;e=g.createElement("div");b.extend=function(a,c){for(k in c)a[k]=c[k];return a};b.qsa=o=function(a,c){return l.call(a.querySelectorAll(c))};b.fn={ready:function(a){g.addEventListener("DOMContentLoaded",
|
||||
a,false);return this},get:function(a){return a===i?this.dom:this.dom[a]},size:function(){return this.length},remove:function(){return this.each(function(){this.parentNode.removeChild(this)})},each:function(a){this.dom.forEach(function(c,d){a.call(c,d,c)});return this},filter:function(a){return b(this.dom.filter(function(c){return o(c.parentNode,a).indexOf(c)>=0}))},is:function(a){return this.length>0&&b(this.dom[0]).filter(a).length>0},eq:function(a){return b(this.get(a))},first:function(){return b(this.get(0))},
|
||||
last:function(){return b(this.get(this.length-1))},find:function(a){var c;c=this.length==1?o(this.get(0),a):h(this.dom.map(function(d){return o(d,a)}));return b(c)},closest:function(a,c){var d=this.dom[0],p=o(c!==i?c:g,a);if(p.length===0)d=null;for(;d&&d!==g&&p.indexOf(d)<0;)d=d.parentNode;return b(d)},parents:function(a){for(var c=[],d=this.get();d.length>0;)d=f(d.map(function(p){if((p=p.parentNode)&&p!==g&&c.indexOf(p)<0){c.push(p);return p}}));c=b(c);return a===i?c:c.filter(a)},parent:function(a){var c,
|
||||
d=[];this.each(function(){if((c=this.parentNode)&&d.indexOf(c)<0)d.push(c)});d=b(d);return a===i?d:d.filter(a)},pluck:function(a){return this.dom.map(function(c){return c[a]})},show:function(){return this.css("display","block")},hide:function(){return this.css("display","none")},prev:function(){return b(this.pluck("previousElementSibling"))},next:function(){return b(this.pluck("nextElementSibling"))},html:function(a){return a===i?this.length>0?this.dom[0].innerHTML:null:this.each(function(c){this.innerHTML=
|
||||
typeof a=="function"?a(c,this.innerHTML):a})},text:function(a){return a===i?this.length>0?this.dom[0].innerText:null:this.each(function(){this.innerText=a})},attr:function(a,c){return typeof a=="string"&&c===i?this.length>0&&this.dom[0].nodeName==="INPUT"&&this.dom[0].type==="text"&&a==="value"?this.val():this.length>0?this.dom[0].getAttribute(a)||i:null:this.each(function(d){if(typeof a=="object")for(k in a)this.setAttribute(k,a[k]);else this.setAttribute(a,typeof c=="function"?c(d,this.getAttribute(a)):
|
||||
c)})},removeAttr:function(a){return this.each(function(){this.removeAttribute(a)})},val:function(a){return a===i?this.length>0?this.dom[0].value:null:this.each(function(){this.value=a})},offset:function(){var a=this.dom[0].getBoundingClientRect();return{left:a.left+g.body.scrollLeft,top:a.top+g.body.scrollTop,width:a.width,height:a.height}},css:function(a,c){if(c===i&&typeof a=="string")return this.dom[0].style[n(a)];m="";for(k in a)m+=k+":"+a[k]+";";if(typeof a=="string")m=a+":"+c;return this.each(function(){this.style.cssText+=
|
||||
";"+m})},index:function(a){return this.dom.indexOf(b(a).get(0))},hasClass:function(a){return RegExp("(^|\\s)"+a+"(\\s|$)").test(this.dom[0].className)},addClass:function(a){return this.each(function(){!b(this).hasClass(a)&&(this.className+=(this.className?" ":"")+a)})},removeClass:function(a){return this.each(function(){this.className=this.className.replace(RegExp("(^|\\s)"+a+"(\\s|$)")," ").trim()})},toggleClass:function(a,c){return this.each(function(){c!==i&&!c||b(this).hasClass(a)?b(this).removeClass(a):
|
||||
b(this).addClass(a)})}};["width","height"].forEach(function(a){b.fn[a]=function(){return this.offset()[a]}});var r={append:"beforeEnd",prepend:"afterBegin",before:"beforeBegin",after:"afterEnd"};for(k in r)b.fn[k]=function(a){return function(c){return this.each(function(d,p){if(c instanceof j){dom=c.dom;if(a=="afterBegin"||a=="afterEnd")for(var s=0;s<dom.length;s++)p.insertAdjacentElement(a,dom[dom.length-s-1]);else for(s=0;s<dom.length;s++)p.insertAdjacentElement(a,dom[s])}else p["insertAdjacent"+
|
||||
(c instanceof Element?"Element":"HTML")](a,c)})}}(r[k]);j.prototype=b.fn;return b}();"$"in window||(window.$=Zepto);
|
||||
(function(f){function h(e,g,i,r){g=n(g);if(g.ns)var a=RegExp("(?:^| )"+g.ns.replace(" "," .* ?")+"(?: |$)");return(m[e._zid||(e._zid=o++)]||[]).filter(function(c){return c&&(!g.e||c.e==g.e)&&(!g.ns||a.test(c.ns))&&(!i||c.fn==i)&&(!r||c.sel==r)})}function n(e){e=(""+e).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function j(e,g,i,r,a){var c=e._zid||(e._zid=o++),d=m[c]||(m[c]=[]);g.split(/\s/).forEach(function(p){p=f.extend(n(p),{fn:i,sel:r,del:a,i:d.length});d.push(p);e.addEventListener(p.e,
|
||||
a||i,false)})}function b(e,g,i,r){var a=e._zid||(e._zid=o++);(g||"").split(/\s/).forEach(function(c){h(e,c,i,r).forEach(function(d){delete m[a][d.i];e.removeEventListener(d.e,d.del||d.fn,false)})})}function l(e){var g=f.extend({originalEvent:e},e);q.forEach(function(i){g[i]=function(){return e[i].apply(e,arguments)}});return g}var k=f.qsa,m={},o=1;f.event={add:function(e,g,i){j(e,g,i)},remove:function(e,g,i){b(e,g,i)}};f.fn.bind=function(e,g){return this.each(function(){j(this,e,g)})};f.fn.unbind=
|
||||
function(e,g){return this.each(function(){b(this,e,g)})};var q=["preventDefault","stopImmediatePropagation","stopPropagation"];f.fn.delegate=function(e,g,i){return this.each(function(r,a){j(a,g,i,e,function(c){for(var d=c.target,p=k(a,e);d&&p.indexOf(d)<0;)d=d.parentNode;d&&d!==a&&d!==document&&i.call(d,f.extend(l(c),{currentTarget:d,liveFired:a}))})})};f.fn.undelegate=function(e,g,i){return this.each(function(){b(this,g,i,e)})};f.fn.live=function(e,g){f(document.body).delegate(this.selector,e,g);
|
||||
return this};f.fn.die=function(e,g){f(document.body).undelegate(this.selector,e,g);return this};f.fn.trigger=function(e){return this.each(function(){var g=document.createEvent("Events");this.dispatchEvent(g,g.initEvent(e,true,false))})}})(Zepto);
|
||||
(function(f){function h(j){var b={},l=j.match(/(Android)\s+([\d.]+)/),k=j.match(/(iPhone\sOS)\s([\d_]+)/),m=j.match(/(iPad).*OS\s([\d_]+)/),o=j.match(/(webOS)\/([\d.]+)/);j=j.match(/(BlackBerry).*Version\/([\d.]+)/);if(l){b.android=true;b.version=l[2]}if(k){b.ios=true;b.version=k[2].replace(/_/g,".");b.iphone=true}if(m){b.ios=true;b.version=m[2].replace(/_/g,".");b.ipad=true}if(o){b.webos=true;b.version=o[2]}if(j){b.blackberry=true;b.version=j[2]}return b}f.os=h(navigator.userAgent);f.__detect=h;
|
||||
var n=navigator.userAgent.match(/WebKit\/([\d.]+)/);f.browser=n?{webkit:true,version:n[1]}:{webkit:false}})(Zepto);(function(f){f.fn.anim=function(h,n,j){var b=[],l,k;for(k in h)if(k==="opacity")l=h[k];else b.push(k+"("+h[k]+")");return this.css({"-webkit-transition":"all "+(n!==undefined?n:0.5)+"s "+(j||""),"-webkit-transform":b.join(" "),opacity:l})}})(Zepto);
|
||||
(function(f){var h={},n;f(document).ready(function(){f(document.body).bind("touchstart",function(j){var b=Date.now(),l=b-(h.last||b);h.target="tagName"in j.touches[0].target?j.touches[0].target:j.touches[0].target.parentNode;n&&clearTimeout(n);h.x1=j.touches[0].pageX;if(l>0&&l<=250)h.isDoubleTap=true;h.last=b}).bind("touchmove",function(j){h.x2=j.touches[0].pageX}).bind("touchend",function(){if(h.isDoubleTap){f(h.target).trigger("doubleTap");h={}}else if(h.x2>0){Math.abs(h.x1-h.x2)>30&&f(h.target).trigger("swipe")&&
|
||||
f(h.target).trigger("swipe"+(h.x1-h.x2>0?"Left":"Right"));h.x1=h.x2=h.last=0}else if("last"in h)n=setTimeout(function(){n=null;f(h.target).trigger("tap");h={}},250)}).bind("touchcancel",function(){h={}})});["swipe","swipeLeft","swipeRight","doubleTap","tap"].forEach(function(j){f.fn[j]=function(b){return this.bind(j,b)}})})(Zepto);
|
||||
(function(f){function h(){}var n=0;f.ajaxJSONP=function(b){var l;l="jsonp"+ ++n;window[l]=b.success;var k=document.createElement("script");f(k).attr({src:b.url.replace(/callback=\?/,"callback="+l)});f("head").append(k)};f.ajax=function(b){b=b||{};if(b.url&&/callback=\?/.test(b.url))return f.ajaxJSONP(b);var l=b.data,k=b.success||h,m=b.error||h,o=j[b.dataType],q=b.contentType,e=new XMLHttpRequest;e.onreadystatechange=function(){if(e.readyState==4)if(e.status>=200&&e.status<300||e.status==0)if(o=="application/json"){var g,
|
||||
i=false;try{g=JSON.parse(e.responseText)}catch(r){i=r}i?m(e,"parsererror",i):k(g,"success",e)}else k(e.responseText,"success",e);else m(e,"error")};e.open(b.type||"GET",b.url||window.location,true);o&&e.setRequestHeader("Accept",o);if(l instanceof Object){l=JSON.stringify(l);q=q||"application/json"}q&&e.setRequestHeader("Content-Type",q);e.setRequestHeader("X-Requested-With","XMLHttpRequest");e.send(l)};var j=f.ajax.mimeTypes={json:"application/json",xml:"application/xml",html:"text/html",text:"text/plain"};
|
||||
f.get=function(b,l){f.ajax({url:b,success:l})};f.post=function(b,l,k,m){if(l instanceof Function){m=m||k;k=l;l=null}f.ajax({type:"POST",url:b,data:l,success:k,dataType:m})};f.getJSON=function(b,l){f.ajax({url:b,success:l,dataType:"json"})};f.fn.load=function(b,l){if(!this.dom.length)return this;var k=this,m=b.split(/\s/),o;if(m.length>1){b=m[0];o=m[1]}f.get(b,function(q){k.html(o?f(document.createElement("div")).html(q).find(o).html():q);l&&l()});return this}})(Zepto);
|
||||
(function(f){var h=[],n;f.fn.remove=function(){return this.each(function(j){if(j.tagName=="IMG"){h.push(j);j.src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";n&&clearTimeout(n);n=setTimeout(function(){h=[]},6E4)}j.parentNode.removeChild(j)})}})(Zepto);
|
||||
Loading…
Add table
Add a link
Reference in a new issue