$(document).ready(function() { // scroll up to avoid having the form input // hidden under the navbar if (location.hash == "#text") { scrollBy(0, -100); } var converter = new showdown.Converter({ simplifiedAutoLink: true }); // Live rendering of markdown comment to HTML $("#text").keyup(function(event) { var comment = $(this).val(); $("#commentLivePreview").html(converter.makeHtml(comment)); }); // render existing comments to HTML $(".item-comment").each(function() { var raw = $(this).html(); $(this).html(converter.makeHtml(raw)); }); $("#clear").click(function() { // clear all select fields $("select").val(''); }); var items_table = $("#items_table").DataTable({ "ajax": function(data, callback, settings) { $.getJSON( $SCRIPT_ROOT + "/inventory/_retrieve_items", function(json) { callback(json); }); }, "order": [[3, 'desc']], "pagingType": "full_numbers", "pageLength": 20, "lengthMenu": [[20, 50, 100, -1], [20, 50, 100, "All"]], "columnDefs": [ { "targets": [0], "visible": false, "searchable": false }, { "targets": [1, 9], "render": function(data, type, row) { // render funtion to create link to Item view page if ( data === null ) { return data; } var url = $SCRIPT_ROOT + "/inventory/items/view/" + data; return '<a href="'+ url + '">' + data + '</a>'; } } ] }); });