plugins/ajim/shoutbox.js
author Dan
Sun, 11 Jan 2009 21:38:42 -0500
changeset 0 db23957ad1c7
child 1 f7b24c744747
permissions -rw-r--r--
First commit; requires latest Enano from Hg. It works!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     1
var ajim_last_refresh = 0;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     2
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     3
window.ajim_init = function()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     4
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     5
  window.ajim_authed = ( auth_level >= USER_LEVEL_CHPREF && ajim_can_mod );
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     6
  // have it immediately pull in whatever comments the server wants us to pull
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     7
  ajim_watch(true);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     8
  ajim_setup_textarea();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
     9
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    10
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    11
addOnloadHook(ajim_init);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    12
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    13
window.ajim_watch = function(immediate)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    14
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    15
  ajim_send_request({
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    16
      mode: 'watch',
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    17
      lastrefresh: immediate ? 0 : ajim_last_refresh
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    18
  });
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    19
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    20
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    21
window.ajim_send_request = function(request)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    22
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    23
  request = ajaxEscape(toJSONString(request));
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    24
  ajaxPost(makeUrlNS('Special', 'AjimJson'), 'r=' + request, function()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    25
    {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    26
      if ( ajax.readyState == 4 && ajax.status == 200 )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    27
      {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    28
        var response = String(ajax.responseText + '');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    29
        if ( !check_json_response(response) )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    30
        {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    31
          ajim_handle_invalid_json(response);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    32
          return false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    33
        }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    34
        response = parseJSON(response);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    35
        ajim_handle_response(response);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    36
      }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    37
    });
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    38
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    39
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    40
window.ajim_handle_invalid_json = function(response)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    41
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    42
  ajim_fail_message_list();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    43
  load_component('l10n');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    44
  var messages = document.getElementById('ajim_messages');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    45
  messages.innerHTML = $lang.get('ajim_err_bad_json') + '<br />';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    46
  messages.appendChild(document.createTextNode(response));
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    47
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    48
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    49
window.ajim_handle_response = function(response)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    50
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    51
  switch(response.mode)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    52
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    53
    case 'messages':
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    54
      ajim_show_message_list();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    55
      
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    56
      var noposts = document.getElementById('ajim_noposts');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    57
      if ( noposts )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    58
        noposts.parentNode.removeChild(noposts);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    59
      for ( var i = response.messages.length - 1; i >= 0; i-- )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    60
      {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    61
        ajim_inject_message(response.messages[i]);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    62
      }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    63
      if ( response.now )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    64
      {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    65
        window.ajim_last_refresh = response.now;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    66
        ajim_watch();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    67
      }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    68
      break;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    69
    case 'delete':
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    70
      var message = document.getElementById('ajim_message:' + response.message_id);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    71
      if ( message )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    72
      {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    73
        message.parentNode.removeChild(message);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    74
      }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    75
      ajim_show_message_list();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    76
      break;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    77
    case 'update':
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    78
      var message = document.getElementById('ajim_message:' + response.message_id);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    79
      if ( message )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    80
      {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    81
        var inner = getElementsByClassName(message, 'div', 'ajim_message_inner')[0];
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    82
        inner.innerHTML = response.message_html;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    83
        message.meta.message_src = response.message;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    84
      }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    85
      ajim_show_message_list();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    86
      break;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    87
    case 'error':
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    88
      ajim_fail_message_list();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    89
      ajim_show_error(response.error);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    90
      break;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    91
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    92
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    93
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    94
window.ajim_draw_message = function(message)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    95
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    96
  var div = document.createElement('div');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    97
  div.id = 'ajim_message:' + message.message_id;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    98
  div.className = 'ajim_message';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
    99
  div.meta = {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   100
    message_id: message.message_id,
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   101
    message_src: message.message
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   102
  };
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   103
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   104
  // deleted message?
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   105
  if ( message.message == '' )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   106
    return div;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   107
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   108
  // *sigh* actually draw a message.
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   109
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   110
  // mod buttons
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   111
    var modbuttons = document.createElement('div');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   112
    modbuttons.className = 'ajim_modbuttons';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   113
    if ( !window.ajim_authed && ( ( message.user_id != 1 && message.user_id != ajim_user_id ) || message.user_id == 1 ) )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   114
      modbuttons.style.display = 'none';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   115
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   116
    var edbtn = document.createElement('a');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   117
    edbtn.href = '#';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   118
    edbtn.className = 'ajim_btn_edit';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   119
    edbtn.appendChild(document.createTextNode(ajim_str_edit));
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   120
    edbtn.onclick = ajim_handle_click_edit;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   121
    modbuttons.appendChild(edbtn);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   122
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   123
    modbuttons.appendChild(document.createTextNode(' | '));
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   124
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   125
    var delbtn = document.createElement('a');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   126
    delbtn.href = '#';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   127
    delbtn.className = 'ajim_btn_delete';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   128
    delbtn.appendChild(document.createTextNode(ajim_str_delete));
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   129
    delbtn.onclick = ajim_handle_click_delete;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   130
    modbuttons.appendChild(delbtn);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   131
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   132
    div.appendChild(modbuttons);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   133
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   134
  // username
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   135
    var el = message.user_id == 1 ? 'span' : 'a';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   136
    var username = document.createElement(el);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   137
    username.appendChild(document.createTextNode(message.username));
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   138
    username.title = message.rank_info.rank_title;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   139
    username.setAttribute('style', message.rank_info.rank_style);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   140
    if ( message.user_id != 1 )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   141
      username.href = makeUrlNS('User', message.username);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   142
    div.appendChild(username);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   143
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   144
  // message header (does a clear: both)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   145
    var messagehead = document.createElement('div');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   146
    messagehead.className = 'ajim_messagehead';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   147
    div.appendChild(messagehead);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   148
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   149
  // date
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   150
    var date = document.createElement('div');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   151
    date.className = 'ajim_timestamp';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   152
    date.appendChild(document.createTextNode(message.human_time));
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   153
    div.appendChild(date);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   154
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   155
  // *finally* message
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   156
    var msgdata = document.createElement('div');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   157
    msgdata.innerHTML = message.message_html;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   158
    msgdata.className = 'ajim_message_inner';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   159
    div.appendChild(msgdata);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   160
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   161
  // message footer
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   162
    var messagefoot = document.createElement('div');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   163
    messagefoot.className = 'ajim_messagefoot';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   164
    div.appendChild(messagefoot);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   165
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   166
  return div;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   167
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   168
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   169
window.ajim_inject_message = function(message)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   170
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   171
  var drawn = ajim_draw_message(message);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   172
  var existing = document.getElementById('ajim_message:' + message.message_id);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   173
  if ( existing )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   174
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   175
    insertAfter(existing.parentNode, drawn, existing);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   176
    existing.parentNode.removeChild(existing);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   177
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   178
  else
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   179
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   180
    ajim_inject_object(drawn);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   181
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   182
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   183
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   184
window.ajim_inject_object = function(element)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   185
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   186
  var error = document.getElementById('ajim_error');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   187
  insertAfter(error.parentNode, element, error);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   188
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   189
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   190
window.ajim_show_error = function(message)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   191
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   192
  if ( window.ajim_error_timeout )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   193
    window.clearTimeout(ajim_error_timeout);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   194
  var error = document.getElementById('ajim_error');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   195
  error.innerHTML = '';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   196
  error.appendChild(document.createTextNode(message));
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   197
  window.ajim_error_timeout = window.setTimeout(ajim_clear_error, 5000);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   198
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   199
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   200
window.ajim_clear_error = function()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   201
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   202
  var error = document.getElementById('ajim_error');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   203
  error.innerHTML = '';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   204
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   205
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   206
window.ajim_handle_click_edit = function()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   207
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   208
  if ( this.editing )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   209
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   210
    this.editing = false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   211
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   212
    this.firstChild.nodeValue = $lang.get('ajim_btn_edit');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   213
    this.nextSibling.nextSibling.firstChild.nodeValue = $lang.get('ajim_btn_delete');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   214
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   215
    var newsrc = this.ta.value;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   216
    this.ta.parentNode.removeChild(this.ta);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   217
    this.inner.style.display = 'block';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   218
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   219
    if ( newsrc == '' )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   220
      ajim_show_error($lang.get('ajim_err_no_post'));
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   221
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   222
    ajim_hide_message_list();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   223
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   224
    ajim_send_request({
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   225
        mode: 'update',
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   226
        message_id: this.parentNode.parentNode.meta.message_id,
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   227
        message: newsrc
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   228
      });
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   229
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   230
  else
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   231
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   232
    load_component('l10n');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   233
    this.firstChild.nodeValue = $lang.get('ajim_btn_save');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   234
    this.nextSibling.nextSibling.firstChild.nodeValue = $lang.get('etc_cancel').toLowerCase();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   235
    this.editing = true;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   236
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   237
    var src = this.parentNode.parentNode.meta.message_src;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   238
    var inner = this.parentNode.nextSibling.nextSibling.nextSibling.nextSibling;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   239
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   240
    var ta = document.createElement('textarea');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   241
    ta.value = src;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   242
    ta.style.fontSize = '100%';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   243
    ta.style.width = '93%';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   244
    inner.style.display = 'none';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   245
    this.parentNode.parentNode.appendChild(ta);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   246
    this.ta = ta;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   247
    this.inner = inner;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   248
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   249
  return false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   250
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   251
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   252
window.ajim_handle_click_delete = function()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   253
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   254
  var editlink = this.previousSibling.previousSibling;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   255
  if ( editlink.editing )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   256
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   257
    editlink.editing = false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   258
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   259
    editlink.firstChild.nodeValue = $lang.get('ajim_btn_edit');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   260
    this.firstChild.nodeValue = $lang.get('ajim_btn_delete');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   261
    
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   262
    editlink.ta.parentNode.removeChild(editlink.ta);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   263
    editlink.inner.style.display = 'block';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   264
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   265
  else
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   266
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   267
    ajim_hide_message_list();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   268
    var message_id = this.parentNode.parentNode.meta.message_id;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   269
    ajim_send_request({
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   270
        mode: 'delete',
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   271
        message_id: message_id
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   272
      });
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   273
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   274
  return false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   275
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   276
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   277
window.ajim_handle_click_mod = function()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   278
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   279
  if ( auth_level >= USER_LEVEL_CHPREF )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   280
    return false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   281
  load_component('login');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   282
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   283
  ajaxLogonInit(function(k)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   284
    {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   285
      ajaxLoginReplaceSIDInline(k, false, USER_LEVEL_CHPREF);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   286
      window.setTimeout(function()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   287
        {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   288
          mb_current_obj.destroy();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   289
          ajim_enable_mod_tools();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   290
        }, 500);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   291
    }, USER_LEVEL_CHPREF);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   292
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   293
  return false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   294
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   295
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   296
window.ajim_enable_mod_tools = function()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   297
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   298
  var mods = document.getElementsByClassName('div', 'ajim_modbuttons');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   299
  for ( var i = 0; i < mods.length; i++ )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   300
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   301
    mods[i].style.display = 'block';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   302
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   303
  document.getElementById('ajim_mod').innerHTML = '';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   304
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   305
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   306
window.ajim_setup_textarea = function()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   307
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   308
  var ta = document.getElementById('ajim_message');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   309
  if ( !ta )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   310
    return false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   311
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   312
  ta.shift = false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   313
  ta.onkeypress = function(e)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   314
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   315
    if ( !e )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   316
      e = window.event;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   317
    if ( !e )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   318
      return true;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   319
    if ( typeof(e.keyCode) == undefined )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   320
      return true;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   321
    if ( e.keyCode == 13 )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   322
    {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   323
      if ( !this.shift )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   324
      {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   325
        ajim_submit_message();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   326
        e.preventDefault();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   327
        return false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   328
      }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   329
    }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   330
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   331
  ta.onkeydown = function(e)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   332
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   333
    if ( !e )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   334
      e = window.event;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   335
    if ( !e )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   336
      return true;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   337
    if ( !e.keyCode )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   338
      return true;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   339
    if ( e.keyCode == 16 )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   340
    {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   341
      this.shift = true;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   342
    }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   343
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   344
  ta.onkeyup = function(e)
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   345
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   346
    if ( !e )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   347
      e = window.event;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   348
    if ( !e )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   349
      return true;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   350
    if ( !e.keyCode )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   351
      return true;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   352
    if ( e.keyCode == 16 )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   353
    {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   354
      this.shift = false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   355
    }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   356
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   357
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   358
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   359
window.ajim_submit_message = function()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   360
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   361
  var ta = document.getElementById('ajim_message');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   362
  if ( ta.value == '' )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   363
  {
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   364
    load_component('l10n');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   365
    ajim_show_error($lang.get('ajim_err_no_post'));
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   366
    return false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   367
  }
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   368
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   369
  var user = document.getElementById('ajim_nickname');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   370
  if ( user.value == '' )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   371
    user.value = 'Guest';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   372
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   373
  ajim_hide_message_list();
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   374
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   375
  ajim_send_request({
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   376
      mode: 'submit',
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   377
      user: user.value,
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   378
      message: ta.value
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   379
    });
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   380
  
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   381
  ta.value = '';
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   382
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   383
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   384
window.ajim_hide_message_list = function()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   385
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   386
  var messages = document.getElementById('ajim_messages');
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   387
  window.ajim_submit_whitey = whiteOutElement(messages);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   388
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   389
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   390
window.ajim_show_message_list = function()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   391
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   392
  if ( window.ajim_submit_whitey )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   393
    whiteOutReportSuccess(window.ajim_submit_whitey);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   394
  window.ajim_submit_whitey = false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   395
}
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   396
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   397
window.ajim_fail_message_list = function()
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   398
{
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   399
  if ( window.ajim_submit_whitey )
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   400
    whiteOutReportFailure(window.ajim_submit_whitey);
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   401
  window.ajim_submit_whitey = false;
db23957ad1c7 First commit; requires latest Enano from Hg. It works!
Dan
parents:
diff changeset
   402
}