MediaWiki:CreatureForm.js
Revision as of 15:11, 6 August 2019 by Nussnougat (talk | contribs)
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
$(document).ready(function() { $("#creature_submit").click(function() { $("#error_msg").html(""); $("#success_msg").html(""); $("#creature-submit").attr("disabled", true); var cname = $("#creature_name").val(); var cmaturity = $("#creature_maturity").val(); var isComplete = true; if (cname === "") { $("#error_msg").append("Name cannot be empty<br/>"); isComplete = false; } if (cmaturity === "") { $("#error_msg").append("Maturity cannot be empty<br/>"); isComplete = false; } if (isComplete) { var minDmg = $("#creature_min_dmg").val(); var maxDmg = $("#creature_max_dmg").val(); var chp = $("#creature_hp").val(); var planet1 = $('#creature-planet-1 option:selected').val(); var planet2 = $('#creature-planet-2 option:selected').val(); var body = { name: cname, hp: chp, min_dmg: minDmg, max_dmg: maxDmg, maturity: cmaturity, planets: [planet1, planet2] }; $.ajax({ type: "POST", dataType: "JSON", url: "/vv-api/update/create-creature.php", data: body, success: function(result) { $("#creature-submit").attr("disabled", false); if (result.success === true) { var newLink = "<a href='/index.php/Creature:"+cname+"'>"+cname+" page</a>"; $("#success_msg").html("Creature "+cname+" is successfully added. Go to "+newLink+" to add more information"); } else { $("#error_msg").html("Failed: "+result.message); } }, error: function(err) { $("#creature-submit").attr("disabled", false); } }); } }); });