Skip to content

Commit

Permalink
Merge pull request #4 from Grassboy/gh-pages
Browse files Browse the repository at this point in the history
增加「逐字朗讀」功能 thanks to @Grassboy
  • Loading branch information
zhusee2 committed May 21, 2013
2 parents ed054f5 + 31877c5 commit e8be723
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
12 changes: 12 additions & 0 deletions coffeescripts/application.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,15 @@ $ ->
speaker.play()

event.preventDefault()

$('#btn-digitplay').on 'click', (event) ->
numberToPlay = $('#ma-number').val()
numberToPlay = numberToPlay.match(/^[1-9]+$/)

if numberToPlay
seq = numberToPlay[0].replace(/([\d])/g, ",d$1").split(",")
seq.splice 0 1
speaker.numberQueue.push "thank"
speaker.playSequence seq

event.preventDefault()
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ <h1>Bumbler to Speech <span class="text-group">邦伯來數數</span></h1>
<input type="button" id="btn-play" class="btn btn-success" value="播放數字">
<input type="button" id="btn-countup" class="btn btn-warning" value="從1開始數!">
<input type="button" id="btn-countdown" class="btn btn-danger" value="通牒倒數!">
<input type="button" id="btn-digitplay" class="btn btn-info" value="逐字朗讀!">
</form>
</div>

Expand Down
16 changes: 14 additions & 2 deletions javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
}
return event.preventDefault();
});
return $('#btn-countdown').on('click', function(event) {
$('#btn-countdown').on('click', function(event) {
var numberToPlay, _j, _results1;
numberToPlay = checkInput();
if (numberToPlay) {
Expand All @@ -222,6 +222,18 @@
}
return event.preventDefault();
});
return $('#btn-digitplay').on('click', function(event) {
var numberToPlay, seq;
numberToPlay = $('#ma-number').val();
numberToPlay = numberToPlay.match(/^[1-9]+$/);
if (numberToPlay) {
seq = numberToPlay[0].replace(/([\d])/g, ",d$1").split(",");
seq.splice(0, 1);
speaker.numberQueue.push("thank");
speaker.playSequence(seq);
}
return event.preventDefault();
});
});

}).call(this);
}).call(this);

0 comments on commit e8be723

Please sign in to comment.