Skip to content

Commit

Permalink
added mute and audio detect just in case
Browse files Browse the repository at this point in the history
  • Loading branch information
h3knix committed May 9, 2016
1 parent 9f0809a commit de1f664
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
30 changes: 24 additions & 6 deletions www/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,31 @@ var delete_audio = new Audio('media/snap.mp3');
var new_audio = new Audio('media/throw.mp3');

app.controller('tasksController', function($scope, $http, $mdDialog) {
$scope.muted = false;
$scope.has_audio = false;

var audio_controller = {
"audios": {}
,"play": function(sound_name) {
if ( ! $scope.muted && sound_name in audio_controller.audios ) {
audio_controller.audios[sound_name].play();
}
}
};
if ( Modernizr.audio ) {
$scope.has_audio = true;
audio_controller.audios = {
"complete": new Audio('media/slap.mp3')
,"delete": new Audio('media/snap.mp3')
,"new": new Audio('media/throw.mp3')
};
}

get_tasks();

function get_tasks(){
$http.get('task').then(function(response){
$scope.tasks = response.data;
console.log(response);
$scope.tasks = response.data;
},handle_response_error);
};
function show_alert(text) {
Expand Down Expand Up @@ -44,7 +62,7 @@ app.controller('tasksController', function($scope, $http, $mdDialog) {

$scope.add_task = function() {
$http.post('task/',{"name": $scope.taskNewName}).then(function(response){
new_audio.play();
audio_controller.play('new');
get_tasks();
$scope.taskNewName = '';
},handle_response_error);
Expand All @@ -53,7 +71,7 @@ app.controller('tasksController', function($scope, $http, $mdDialog) {
$scope.delete_task = function(id) {
show_yesno('Are you sure to delete this task?',function(){
$http.delete('task/'+ id).then(function(data){
delete_audio.play();
audio_controller.play('delete');
get_tasks();
},handle_response_error);
});
Expand All @@ -67,9 +85,9 @@ app.controller('tasksController', function($scope, $http, $mdDialog) {
}
$http.post('task/'+ id,{ "is_complete": is_complete }).then(function(response){
if ( is_complete ) {
complete_audio.play();
audio_controller.play('complete');
} else {
new_audio.play();
audio_controller.play('new');
}
get_tasks();
},handle_response_error);
Expand Down
8 changes: 7 additions & 1 deletion www/app/views/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
<header>
<img src="img/ninja.png" alt="">
TaskLee
<span class="credit"><a href="http://seldomshort.com/">Michael Vandenberghe <i class="fa fa-external-link"></i></a></span>
<span class="right">
<a href="http://seldomshort.com/">Michael Vandenberghe <i class="fa fa-external-link"></i></a>
</span>
</header>

<section>
Expand All @@ -27,12 +29,16 @@
</div>
</section>
<section class="add_task">
<span class="right" ng-show="has_audio">
<a ng-class="{sound_control: true,'muted': muted}" ng-click="muted = (muted ? false : true )"><i ng-class="{fa: true,'fa-volume-up': ! muted,'fa-volume-off': muted}"></i> sound fx</a>
</span>
<form ng-submit="add_task()">
<input type="text" placeholder="Task Name" ng-model="taskNewName">
<button type="submit"><i class="fa fa-plus"></i> Add Task</button>
</form>
</section>

<script src="js/modernizr.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-aria.min.js"></script>
Expand Down
13 changes: 11 additions & 2 deletions www/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ html,body {

a {
text-decoration: none;
color: #000 !important;
color: #000 !important;/*important to override material css*/
}
a:hover {
opacity: 0.6;
Expand All @@ -28,7 +28,7 @@ header img {
width: 40px;
}

header .credit {
.right {
float: right;
font-size: 12px;
}
Expand Down Expand Up @@ -64,6 +64,15 @@ section {
margin-left: 4px;
}

.sound_control {
display: inline-block;
margin-left: 10px;
color: #4D642D !important;
}
.sound_control.muted {
color: #FA2A00 !important;
}

.add_task input, button {
font-size: 0.7em;
line-height: 1;
Expand Down
3 changes: 3 additions & 0 deletions www/js/modernizr.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de1f664

Please sign in to comment.