$(document).ready(function() { $(document).on('change', '#itemTypeValue', function() { if ($(this).find("option:selected").attr('value') == 3) { $("#itempriceContainer").css("display", "none"); }else{ $("#itempriceContainer").css("display", "block"); } }) $("#uploadItem").click(function() { if ($("#uploadItem").is(":disabled") == false) { $("#uploadItem").prop("disabled", true); $("#itemNameValue").prop("disabled", true); $("#itemDescriptionValue").prop("disabled", true); $("#itemTypeValue").prop("disabled", true); $("#itemPriceValue").prop("disabled", true); $("#fileValue").prop("disabled", true); var formData = new FormData(); formData.append('file', $('#fileValue')[0].files[0]); formData.append('itemName', $("#itemNameValue").val()); formData.append('itemDescription', $("#itemDescriptionValue").val()); formData.append('itemType', $("#itemTypeValue").val()); formData.append('itemPrice', $("#itemPriceValue").val()); formData.append('csrf_token', $('meta[name="csrf-token"]').attr('content')); $.ajax({ type: "POST", url : "/core/func/api/catalog/post/uploadItem.php", data : formData, cache: false, contentType: false, processData: false, success: function(data) { console.log(data); $("#uploadItem").prop("disabled", false); $("#itemNameValue").prop("disabled", false); $("#itemDescriptionValue").prop("disabled", false); $("#itemTypeValue").prop("disabled", false); $("#itemPriceValue").prop("disabled", false); $("#fileValue").prop("disabled", false); if (data == "error") { $("#uploadStatus").html("
Could not upload item because a network error occurred.
"); }else if (data == "name-too-short") { $("#uploadStatus").html("
Your item name is too short. Try something else.
"); }else if (data == "name-too-long") { $("#uploadStatus").html("
Your item name is too long. Try something else.
"); }else if (data == "description-too-long") { $("#uploadStatus").html("
Your description is too long. Try something else.
"); }else if (data == "price-too-low") { $("#uploadStatus").html("
Your item price is too low.
"); }else if (data == "rate-limit") { $("#uploadStatus").html("
Please wait a bit before uploading again.
"); }else if (data == "rate-limit") { $("#uploadStatus").html("
Please wait a bit before uploading again.
"); }else if (data == "incorrect-size") { $("#uploadStatus").html("
Your image has an incorrect size. Did you use the template?
"); }else if (data == "no-image") { $("#uploadStatus").html("
The file you have tried to upload is not an image.
"); }else if (data == "file-too-large") { $("#uploadStatus").html("
The file you have tried to upload is too large.
"); }else if (data == "incorrect-extension") { $("#uploadStatus").html("
The file you have tried to upload is not a valid image.
"); }else if (data == "not-enough-coins") { $("#uploadStatus").html("
You do not have enough coins to upload an item.
"); }else if (data == "file-upload-error") { $("#uploadStatus").html("
An error occured while uploading your item. Please contact an administrator.
"); }else if (data == "no-file") { $("#uploadStatus").html("
Please select a file to upload.
"); }else if (data == "bad-hash") { $("#uploadStatus").html("
This item can not be uploaded to Graphictoria.
"); }else{ $("#uploadStatus").html("
Your file has been uploaded. It will appear in the catalog when it has been approved.
"); $("#userCoins").html(data); } }, error: function() { $("#uploadStatus").html("
Could not upload item because a network error occurred.
"); } }); } }) });