made all parts relative with a global rootURL variable, for easy server deployment

master
Marek Baczynski 6 years ago
parent efc5af0b61
commit f8301552c4

@ -1,3 +1,5 @@
var rootURL = '/parts/'
function overlay_in() { function overlay_in() {
$('.shadow').css({'display' : 'block'}); $('.shadow').css({'display' : 'block'});
$('.overlay').css({'display' : 'block'}); $('.overlay').css({'display' : 'block'});
@ -123,7 +125,7 @@ function save(partID) {
$.ajax({ $.ajax({
// Your server script to process the upload // Your server script to process the upload
url: 'http://127.0.0.1:5000/parts/alter/' + partID, url: rootURL + 'alter/' + partID,
type: 'POST', type: 'POST',
data: data, data: data,
@ -162,7 +164,7 @@ function delete_entry(partID) {
if (!confirm('Delete the selected entry?')) if (!confirm('Delete the selected entry?'))
return; return;
$.ajax({ $.ajax({
url: 'http://127.0.0.1:5000/parts/delete/' + partID, url: rootURL + 'delete/' + partID,
type: 'GET', type: 'GET',
cache: false, cache: false,
contentType: false, contentType: false,
@ -178,7 +180,7 @@ function delete_entry(partID) {
} }
function show_part_info(partID) { function show_part_info(partID) {
$.getJSON('http://127.0.0.1:5000/parts/getpartinfo/' + partID, function(data) { $.getJSON(rootURL + 'getpartinfo/' + partID, function(data) {
$('table#details tr#location td p').text(text_filter(data.name)); // name is the location friendly name $('table#details tr#location td p').text(text_filter(data.name)); // name is the location friendly name
$('table#details tr#location td select').val(data.location_id); // name is the location friendly name $('table#details tr#location td select').val(data.location_id); // name is the location friendly name
$('table#details tr#partno td p').text(text_filter(data.partno)); $('table#details tr#partno td p').text(text_filter(data.partno));
@ -187,7 +189,7 @@ function show_part_info(partID) {
$('table#details tr#description td input').val(text_filter(data.description)); $('table#details tr#description td input').val(text_filter(data.description));
$('img#map').attr('src', 'parts/map/' + data.map); $('img#map').attr('src', 'parts/map/' + data.map);
if (data.datasheet != null) if (data.datasheet != null)
$('tr#datasheet-head').html($('<td>DATASHEET: <a href="http://127.0.0.1:5000/parts/getfile/' + data.datasheet.substring(0, data.datasheet.length - 4) + '"><i class="fa fa-file-text" aria-hidden="true"></i></a></td>')); $('tr#datasheet-head').html($('<td>DATASHEET: <a href="' + rootURL + 'getfile/' + data.datasheet.substring(0, data.datasheet.length - 4) + '"><i class="fa fa-file-text" aria-hidden="true"></i></a></td>'));
else else
$('tr#datasheet-head td').text('DATASHEET: '); $('tr#datasheet-head td').text('DATASHEET: ');
$('#edit-button').click(function() { $('#edit-button').click(function() {
@ -212,7 +214,7 @@ function perform_query() {
n:$('#notes').is(':checked') n:$('#notes').is(':checked')
}; };
filter = '0'; filter = '0';
$.getJSON('http://127.0.0.1:5000/parts/query/' + filter + '/' + query, data, function(data) { $.getJSON(rootURL + 'query/' + filter + '/' + query, data, function(data) {
$("#results").find("tr:not(:first)").remove(); // Delete all table rows $("#results").find("tr:not(:first)").remove(); // Delete all table rows
for(var i = 0; i < data.length; i++) { for(var i = 0; i < data.length; i++) {
var newRow = $('<tr onclick="show_part_info(' + data[i].id + ')"></tr>'); var newRow = $('<tr onclick="show_part_info(' + data[i].id + ')"></tr>');

Loading…
Cancel
Save