Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions controllers/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

var module = angular.module('PlayerApp');

module.controller('PlayerController', function($scope, $rootScope, Auth, API, PlayQueue, Playback, $location) {
module.controller('PlayerController', function($scope, $rootScope, Auth, API, PlayQueue, Playback, $location, $timeout) {
var searchTimeoutId;
var searchDelay = 1000;

$scope.view = 'welcome';
$scope.profileUsername = Auth.getUsername();
$scope.playlists = [];
Expand All @@ -11,6 +14,7 @@
$scope.duration = 4000;
$scope.trackdata = null;
$scope.currenttrack = '';
$scope.isSearching = false;

function updatePlaylists() {
if ($scope.profileUsername != '') {
Expand Down Expand Up @@ -81,8 +85,14 @@
$scope.query = '';

$scope.loadsearch = function() {
console.log('search for', $scope.query);
$location.path('/search').search({ q: $scope.query }).replace();
$timeout.cancel(searchTimeoutId);
$scope.isSearching = true;

searchTimeoutId = $timeout(function() {
console.log('search for', $scope.query);
$scope.isSearching = false;
$location.path('/search').search({ q: $scope.query }).replace();
}, searchDelay)
};


Expand Down
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
<div ng-controller="PlayerController">
<div class="topgroup">
<div class="searchbox">
<input type="text" ng-model="query" ng-change="loadsearch()" ng-keyup="loadsearch()" placeholder="Search..." />
<input type="search" ng-model="query" ng-change="loadsearch()" ng-keyup="loadsearch()" placeholder="Search..." />
<span ng-hide="!isSearching">Searching...</span>
</div>
<div class="titlebox">
<a href="#/home">SAMPLE PLAYER APPLICATION</a>
Expand Down
4 changes: 2 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ hr {
position: absolute;
left: 0px;
top: 0px;
width: 220px;
width: 300px;
box-sizing: border-box;
padding: 7px;
}
Expand All @@ -102,7 +102,7 @@ hr {
padding: 5px 10px;
border-radius: 20px;
background-color: #ddd;
width: 100%;
width: 200px;
outline: none;
}

Expand Down