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 = $('') block_input.val($('#block-info').text()); $('#block-info').replaceWith(block_input); var partno_input = $('') partno_input.val($('#partno-info').text()); $('#partno-info').replaceWith(partno_input); var description_input = $('') description_input.val($('#description-info').text()); $('#description-info').replaceWith(description_input); var quantity_input = $('') quantity_input.val($('#quantity-info').text()); $('#quantity-info').replaceWith(quantity_input); var notes_input = $('') notes_input.val($('#notes-info').text()); $('#notes-info').replaceWith(notes_input); var datasheet_input = $('') datasheet_input.val($('#datasheet-info').text()); $('#datasheet-info').replaceWith(datasheet_input); var newButton = '
'; $('.round-button').replaceWith(newButton); } function save() { var newButton = '
'; 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('https://www.elab.kth.se/parts/query/' + filter + '/' + query, function(data) { var newResults = '
'; for(var i = 0; i < data.length; i++) { // Create new view for results newResults += '
'; newResults += '' newResults += '
'; if (data[i].block != null) newResults += data[i].block; newResults += '
'; newResults += '
'; if (data[i].type != null) newResults += data[i].type; newResults += '
'; newResults += '
'; if (data[i].partno != null) newResults += data[i].partno; newResults += '
'; newResults += '
'; if (data[i].description != null) newResults += data[i].description; newResults += '
'; newResults += '
'; if (data[i].notes != null) newResults += '
' + data[i].notes + '
'; //newResults += data[i].notes; newResults += '
'; newResults += '
'; newResults += '' newResults += '
'; } newResults += '
'; $('.results').replaceWith(newResults); }).fail(function() { console.log( "Query failed" ); }); }); $('.results-row').on('click', function() { var partID = $(this).attr('part-id'); $.getJSON('https://www.elab.kth.se/parts/getpartinfo/' + partID, function(data) { // TODO: Fill stuff with the fetched info }).fail(function() { console.log( "Fetching part info failed" ); }); }); });