diff --git a/static/script.js b/static/script.js index aaebfda..d17d9f5 100644 --- a/static/script.js +++ b/static/script.js @@ -12,9 +12,10 @@ function overlay_out() { $('.overlay').animate({'top' : '-70%'}, function () { $('.shadow').css({'display' : 'none'}); }); + end_edit(); } -function init_edit() { +function init_edit(partID) { var block_input = $('') block_input.val($('#block-info').text()); $('#block-info').replaceWith(block_input); @@ -38,10 +39,20 @@ function init_edit() { var datasheet_input = $('') $('#datasheet-info').replaceWith(datasheet_input); - var newButton = '
'; + var newButton = ' '; $('.round-button').replaceWith(newButton); } +function new_entry() { + $('#block-info').text(''); + $('#partno-info').text(''); + $('#description-info').text(''); + $('#quantity-info').text(''); + $('#notes-info').text(''); + init_edit(-1); + overlay_in(); +} + function end_edit() { var block_par = '' + $('#block-input').val() + '
'; $('#block-input').replaceWith(block_par); @@ -58,15 +69,66 @@ function end_edit() { var notes_par = '' + $('#notes-input').val() + '
'; $('#notes-input').replaceWith(notes_par); - var datasheet_par = 'Please reload part info.
'; + var datasheet_par = ''; $('#datasheet-input').replaceWith(datasheet_par); var newButton = ' '; $('.round-button').replaceWith(newButton); } -function save() { - console.log('pls add init edit code'); +function save(partID) { + var block_v = $('#block-input').val(); + var partno_v = $('#partno-input').val(); + var description_v = $('#description-input').val(); + var quantity_v = $('#quantity-input').val(); + var notes_v = $('#notes-input').val(); + var datasheet = $('#datasheet-input')[0].files; + if(! partno.match(/^([a-zA-Z0-9]+\s*){1,3}$/g)) { + alert('Invalid part number format. Accepted:
'; + $('#datasheet-info').replaceWith(datasheet_par); + } ; + return xhr; + }, + }); + } + end_edit(); } diff --git a/templates/partsearch.html b/templates/partsearch.html index 8144bf4..a2127ca 100644 --- a/templates/partsearch.html +++ b/templates/partsearch.html @@ -79,6 +79,6 @@ --> - +