Skip to content

Commit

Permalink
Some more bells and whistles on item writeup
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnautDaniel committed Mar 4, 2017
1 parent 4964253 commit 33f2180
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 37 deletions.
2 changes: 1 addition & 1 deletion main.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@
(defmacro standard-item-writeup (&key image full-images invoice-data)
`(with-html-output (*standard-output* nil :indent t)

(:div :class "box"
(:div :class "box" :id "write-up-box"

(:div :class "box-header" :id "box-picture"
(:center (:img :id "input-picture" :src ,image :class "img-responsive"
Expand Down
94 changes: 58 additions & 36 deletions www/plugins/custom/ajax-item.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,61 @@
$(function() { var form = $('#new-item');
$(form).submit(function(event) { event.preventDefault();
var desc = document.getElementById('input-item-description').value;
var price = document.getElementById('input-item-price').value;
var qty = document.getElementById('input-item-qty').value;
var imageloc = document.getElementById('input-picture');
$(function() {
var form = $('#new-item');
$(form).submit(function(event) {
event.preventDefault();
var desc = document.getElementById('input-item-description').value;
var price = document.getElementById('input-item-price').value;
var qty = document.getElementById('input-item-qty').value;
var imageloc = document.getElementById('input-picture');

$.ajax({
type: 'POST',
url: 'additem',
data: {
'input-item-qty' : qty ,
'input-item-description' : desc ,
'input-item-price' : price ,
'image-data' : imageloc.name },
success: function () {
var table = document.getElementById('itemlist');
var row = table.insertRow(1);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
cell1.innerHTML = desc;
cell2.innerHTML = price;
cell3.innerHTML = qty;
var newimg = $("#image-name");
$.ajax({
type: 'POST',
url: 'additem',
data: {
'input-item-qty': qty,
'input-item-description': desc,
'input-item-price': price,
'image-data': imageloc.name
},
success: function() {
var table = document.getElementById('itemlist');
var row = table.insertRow(1);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
cell1.innerHTML = desc;
cell2.innerHTML = price;
cell3.innerHTML = qty;
var newimg = $("#image-name");

if ($("#image-name").attr("value") == null) {
$("#input-picture").replaceWith("<p> All out of pictures </p>"); }
else {
$("#input-picture").replaceWith("<img id='input-picture' src='" + $("#image-name").attr("value") + "' class='img-responsive' width='40%' height='40%' name='" + $("#image-name").attr("value") + "' />");
$("#input-picture").fadeOut(0);
$("#input-picture").fadeIn("slow");
$('#modalImg').find('form').first().remove();}
},
error: function() {
alert('error');
} } ); }); });
if ($("#image-name").attr("value") == null) {
$("#input-picture").replaceWith("<p> All out of pictures </p>");
$("#write-up-box").fadeOut(0);
$("#write-up-box").attr("class", "box collapsed-box")
$("#write-up-box").fadeIn("slow");
} else {
$("#input-picture").replaceWith("<img id='input-picture' src='" + $("#image-name").attr("value") + "' class='img-responsive' width='40%' height='40%' name='" + $("#image-name").attr("value") + "' />");
$("#input-picture").fadeOut(0);
$("#input-picture").fadeIn("slow");
$('#modalImg').find('form').first().remove();
}
$("#new-item").trigger("reset");
$("html").animate({scrollTop: 0}, "slow");
$("#input-item-description").focus();


},
error: function() {
alert('error');
}
});
});
});

$(function () {
if ($("#input-picture").attr("src") == null) {
$("#input-picture").replaceWith("<p> Add more pictures to continue </p>");
$("#write-up-box").attr("class", "box collapsed-box");
}

});

0 comments on commit 33f2180

Please sign in to comment.