diff media/js/bio.js @ 138:7ea842744a57

Ticket #15, add a way to report user profiles.
author Brian Neal <bgneal@gmail.com>
date Fri, 27 Nov 2009 21:55:32 +0000
parents c515b7401078
children
line wrap: on
line diff
--- a/media/js/bio.js	Fri Nov 27 04:11:12 2009 +0000
+++ b/media/js/bio.js	Fri Nov 27 21:55:32 2009 +0000
@@ -1,10 +1,36 @@
-
 $(document).ready(function() {
-    $('#id_birthday').datepicker({changeMonth: true, 
-       changeYear: true,
-       dateFormat: 'yy-mm-dd',
-       defaultDate: '-30y',
-       minDate: new Date(1909, 0, 1),
-       maxDate: new Date(),
-       yearRange: '-100:+0'});
+   var bday = $('#id_birthday');
+   // jquery ui may not always be loaded
+   if (bday.length) {
+      bday.datepicker({changeMonth: true, 
+         changeYear: true,
+         dateFormat: 'yy-mm-dd',
+         defaultDate: '-30y',
+         minDate: new Date(1909, 0, 1),
+         maxDate: new Date(),
+         yearRange: '-100:+0'});
+   }
+   $('a.profile-flag').click(function() {
+      var id = this.id;
+      if (id.match(/fp-(\d+)/)) {
+         id = RegExp.$1;
+         if (confirm('Only report a profile if you feel it is spam, abuse, ' +
+                 'violates site rules, or is not appropriate. ' +
+                 'A moderator will be notified and will review the profile. ' +
+                 'Are you sure you want to report this profile?')) {
+             $.ajax({
+               url: '/profile/flag/' + id + '/',
+               type: 'POST',
+               dataType: 'text',
+               success: function (response, textStatus) {
+                  alert(response);
+               },
+               error: function (xhr, textStatus, ex) {
+                  alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
+               }
+             });
+         }
+     }
+     return false;
+   });
 });