bgneal@312: $(document).ready(function() {
bgneal@312:    $('a.weblinks-broken').click(function () {
bgneal@312:       var id = this.id;
bgneal@312:       if (id.match(/^link-(\d+)$/)) {
bgneal@312:          id = RegExp.$1;
bgneal@312:          if (confirm('Do you really want to report this link as broken? ' +
bgneal@312:                'This will notify the site staff that the link is dead and that ' +
bgneal@312:                'it may need to be deleted or revised.')) {
bgneal@312:             $.ajax({
bgneal@312:                url: '/links/report/' + id + '/',
bgneal@312:                type: 'POST',
bgneal@312:                dataType: 'text',
bgneal@312:                success: function (response, textStatus) {
bgneal@312:                   alert(response);
bgneal@312:                },
bgneal@312:                error: function (xhr, textStatus, ex) {
bgneal@312:                   alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
bgneal@312:                }
bgneal@312:             });
bgneal@312:          }
bgneal@312:       }
bgneal@312:       return false;
bgneal@312:    });
bgneal@312: });