plugins/nuggie/client/usercp.js
author Dan
Fri, 01 Feb 2008 21:54:00 -0500
changeset 3 a050ff3d4509
child 5 172544257e2c
permissions -rw-r--r--
Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
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();
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    38
            setTimeout('_global_ng_row.parentNode.removeChild(_global_ng_row);', 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
    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
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    54
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
    55
{
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    56
  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
    57
  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
    58
  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
    59
  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
    60
    {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    61
      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
    62
      {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    63
        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
    64
        {
a050ff3d4509 Added the post manager. It uses AJAX. And it's pretty. At least a little. And it rips Wordpress.
Dan
parents:
diff changeset
    65
          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
    66
          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
    67
          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
    68
        }
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
        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
    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
          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
    72
          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
    73
          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
    74
        }
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
        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
    76
        {
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
          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
    78
        }
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
    });
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
}
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