Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加「逐字朗讀!」功能 #4

Merged
merged 5 commits into from May 21, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions coffeescripts/application.js.coffee
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
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
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);