582
+ − 1
// all utility functions go in here
+ − 2
+ − 3
function makeUrl(page, query, html_friendly)
+ − 4
{
+ − 5
url = contentPath+page;
+ − 6
if(url.indexOf('?') > 0) sep = '&';
+ − 7
else sep = '?';
+ − 8
if(query)
+ − 9
{
+ − 10
url = url + sep + query;
+ − 11
}
+ − 12
if(html_friendly)
+ − 13
{
+ − 14
url = url.replace('&', '&');
+ − 15
url = url.replace('<', '<');
+ − 16
url = url.replace('>', '>');
+ − 17
}
+ − 18
return url;
+ − 19
}
+ − 20
+ − 21
function makeUrlNS(namespace, page, query, html_friendly)
+ − 22
{
+ − 23
var url = contentPath+namespace_list[namespace]+(page.replace(/ /g, '_'));
+ − 24
if(url.indexOf('?') > 0) sep = '&';
+ − 25
else sep = '?';
+ − 26
if(query)
+ − 27
{
+ − 28
url = url + sep + query;
+ − 29
}
+ − 30
if(html_friendly)
+ − 31
{
+ − 32
url = url.replace('&', '&');
+ − 33
url = url.replace('<', '<');
+ − 34
url = url.replace('>', '>');
+ − 35
}
+ − 36
return append_sid(url);
+ − 37
}
+ − 38
+ − 39
function strToPageID(string)
+ − 40
{
+ − 41
// Convert Special:UploadFile to ['UploadFile', 'Special'], but convert 'Image:Enano.png' to ['Enano.png', 'File']
+ − 42
for(var i in namespace_list)
+ − 43
if(namespace_list[i] != '')
+ − 44
if(namespace_list[i] == string.substr(0, namespace_list[i].length))
+ − 45
return [string.substr(namespace_list[i].length), i];
+ − 46
return [string, 'Article'];
+ − 47
}
+ − 48
+ − 49
function append_sid(url)
+ − 50
{
+ − 51
sep = ( url.indexOf('?') > 0 ) ? '&' : '?';
+ − 52
if(ENANO_SID.length > 10)
+ − 53
{
+ − 54
url = url + sep + 'auth=' + ENANO_SID;
+ − 55
sep = '&';
+ − 56
}
+ − 57
if ( pagepass.length > 0 )
+ − 58
{
+ − 59
url = url + sep + 'pagepass=' + pagepass;
+ − 60
}
+ − 61
return url;
+ − 62
}
+ − 63
+ − 64
var stdAjaxPrefix = append_sid(scriptPath+'/ajax.php?title='+title);
+ − 65
+ − 66
/**
+ − 67
* Core AJAX library
+ − 68
*/
+ − 69
+ − 70
function ajaxMakeXHR()
+ − 71
{
+ − 72
var ajax;
+ − 73
if (window.XMLHttpRequest) {
+ − 74
ajax = new XMLHttpRequest();
+ − 75
} else {
+ − 76
if (window.ActiveXObject) {
+ − 77
ajax = new ActiveXObject("Microsoft.XMLHTTP");
+ − 78
} else {
+ − 79
alert('Enano client-side runtime error: No AJAX support, unable to continue');
+ − 80
return;
+ − 81
}
+ − 82
}
+ − 83
return ajax;
+ − 84
}
+ − 85
+ − 86
function ajaxGet(uri, f, call_editor_safe) {
+ − 87
// Is the editor open?
+ − 88
if ( editor_open && !call_editor_safe )
+ − 89
{
+ − 90
// Make sure the user is willing to close the editor
+ − 91
var conf = confirm($lang.get('editor_msg_confirm_ajax'));
+ − 92
if ( !conf )
+ − 93
{
+ − 94
// Kill off any "loading" windows, etc. and cancel the request
+ − 95
unsetAjaxLoading();
+ − 96
return false;
+ − 97
}
+ − 98
// The user allowed the editor to be closed. Reset flags and knock out the on-close confirmation.
+ − 99
editor_open = false;
+ − 100
enableUnload();
+ − 101
}
+ − 102
ajax = ajaxMakeXHR();
+ − 103
if ( !ajax )
+ − 104
{
+ − 105
console.error('ajaxMakeXHR() failed');
+ − 106
return false;
+ − 107
}
+ − 108
ajax.onreadystatechange = f;
+ − 109
ajax.open('GET', uri, true);
+ − 110
ajax.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
+ − 111
ajax.send(null);
+ − 112
}
+ − 113
+ − 114
function ajaxPost(uri, parms, f, call_editor_safe) {
+ − 115
// Is the editor open?
+ − 116
if ( editor_open && !call_editor_safe )
+ − 117
{
+ − 118
// Make sure the user is willing to close the editor
+ − 119
var conf = confirm($lang.get('editor_msg_confirm_ajax'));
+ − 120
if ( !conf )
+ − 121
{
+ − 122
// Kill off any "loading" windows, etc. and cancel the request
+ − 123
unsetAjaxLoading();
+ − 124
return false;
+ − 125
}
+ − 126
// The user allowed the editor to be closed. Reset flags and knock out the on-close confirmation.
+ − 127
editor_open = false;
+ − 128
enableUnload();
+ − 129
}
+ − 130
ajax = ajaxMakeXHR();
+ − 131
if ( !ajax )
+ − 132
{
+ − 133
console.error('ajaxMakeXHR() failed');
+ − 134
return false;
+ − 135
}
+ − 136
ajax.onreadystatechange = f;
+ − 137
ajax.open('POST', uri, true);
+ − 138
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ − 139
// Setting Content-length in Safari triggers a warning
+ − 140
if ( !is_Safari )
+ − 141
{
+ − 142
ajax.setRequestHeader("Content-length", parms.length);
+ − 143
}
+ − 144
ajax.setRequestHeader("Connection", "close");
+ − 145
ajax.send(parms);
+ − 146
}
+ − 147
+ − 148
/**
+ − 149
* Show a friendly error message depicting an AJAX response that is not valid JSON
+ − 150
* @param string Response text
+ − 151
* @param string Custom error message. If omitted, the default will be shown.
+ − 152
*/
+ − 153
+ − 154
function handle_invalid_json(response, customerror)
+ − 155
{
779
609e35845ec3
load_component() now accepts an array, and most JS components are loaded all in one request now. Totally modular baby. And failsafe too.
Dan
diff
changeset
+ − 156
load_component(['messagebox', 'jquery', 'jquery-ui', 'fadefilter', 'flyin', 'l10n']);
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 157
727
591562495e87
JSON parse failures should spawn their own darkener layer now instead of reusing the main one if applicable
Dan
diff
changeset
+ − 158
darken(aclDisableTransitionFX, 70, 'invalidjsondarkener');
582
+ − 159
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 160
var box = document.createElement('div');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 161
var mainwin = document.createElement('div');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 162
var panel = document.createElement('div');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 163
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 164
//
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 165
// main window
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 166
//
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 167
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 168
mainwin.style.padding = '10px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 169
mainwin.style.width = '580px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 170
mainwin.style.height = '360px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 171
mainwin.style.clip = 'rect(0px,auto,auto,0px)';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 172
mainwin.style.overflow = 'auto';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 173
mainwin.style.backgroundColor = '#ffffff';
582
+ − 174
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 175
// Title
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 176
var h3 = document.createElement('h3');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 177
var h3_text = ( $lang.placeholder ) ? 'The site encountered an error while processing your request.' : $lang.get('ajax_badjson_title');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 178
h3.appendChild(document.createTextNode(h3_text));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 179
mainwin.appendChild(h3);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 180
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 181
if ( typeof(customerror) == 'string' )
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 182
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 183
var el = document.createElement('p');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 184
el.appendChild(document.createTextNode(customerror));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 185
mainwin.appendChild(el);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 186
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 187
else
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 188
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 189
var error = 'We unexpectedly received the following response from the server. The response should have been in the JSON ';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 190
error += 'serialization format, but the response wasn\'t composed only of the JSON response. There are three possible triggers ';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 191
error += 'for this problem:';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 192
customerror = ( $lang.placeholder ) ? error : $lang.get('ajax_badjson_body');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 193
var el = document.createElement('p');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 194
el.appendChild(document.createTextNode(customerror));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 195
mainwin.appendChild(el);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 196
var ul = document.createElement('ul');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 197
var li1 = document.createElement('li');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 198
var li2 = document.createElement('li');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 199
var li3 = document.createElement('li');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 200
var li1_text = ( $lang.placeholder ) ? 'The server sent back a bad HTTP response code and thus sent an error page instead of running Enano. This indicates a possible problem with your server, and is not likely to be a bug with Enano.' : $lang.get('ajax_badjson_tip1');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 201
var li2_text = ( $lang.placeholder ) ? 'The server sent back the expected JSON response, but also injected some code into the response that should not be there. Typically this consists of advertisement code. In this case, the administrator of this site will have to contact their web host to have advertisements disabled.' : $lang.get('ajax_badjson_tip2');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 202
var li3_text = ( $lang.placeholder ) ? 'It\'s possible that Enano triggered a PHP error or warning. In this case, you may be looking at a bug in Enano.' : $lang.get('ajax_badjson_tip3');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 203
var osc_ex_data = ( $lang.placeholder ) ? 'This is KNOWN to be the case with the OpenSourceCMS.com demo version of Enano.' : $lang.get('ajax_badjson_osc');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 204
li1.appendChild(document.createTextNode(li1_text));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 205
var osc_exception = ( window.location.hostname == 'demo.opensourcecms.com' ) ? ' ' + osc_ex_data : '';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 206
li2.appendChild(document.createTextNode(li2_text + osc_exception));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 207
li3.appendChild(document.createTextNode(li3_text));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 208
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 209
ul.appendChild(li1);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 210
ul.appendChild(li2);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 211
ul.appendChild(li3);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 212
mainwin.appendChild(ul);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 213
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 214
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 215
var p2 = document.createElement('p');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 216
var p2_text = ( $lang.placeholder ) ? 'The response received from the server is as follows:' : $lang.get('ajax_badjson_msg_response');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 217
p2.appendChild(document.createTextNode(p2_text));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 218
mainwin.appendChild(p2);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 219
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 220
var pre = document.createElement('pre');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 221
pre.appendChild(document.createTextNode(response));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 222
mainwin.appendChild(pre);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 223
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 224
var p3 = document.createElement('p');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 225
var p3_text = $lang.placeholder ? 'You may also choose to view the response as HTML.' : $lang.get('ajax_badjson_msg_viewashtml');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 226
p3.appendChild(document.createTextNode(p3_text + ' '));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 227
var a = document.createElement('a');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 228
var a_text = $lang.placeholder ? 'View as HTML' : $lang.get('ajax_badjson_btn_viewashtml');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 229
a.appendChild(document.createTextNode(a_text + '...'));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 230
a._resp = response;
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 231
a.onclick = function()
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 232
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 233
var vah_title = ( $lang.placeholder ) ? 'View the response as HTML?' : $lang.get('ajax_badjson_html_confirm_title');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 234
var vah_body = ( $lang.placeholder ) ? 'If the server\'s response was modified by an attacker to include malicious code, viewing the response as HTML might allow that malicious code to run. Only continue if you have inspected the response text and verified that it is safe.' : $lang.get('ajax_badjson_html_confirm_body');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 235
var btn_confirm = $lang.placeholder ? 'View as HTML' : $lang.get('ajax_badjson_btn_viewashtml');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 236
var btn_cancel = $lang.placeholder ? 'Cancel' : $lang.get('etc_cancel');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 237
var mp = miniPromptMessage({
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 238
title: vah_title,
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 239
message: vah_body,
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 240
buttons: [
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 241
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 242
text: btn_confirm,
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 243
color: 'blue',
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 244
style: {
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 245
fontWeight: 'bold'
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 246
},
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 247
onclick: function() {
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 248
var mp = miniPromptGetParent(this);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 249
var win = window.open('about:blank', 'invalidjson_htmlwin', 'width=550,height=400,status=no,toolbars=no,toolbar=no,address=no,scroll=yes');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 250
win.document.write(mp._response);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 251
win.document.close();
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 252
miniPromptDestroy(this);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 253
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 254
},
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 255
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 256
text: btn_cancel,
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 257
onclick: function() {
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 258
miniPromptDestroy(this);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 259
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 260
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 261
]
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 262
});
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 263
mp._response = this._resp;
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 264
return false;
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 265
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 266
a.href = '#';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 267
p3.appendChild(a);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 268
mainwin.appendChild(p3);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 269
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 270
//
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 271
// panel
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 272
//
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 273
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 274
panel.style.backgroundColor = '#D0D0D0';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 275
panel.style.textAlign = 'right';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 276
panel.style.padding = '0 10px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 277
panel.style.lineHeight = '40px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 278
panel.style.width = '580px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 279
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 280
var closer = document.createElement('input');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 281
var btn_close = $lang.placeholder ? 'Close' : $lang.get('ajax_badjson_btn_close');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 282
closer.type = 'button';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 283
closer.value = btn_close;
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 284
closer.onclick = function()
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 285
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 286
var parentdiv = this.parentNode.parentNode;
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 287
if ( aclDisableTransitionFX )
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 288
{
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 289
parentdiv.parentNode.removeChild(parentdiv);
727
591562495e87
JSON parse failures should spawn their own darkener layer now instead of reusing the main one if applicable
Dan
diff
changeset
+ − 290
enlighten(aclDisableTransitionFX, 'invalidjsondarkener');
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 291
}
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 292
else
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 293
{
699
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 294
$(parentdiv).hide("blind", {}, 1000, function()
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 295
{
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 296
parentdiv.parentNode.removeChild(parentdiv);
727
591562495e87
JSON parse failures should spawn their own darkener layer now instead of reusing the main one if applicable
Dan
diff
changeset
+ − 297
enlighten(aclDisableTransitionFX, 'invalidjsondarkener');
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 298
});
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 299
}
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 300
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 301
panel.appendChild(closer);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 302
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 303
//
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 304
// put it together
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 305
//
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 306
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 307
box.appendChild(mainwin);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 308
box.appendChild(panel);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 309
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 310
// add it to the body to allow height/width calculation
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 311
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 312
box.style.display = 'block';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 313
box.style.position = 'absolute';
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 314
box.style.zIndex = getHighestZ() + 1;
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 315
domObjChangeOpac(0, box);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 316
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 317
var body = document.getElementsByTagName('body')[0];
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 318
body.appendChild(box);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 319
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 320
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 321
// calculate position of the box
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 322
// box should be exactly 640px high, 480px wide
699
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 323
var top = ( getHeight() / 2 ) - ( $dynano(box).Height() / 2 ) + getScrollOffset();
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 324
var left = ( getWidth() / 2 ) - ( $dynano(box).Width() / 2 );
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 325
console.debug('top = %d, left = %d', top, left);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 326
box.style.top = top + 'px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 327
box.style.left = left + 'px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 328
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 329
// we have width and height, set display to none and reset opacity
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 330
if ( aclDisableTransitionFX )
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 331
{
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 332
domObjChangeOpac(100, box);
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 333
box.style.display = 'block';
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 334
}
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 335
else
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 336
{
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 337
box.style.display = 'none';
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 338
domObjChangeOpac(100, box);
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 339
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 340
setTimeout(function()
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 341
{
699
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 342
$(box).show("blind", {}, 1000);
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 343
}, 1000);
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 344
}
679
+ − 345
return false;
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 346
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 347
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 348
/**
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 349
* Verify that a string is roughly a valid JSON object. Warning - this is only a very cheap syntax check.
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 350
* @param string
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 351
* @return bool true if JSON is valid
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 352
*/
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 353
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 354
function check_json_response(response)
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 355
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 356
response = trim(response);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 357
if ( response.substr(0, 1) == '{' && response.substr(response.length - 1, 1) == '}' )
582
+ − 358
{
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 359
return true;
582
+ − 360
}
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 361
return false;
582
+ − 362
}
+ − 363
+ − 364
function ajaxEscape(text)
+ − 365
{
+ − 366
/*
+ − 367
text = escape(text);
+ − 368
text = text.replace(/\+/g, '%2B', text);
+ − 369
*/
+ − 370
text = window.encodeURIComponent(text);
+ − 371
return text;
+ − 372
}
+ − 373
+ − 374
/**
+ − 375
* String functions
+ − 376
*/
+ − 377
+ − 378
// Equivalent to PHP trim() function
+ − 379
function trim(text)
+ − 380
{
+ − 381
text = text.replace(/^([\s]+)/, '');
+ − 382
text = text.replace(/([\s]+)$/, '');
+ − 383
return text;
+ − 384
}
+ − 385
+ − 386
// Equivalent to PHP implode() function
+ − 387
function implode(chr, arr)
+ − 388
{
+ − 389
if ( typeof ( arr.toJSONString ) == 'function' )
+ − 390
delete(arr.toJSONString);
+ − 391
+ − 392
var ret = '';
+ − 393
var c = 0;
+ − 394
for ( var i in arr )
+ − 395
{
+ − 396
if(i=='toJSONString')continue;
+ − 397
if ( c > 0 )
+ − 398
ret += chr;
+ − 399
ret += arr[i];
+ − 400
c++;
+ − 401
}
+ − 402
return ret;
+ − 403
}
+ − 404
+ − 405
function form_fetch_field(form, name)
+ − 406
{
+ − 407
var fields = form.getElementsByTagName('input');
+ − 408
if ( fields.length < 1 )
+ − 409
return false;
+ − 410
for ( var i = 0; i < fields.length; i++ )
+ − 411
{
+ − 412
var field = fields[i];
+ − 413
if ( field.name == name )
+ − 414
return field;
+ − 415
}
+ − 416
return false;
+ − 417
}
+ − 418
+ − 419
function get_parent_form(o)
+ − 420
{
+ − 421
if ( !o.parentNode )
+ − 422
return false;
+ − 423
if ( o.tagName == 'FORM' )
+ − 424
return o;
+ − 425
var p = o.parentNode;
+ − 426
while(true)
+ − 427
{
+ − 428
if ( p.tagName == 'FORM' )
+ − 429
return p;
+ − 430
else if ( !p )
+ − 431
return false;
+ − 432
else
+ − 433
p = p.parentNode;
+ − 434
}
+ − 435
}
+ − 436
+ − 437
function findParentForm(o)
+ − 438
{
+ − 439
return get_parent_form(o);
+ − 440
}
+ − 441
+ − 442
function domObjChangeOpac(opacity, id) {
+ − 443
var object = id.style;
+ − 444
object.opacity = (opacity / 100);
+ − 445
object.MozOpacity = (opacity / 100);
+ − 446
object.KhtmlOpacity = (opacity / 100);
+ − 447
object.filter = "alpha(opacity=" + opacity + ")";
+ − 448
}
+ − 449
704
+ − 450
function getScrollOffset(el)
582
+ − 451
{
+ − 452
var position;
704
+ − 453
var s = el || self;
+ − 454
el = el || document;
+ − 455
if ( el.scrollTop )
+ − 456
{
+ − 457
position = el.scrollTop;
+ − 458
}
+ − 459
else if (s.pageYOffset)
582
+ − 460
{
+ − 461
position = self.pageYOffset;
+ − 462
}
+ − 463
else if (document.documentElement && document.documentElement.scrollTop)
+ − 464
{
+ − 465
position = document.documentElement.scrollTop;
+ − 466
}
+ − 467
else if (document.body)
+ − 468
{
+ − 469
position = document.body.scrollTop;
+ − 470
}
+ − 471
return position;
+ − 472
}
+ − 473
672
08a7875258b4
Added tab-based interface to userpage UI. Yes, it is plugin expansible, and yes, it breaks existing plugins that add code to the userpage (but that can be fixed with a "colspan=4")
Dan
diff
changeset
+ − 474
function setScrollOffset(offset)
08a7875258b4
Added tab-based interface to userpage UI. Yes, it is plugin expansible, and yes, it breaks existing plugins that add code to the userpage (but that can be fixed with a "colspan=4")
Dan
diff
changeset
+ − 475
{
08a7875258b4
Added tab-based interface to userpage UI. Yes, it is plugin expansible, and yes, it breaks existing plugins that add code to the userpage (but that can be fixed with a "colspan=4")
Dan
diff
changeset
+ − 476
window.scroll(0, offset);
08a7875258b4
Added tab-based interface to userpage UI. Yes, it is plugin expansible, and yes, it breaks existing plugins that add code to the userpage (but that can be fixed with a "colspan=4")
Dan
diff
changeset
+ − 477
}
08a7875258b4
Added tab-based interface to userpage UI. Yes, it is plugin expansible, and yes, it breaks existing plugins that add code to the userpage (but that can be fixed with a "colspan=4")
Dan
diff
changeset
+ − 478
582
+ − 479
// Function to fade classes info-box, warning-box, error-box, etc.
+ − 480
+ − 481
function fadeInfoBoxes()
+ − 482
{
+ − 483
var divs = new Array();
+ − 484
d = document.getElementsByTagName('div');
+ − 485
j = 0;
+ − 486
for(var i in d)
+ − 487
{
+ − 488
if ( !d[i] )
+ − 489
continue;
+ − 490
if ( !d[i].tagName )
+ − 491
continue;
+ − 492
if(d[i].className=='info-box' || d[i].className=='error-box' || d[i].className=='warning-box' || d[i].className=='question-box')
+ − 493
{
+ − 494
divs[j] = d[i];
+ − 495
j++;
+ − 496
}
+ − 497
}
+ − 498
if(divs.length < 1) return;
+ − 499
load_component('fat');
+ − 500
for(i in divs)
+ − 501
{
+ − 502
if(!divs[i].id) divs[i].id = 'autofade_'+Math.floor(Math.random() * 100000);
+ − 503
switch(divs[i].className)
+ − 504
{
+ − 505
case 'info-box':
+ − 506
default:
+ − 507
from = '#3333FF';
+ − 508
break;
+ − 509
case 'error-box':
+ − 510
from = '#FF3333';
+ − 511
break;
+ − 512
case 'warning-box':
+ − 513
from = '#FFFF33';
+ − 514
break;
+ − 515
case 'question-box':
+ − 516
from = '#33FF33';
+ − 517
break;
+ − 518
}
+ − 519
Fat.fade_element(divs[i].id,30,2000,from,Fat.get_bgcolor(divs[i].id));
+ − 520
}
+ − 521
}
+ − 522
+ − 523
addOnloadHook(fadeInfoBoxes);
+ − 524
+ − 525
// Alpha fades
+ − 526
+ − 527
function opacity(id, opacStart, opacEnd, millisec)
+ − 528
{
+ − 529
var object = document.getElementById(id);
+ − 530
domOpacity(object, opacStart, opacEnd, millisec);
+ − 531
}
+ − 532
+ − 533
var opacityDOMCache = new Object();
+ − 534
function domOpacity(obj, opacStart, opacEnd, millisec) {
+ − 535
//speed for each frame
+ − 536
var speed = Math.round(millisec / 100);
+ − 537
var timer = 0;
+ − 538
+ − 539
// unique ID for this animation
+ − 540
var uniqid = Math.floor(Math.random() * 1000000);
+ − 541
opacityDOMCache[uniqid] = obj;
+ − 542
+ − 543
//determine the direction for the blending, if start and end are the same nothing happens
+ − 544
if(opacStart > opacEnd) {
+ − 545
for(i = opacStart; i >= opacEnd; i--) {
+ − 546
setTimeout("var obj = opacityDOMCache["+uniqid+"]; domObjChangeOpac(" + i + ",obj)",(timer * speed));
+ − 547
timer++;
+ − 548
}
+ − 549
} else if(opacStart < opacEnd) {
+ − 550
for(i = opacStart; i <= opacEnd; i++)
+ − 551
{
+ − 552
setTimeout("var obj = opacityDOMCache["+uniqid+"]; domObjChangeOpac(" + i + ",obj)",(timer * speed));
+ − 553
timer++;
+ − 554
}
+ − 555
}
+ − 556
setTimeout("delete(opacityDOMCache["+uniqid+"]);",(timer * speed));
+ − 557
}
+ − 558
+ − 559
// change the opacity for different browsers
+ − 560
function changeOpac(opacity, id)
+ − 561
{
+ − 562
var object = document.getElementById(id);
+ − 563
return domObjChangeOpac(opacity, object);
+ − 564
}
+ − 565
+ − 566
// draw a white ajax-ey "loading" box over an object
+ − 567
function whiteOutElement(el)
+ − 568
{
699
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 569
var top = $dynano(el).Top();
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 570
var left = $dynano(el).Left();
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 571
var width = $dynano(el).Width();
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 572
var height = $dynano(el).Height();
582
+ − 573
+ − 574
var blackout = document.createElement('div');
691
+ − 575
// using fixed here allows modal windows to be blacked out
+ − 576
blackout.style.position = ( el.style.position == 'fixed' ) ? 'fixed' : 'absolute';
582
+ − 577
blackout.style.top = top + 'px';
+ − 578
blackout.style.left = left + 'px';
+ − 579
blackout.style.width = width + 'px';
+ − 580
blackout.style.height = height + 'px';
+ − 581
+ − 582
blackout.style.backgroundColor = '#FFFFFF';
+ − 583
domObjChangeOpac(60, blackout);
699
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 584
var background = ( $dynano(el).Height() < 48 ) ? 'url(' + scriptPath + '/images/loading.gif)' : 'url(' + scriptPath + '/includes/clientside/tinymce/themes/advanced/skins/default/img/progress.gif)';
672
08a7875258b4
Added tab-based interface to userpage UI. Yes, it is plugin expansible, and yes, it breaks existing plugins that add code to the userpage (but that can be fixed with a "colspan=4")
Dan
diff
changeset
+ − 585
blackout.style.backgroundImage = background;
582
+ − 586
blackout.style.backgroundPosition = 'center center';
+ − 587
blackout.style.backgroundRepeat = 'no-repeat';
+ − 588
blackout.style.zIndex = getHighestZ() + 2;
+ − 589
+ − 590
var body = document.getElementsByTagName('body')[0];
+ − 591
body.appendChild(blackout);
+ − 592
+ − 593
return blackout;
+ − 594
}
+ − 595
628
+ − 596
/**
+ − 597
* Take a div generated by whiteOutElement() and report success using the glossy "check" graphic. Sets the image, then
+ − 598
* briefly fades in, then fades out and destroys the box so as to re-allow control over the underlying element
+ − 599
*/
+ − 600
+ − 601
function whiteOutReportSuccess(whitey)
+ − 602
{
+ − 603
// fade the status indicator in and then out
+ − 604
whitey.style.backgroundImage = 'url(' + scriptPath + '/images/check.png)';
679
+ − 605
if ( aclDisableTransitionFX )
+ − 606
{
+ − 607
domObjChangeOpac(80, whitey);
+ − 608
}
+ − 609
else
+ − 610
{
+ − 611
domOpacity(whitey, 60, 80, 500);
+ − 612
setTimeout(function()
+ − 613
{
+ − 614
domOpacity(whitey, 60, 0, 500);
+ − 615
}, 750);
+ − 616
}
628
+ − 617
setTimeout(function()
+ − 618
{
+ − 619
whitey.parentNode.removeChild(whitey);
+ − 620
}, 1250);
+ − 621
}
+ − 622
691
+ − 623
/**
+ − 624
* Whites out a form and disables all buttons under it. Useful for onsubmit functions.
+ − 625
* @example
+ − 626
<code>
+ − 627
<form action="foo" onsubmit="whiteOutForm(this);">
+ − 628
</code>
+ − 629
* @param object Form object
+ − 630
* @return object Whiteout div
+ − 631
*/
+ − 632
+ − 633
function whiteOutForm(form)
+ − 634
{
+ − 635
if ( !form.getElementsByTagName )
+ − 636
return false;
+ − 637
+ − 638
// disable all buttons
+ − 639
var buttons = form.getElementsByTagName('input');
+ − 640
for ( var i = 0; i < buttons.length; i++ )
+ − 641
{
+ − 642
if ( buttons[i].type == 'button' || buttons[i].type == 'submit' || buttons[i].type == 'image' )
+ − 643
{
+ − 644
buttons[i].disabled = 'disabled';
+ − 645
// ... but also make a hidden element to preserve any flags
+ − 646
var clone = buttons[i].cloneNode(true);
+ − 647
clone.type = 'hidden';
+ − 648
clone.disabled = false;
+ − 649
console.debug(clone);
+ − 650
form.appendChild(clone);
+ − 651
}
+ − 652
}
+ − 653
var buttons = form.getElementsByTagName('button');
+ − 654
for ( var i = 0; i < buttons.length; i++ )
+ − 655
{
+ − 656
buttons[i].disabled = 'disabled';
+ − 657
// ... but also make a hidden element to preserve any flags
+ − 658
if ( buttons[i].name )
+ − 659
{
+ − 660
var clone = document.createElement('input');
+ − 661
clone.type = 'hidden';
+ − 662
clone.name = buttons[i].name;
+ − 663
clone.value = ( buttons[i].value ) ? buttons[i].value : '';
+ − 664
form.appendChild(clone);
+ − 665
}
+ − 666
}
+ − 667
+ − 668
return whiteOutElement(form);
+ − 669
}
+ − 670
582
+ − 671
// other DHTML functions
+ − 672
+ − 673
function fetch_offset(obj)
+ − 674
{
+ − 675
var left_offset = obj.offsetLeft;
+ − 676
var top_offset = obj.offsetTop;
+ − 677
while ((obj = obj.offsetParent) != null) {
+ − 678
left_offset += obj.offsetLeft;
+ − 679
top_offset += obj.offsetTop;
+ − 680
}
+ − 681
return { 'left' : left_offset, 'top' : top_offset };
+ − 682
}
+ − 683
+ − 684
function fetch_dimensions(o) {
+ − 685
var w = o.offsetWidth;
+ − 686
var h = o.offsetHeight;
+ − 687
return { 'w' : w, 'h' : h };
+ − 688
}
+ − 689
+ − 690
function findParentForm(o)
+ − 691
{
+ − 692
if ( o.tagName == 'FORM' )
+ − 693
return o;
+ − 694
while(true)
+ − 695
{
+ − 696
o = o.parentNode;
+ − 697
if ( !o )
+ − 698
return false;
+ − 699
if ( o.tagName == 'FORM' )
+ − 700
return o;
+ − 701
}
+ − 702
return false;
+ − 703
}
+ − 704
+ − 705
function bannerOn(text)
+ − 706
{
+ − 707
darken(true);
+ − 708
var thediv = document.createElement('div');
+ − 709
thediv.className = 'mdg-comment';
+ − 710
thediv.style.padding = '0';
+ − 711
thediv.style.marginLeft = '0';
+ − 712
thediv.style.position = 'absolute';
+ − 713
thediv.style.display = 'none';
+ − 714
thediv.style.padding = '4px';
+ − 715
thediv.style.fontSize = '14pt';
+ − 716
thediv.id = 'mdgDynamic_bannerDiv_'+Math.floor(Math.random() * 1000000);
+ − 717
thediv.innerHTML = text;
+ − 718
+ − 719
var body = document.getElementsByTagName('body');
+ − 720
body = body[0];
+ − 721
body.appendChild(thediv);
+ − 722
body.style.cursor = 'wait';
+ − 723
+ − 724
thediv.style.display = 'block';
+ − 725
dim = fetch_dimensions(thediv);
+ − 726
thediv.style.display = 'none';
+ − 727
bdim = { 'w' : getWidth(), 'h' : getHeight() };
+ − 728
so = getScrollOffset();
+ − 729
+ − 730
var left = (bdim['w'] / 2) - ( dim['w'] / 2 );
+ − 731
+ − 732
var top = (bdim['h'] / 2);
+ − 733
top = top - ( dim['h'] / 2 );
+ − 734
+ − 735
top = top + so;
+ − 736
+ − 737
thediv.style.top = top + 'px';
+ − 738
thediv.style.left = left + 'px';
+ − 739
+ − 740
thediv.style.display = 'block';
+ − 741
+ − 742
return thediv.id;
+ − 743
}
+ − 744
+ − 745
function bannerOff(id)
+ − 746
{
+ − 747
e = document.getElementById(id);
+ − 748
if(!e) return;
+ − 749
e.innerHTML = '';
+ − 750
e.style.display = 'none';
+ − 751
var body = document.getElementsByTagName('body');
+ − 752
body = body[0];
+ − 753
body.style.cursor = 'default';
+ − 754
enlighten(true);
+ − 755
}
+ − 756
+ − 757
function disableUnload(message)
+ − 758
{
+ − 759
if(typeof message != 'string') message = 'You may want to save your changes first.';
+ − 760
window._unloadmsg = message;
+ − 761
window.onbeforeunload = function(e)
+ − 762
{
+ − 763
if ( !e )
+ − 764
e = window.event;
+ − 765
e.returnValue = window._unloadmsg;
+ − 766
}
+ − 767
}
+ − 768
+ − 769
function enableUnload()
+ − 770
{
+ − 771
window._unloadmsg = null;
+ − 772
window.onbeforeunload = null;
+ − 773
}
+ − 774
+ − 775
/**
+ − 776
* Gets the highest z-index of all divs in the document
+ − 777
* @return integer
+ − 778
*/
+ − 779
function getHighestZ()
+ − 780
{
+ − 781
z = 0;
+ − 782
var divs = document.getElementsByTagName('div');
+ − 783
for(var i = 0; i < divs.length; i++)
+ − 784
{
+ − 785
if(divs[i].style.zIndex > z) z = divs[i].style.zIndex;
+ − 786
}
677
2a263b598a2b
Improved miniPrompt and fadefilter to properly overlap parent modal windows. MessageBox() is next. Fixed pref_disable_js_fx not working due to wrong type (number instead of boolean).
Dan
diff
changeset
+ − 787
return parseInt(z);
582
+ − 788
}
+ − 789
592
+ − 790
var shift = false;
582
+ − 791
function isKeyPressed(event)
+ − 792
{
+ − 793
if (event.shiftKey==1)
+ − 794
{
+ − 795
shift = true;
+ − 796
}
+ − 797
else
+ − 798
{
+ − 799
shift = false;
+ − 800
}
+ − 801
}
+ − 802
+ − 803
function moveDiv(div, newparent)
+ − 804
{
+ − 805
var backup = div;
+ − 806
var oldparent = div.parentNode;
+ − 807
oldparent.removeChild(div);
+ − 808
newparent.appendChild(backup);
+ − 809
}
+ − 810
+ − 811
var busyBannerID;
+ − 812
function goBusy(msg)
+ − 813
{
+ − 814
if(!msg) msg = 'Please wait...';
+ − 815
body = document.getElementsByTagName('body');
+ − 816
body = body[0];
+ − 817
body.style.cursor = 'wait';
+ − 818
busyBannerID = bannerOn(msg);
+ − 819
}
+ − 820
+ − 821
function unBusy()
+ − 822
{
+ − 823
body = document.getElementsByTagName('body');
+ − 824
body = body[0];
+ − 825
body.style.cursor = 'default';
+ − 826
bannerOff(busyBannerID);
+ − 827
}
+ − 828
+ − 829
function setAjaxLoading()
+ − 830
{
+ − 831
if ( document.getElementById('ajaxloadicon') )
+ − 832
{
+ − 833
document.getElementById('ajaxloadicon').src=ajax_load_icon;
+ − 834
}
+ − 835
}
+ − 836
+ − 837
function unsetAjaxLoading()
+ − 838
{
+ − 839
if ( document.getElementById('ajaxloadicon') )
+ − 840
{
650
e45183014778
Added CDN support: a URL to a CDN can now be specified and Enano will load all images, CSS, and javascript (except TinyMCE) from that server
Dan
diff
changeset
+ − 841
document.getElementById('ajaxloadicon').src=cdnPath + '/images/spacer.gif';
582
+ − 842
}
+ − 843
}
+ − 844
+ − 845
function readCookie(name) {var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++){var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;}
+ − 846
function createCookie(name,value,days){if (days){var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";document.cookie = name+"="+value+expires+"; path=/";}
+ − 847
function eraseCookie(name) {createCookie(name,"",-1);}
+ − 848
+ − 849
/*
+ − 850
* AJAX login box (experimental)
+ − 851
* Moved / rewritten in login.js
+ − 852
*/
+ − 853
+ − 854
// Included only for API-compatibility
+ − 855
function ajaxPromptAdminAuth(call_on_ok, level)
+ − 856
{
+ − 857
ajaxLogonInit(call_on_ok, level);
+ − 858
}
+ − 859
+ − 860
/**
+ − 861
* Insert a DOM object _after_ the specified child.
+ − 862
* @param object Parent node
+ − 863
* @param object Node to insert
+ − 864
* @param object Node to insert after
+ − 865
*/
+ − 866
+ − 867
function insertAfter(parent, baby, bigsister)
+ − 868
{
+ − 869
try
+ − 870
{
+ − 871
if ( parent.childNodes[parent.childNodes.length-1] == bigsister )
+ − 872
parent.appendChild(baby);
+ − 873
else
+ − 874
parent.insertBefore(baby, bigsister.nextSibling);
+ − 875
}
+ − 876
catch(e)
+ − 877
{
+ − 878
alert(e.toString());
+ − 879
if ( window.console )
+ − 880
{
+ − 881
// Firebug support
+ − 882
window.console.warn(e);
+ − 883
}
+ − 884
}
+ − 885
}
+ − 886
+ − 887
/**
+ − 888
* Validates an e-mail address.
+ − 889
* @param string E-mail address
+ − 890
* @return bool
+ − 891
*/
+ − 892
+ − 893
function validateEmail(email)
+ − 894
{
+ − 895
return ( email.match(/^(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*|(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]*(?:(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]*)*<[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*(?:,[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*)*:[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)?(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*>)$/) ) ? true : false;
+ − 896
}
+ − 897
+ − 898
/**
+ − 899
* Validates a username.
+ − 900
* @param string Username to test
+ − 901
* @return bool
+ − 902
*/
+ − 903
+ − 904
function validateUsername(username)
+ − 905
{
+ − 906
var regex = new RegExp('^[^<>&\?\'"%\n\r/]+$', '');
+ − 907
return ( username.match(regex) ) ? true : false;
+ − 908
}
+ − 909
+ − 910
/*
+ − 911
* Utility functions, moved from windows.js
+ − 912
*/
+ − 913
+ − 914
function getHeight() {
+ − 915
var myHeight = 0;
+ − 916
if( typeof( window.innerWidth ) == 'number' ) {
+ − 917
myHeight = window.innerHeight;
+ − 918
} else if( document.documentElement &&
+ − 919
( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
+ − 920
myHeight = document.documentElement.clientHeight;
+ − 921
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
+ − 922
myHeight = document.body.clientHeight;
+ − 923
}
+ − 924
return myHeight;
+ − 925
}
+ − 926
+ − 927
function getWidth() {
+ − 928
var myWidth = 0;
+ − 929
if( typeof( window.innerWidth ) == 'number' ) {
+ − 930
myWidth = window.innerWidth;
+ − 931
} else if( document.documentElement &&
+ − 932
( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) {
+ − 933
myWidth = document.documentElement.clientWidth;
+ − 934
} else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) {
+ − 935
myWidth = document.body.clientWidth;
+ − 936
}
+ − 937
return myWidth;
+ − 938
}
+ − 939
+ − 940
/**
+ − 941
* Sanitizes a page URL string so that it can safely be stored in the database.
+ − 942
* @param string Page ID to sanitize
+ − 943
* @return string Cleaned text
+ − 944
*/
+ − 945
+ − 946
function sanitize_page_id(page_id)
+ − 947
{
+ − 948
// Remove character escapes
+ − 949
page_id = dirtify_page_id(page_id);
+ − 950
+ − 951
var regex = new RegExp('[A-Za-z0-9\\[\\]\./:;\(\)@_-]', 'g');
+ − 952
pid_clean = page_id.replace(regex, 'X');
+ − 953
var pid_dirty = [];
+ − 954
for ( var i = 0; i < pid_clean.length; i++ )
+ − 955
pid_dirty[i] = pid_clean.substr(i, 1);
+ − 956
+ − 957
for ( var i = 0; i < pid_dirty.length; i++ )
+ − 958
{
+ − 959
var chr = pid_dirty[i];
+ − 960
if ( chr == 'X' )
+ − 961
continue;
+ − 962
var cid = chr.charCodeAt(0);
+ − 963
cid = cid.toString(16).toUpperCase();
+ − 964
if ( cid.length < 2 )
+ − 965
{
+ − 966
cid = '0' + cid;
+ − 967
}
+ − 968
pid_dirty[i] = "." + cid;
+ − 969
}
+ − 970
+ − 971
var pid_chars = [];
+ − 972
for ( var i = 0; i < page_id.length; i++ )
+ − 973
pid_chars[i] = page_id.substr(i, 1);
+ − 974
+ − 975
var page_id_cleaned = '';
+ − 976
+ − 977
for ( var id in pid_chars )
+ − 978
{
+ − 979
var chr = pid_chars[id];
+ − 980
if ( pid_dirty[id] == 'X' )
+ − 981
page_id_cleaned += chr;
+ − 982
else
+ − 983
page_id_cleaned += pid_dirty[id];
+ − 984
}
+ − 985
+ − 986
return page_id_cleaned;
+ − 987
}
+ − 988
+ − 989
/**
+ − 990
* Removes character escapes in a page ID string
+ − 991
* @param string Page ID string to dirty up
+ − 992
* @return string
+ − 993
*/
+ − 994
+ − 995
function dirtify_page_id(page_id)
+ − 996
{
+ − 997
// First, replace spaces with underscores
+ − 998
page_id = page_id.replace(/ /g, '_');
+ − 999
+ − 1000
var matches = page_id.match(/\.[A-Fa-f0-9][A-Fa-f0-9]/g);
+ − 1001
+ − 1002
if ( matches != null )
+ − 1003
{
+ − 1004
for ( var i = 0; i < matches.length; i++ )
+ − 1005
{
+ − 1006
var match = matches[i];
+ − 1007
var byt = (match.substr(1)).toUpperCase();
+ − 1008
var code = eval("0x" + byt);
+ − 1009
var regex = new RegExp('\\.' + byt, 'g');
+ − 1010
page_id = page_id.replace(regex, String.fromCharCode(code));
+ − 1011
}
+ − 1012
}
+ − 1013
+ − 1014
return page_id;
+ − 1015
}
+ − 1016
740
+ − 1017
/*
+ − 1018
the getElementsByClassName function I pilfered from this guy. It's
+ − 1019
a useful function that'll return any/all tags with a specific css class.
+ − 1020
+ − 1021
Written by Jonathan Snook, http://www.snook.ca/jonathan
+ − 1022
Add-ons by Robert Nyman, http://www.robertnyman.com
+ − 1023
+ − 1024
Modified to match all elements that match the class name plus an integer after the name
+ − 1025
This is used in Enano to allow sliding sidebar widgets that use their own CSS
+ − 1026
*/
+ − 1027
function getElementsByClassName(oElm, strTagName, strClassName)
+ − 1028
{
+ − 1029
// first it gets all of the specified tags
+ − 1030
var arrElements = (strTagName == "*" && document.all) ? document.all : oElm.getElementsByTagName(strTagName);
+ − 1031
+ − 1032
// then it sets up an array that'll hold the results
+ − 1033
var arrReturnElements = new Array();
+ − 1034
+ − 1035
// some regex stuff you don't need to worry about
+ − 1036
strClassName = strClassName.replace(/\-/g, "\\-");
+ − 1037
+ − 1038
var oRegExp = new RegExp("(^|\\s)" + strClassName + "([0-9]*)(\\s|$)");
+ − 1039
var oElement;
+ − 1040
+ − 1041
// now it iterates through the elements it grabbed above
+ − 1042
for(var i=0; i<arrElements.length; i++)
+ − 1043
{
+ − 1044
oElement = arrElements[i];
+ − 1045
+ − 1046
// if the class matches what we're looking for it ads to the results array
+ − 1047
if(oElement.className.match(oRegExp))
+ − 1048
{
+ − 1049
arrReturnElements.push(oElement);
+ − 1050
}
+ − 1051
}
+ − 1052
+ − 1053
// then it kicks the results back to us
+ − 1054
return (arrReturnElements)
+ − 1055
}
+ − 1056
582
+ − 1057
/**
+ − 1058
* Equivalent to PHP's in_array function.
+ − 1059
*/
+ − 1060
+ − 1061
function in_array(needle, haystack)
+ − 1062
{
+ − 1063
for(var i in haystack)
+ − 1064
{
+ − 1065
if(haystack[i] == needle) return i;
+ − 1066
}
+ − 1067
return false;
+ − 1068
}
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1069
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1070
/**
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1071
* Equivalent of PHP's time()
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1072
* @return int
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1073
*/
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1074
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1075
function unix_time()
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1076
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1077
return parseInt((new Date()).getTime()/1000);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1078
}