plugins/nuggie/client/usercp.js
author Dan
Sat, 15 Mar 2008 15:21:47 -0400
changeset 5 172544257e2c
parent 3 a050ff3d4509
child 12 f0ddbf48c978
permissions -rw-r--r--
Merging changes from Nighthawk - visual tweak to post manager
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
     1
/*
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
     2
 * Nuggie
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
     3
 * Version 0.1
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
     4
 * Copyright (C) 2007 Dan Fuhry
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
     5
 *
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
     6
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
     7
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
     8
 *
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    10
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    11
 */
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    12
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    13
function ajaxNuggieDeletePost(id, row)
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    14
{
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    15
  if ( !confirm('Are you sure you want to permanently delete this blog post?') )
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    16
    return false;
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    17
  
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    18
  _global_ng_row = row;
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    19
  
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    20
  try
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    21
  {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    22
    ajaxPost(makeUrlNS('Special', 'Preferences/Blog/Posts/AjaxHandler'), 'act=delete&post_id=' + id, function()
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    23
      {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    24
        if ( ajax.readyState == 4 )
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    25
        {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    26
          if ( ajax.responseText == '1' )
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    27
          {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    28
            var row = _global_ng_row;
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    29
            for ( var i = 0; i < row.childNodes.length; i++ )
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    30
            {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    31
              if ( row.childNodes[i].tagName == 'TD' )
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    32
              {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    33
                row.childNodes[i].style.backgroundColor = 'transparent';
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    34
              }
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    35
            }
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    36
            var fader = new Spry.Effect.Highlight(row, {to:'#AA0000', duration: 750});
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    37
            fader.start();
5
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    38
            setTimeout('_global_ng_row.parentNode.removeChild(_global_ng_row); nuggie_check_postlist_empty();', 750);
3
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    39
          }
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    40
          else
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    41
          {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    42
            alert(ajax.responseText);
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    43
          }
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    44
        }
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    45
      });
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    46
    return false;
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    47
  }
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    48
  catch(e)
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    49
  {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    50
    return true;
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    51
  }
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    52
}
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    53
5
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    54
function nuggie_check_postlist_empty()
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    55
{
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    56
  if ( document.getElementById('nuggie_postlist').childNodes.length == 1 )
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    57
  {
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    58
    var td = document.createElement('td');
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    59
    td.className = 'row3';
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    60
    td.setAttribute('colspan', '6');
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    61
    td.appendChild(document.createTextNode('No posts.'));
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    62
    td.style.textAlign = 'center';
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    63
    var tr = document.createElement('tr');
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    64
    tr.appendChild(td);
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    65
    document.getElementById('nuggie_postlist').appendChild(tr);
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    66
  }
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    67
}
172544257e2c Merging changes from Nighthawk - visual tweak to post manager
Dan
parents: 3
diff changeset
    68
3
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    69
function ajaxNuggieTogglePublished(id, obj)
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    70
{
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    71
  var published = obj.getAttribute('nuggie:published') == '1' ? true : false;
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    72
  var newstate = ( published ) ? '0' : '1';
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    73
  obj.innerHTML = '<img alt="Loading..." src="' + ajax_load_icon + '" />';
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    74
  ajaxPost(makeUrlNS('Special', 'Preferences/Blog/Posts/AjaxHandler'), 'act=publish&post_id=' + id + '&state=' + newstate, function()
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    75
    {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    76
      if ( ajax.readyState == 4 )
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    77
      {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    78
        if ( ajax.responseText == 'good;1' )
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    79
        {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    80
          obj.className = 'row3_green nuggie_publishbtn';
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    81
          obj.innerHTML = '<b>Yes</b>';
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    82
          obj.setAttribute('nuggie:published', '1');
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    83
        }
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    84
        else if ( ajax.responseText == 'good;0' )
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    85
        {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    86
          obj.className = 'row3_red nuggie_publishbtn';
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    87
          obj.innerHTML = 'No';
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    88
          obj.setAttribute('nuggie:published', '0');
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    89
        }
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    90
        else
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    91
        {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    92
          alert(ajax.responseText);
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    93
        }
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    94
      }
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    95
    });
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    96
}
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    97