Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "use strict";
- var CharPack = CharPack || {};
- (function($) {
- CharPack.add = function () {
- //Validate the character name
- var newCharName = $("#charName").val().trim();
- if (newCharName == "") {
- alert("Sorry, you must provide a character name.");
- return;
- }
- //Validate the character quote
- var newCharQuote = $("#charQuote").val().trim();
- if (newCharQuote == "") {
- alert("Sorry, you must provide a character quote.");
- return;
- }
- //Validate the special move
- var newCharMove = $("#charMove").val().trim();
- if (newCharMove == "") {
- alert("Sorry, you must provide a special move.");
- return;
- }
- //Data Ok
- //Add a new record
- //find the highest ID
- var highestId = CharPack.packDb().max("id");
- //New char's ID is one more
- var newCharId = highestId + 1;
- //Create a new object.
- var newChar = {
- id: newCharId,
- name: newCharName,
- quote: newCharQuote,
- specialmove: newCharMove
- };
- //Add the new item.
- CharPack.packDb.insert(newChar);
- //Go to list page.
- window.location.href = "index.html";
- };
- //Cancel the query
- CharPack.baleet = function(){
- if ( confirm("Are you sure?") ) {
- window.location.href = "index.html";
- }
- };
- $(document).ready(function () {
- //Load the navbar from the library.
- $("#navbar").load("library/includes/navbar.html");
- //Load the footer from the library.
- $("#footer").load("library/includes/footer.html");
- });
- }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement