$('document').ready(function(){ // Botones $("#home").click(function(){ $("#load").fadeIn(0); $( "#body" ).load( "/templates/home.html" ); $.get("/info", function( data ) { var text = "" $.each(data, function(i, obj) { text += ""; }); text += "
"+i+" "+obj+"
" $( "#info" ).html( text ); $("#load").fadeOut("fast"); }); }); $("#animals").click(function(){ $("#load").fadeIn(0); $.get( "/animal", function( data ) { $( "#body" ).html("

Yours Dinos

"); $( "#animal-add").click(function(){ $( "#body" ).load( "/templates/animal-form.html", function (){ set_animal_include(""); }); }) dataSet = data.data.map(function(item) { return [item._id, item.name, item.initial_level + " - " + item.level, species[item.specie].name]; }); $('#animals-table').DataTable({ data: dataSet, responsive: true, columns: [ { title: "id", visible: false}, { title: "Name" }, { title: "Level" }, { title: "Specie" }, { title: "Options", className: "options-table", orderable: false,data: null, targets: -1, "mRender": function(data, type, full) { return '  ' + '  ' + ''; }} ]}); $("#load").fadeOut("fast"); }); }); $("#species").click(function(){ $("#load").fadeIn(0); $( "#body" ).html("

All Species

") dataSet = []; for(var i in species){ dataSet.push([species[i].name, species[i].description]); } $('#species-table').DataTable({ data: dataSet, responsive: true, columns: [ { title: "Name" }, { title: "Description" } ] }); $("#load").fadeOut("fast"); }); $("#about").click(function(){ $("#load").fadeIn(0); $( "#body" ).load( "/templates/about.html", function(){$("#load").fadeOut("fast");} ); }); });