summaryrefslogtreecommitdiff
path: root/static/nickinterview/peoplewholiketochatalot dump.fm_files/admin.js
diff options
context:
space:
mode:
authorJulie Lala <jules@okfoc.us>2014-06-24 18:52:07 -0400
committerJulie Lala <jules@okfoc.us>2014-06-24 18:52:07 -0400
commit948926970571793e774ebf34c16e14ef8e694062 (patch)
tree90250502c299fc130efbd4c54a62e3c158cb7acd /static/nickinterview/peoplewholiketochatalot dump.fm_files/admin.js
parent0e9eb8b4fc0ef43f91b69749f276cadf2d3bb3ad (diff)
parentc14e6d4356a2c4d9981a6808ef19edb66fc96e51 (diff)
Merge branch 'master' of dumpfm:/pichat/repo
Diffstat (limited to 'static/nickinterview/peoplewholiketochatalot dump.fm_files/admin.js')
-rw-r--r--static/nickinterview/peoplewholiketochatalot dump.fm_files/admin.js120
1 files changed, 120 insertions, 0 deletions
diff --git a/static/nickinterview/peoplewholiketochatalot dump.fm_files/admin.js b/static/nickinterview/peoplewholiketochatalot dump.fm_files/admin.js
new file mode 100644
index 0000000..fc18685
--- /dev/null
+++ b/static/nickinterview/peoplewholiketochatalot dump.fm_files/admin.js
@@ -0,0 +1,120 @@
+var Admin = {};
+
+Admin._dialogHtml = '<div class="dialog">';
+
+Admin._select = function(name, opts) {
+ var sel = $('<select>').attr('name', name);
+ $.each(opts, function(i, o) {
+ sel.append($('<option>').html(o));
+ });
+ return sel;
+}
+
+Admin.mute = function(nick) {
+ var time = $('<input type="text" name="time" size="3">');
+ var unit = Admin._select('unit', ['minutes', 'hours', 'days']);
+ var reason = $('<textarea name="reason" rows="4" cols="30">');
+ var html = $('<div>')
+ .append($('<div>').text(nick + ' will be muted for:'))
+ .append(time)
+ .append(unit)
+ .append($('<br>'))
+ .append($('<br>'))
+ .append($('<div>').text('Reason:'))
+ .append(reason)
+ .appendTo($(Admin._dialogHtml));
+ var title = 'Mute ' + nick;
+ var close = function() { html.dialog('close'); }
+ var submit = function() {
+ html.find('[name]').removeClass('ui-state-error');
+
+ var t = parseInt(time.val());
+ var u = unit.val();
+ var r = reason.val();
+
+ if (!t) { time.addClass('ui-state-error'); }
+ if (!u) { reason.addClass('ui-state-error'); }
+ if (!r) { reason.addClass('ui-state-error'); }
+ if (!t || !u || !r) { return; }
+
+ $.ajax({
+ type: 'POST',
+ timeout: 5000,
+ url: '/mute',
+ cache: false,
+ data: { 'time': t, 'unit': u,
+ 'reason': r, 'nick': nick },
+ success: close,
+ error: function(s) {
+ alert("Error muting user: " + s.responseText);
+ }
+ });
+ };
+ html.dialog({
+ modal: true,
+ title: title,
+ width: 400,
+ buttons: { 'OK': submit , 'Cancel': close }
+ });
+ html.dialog('open');
+};
+
+Admin.cancelMute = function(id, nick) {
+ var reason = $('<textarea name="reason" rows="4" cols="30">');
+ var html = $('<div>')
+ .append($('<div>').text('Cancelling mute for ' + nick))
+ .append($('<br>'))
+ .append($('<div>').text('Reason:'))
+ .append(reason)
+ .appendTo($(Admin._dialogHtml));
+ var title = 'Cancelling mute for ' + nick;
+ var close = function() { html.dialog('close'); }
+ var submit = function() {
+ html.find('[name]').removeClass('ui-state-error');
+
+ var r = reason.val();
+ if (!r) {
+ reason.addClass('ui-state-error');
+ return;
+ }
+
+ var onSuccess = function(resp) {
+ location.reload();
+ };
+
+ $.ajax({
+ type: 'POST',
+ timeout: 5000,
+ url: '/cancel-mute',
+ cache: false,
+ data: { 'mute_id': id, 'reason': r },
+ success: onSuccess,
+ error: function(s) {
+ alert("Error cancelling mute: " + s.responseText);
+ close();
+ }
+ });
+ };
+ html.dialog({
+ modal: true,
+ title: title,
+ width: 400,
+ buttons: { 'OK': submit , 'Cancel': close }
+ });
+ html.dialog('open');
+}
+
+
+/*
+$('.msgDiv').live('mouseenter', function() {
+ $(this).css({'border': '1px dotted red',
+ 'margin': '-1' });
+})
+
+$('.msgDiv').live('mouseleave', function() {
+ $(this).css({'border': 'none',
+ 'margin': '0'});
+})
+
+
+*/ \ No newline at end of file