1
+ − 1
var disenable_currentBlock;
+ − 2
function ajaxDisenableBlock(id)
+ − 3
{
+ − 4
disenable_currentBlock = document.getElementById('disabled_'+id);
+ − 5
ajaxGet(makeUrlNS('Special', 'EditSidebar', 'action=disenable&ajax=true&noheaders&id='+id), function()
+ − 6
{
+ − 7
if(ajax.readyState == 4)
+ − 8
{
+ − 9
if(ajax.responseText == 'GOOD')
+ − 10
{
+ − 11
if(disenable_currentBlock.style.display == 'none')
+ − 12
{
+ − 13
disenable_currentBlock.style.display = 'inline';
+ − 14
}
+ − 15
else
+ − 16
{
+ − 17
disenable_currentBlock.style.display = 'none';
+ − 18
}
+ − 19
}
+ − 20
else
+ − 21
{
+ − 22
document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
+ − 23
}
+ − 24
}
+ − 25
});
+ − 26
}
+ − 27
+ − 28
var delete_currentBlock;
+ − 29
function ajaxDeleteBlock(id, oElm)
+ − 30
{
+ − 31
delete_currentBlock = { 0 : id, 1 : oElm };
+ − 32
ajaxGet(makeUrlNS('Special', 'EditSidebar', 'action=delete&ajax=true&noheaders&id='+id), function()
+ − 33
{
+ − 34
if(ajax.readyState == 4)
+ − 35
{
+ − 36
if(ajax.responseText == 'GOOD')
+ − 37
{
+ − 38
e = delete_currentBlock[1];
+ − 39
e = e.parentNode.parentNode;
+ − 40
e.parentNode.removeChild(e);
+ − 41
}
+ − 42
else
+ − 43
{
+ − 44
document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
+ − 45
}
+ − 46
}
+ − 47
});
+ − 48
}
+ − 49
+ − 50
var blockEdit_current;
+ − 51
function ajaxEditBlock(id, oElm)
+ − 52
{
+ − 53
blockEdit_current = { 0 : id, 1 : oElm };
+ − 54
ajaxGet(makeUrlNS('Special', 'EditSidebar', 'action=getsource&noheaders&id='+id), function()
+ − 55
{
+ − 56
if(ajax.readyState == 4)
+ − 57
{
+ − 58
id = blockEdit_current[0];
+ − 59
oElm = blockEdit_current[1];
+ − 60
var thediv = document.createElement('div');
+ − 61
//if(!oElm.id) oElm.id = 'autoEditButton_'+Math.floor(Math.random() * 100000);
+ − 62
oElm = oElm.parentNode;
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 63
var magic = $(oElm).Top() + $(oElm).Height();
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 64
var top = String(magic);
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 65
top = top + 'px';
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 66
left = $(oElm).Left() + 'px';
1
+ − 67
thediv.style.top = top;
+ − 68
thediv.style.left = left;
+ − 69
thediv.style.position = 'absolute';
+ − 70
thediv.className = 'mdg-comment';
+ − 71
thediv.style.margin = '0';
+ − 72
if(ajax.responseText == 'HOUSTON_WE_HAVE_A_PLUGIN')
+ − 73
{
+ − 74
thediv.innerHTML = '<h3>This block cannot be edited.</h3><p>This is a plugin block, and cannot be edited.</p><p><a href="#" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); return false;">close</a></p>';
+ − 75
}
+ − 76
else
+ − 77
{
+ − 78
ta = document.createElement('textarea');
+ − 79
ta.rows = '15';
+ − 80
ta.cols = '50';
+ − 81
ta.innerHTML = ajax.responseText;
+ − 82
thediv.appendChild(ta);
+ − 83
b = document.createElement('br');
+ − 84
thediv.appendChild(b);
+ − 85
thediv.innerHTML += '<a href="#" onclick="ajaxSaveBlock(this, \''+id+'\'); return false;">save</a> | <a href="#" onclick="if(confirm(\'Do you really want to discard your changes?\')) this.parentNode.parentNode.removeChild(this.parentNode); return false;">cancel</a>';
+ − 86
}
+ − 87
body = document.getElementsByTagName('body');
+ − 88
body = body[0];
+ − 89
body.appendChild(thediv);
+ − 90
}
+ − 91
});
+ − 92
}
+ − 93
+ − 94
var blockSave_current;
+ − 95
function ajaxSaveBlock(oElm, id)
+ − 96
{
+ − 97
taContent = escape(oElm.previousSibling.previousSibling.value);
+ − 98
taContent = taContent.replace(unescape('%0A'), '%0A');
+ − 99
taContent = taContent.replace('+', '%2B');
+ − 100
blockSave_current = { 0 : id, 1 : oElm };
+ − 101
ajaxPost(makeUrlNS('Special', 'EditSidebar', 'noheaders&action=save&id='+id), 'content='+taContent, function()
+ − 102
{
+ − 103
if(ajax.readyState == 4)
+ − 104
{
+ − 105
id = blockSave_current[0];
+ − 106
oElm = blockSave_current[1];
+ − 107
eval(ajax.responseText);
+ − 108
if(status == 'GOOD')
+ − 109
{
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 110
var _id = 'disabled_' + String(id);
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 111
var parent = document.getElementById(_id).parentNode.parentNode;
1
+ − 112
oElm.parentNode.parentNode.removeChild(oElm.parentNode);
+ − 113
content = content.replace('%a', unescape('%0A'));
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 114
var obj = ( IE ) ? parent.firstChild.nextSibling.nextSibling : parent.firstChild.nextSibling.nextSibling.nextSibling;
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 115
if ( obj )
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 116
obj.innerHTML = content; // $content is set in ajax.responseText
1
+ − 117
}
+ − 118
else
+ − 119
{
+ − 120
alert(status);
+ − 121
}
+ − 122
}
+ − 123
});
+ − 124
}
+ − 125
179
+ − 126
function ajaxRenameSidebarStage1(parent, id)
+ − 127
{
+ − 128
var oldname = parent.firstChild.nodeValue;
+ − 129
parent.removeChild(parent.firstChild);
+ − 130
parent.ondblclick = function() {};
+ − 131
parent._idcache = id;
+ − 132
var input = document.createElement('input');
+ − 133
input.type = 'text';
+ − 134
input.sbedit_id = id;
+ − 135
input.oldvalue = oldname;
+ − 136
input.onkeyup = function(e)
+ − 137
{
+ − 138
if ( typeof(e) != 'object' )
+ − 139
return false;
+ − 140
if ( !e.keyCode )
+ − 141
return false;
+ − 142
if ( e.keyCode == 13 )
+ − 143
{
+ − 144
ajaxRenameSidebarStage2(this);
+ − 145
}
+ − 146
if ( e.keyCode == 27 )
+ − 147
{
+ − 148
ajaxRenameSidebarCancel(this);
+ − 149
}
+ − 150
};
+ − 151
input.onblur = function()
+ − 152
{
+ − 153
ajaxRenameSidebarCancel(this);
+ − 154
};
+ − 155
input.value = oldname;
+ − 156
input.style.fontSize = '7pt';
+ − 157
parent.appendChild(input);
+ − 158
input.focus();
+ − 159
}
+ − 160
+ − 161
function ajaxRenameSidebarStage2(input)
+ − 162
{
+ − 163
var newname = input.value;
+ − 164
var id = input.sbedit_id;
+ − 165
var parent = input.parentNode;
+ − 166
parent.removeChild(input);
+ − 167
parent.appendChild(document.createTextNode(newname));
+ − 168
parent.ondblclick = function() { ajaxRenameSidebarStage1(this, this._idcache); return false; };
+ − 169
var img = document.createElement('img');
+ − 170
img.src = scriptPath + '/images/loading.gif';
+ − 171
parent.appendChild(img);
+ − 172
newname = ajaxEscape(newname);
+ − 173
ajaxPost(makeUrlNS('Special', 'EditSidebar', 'ajax&noheaders&action=rename&id='+id), 'newname=' +newname, function()
+ − 174
{
+ − 175
if ( ajax.readyState == 4 )
+ − 176
{
+ − 177
parent.removeChild(img);
+ − 178
if ( ajax.responseText != 'GOOD' )
+ − 179
new messagebox(MB_OK|MB_ICONSTOP, 'Error renaming block', ajax.responseText);
+ − 180
}
+ − 181
});
+ − 182
}
+ − 183
+ − 184
function ajaxRenameSidebarCancel(input)
+ − 185
{
+ − 186
var newname = input.oldvalue;
+ − 187
var id = input.sbedit_id;
+ − 188
var parent = input.parentNode;
+ − 189
parent.removeChild(input);
+ − 190
parent.appendChild(document.createTextNode(newname));
+ − 191
parent.ondblclick = function() { ajaxRenameSidebarStage1(this, this._idcache); return false; };
+ − 192
}
+ − 193