You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
4.8 KiB
119 lines
4.8 KiB
function overlay_in() {
|
|
$('.shadow').css({'display' : 'block'});
|
|
$('.overlay').css({'display' : 'block'});
|
|
$('.shadow').animate({'opacity' : 0.7});
|
|
$('.overlay').animate({'top' : '10%'});
|
|
}
|
|
|
|
function overlay_out() {
|
|
$('.shadow').animate({'opacity' : 0.0}, function () {
|
|
$('.overlay').css({'display' : 'none'});
|
|
});
|
|
$('.overlay').animate({'top' : '-70%'}, function () {
|
|
$('.shadow').css({'display' : 'none'});
|
|
});
|
|
}
|
|
|
|
function init_edit() {
|
|
var block_input = $('<input type="text" class="part-edit-input" id="block-input" placeholder="Location">')
|
|
block_input.val($('#block-info').text());
|
|
$('#block-info').replaceWith(block_input);
|
|
|
|
var partno_input = $('<input type="text" class="part-edit-input" id="partno-input" placeholder="Part number">')
|
|
partno_input.val($('#partno-info').text());
|
|
$('#partno-info').replaceWith(partno_input);
|
|
|
|
var description_input = $('<input type="text" class="part-edit-input" id="description-input" placeholder="Description">')
|
|
description_input.val($('#description-info').text());
|
|
$('#description-info').replaceWith(description_input);
|
|
|
|
var quantity_input = $('<input type="text" class="part-edit-input" id="quantity-input" placeholder="Quantity">')
|
|
quantity_input.val($('#quantity-info').text());
|
|
$('#quantity-info').replaceWith(quantity_input);
|
|
|
|
var notes_input = $('<input type="text" class="part-edit-input" id="notes-input" placeholder="Notes">')
|
|
notes_input.val($('#notes-info').text());
|
|
$('#notes-info').replaceWith(notes_input);
|
|
|
|
var datasheet_input = $('<input type="text" class="part-edit-input" id="datasheet-input" placeholder="Datasheet">')
|
|
datasheet_input.val($('#datasheet-info').text());
|
|
$('#datasheet-info').replaceWith(datasheet_input);
|
|
|
|
var newButton = '<div class="round-button"><a href="#" onclick="save()"><i class="fa fa-check" aria-hidden="true"></i></a></div>';
|
|
$('.round-button').replaceWith(newButton);
|
|
}
|
|
|
|
function save() {
|
|
var newButton = '<div class="round-button"><a href="#" onclick="init_edit()"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>';
|
|
console.log('pls add init edit code')
|
|
$('.round-button').replaceWith(newButton);
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
$('.search-bar').on('keyup', function() {
|
|
var query = $('.search-bar').val();
|
|
var filter = 0;
|
|
if($('#type').is(':checked'))
|
|
filter += 1;
|
|
if($('#partno').is(':checked'))
|
|
filter += 2 + 4 + 8;
|
|
if($('#description').is(':checked'))
|
|
filter += 16;
|
|
if($('#notes').is(':checked'))
|
|
filter += 32;
|
|
$.getJSON('http://127.0.0.1:5000/query/' + filter + '/' + query, function(data) {
|
|
var newResults = '<div class="results">';
|
|
for(var i = 0; i < data.length; i++) { // Create new view for results
|
|
newResults += '<div class="results-row" part-id="' + data[i].id + '">';
|
|
newResults += '<a href=#>'
|
|
|
|
newResults += '<div class="results-block">';
|
|
if (data[i].block != null)
|
|
newResults += data[i].block;
|
|
newResults += '</div>';
|
|
|
|
newResults += '<div class="results-type">';
|
|
if (data[i].type != null)
|
|
newResults += data[i].type;
|
|
newResults += '</div>';
|
|
|
|
newResults += '<div class="results-partno">';
|
|
if (data[i].partno != null)
|
|
newResults += data[i].partno;
|
|
newResults += '</div>';
|
|
|
|
newResults += '<div class="results-description">';
|
|
if (data[i].description != null)
|
|
newResults += data[i].description;
|
|
newResults += '</div>';
|
|
|
|
newResults += '<div class="results-notes">';
|
|
if (data[i].notes != null)
|
|
newResults += '<div class="tooltip"><i class="fa fa-sicky-note"></i><span class="tooltiptext">' + data[i].notes + '</span></div>';
|
|
//newResults += data[i].notes;
|
|
newResults += '</div>';
|
|
|
|
newResults += '<div class="results-datasheet">';
|
|
if (data[i].datasheet != null)
|
|
newResults += '<a href="http://127.0.0.1:5000/getfile/' + data[i].datasheet + '"><i class="fa fa-file-text" aria-hidden="true"></i></a>';
|
|
newResults += '</div>';
|
|
newResults += '</a>'
|
|
newResults += '</div>';
|
|
}
|
|
newResults += '</div>';
|
|
$('.results').replaceWith(newResults);
|
|
}).fail(function() {
|
|
console.log( "Query failed" );
|
|
});
|
|
});
|
|
|
|
$('.results-row').on('click', function() {
|
|
var partID = $(this).attr('part-id');
|
|
$.getJSON('http://127.0.0.1:5000/getpartinfo/' + partID, function(data) {
|
|
// TODO: Fill stuff with the fetched info
|
|
}).fail(function() {
|
|
console.log( "Fetching part info failed" );
|
|
});
|
|
});
|
|
});
|