diff options
Diffstat (limited to 'static/resizetest/dump.fm.all.files/admin.js')
| -rwxr-xr-x | static/resizetest/dump.fm.all.files/admin.js | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/static/resizetest/dump.fm.all.files/admin.js b/static/resizetest/dump.fm.all.files/admin.js new file mode 100755 index 0000000..fc18685 --- /dev/null +++ b/static/resizetest/dump.fm.all.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 |
