diff --git a/parts/static/script.js b/parts/static/script.js index b32f549..64eaa02 100755 --- a/parts/static/script.js +++ b/parts/static/script.js @@ -215,8 +215,19 @@ function show_part_info(partID) { }); // update URL and history + update_url(partID); +} + +function update_url(partID){ + params = {} var query = $('.search-bar').val(); - window.history.pushState('searching', '', 'parts?q=' + query + '&p=' + partID) + if(len(query)>0){ + params['q'] = query + } + 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..12f0a05 100755 --- a/parts/templates/partsearch.html +++ b/parts/templates/partsearch.html @@ -37,7 +37,7 @@

No results.

-
+

Part Details

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