Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ajax search and hashtag support

  • Loading branch information...
commit dd518560f7778d019f98bc65be86d4a3288ccdd0 1 parent 768f8ce
@ahmetalpbalkan authored
Showing with 22 additions and 12 deletions.
  1. +22 −12 index.html
View
34 index.html
@@ -50,7 +50,6 @@
div#description { font-size: 15px; margin-bottom: 1em; color: #666;}
div#about {position:absolute; bottom:0px; right: 10px; width:150px; font-size: 10px; text-align:right; color: #777;}
- img#logo {position:absolute; top:10px; right:15px;}
a.github { background-image: url(https://a248.e.akamai.net/assets.github.com/img/e6bef7a091f5f3138b8cd40bc3e114258dd68ddf/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67); background-position: 0 0; background-repeat: no-repeat; display: block; width: 150px; height: 150px; overflow: hidden; position: absolute; text-indent: -9999px; right: 0; top: 0px; }
@@ -96,7 +95,7 @@
}
}
- function doSearch(q){
+ function doSearch(q, callback){
$('#searchResults').html('');
preSearchHook();
@@ -119,7 +118,7 @@
});
});
- postSearchHook();
+ postSearchHook(callback);
});
}
@@ -130,7 +129,7 @@
$('#searchResults').slideDown();
}
- function postSearchHook(){
+ function postSearchHook(callback){
$('#searchLoading').hide();
searchResults = searchResults.slice(0, maxSearchResults);
@@ -143,14 +142,13 @@
click: function() {
startPlaying(result);
$('#searchResults').slideUp();
- return false;
}
}).appendTo('#searchResults')
anchor = $('<a />', {
src: result.images[0], // small
text: result.artist + ' - ' + result.name,
- href: '#'
+ href: '#'+encodeURIComponent(result.artist + ' - ' + result.name)
}).appendTo(main);
$('<img />', {
@@ -161,8 +159,9 @@
}).prependTo(anchor);
});
-
- $('#searchResults').slideDown();
+
+ if (callback) callback();
+ else $('#searchResults').slideDown();
}
}
@@ -283,6 +282,7 @@
_biggestImg = result.images.pop();
if (_biggestImg) $('#albumCover').attr('src', _biggestImg);
}
+ location.hash = encodeURIComponent(result.artist+' '+result.name);
startPlayingFromYoutube(result.artist, result.name);
}
@@ -346,6 +346,18 @@
var o = document.getElementById('ytplayer_object');
o.addEventListener("onStateChange", "ytPlayerState" );
o.addEventListener("onError", "playNext" );
+
+ if (location.hash && location.hash.length>2){
+ hash = location.hash.replace('#','');
+ hash = decodeURIComponent(hash);
+ //$('#q').val(hash);
+ cb = function(){
+ console.log($('#searchResults').length);
+ $('#searchResults a').first().trigger('click');
+ }
+
+ doSearch(hash, cb);
+ }
}
// on document ready
@@ -394,16 +406,14 @@
</script>
- <img src='radyo.png' width='150' height='150' id='logo'/>
-
<div id='description'>
- Radyo plays similar tracks one after another. Start by searching a well-known song
+ <strong>Radyo</strong> plays similar tracks one after another. Start by searching a well-known song
and enjoy!
</div>
<div id='about'>
<a target='_blank' href='http://ahmetalpbalkan.com/'><u>alp</u></a> made
- this. source-code is <a target='_blank' href='http://github.com/ahmetalpalkan/radyo'>available</a>
+ this and source code is <a target='_blank' href='http://github.com/ahmetalpalkan/radyo'>available</a>
on Github.
</div>
<!--<a class='github' target='_blank' href='http://github.com/ahmetalpbalkan/radyo'>Fork me on GitHub</a>-->
Please sign in to comment.
Something went wrong with that request. Please try again.