String.prototype.startsWith = function(str) {return (this.match("^"+str)==str)} $(document).ready(function() { var is_star = function(htmlElement) { return (htmlElement === "\u272D"); }; $(".delete-confirm-link").bind("click", function(event){ var $dialog = $(this).siblings(".confirmation.dialog").clone(), $submit = $(this); if($dialog.length !== 0){ event.preventDefault(); event.stopImmediatePropagation(); var $confirmation = $(document.createElement('input')).attr({type: 'hidden', name:'confirm', value: 'true'}); var targetUrl = $(this).attr("href"); var row = $(this).closest("tr") var table = row.closest("table") var dataTable = table.dataTable() $dialog.dialog({ autoOpen: false, modal: true, buttons: { Cancel: function(){ $dialog.dialog("close") }, Ok: function(){ $dialog.dialog("close") dataTable.fnDeleteRow( dataTable.fnGetPosition(row.get(0)) ); zebra($('.zebra')); $.post(targetUrl, {_method:'delete'}, function(data) { setFlashMessage("The note has been deleted"); } ); } } }); $dialog.dialog("open"); return false; } }); $(".starable").live('click', function() { var star = $.trim($(this).html()), person_id = $(this).attr("data-person-id"), type = $(this).attr("data-type"), id = $(this).attr("data-action-id"), this_table = $(this).parents('table'), this_row = $(this).parents('tr'); $.ajax({ type: "POST", url: "/people/" + person_id + "/star/" + type + "/" + id }); if(is_star(star)) { $(this).html("✩"); $(this).trigger("unstarred"); } else { $(this).html("✭"); $(this).trigger("starred"); } //and re-zebra the table zebra(this_table); }); $(".relationship_starred").click(function() { var star = $.trim($(this).html()), person_id = $(this).attr("data-person-id"), type = $(this).attr("data-type"), id = $(this).attr("data-action-id"), relationship_type = $.trim($('.relationship_type',this.parent).html()), name = $.trim($('.relationship_person',this.parent).html()), relationships_list = $('#key_relationships'); if(is_star(star)) { relationships_list.append("