dukebody@906: function qid(id) { dukebody@906: return id.replace(/([.:])/g, "\\$1"); dukebody@906: } dukebody@906: dukebody@906: function beforeComment(formData, jqForm, options) { dukebody@906: var form = jqForm[0]; dukebody@906: if (!form.comment.value) { dukebody@906: $(options.target + " span.comment_error").empty().append( dukebody@906: "Your comment is empty"); dukebody@906: return false; dukebody@906: } dukebody@906: if (!form.name.value) { dukebody@906: $(options.target + " span.comment_error").empty().append( dukebody@906: "Please provide a name"); dukebody@906: return false; dukebody@906: } dukebody@906: $(options.target + " span.comment_error").empty().after( dukebody@916: ""); dukebody@906: $(options.target + " input[@name=submit]").attr("disabled", true); dukebody@906: } dukebody@906: dukebody@906: function ajaxifyForm(id) { dukebody@906: var q = qid(id); dukebody@906: dukebody@906: $("#form_" + q).ajaxForm({ beforeSubmit: beforeComment, dukebody@906: success: function() { ajaxifyForm(id); }, dukebody@906: target: "#comments_" + q }); dukebody@906: } dukebody@906: dukebody@906: function toggleComment(id) { dukebody@906: $("#toggle_" + qid(id)).nextAll().toggle(); dukebody@906: return false; dukebody@906: } dukebody@906: dukebody@906: function loadComments(id) { dukebody@906: $("#comments_" + qid(id)).load(location.protocol + "//" + location.host + dukebody@906: "/comments/single/" + id + "/", function() { dukebody@906: ajaxifyForm(id); dukebody@906: }); dukebody@906: return false; dukebody@906: } dukebody@906: dukebody@906: function loadAllComments() { dukebody@906: $("a.commenttoggle").each(function() { dukebody@906: var id = $(this).attr("pid"); dukebody@906: if (id) { dukebody@906: loadComments(id); dukebody@906: } dukebody@906: }); dukebody@906: } dukebody@906: dukebody@906: $(document).ready(function() { dukebody@906: function loading(id) { dukebody@906: return " " + dukebody@906: "Loading..." + dukebody@906: ""; dukebody@906: } dukebody@906: $("div.toc>p") dukebody@906: .after("
") dukebody@906: .toggle(function() { $(this).nextAll().show("normal"); }, dukebody@906: function() { $(this).nextAll().hide("normal"); }) dukebody@906: .hover(function() { $(this).fadeTo("normal", 0.8); }, dukebody@906: function() { $(this).fadeTo("normal", 0.35); }); dukebody@913: $(".chapter p[@id]").each(function() { dukebody@906: $(this).append(loading($(this).attr("id"))); dukebody@906: }); dukebody@913: $(".chapter table[@id].equation").each(function() { dukebody@908: id = $(this).attr("id"); dukebody@908: $("#" + id + " tr").after('