diff --git a/parts/static/script.js b/parts/static/script.js index b32f549..267e7fb 100755 --- a/parts/static/script.js +++ b/parts/static/script.js @@ -215,8 +215,19 @@ function show_part_info(partID) { }); // update URL and history - var query = $('.search-bar').val(); - window.history.pushState('searching', '', 'parts?q=' + query + '&p=' + partID) + update_url(partID); +} + +function update_url(partID){ + params = {} + // If there is a seach bar, take its content + if($('.search-bar').length){ + params['q'] = $('.search-bar').val(); + } + if(partID != 0){ + params['p'] = partID + } + window.history.pushState('searching', '', 'parts?' + jQuery.param(params)); } function perform_query() { @@ -250,8 +261,7 @@ function perform_query() { console.log( "Query failed" ); }); - // update URL and history - window.history.pushState('searching', '', 'parts?q=' + query) + update_url(0); } function container_onchange() { diff --git a/parts/templates/partsearch.html b/parts/templates/partsearch.html index 30f087c..41f55c3 100755 --- a/parts/templates/partsearch.html +++ b/parts/templates/partsearch.html @@ -37,7 +37,7 @@

No results.

-
+

Part Details

@@ -73,7 +73,7 @@
-
+