|
1 /* |
|
2 * Nuggie |
|
3 * Version 0.1 |
|
4 * Copyright (C) 2007 Dan Fuhry |
|
5 * |
|
6 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
|
7 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
10 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
11 */ |
|
12 |
|
13 function ajaxNuggieDeletePost(id, row) |
|
14 { |
|
15 if ( !confirm('Are you sure you want to permanently delete this blog post?') ) |
|
16 return false; |
|
17 |
|
18 _global_ng_row = row; |
|
19 |
|
20 try |
|
21 { |
|
22 ajaxPost(makeUrlNS('Special', 'Preferences/Blog/Posts/AjaxHandler'), 'act=delete&post_id=' + id, function() |
|
23 { |
|
24 if ( ajax.readyState == 4 ) |
|
25 { |
|
26 if ( ajax.responseText == '1' ) |
|
27 { |
|
28 var row = _global_ng_row; |
|
29 for ( var i = 0; i < row.childNodes.length; i++ ) |
|
30 { |
|
31 if ( row.childNodes[i].tagName == 'TD' ) |
|
32 { |
|
33 row.childNodes[i].style.backgroundColor = 'transparent'; |
|
34 } |
|
35 } |
|
36 var fader = new Spry.Effect.Highlight(row, {to:'#AA0000', duration: 750}); |
|
37 fader.start(); |
|
38 setTimeout('_global_ng_row.parentNode.removeChild(_global_ng_row);', 750); |
|
39 } |
|
40 else |
|
41 { |
|
42 alert(ajax.responseText); |
|
43 } |
|
44 } |
|
45 }); |
|
46 return false; |
|
47 } |
|
48 catch(e) |
|
49 { |
|
50 return true; |
|
51 } |
|
52 } |
|
53 |
|
54 function ajaxNuggieTogglePublished(id, obj) |
|
55 { |
|
56 var published = obj.getAttribute('nuggie:published') == '1' ? true : false; |
|
57 var newstate = ( published ) ? '0' : '1'; |
|
58 obj.innerHTML = '<img alt="Loading..." src="' + ajax_load_icon + '" />'; |
|
59 ajaxPost(makeUrlNS('Special', 'Preferences/Blog/Posts/AjaxHandler'), 'act=publish&post_id=' + id + '&state=' + newstate, function() |
|
60 { |
|
61 if ( ajax.readyState == 4 ) |
|
62 { |
|
63 if ( ajax.responseText == 'good;1' ) |
|
64 { |
|
65 obj.className = 'row3_green nuggie_publishbtn'; |
|
66 obj.innerHTML = '<b>Yes</b>'; |
|
67 obj.setAttribute('nuggie:published', '1'); |
|
68 } |
|
69 else if ( ajax.responseText == 'good;0' ) |
|
70 { |
|
71 obj.className = 'row3_red nuggie_publishbtn'; |
|
72 obj.innerHTML = 'No'; |
|
73 obj.setAttribute('nuggie:published', '0'); |
|
74 } |
|
75 else |
|
76 { |
|
77 alert(ajax.responseText); |
|
78 } |
|
79 } |
|
80 }); |
|
81 } |
|
82 |