adding search to hash (page link)
This commit is contained in:
3
.gitignore
vendored
Normal file → Executable file
3
.gitignore
vendored
Normal file → Executable file
@@ -3,4 +3,5 @@
|
||||
/.settings/
|
||||
/build.xml
|
||||
/.externalToolBuilders/
|
||||
/.sass-cache/
|
||||
/.sass-cache/
|
||||
/tmp/
|
||||
|
||||
@@ -203,6 +203,7 @@ function Ugc()
|
||||
this.settings = new Settings();
|
||||
this._films = {};
|
||||
this._wip = 0;
|
||||
this.hash_sep = '-';
|
||||
|
||||
this.$Header = $('header');
|
||||
this.$Nav = $('nav');
|
||||
@@ -289,10 +290,13 @@ function Ugc()
|
||||
|
||||
this.initSearch = function()
|
||||
{
|
||||
$("#search")
|
||||
var $SearchInput = $("#search");
|
||||
$SearchInput
|
||||
.attr('placeholder', 'Search...')
|
||||
.on("change paste keyup", function() {
|
||||
if($(this).val()=='') $('.film').not('.banned').show();
|
||||
.on("change paste keyup", function(){
|
||||
var sValue = $(this).val();
|
||||
self.hash('search', sValue);
|
||||
if(sValue=='') $('.film').not('.banned').show();
|
||||
})
|
||||
.autocomplete(
|
||||
{
|
||||
@@ -319,6 +323,33 @@ function Ugc()
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var asHash = self.hash();
|
||||
var sDefaultSearch = asHash.items[0] || '';
|
||||
if(asHash.page=='search' && sDefaultSearch!='')
|
||||
{
|
||||
$SearchInput.val(sDefaultSearch).autocomplete("search", sDefaultSearch);
|
||||
}
|
||||
};
|
||||
|
||||
this.hash = function(sPage, asItems)
|
||||
{
|
||||
sPage = sPage || '';
|
||||
asItems = asItems || [];
|
||||
if(sPage=='')
|
||||
{
|
||||
var sHash = decodeURIComponent(window.location.hash.slice(1));
|
||||
var asHash = sHash.split(self.hash_sep);
|
||||
sPage = asHash.shift() || '';
|
||||
return {hash:sHash, page:sPage, items:asHash};
|
||||
}
|
||||
else
|
||||
{
|
||||
if(typeof asItems == 'string') asItems = [asItems];
|
||||
var sItems = (asItems.length > 0)?self.hash_sep+asItems.join(self.hash_sep):'';
|
||||
if(sItems=='') sPage = '';
|
||||
window.location.hash = '#'+encodeURIComponent(sPage+sItems);
|
||||
}
|
||||
};
|
||||
|
||||
this.addCinema = function(iCinemaId, hDom)
|
||||
|
||||
Reference in New Issue
Block a user