User editor, baseURL change, remove octopart autofill
This commit is contained in:
Regular → Executable
Regular → Executable
+30
-14
@@ -213,6 +213,10 @@ function show_part_info(partID) {
|
||||
}).fail(function() {
|
||||
console.log( "Fetching part info failed" );
|
||||
});
|
||||
|
||||
// update URL and history
|
||||
var query = $('.search-bar').val();
|
||||
window.history.pushState('searching', '', 'parts?q=' + query + '&p=' + partID)
|
||||
}
|
||||
|
||||
function perform_query() {
|
||||
@@ -245,6 +249,9 @@ function perform_query() {
|
||||
$('#no-results').animate({opacity:1},2000);
|
||||
console.log( "Query failed" );
|
||||
});
|
||||
|
||||
// update URL and history
|
||||
window.history.pushState('searching', '', 'parts?q=' + query)
|
||||
}
|
||||
|
||||
function container_onchange() {
|
||||
@@ -260,20 +267,20 @@ function container_onchange() {
|
||||
}
|
||||
}
|
||||
|
||||
function octopartFetch(){
|
||||
$('#magic-autofill-button').attr('disabled', 'disabled');
|
||||
$.getJSON(rootURL + 'fetchOctopartSnippet/' + $('#partno-input').val()).done(function(json){
|
||||
$('#magic-autofill-button').removeAttr('disabled');
|
||||
if (json['result']=='ok'){
|
||||
$('#description-input').val(json['snippet']);
|
||||
}else{
|
||||
$('#description-input').val('');
|
||||
$('#description-input').attr('placeholder', json['result']);
|
||||
}
|
||||
}).fail(function() {
|
||||
$('#magic-autofill-button').removeAttr('disabled');
|
||||
});
|
||||
}
|
||||
// function octopartFetch(){
|
||||
// $('#magic-autofill-button').attr('disabled', 'disabled');
|
||||
// $.getJSON(rootURL + 'fetchOctopartSnippet/' + $('#partno-input').val()).done(function(json){
|
||||
// $('#magic-autofill-button').removeAttr('disabled');
|
||||
// if (json['result']=='ok'){
|
||||
// $('#description-input').val(json['snippet']);
|
||||
// }else{
|
||||
// $('#description-input').val('');
|
||||
// $('#description-input').attr('placeholder', json['result']);
|
||||
// }
|
||||
// }).fail(function() {
|
||||
// $('#magic-autofill-button').removeAttr('disabled');
|
||||
// });
|
||||
// }
|
||||
|
||||
$(document).ready(function() {
|
||||
$.ajaxSetup({ cache: false });
|
||||
@@ -291,6 +298,15 @@ $(document).ready(function() {
|
||||
perform_query();
|
||||
});
|
||||
|
||||
//For linking to a search query or specific part
|
||||
const search_params = new URLSearchParams(window.location.search);
|
||||
if(search_params.has('q')){
|
||||
$('.search-bar').val(search_params.get('q')); perform_query();
|
||||
}
|
||||
if(search_params.has('p')){
|
||||
show_part_info(search_params.get('p'));
|
||||
}
|
||||
|
||||
// $('#partno-input').bind('blur',function() {
|
||||
// if($('#partno-input').val().length > 0){
|
||||
// octopartFetch();
|
||||
|
||||
Regular → Executable
Regular → Executable
Reference in New Issue
Block a user