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
}
1033
+ − 18
return append_sid(url);
582
+ − 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
{
810
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 51
var match = url.match(/#(.*?)$/);
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 52
url = url.replace(/#(.*?)$/, '');
582
+ − 53
sep = ( url.indexOf('?') > 0 ) ? '&' : '?';
+ − 54
if(ENANO_SID.length > 10)
+ − 55
{
+ − 56
url = url + sep + 'auth=' + ENANO_SID;
+ − 57
sep = '&';
+ − 58
}
+ − 59
if ( pagepass.length > 0 )
+ − 60
{
+ − 61
url = url + sep + 'pagepass=' + pagepass;
+ − 62
}
810
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 63
if ( match )
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 64
{
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 65
url = url + match[0];
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 66
}
582
+ − 67
return url;
+ − 68
}
+ − 69
+ − 70
var stdAjaxPrefix = append_sid(scriptPath+'/ajax.php?title='+title);
+ − 71
+ − 72
/**
+ − 73
* Core AJAX library
+ − 74
*/
+ − 75
+ − 76
function ajaxMakeXHR()
+ − 77
{
+ − 78
var ajax;
+ − 79
if (window.XMLHttpRequest) {
+ − 80
ajax = new XMLHttpRequest();
+ − 81
} else {
+ − 82
if (window.ActiveXObject) {
+ − 83
ajax = new ActiveXObject("Microsoft.XMLHTTP");
+ − 84
} else {
+ − 85
alert('Enano client-side runtime error: No AJAX support, unable to continue');
+ − 86
return;
+ − 87
}
+ − 88
}
+ − 89
return ajax;
+ − 90
}
+ − 91
+ − 92
function ajaxGet(uri, f, call_editor_safe) {
+ − 93
// Is the editor open?
+ − 94
if ( editor_open && !call_editor_safe )
+ − 95
{
+ − 96
// Make sure the user is willing to close the editor
+ − 97
var conf = confirm($lang.get('editor_msg_confirm_ajax'));
+ − 98
if ( !conf )
+ − 99
{
+ − 100
// Kill off any "loading" windows, etc. and cancel the request
+ − 101
unsetAjaxLoading();
+ − 102
return false;
+ − 103
}
+ − 104
// The user allowed the editor to be closed. Reset flags and knock out the on-close confirmation.
+ − 105
editor_open = false;
+ − 106
enableUnload();
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 107
// destroy the MCE instance so it can be recreated later
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 108
$dynano('ajaxEditArea').destroyMCE(false);
582
+ − 109
}
823
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 110
var ajax = ajaxMakeXHR();
582
+ − 111
if ( !ajax )
+ − 112
{
+ − 113
console.error('ajaxMakeXHR() failed');
+ − 114
return false;
+ − 115
}
823
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 116
ajax.onreadystatechange = function()
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 117
{
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 118
f(ajax);
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 119
};
582
+ − 120
ajax.open('GET', uri, true);
+ − 121
ajax.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
+ − 122
ajax.send(null);
823
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 123
window.ajax = ajax;
582
+ − 124
}
+ − 125
+ − 126
function ajaxPost(uri, parms, f, call_editor_safe) {
+ − 127
// Is the editor open?
+ − 128
if ( editor_open && !call_editor_safe )
+ − 129
{
+ − 130
// Make sure the user is willing to close the editor
+ − 131
var conf = confirm($lang.get('editor_msg_confirm_ajax'));
+ − 132
if ( !conf )
+ − 133
{
+ − 134
// Kill off any "loading" windows, etc. and cancel the request
+ − 135
unsetAjaxLoading();
+ − 136
return false;
+ − 137
}
+ − 138
// The user allowed the editor to be closed. Reset flags and knock out the on-close confirmation.
+ − 139
editor_open = false;
+ − 140
enableUnload();
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 141
// destroy the MCE instance so it can be recreated later
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 142
$dynano('ajaxEditArea').destroyMCE(false);
582
+ − 143
}
823
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 144
var ajax = ajaxMakeXHR();
582
+ − 145
if ( !ajax )
+ − 146
{
+ − 147
console.error('ajaxMakeXHR() failed');
+ − 148
return false;
+ − 149
}
823
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 150
ajax.onreadystatechange = function()
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 151
{
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 152
f(ajax);
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 153
};
582
+ − 154
ajax.open('POST', uri, true);
+ − 155
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ − 156
// Setting Content-length in Safari triggers a warning
+ − 157
if ( !is_Safari )
+ − 158
{
+ − 159
ajax.setRequestHeader("Content-length", parms.length);
+ − 160
}
1007
+ − 161
// fails under chrome 2.0
+ − 162
// ajax.setRequestHeader("Connection", "close");
582
+ − 163
ajax.send(parms);
823
4596c40aaa94
AJAX core library: possible breaking change, readystatechange functions are now called with the XHR instance as the first parameter, to allow requests to run in parallel. This means much better stability but may break some applets (compatibility hack is included)
Dan
diff
changeset
+ − 164
window.ajax = ajax;
582
+ − 165
}
+ − 166
+ − 167
/**
+ − 168
* Show a friendly error message depicting an AJAX response that is not valid JSON
+ − 169
* @param string Response text
+ − 170
* @param string Custom error message. If omitted, the default will be shown.
+ − 171
*/
+ − 172
+ − 173
function handle_invalid_json(response, customerror)
+ − 174
{
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
+ − 175
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
+ − 176
727
591562495e87
JSON parse failures should spawn their own darkener layer now instead of reusing the main one if applicable
Dan
diff
changeset
+ − 177
darken(aclDisableTransitionFX, 70, 'invalidjsondarkener');
582
+ − 178
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 179
var box = document.createElement('div');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 180
var mainwin = document.createElement('div');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 181
var panel = document.createElement('div');
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
//
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 184
// main window
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 185
//
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
mainwin.style.padding = '10px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 188
mainwin.style.width = '580px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 189
mainwin.style.height = '360px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 190
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
+ − 191
mainwin.style.overflow = 'auto';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 192
mainwin.style.backgroundColor = '#ffffff';
582
+ − 193
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 194
// Title
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 195
var h3 = document.createElement('h3');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 196
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
+ − 197
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
+ − 198
mainwin.appendChild(h3);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 199
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 200
if ( typeof(customerror) == 'string' )
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 201
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 202
var el = document.createElement('p');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 203
el.appendChild(document.createTextNode(customerror));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 204
mainwin.appendChild(el);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 205
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 206
else
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 207
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 208
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
+ − 209
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
+ − 210
error += 'for this problem:';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 211
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
+ − 212
var el = document.createElement('p');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 213
el.appendChild(document.createTextNode(customerror));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 214
mainwin.appendChild(el);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 215
var ul = document.createElement('ul');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 216
var li1 = document.createElement('li');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 217
var li2 = document.createElement('li');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 218
var li3 = document.createElement('li');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 219
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
+ − 220
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
+ − 221
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
+ − 222
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
+ − 223
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
+ − 224
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
+ − 225
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
+ − 226
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
+ − 227
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 228
ul.appendChild(li1);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 229
ul.appendChild(li2);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 230
ul.appendChild(li3);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 231
mainwin.appendChild(ul);
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
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 234
var p2 = document.createElement('p');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 235
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
+ − 236
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
+ − 237
mainwin.appendChild(p2);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 238
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 239
var pre = document.createElement('pre');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 240
pre.appendChild(document.createTextNode(response));
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 241
mainwin.appendChild(pre);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 242
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 243
var p3 = document.createElement('p');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 244
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
+ − 245
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
+ − 246
var a = document.createElement('a');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 247
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
+ − 248
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
+ − 249
a._resp = response;
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 250
a.onclick = function()
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 251
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 252
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
+ − 253
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
+ − 254
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
+ − 255
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
+ − 256
var mp = miniPromptMessage({
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 257
title: vah_title,
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 258
message: vah_body,
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 259
buttons: [
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
text: btn_confirm,
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 262
color: 'blue',
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 263
style: {
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 264
fontWeight: 'bold'
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
onclick: function() {
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 267
var mp = miniPromptGetParent(this);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 268
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
+ − 269
win.document.write(mp._response);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 270
win.document.close();
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 271
miniPromptDestroy(this);
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
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 275
text: btn_cancel,
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 276
onclick: function() {
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 277
miniPromptDestroy(this);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 278
}
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
]
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 281
});
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 282
mp._response = this._resp;
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 283
return false;
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 284
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 285
a.href = '#';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 286
p3.appendChild(a);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 287
mainwin.appendChild(p3);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 288
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 289
//
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 290
// panel
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 291
//
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 292
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 293
panel.style.backgroundColor = '#D0D0D0';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 294
panel.style.textAlign = 'right';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 295
panel.style.padding = '0 10px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 296
panel.style.lineHeight = '40px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 297
panel.style.width = '580px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 298
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 299
var closer = document.createElement('input');
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 300
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
+ − 301
closer.type = 'button';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 302
closer.value = btn_close;
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 303
closer.onclick = function()
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 304
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 305
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
+ − 306
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
+ − 307
{
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
+ − 308
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
+ − 309
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
+ − 310
}
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
+ − 311
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
+ − 312
{
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
+ − 313
$(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
+ − 314
{
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
+ − 315
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
+ − 316
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
+ − 317
});
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
+ − 318
}
651
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
panel.appendChild(closer);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 321
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 322
//
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 323
// put it together
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 324
//
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 325
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 326
box.appendChild(mainwin);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 327
box.appendChild(panel);
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
// 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
+ − 330
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 331
box.style.display = 'block';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 332
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
+ − 333
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
+ − 334
domObjChangeOpac(0, box);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 335
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 336
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
+ − 337
body.appendChild(box);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 338
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 339
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 340
// calculate position of the box
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 341
// 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
+ − 342
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
+ − 343
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
+ − 344
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
+ − 345
box.style.top = top + 'px';
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 346
box.style.left = left + 'px';
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
// 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
+ − 349
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
+ − 350
{
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
+ − 351
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
+ − 352
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
+ − 353
}
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
+ − 354
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
+ − 355
{
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
+ − 356
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
+ − 357
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
+ − 358
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
+ − 359
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
+ − 360
{
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
+ − 361
$(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
+ − 362
}, 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
+ − 363
}
679
+ − 364
return false;
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 365
}
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 366
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 367
/**
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 368
* 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
+ − 369
* @param string
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 370
* @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
+ − 371
*/
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 372
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 373
function check_json_response(response)
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 374
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 375
response = trim(response);
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 376
if ( response.substr(0, 1) == '{' && response.substr(response.length - 1, 1) == '}' )
582
+ − 377
{
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 378
return true;
582
+ − 379
}
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 380
return false;
582
+ − 381
}
+ − 382
+ − 383
function ajaxEscape(text)
+ − 384
{
+ − 385
/*
+ − 386
text = escape(text);
+ − 387
text = text.replace(/\+/g, '%2B', text);
+ − 388
*/
+ − 389
text = window.encodeURIComponent(text);
+ − 390
return text;
+ − 391
}
+ − 392
+ − 393
/**
+ − 394
* String functions
+ − 395
*/
+ − 396
+ − 397
// Equivalent to PHP trim() function
+ − 398
function trim(text)
+ − 399
{
+ − 400
text = text.replace(/^([\s]+)/, '');
+ − 401
text = text.replace(/([\s]+)$/, '');
+ − 402
return text;
+ − 403
}
+ − 404
+ − 405
// Equivalent to PHP implode() function
+ − 406
function implode(chr, arr)
+ − 407
{
+ − 408
if ( typeof ( arr.toJSONString ) == 'function' )
+ − 409
delete(arr.toJSONString);
+ − 410
+ − 411
var ret = '';
+ − 412
var c = 0;
+ − 413
for ( var i in arr )
+ − 414
{
+ − 415
if(i=='toJSONString')continue;
+ − 416
if ( c > 0 )
+ − 417
ret += chr;
+ − 418
ret += arr[i];
+ − 419
c++;
+ − 420
}
+ − 421
return ret;
+ − 422
}
+ − 423
+ − 424
function form_fetch_field(form, name)
+ − 425
{
+ − 426
var fields = form.getElementsByTagName('input');
+ − 427
if ( fields.length < 1 )
+ − 428
return false;
+ − 429
for ( var i = 0; i < fields.length; i++ )
+ − 430
{
+ − 431
var field = fields[i];
+ − 432
if ( field.name == name )
+ − 433
return field;
+ − 434
}
+ − 435
return false;
+ − 436
}
+ − 437
+ − 438
function get_parent_form(o)
+ − 439
{
+ − 440
if ( !o.parentNode )
+ − 441
return false;
+ − 442
if ( o.tagName == 'FORM' )
+ − 443
return o;
+ − 444
var p = o.parentNode;
+ − 445
while(true)
+ − 446
{
+ − 447
if ( p.tagName == 'FORM' )
+ − 448
return p;
+ − 449
else if ( !p )
+ − 450
return false;
+ − 451
else
+ − 452
p = p.parentNode;
+ − 453
}
+ − 454
}
+ − 455
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 456
/**
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 457
* Return a DOMElement that uses a sprite image.
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 458
* @param string Path to sprite image
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 459
* @param int Width of resulting image
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 460
* @param int Height of resulting image
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 461
* @param int X offset
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 462
* @param int Y offset
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 463
* @return object HTMLImageElement
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 464
*/
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 465
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 466
function gen_sprite(path, width, height, xpos, ypos)
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 467
{
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 468
var image = document.createElement('img');
906
+ − 469
image.src = cdnPath + '/images/spacer.gif';
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 470
image.width = String(width);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 471
image.height = String(height);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 472
image.style.backgroundImage = 'url(' + path + ')';
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 473
image.style.backgroundRepeat = 'no-repeat';
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 474
xpos = ( xpos == 0 ) ? '0' : '-' + String(xpos);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 475
ypos = ( ypos == 0 ) ? '0' : '-' + String(ypos);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 476
image.style.backgroundPosition = ypos + 'px ' + xpos + 'px';
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 477
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 478
return image;
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 479
}
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 480
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 481
/**
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 482
* The same as gen_sprite but generates HTML instead of a DOMElement.
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 483
* @param string Path to sprite image
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 484
* @param int Width of resulting image
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 485
* @param int Height of resulting image
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 486
* @param int X offset
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 487
* @param int Y offset
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 488
* @return object HTMLImageElement
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 489
*/
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 490
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 491
function gen_sprite_html(path, width, height, xpos, ypos)
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 492
{
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 493
var html = '<img src="' + scriptPath + '/images/spacer.gif" width="' + width + '" height="' + height + '" ';
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 494
xpos = ( xpos == 0 ) ? '0' : '-' + String(xpos);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 495
ypos = ( ypos == 0 ) ? '0' : '-' + String(ypos);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 496
html += 'style="background-image: url(' + path + '); background-repeat: no-repeat; background-position: ' + ypos + 'px ' + xpos + 'px;"';
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 497
html += ' />';
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 498
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 499
return html;
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 500
}
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 501
582
+ − 502
function findParentForm(o)
+ − 503
{
+ − 504
return get_parent_form(o);
+ − 505
}
+ − 506
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 507
function domObjChangeOpac(opacity, id)
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 508
{
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 509
if ( !id )
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 510
return false;
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 511
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 512
var object = id.style;
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 513
object.opacity = (opacity / 100);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 514
object.MozOpacity = (opacity / 100);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 515
object.KhtmlOpacity = (opacity / 100);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 516
object.filter = "alpha(opacity=" + opacity + ")";
582
+ − 517
}
+ − 518
704
+ − 519
function getScrollOffset(el)
582
+ − 520
{
+ − 521
var position;
704
+ − 522
var s = el || self;
+ − 523
el = el || document;
+ − 524
if ( el.scrollTop )
+ − 525
{
+ − 526
position = el.scrollTop;
+ − 527
}
+ − 528
else if (s.pageYOffset)
582
+ − 529
{
+ − 530
position = self.pageYOffset;
+ − 531
}
+ − 532
else if (document.documentElement && document.documentElement.scrollTop)
+ − 533
{
+ − 534
position = document.documentElement.scrollTop;
+ − 535
}
+ − 536
else if (document.body)
+ − 537
{
+ − 538
position = document.body.scrollTop;
+ − 539
}
+ − 540
return position;
+ − 541
}
+ − 542
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
+ − 543
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
+ − 544
{
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
+ − 545
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
+ − 546
}
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
+ − 547
582
+ − 548
// Function to fade classes info-box, warning-box, error-box, etc.
+ − 549
+ − 550
function fadeInfoBoxes()
+ − 551
{
+ − 552
var divs = new Array();
+ − 553
d = document.getElementsByTagName('div');
+ − 554
j = 0;
+ − 555
for(var i in d)
+ − 556
{
+ − 557
if ( !d[i] )
+ − 558
continue;
+ − 559
if ( !d[i].tagName )
+ − 560
continue;
+ − 561
if(d[i].className=='info-box' || d[i].className=='error-box' || d[i].className=='warning-box' || d[i].className=='question-box')
+ − 562
{
+ − 563
divs[j] = d[i];
+ − 564
j++;
+ − 565
}
+ − 566
}
+ − 567
if(divs.length < 1) return;
+ − 568
load_component('fat');
+ − 569
for(i in divs)
+ − 570
{
+ − 571
if(!divs[i].id) divs[i].id = 'autofade_'+Math.floor(Math.random() * 100000);
+ − 572
switch(divs[i].className)
+ − 573
{
+ − 574
case 'info-box':
+ − 575
default:
+ − 576
from = '#3333FF';
+ − 577
break;
+ − 578
case 'error-box':
+ − 579
from = '#FF3333';
+ − 580
break;
+ − 581
case 'warning-box':
+ − 582
from = '#FFFF33';
+ − 583
break;
+ − 584
case 'question-box':
+ − 585
from = '#33FF33';
+ − 586
break;
+ − 587
}
+ − 588
Fat.fade_element(divs[i].id,30,2000,from,Fat.get_bgcolor(divs[i].id));
+ − 589
}
+ − 590
}
+ − 591
+ − 592
addOnloadHook(fadeInfoBoxes);
+ − 593
+ − 594
// Alpha fades
+ − 595
+ − 596
function opacity(id, opacStart, opacEnd, millisec)
+ − 597
{
+ − 598
var object = document.getElementById(id);
+ − 599
domOpacity(object, opacStart, opacEnd, millisec);
+ − 600
}
+ − 601
869
+ − 602
var opacityDOMCache = {};
582
+ − 603
function domOpacity(obj, opacStart, opacEnd, millisec) {
+ − 604
//speed for each frame
+ − 605
var speed = Math.round(millisec / 100);
+ − 606
var timer = 0;
+ − 607
+ − 608
// unique ID for this animation
+ − 609
var uniqid = Math.floor(Math.random() * 1000000);
+ − 610
opacityDOMCache[uniqid] = obj;
+ − 611
+ − 612
//determine the direction for the blending, if start and end are the same nothing happens
+ − 613
if(opacStart > opacEnd) {
+ − 614
for(i = opacStart; i >= opacEnd; i--) {
869
+ − 615
setTimeout("if ( opacityDOMCache["+uniqid+"] ) { var obj = opacityDOMCache["+uniqid+"]; domObjChangeOpac(" + i + ",obj) }",(timer * speed));
582
+ − 616
timer++;
+ − 617
}
+ − 618
} else if(opacStart < opacEnd) {
+ − 619
for(i = opacStart; i <= opacEnd; i++)
+ − 620
{
869
+ − 621
setTimeout("if ( opacityDOMCache["+uniqid+"] ) { var obj = opacityDOMCache["+uniqid+"]; domObjChangeOpac(" + i + ",obj); }",(timer * speed));
582
+ − 622
timer++;
+ − 623
}
+ − 624
}
+ − 625
setTimeout("delete(opacityDOMCache["+uniqid+"]);",(timer * speed));
+ − 626
}
+ − 627
869
+ − 628
function abortFades()
+ − 629
{
+ − 630
opacityDOMCache = {};
+ − 631
}
+ − 632
582
+ − 633
// change the opacity for different browsers
+ − 634
function changeOpac(opacity, id)
+ − 635
{
+ − 636
var object = document.getElementById(id);
+ − 637
return domObjChangeOpac(opacity, object);
+ − 638
}
+ − 639
+ − 640
// draw a white ajax-ey "loading" box over an object
+ − 641
function whiteOutElement(el)
+ − 642
{
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
+ − 643
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
+ − 644
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
+ − 645
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
+ − 646
var height = $dynano(el).Height();
582
+ − 647
+ − 648
var blackout = document.createElement('div');
691
+ − 649
// using fixed here allows modal windows to be blacked out
+ − 650
blackout.style.position = ( el.style.position == 'fixed' ) ? 'fixed' : 'absolute';
582
+ − 651
blackout.style.top = top + 'px';
+ − 652
blackout.style.left = left + 'px';
+ − 653
blackout.style.width = width + 'px';
+ − 654
blackout.style.height = height + 'px';
+ − 655
+ − 656
blackout.style.backgroundColor = '#FFFFFF';
+ − 657
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
+ − 658
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
+ − 659
blackout.style.backgroundImage = background;
582
+ − 660
blackout.style.backgroundPosition = 'center center';
+ − 661
blackout.style.backgroundRepeat = 'no-repeat';
+ − 662
blackout.style.zIndex = getHighestZ() + 2;
+ − 663
+ − 664
var body = document.getElementsByTagName('body')[0];
+ − 665
body.appendChild(blackout);
+ − 666
+ − 667
return blackout;
+ − 668
}
+ − 669
628
+ − 670
/**
+ − 671
* Take a div generated by whiteOutElement() and report success using the glossy "check" graphic. Sets the image, then
+ − 672
* briefly fades in, then fades out and destroys the box so as to re-allow control over the underlying element
+ − 673
*/
+ − 674
+ − 675
function whiteOutReportSuccess(whitey)
+ − 676
{
810
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 677
whiteOutDestroyWithImage(whitey, cdnPath + '/images/check.png');
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 678
}
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 679
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 680
function whiteOutReportFailure(whitey)
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 681
{
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 682
whiteOutDestroyWithImage(whitey, cdnPath + '/images/checkbad.png');
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 683
}
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 684
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 685
function whiteOutDestroyWithImage(whitey, image)
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 686
{
628
+ − 687
// fade the status indicator in and then out
810
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 688
whitey.style.backgroundImage = 'url(' + image + ')';
679
+ − 689
if ( aclDisableTransitionFX )
+ − 690
{
+ − 691
domObjChangeOpac(80, whitey);
+ − 692
}
+ − 693
else
+ − 694
{
+ − 695
domOpacity(whitey, 60, 80, 500);
+ − 696
setTimeout(function()
+ − 697
{
+ − 698
domOpacity(whitey, 60, 0, 500);
+ − 699
}, 750);
+ − 700
}
628
+ − 701
setTimeout(function()
+ − 702
{
810
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 703
if ( whitey )
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 704
if ( whitey.parentNode )
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 705
whitey.parentNode.removeChild(whitey);
628
+ − 706
}, 1250);
+ − 707
}
+ − 708
691
+ − 709
/**
+ − 710
* Whites out a form and disables all buttons under it. Useful for onsubmit functions.
+ − 711
* @example
+ − 712
<code>
+ − 713
<form action="foo" onsubmit="whiteOutForm(this);">
+ − 714
</code>
+ − 715
* @param object Form object
+ − 716
* @return object Whiteout div
+ − 717
*/
+ − 718
+ − 719
function whiteOutForm(form)
+ − 720
{
+ − 721
if ( !form.getElementsByTagName )
+ − 722
return false;
+ − 723
+ − 724
// disable all buttons
+ − 725
var buttons = form.getElementsByTagName('input');
+ − 726
for ( var i = 0; i < buttons.length; i++ )
+ − 727
{
+ − 728
if ( buttons[i].type == 'button' || buttons[i].type == 'submit' || buttons[i].type == 'image' )
+ − 729
{
+ − 730
buttons[i].disabled = 'disabled';
+ − 731
// ... but also make a hidden element to preserve any flags
+ − 732
var clone = buttons[i].cloneNode(true);
+ − 733
clone.type = 'hidden';
+ − 734
clone.disabled = false;
+ − 735
console.debug(clone);
+ − 736
form.appendChild(clone);
+ − 737
}
+ − 738
}
+ − 739
var buttons = form.getElementsByTagName('button');
+ − 740
for ( var i = 0; i < buttons.length; i++ )
+ − 741
{
+ − 742
buttons[i].disabled = 'disabled';
+ − 743
// ... but also make a hidden element to preserve any flags
+ − 744
if ( buttons[i].name )
+ − 745
{
+ − 746
var clone = document.createElement('input');
+ − 747
clone.type = 'hidden';
+ − 748
clone.name = buttons[i].name;
+ − 749
clone.value = ( buttons[i].value ) ? buttons[i].value : '';
+ − 750
form.appendChild(clone);
+ − 751
}
+ − 752
}
+ − 753
+ − 754
return whiteOutElement(form);
+ − 755
}
+ − 756
582
+ − 757
// other DHTML functions
+ − 758
+ − 759
function fetch_offset(obj)
+ − 760
{
+ − 761
var left_offset = obj.offsetLeft;
+ − 762
var top_offset = obj.offsetTop;
+ − 763
while ((obj = obj.offsetParent) != null) {
+ − 764
left_offset += obj.offsetLeft;
+ − 765
top_offset += obj.offsetTop;
+ − 766
}
+ − 767
return { 'left' : left_offset, 'top' : top_offset };
+ − 768
}
+ − 769
+ − 770
function fetch_dimensions(o) {
+ − 771
var w = o.offsetWidth;
+ − 772
var h = o.offsetHeight;
+ − 773
return { 'w' : w, 'h' : h };
+ − 774
}
+ − 775
+ − 776
function findParentForm(o)
+ − 777
{
+ − 778
if ( o.tagName == 'FORM' )
+ − 779
return o;
+ − 780
while(true)
+ − 781
{
+ − 782
o = o.parentNode;
+ − 783
if ( !o )
+ − 784
return false;
+ − 785
if ( o.tagName == 'FORM' )
+ − 786
return o;
+ − 787
}
+ − 788
return false;
+ − 789
}
+ − 790
+ − 791
function bannerOn(text)
+ − 792
{
+ − 793
darken(true);
+ − 794
var thediv = document.createElement('div');
+ − 795
thediv.className = 'mdg-comment';
+ − 796
thediv.style.padding = '0';
+ − 797
thediv.style.marginLeft = '0';
+ − 798
thediv.style.position = 'absolute';
+ − 799
thediv.style.display = 'none';
+ − 800
thediv.style.padding = '4px';
+ − 801
thediv.style.fontSize = '14pt';
+ − 802
thediv.id = 'mdgDynamic_bannerDiv_'+Math.floor(Math.random() * 1000000);
+ − 803
thediv.innerHTML = text;
+ − 804
+ − 805
var body = document.getElementsByTagName('body');
+ − 806
body = body[0];
+ − 807
body.appendChild(thediv);
+ − 808
body.style.cursor = 'wait';
+ − 809
+ − 810
thediv.style.display = 'block';
+ − 811
dim = fetch_dimensions(thediv);
+ − 812
thediv.style.display = 'none';
+ − 813
bdim = { 'w' : getWidth(), 'h' : getHeight() };
+ − 814
so = getScrollOffset();
+ − 815
+ − 816
var left = (bdim['w'] / 2) - ( dim['w'] / 2 );
+ − 817
+ − 818
var top = (bdim['h'] / 2);
+ − 819
top = top - ( dim['h'] / 2 );
+ − 820
+ − 821
top = top + so;
+ − 822
+ − 823
thediv.style.top = top + 'px';
+ − 824
thediv.style.left = left + 'px';
+ − 825
+ − 826
thediv.style.display = 'block';
+ − 827
+ − 828
return thediv.id;
+ − 829
}
+ − 830
+ − 831
function bannerOff(id)
+ − 832
{
+ − 833
e = document.getElementById(id);
+ − 834
if(!e) return;
+ − 835
e.innerHTML = '';
+ − 836
e.style.display = 'none';
+ − 837
var body = document.getElementsByTagName('body');
+ − 838
body = body[0];
+ − 839
body.style.cursor = 'default';
+ − 840
enlighten(true);
+ − 841
}
+ − 842
+ − 843
function disableUnload(message)
+ − 844
{
+ − 845
if(typeof message != 'string') message = 'You may want to save your changes first.';
+ − 846
window._unloadmsg = message;
+ − 847
window.onbeforeunload = function(e)
+ − 848
{
+ − 849
if ( !e )
+ − 850
e = window.event;
+ − 851
e.returnValue = window._unloadmsg;
+ − 852
}
+ − 853
}
+ − 854
+ − 855
function enableUnload()
+ − 856
{
+ − 857
window._unloadmsg = null;
+ − 858
window.onbeforeunload = null;
+ − 859
}
+ − 860
+ − 861
/**
+ − 862
* Gets the highest z-index of all divs in the document
+ − 863
* @return integer
+ − 864
*/
+ − 865
function getHighestZ()
+ − 866
{
+ − 867
z = 0;
+ − 868
var divs = document.getElementsByTagName('div');
+ − 869
for(var i = 0; i < divs.length; i++)
+ − 870
{
+ − 871
if(divs[i].style.zIndex > z) z = divs[i].style.zIndex;
+ − 872
}
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
+ − 873
return parseInt(z);
582
+ − 874
}
+ − 875
592
+ − 876
var shift = false;
582
+ − 877
function isKeyPressed(event)
+ − 878
{
+ − 879
if (event.shiftKey==1)
+ − 880
{
+ − 881
shift = true;
+ − 882
}
+ − 883
else
+ − 884
{
+ − 885
shift = false;
+ − 886
}
+ − 887
}
+ − 888
+ − 889
function moveDiv(div, newparent)
+ − 890
{
+ − 891
var backup = div;
+ − 892
var oldparent = div.parentNode;
+ − 893
oldparent.removeChild(div);
+ − 894
newparent.appendChild(backup);
+ − 895
}
+ − 896
+ − 897
var busyBannerID;
+ − 898
function goBusy(msg)
+ − 899
{
+ − 900
if(!msg) msg = 'Please wait...';
+ − 901
body = document.getElementsByTagName('body');
+ − 902
body = body[0];
+ − 903
body.style.cursor = 'wait';
+ − 904
busyBannerID = bannerOn(msg);
+ − 905
}
+ − 906
+ − 907
function unBusy()
+ − 908
{
+ − 909
body = document.getElementsByTagName('body');
+ − 910
body = body[0];
+ − 911
body.style.cursor = 'default';
+ − 912
bannerOff(busyBannerID);
+ − 913
}
+ − 914
+ − 915
function setAjaxLoading()
+ − 916
{
+ − 917
if ( document.getElementById('ajaxloadicon') )
+ − 918
{
+ − 919
document.getElementById('ajaxloadicon').src=ajax_load_icon;
+ − 920
}
+ − 921
}
+ − 922
+ − 923
function unsetAjaxLoading()
+ − 924
{
+ − 925
if ( document.getElementById('ajaxloadicon') )
+ − 926
{
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
+ − 927
document.getElementById('ajaxloadicon').src=cdnPath + '/images/spacer.gif';
582
+ − 928
}
+ − 929
}
+ − 930
+ − 931
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;}
+ − 932
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=/";}
+ − 933
function eraseCookie(name) {createCookie(name,"",-1);}
+ − 934
+ − 935
/*
+ − 936
* AJAX login box (experimental)
+ − 937
* Moved / rewritten in login.js
+ − 938
*/
+ − 939
+ − 940
// Included only for API-compatibility
+ − 941
function ajaxPromptAdminAuth(call_on_ok, level)
+ − 942
{
1053
bdbb49cf6f1b
One word: Internet Explorer 6. This includes a rewrite of $paths->parseAdminTree() that encodes to JSON instead of manually generating JS, so good-bye to stupid parser problems I hope.
Dan
diff
changeset
+ − 943
ajaxLoginInit(call_on_ok, level);
582
+ − 944
}
+ − 945
+ − 946
/**
+ − 947
* Insert a DOM object _after_ the specified child.
+ − 948
* @param object Parent node
+ − 949
* @param object Node to insert
+ − 950
* @param object Node to insert after
+ − 951
*/
+ − 952
+ − 953
function insertAfter(parent, baby, bigsister)
+ − 954
{
+ − 955
try
+ − 956
{
+ − 957
if ( parent.childNodes[parent.childNodes.length-1] == bigsister )
+ − 958
parent.appendChild(baby);
+ − 959
else
+ − 960
parent.insertBefore(baby, bigsister.nextSibling);
+ − 961
}
+ − 962
catch(e)
+ − 963
{
+ − 964
alert(e.toString());
+ − 965
if ( window.console )
+ − 966
{
+ − 967
// Firebug support
+ − 968
window.console.warn(e);
+ − 969
}
+ − 970
}
+ − 971
}
+ − 972
+ − 973
/**
+ − 974
* Validates an e-mail address.
+ − 975
* @param string E-mail address
+ − 976
* @return bool
+ − 977
*/
+ − 978
+ − 979
function validateEmail(email)
+ − 980
{
+ − 981
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;
+ − 982
}
+ − 983
+ − 984
/**
+ − 985
* Validates a username.
+ − 986
* @param string Username to test
+ − 987
* @return bool
+ − 988
*/
+ − 989
+ − 990
function validateUsername(username)
+ − 991
{
+ − 992
var regex = new RegExp('^[^<>&\?\'"%\n\r/]+$', '');
+ − 993
return ( username.match(regex) ) ? true : false;
+ − 994
}
+ − 995
+ − 996
/*
+ − 997
* Utility functions, moved from windows.js
+ − 998
*/
+ − 999
+ − 1000
function getHeight() {
+ − 1001
var myHeight = 0;
+ − 1002
if( typeof( window.innerWidth ) == 'number' ) {
+ − 1003
myHeight = window.innerHeight;
+ − 1004
} else if( document.documentElement &&
+ − 1005
( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
+ − 1006
myHeight = document.documentElement.clientHeight;
+ − 1007
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
+ − 1008
myHeight = document.body.clientHeight;
+ − 1009
}
+ − 1010
return myHeight;
+ − 1011
}
+ − 1012
+ − 1013
function getWidth() {
+ − 1014
var myWidth = 0;
+ − 1015
if( typeof( window.innerWidth ) == 'number' ) {
+ − 1016
myWidth = window.innerWidth;
+ − 1017
} else if( document.documentElement &&
+ − 1018
( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) {
+ − 1019
myWidth = document.documentElement.clientWidth;
+ − 1020
} else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) {
+ − 1021
myWidth = document.body.clientWidth;
+ − 1022
}
+ − 1023
return myWidth;
+ − 1024
}
+ − 1025
+ − 1026
/**
+ − 1027
* Sanitizes a page URL string so that it can safely be stored in the database.
+ − 1028
* @param string Page ID to sanitize
+ − 1029
* @return string Cleaned text
+ − 1030
*/
+ − 1031
+ − 1032
function sanitize_page_id(page_id)
+ − 1033
{
+ − 1034
// Remove character escapes
+ − 1035
page_id = dirtify_page_id(page_id);
+ − 1036
+ − 1037
var regex = new RegExp('[A-Za-z0-9\\[\\]\./:;\(\)@_-]', 'g');
+ − 1038
pid_clean = page_id.replace(regex, 'X');
+ − 1039
var pid_dirty = [];
+ − 1040
for ( var i = 0; i < pid_clean.length; i++ )
+ − 1041
pid_dirty[i] = pid_clean.substr(i, 1);
+ − 1042
+ − 1043
for ( var i = 0; i < pid_dirty.length; i++ )
+ − 1044
{
+ − 1045
var chr = pid_dirty[i];
+ − 1046
if ( chr == 'X' )
+ − 1047
continue;
+ − 1048
var cid = chr.charCodeAt(0);
+ − 1049
cid = cid.toString(16).toUpperCase();
+ − 1050
if ( cid.length < 2 )
+ − 1051
{
+ − 1052
cid = '0' + cid;
+ − 1053
}
+ − 1054
pid_dirty[i] = "." + cid;
+ − 1055
}
+ − 1056
+ − 1057
var pid_chars = [];
+ − 1058
for ( var i = 0; i < page_id.length; i++ )
+ − 1059
pid_chars[i] = page_id.substr(i, 1);
+ − 1060
+ − 1061
var page_id_cleaned = '';
+ − 1062
+ − 1063
for ( var id in pid_chars )
+ − 1064
{
+ − 1065
var chr = pid_chars[id];
+ − 1066
if ( pid_dirty[id] == 'X' )
+ − 1067
page_id_cleaned += chr;
+ − 1068
else
+ − 1069
page_id_cleaned += pid_dirty[id];
+ − 1070
}
+ − 1071
+ − 1072
return page_id_cleaned;
+ − 1073
}
+ − 1074
+ − 1075
/**
+ − 1076
* Removes character escapes in a page ID string
+ − 1077
* @param string Page ID string to dirty up
+ − 1078
* @return string
+ − 1079
*/
+ − 1080
+ − 1081
function dirtify_page_id(page_id)
+ − 1082
{
+ − 1083
// First, replace spaces with underscores
+ − 1084
page_id = page_id.replace(/ /g, '_');
+ − 1085
+ − 1086
var matches = page_id.match(/\.[A-Fa-f0-9][A-Fa-f0-9]/g);
+ − 1087
+ − 1088
if ( matches != null )
+ − 1089
{
+ − 1090
for ( var i = 0; i < matches.length; i++ )
+ − 1091
{
+ − 1092
var match = matches[i];
+ − 1093
var byt = (match.substr(1)).toUpperCase();
+ − 1094
var code = eval("0x" + byt);
+ − 1095
var regex = new RegExp('\\.' + byt, 'g');
+ − 1096
page_id = page_id.replace(regex, String.fromCharCode(code));
+ − 1097
}
+ − 1098
}
+ − 1099
+ − 1100
return page_id;
+ − 1101
}
+ − 1102
740
+ − 1103
/*
+ − 1104
the getElementsByClassName function I pilfered from this guy. It's
+ − 1105
a useful function that'll return any/all tags with a specific css class.
+ − 1106
+ − 1107
Written by Jonathan Snook, http://www.snook.ca/jonathan
+ − 1108
Add-ons by Robert Nyman, http://www.robertnyman.com
+ − 1109
+ − 1110
Modified to match all elements that match the class name plus an integer after the name
+ − 1111
This is used in Enano to allow sliding sidebar widgets that use their own CSS
+ − 1112
*/
+ − 1113
function getElementsByClassName(oElm, strTagName, strClassName)
+ − 1114
{
+ − 1115
// first it gets all of the specified tags
+ − 1116
var arrElements = (strTagName == "*" && document.all) ? document.all : oElm.getElementsByTagName(strTagName);
+ − 1117
+ − 1118
// then it sets up an array that'll hold the results
+ − 1119
var arrReturnElements = new Array();
+ − 1120
+ − 1121
// some regex stuff you don't need to worry about
+ − 1122
strClassName = strClassName.replace(/\-/g, "\\-");
+ − 1123
+ − 1124
var oRegExp = new RegExp("(^|\\s)" + strClassName + "([0-9]*)(\\s|$)");
+ − 1125
var oElement;
+ − 1126
+ − 1127
// now it iterates through the elements it grabbed above
+ − 1128
for(var i=0; i<arrElements.length; i++)
+ − 1129
{
+ − 1130
oElement = arrElements[i];
+ − 1131
+ − 1132
// if the class matches what we're looking for it ads to the results array
+ − 1133
if(oElement.className.match(oRegExp))
+ − 1134
{
+ − 1135
arrReturnElements.push(oElement);
+ − 1136
}
+ − 1137
}
+ − 1138
+ − 1139
// then it kicks the results back to us
+ − 1140
return (arrReturnElements)
+ − 1141
}
+ − 1142
582
+ − 1143
/**
+ − 1144
* Equivalent to PHP's in_array function.
+ − 1145
*/
+ − 1146
+ − 1147
function in_array(needle, haystack)
+ − 1148
{
+ − 1149
for(var i in haystack)
+ − 1150
{
+ − 1151
if(haystack[i] == needle) return i;
+ − 1152
}
+ − 1153
return false;
+ − 1154
}
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1155
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1156
/**
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1157
* Equivalent of PHP's time()
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1158
* @return int
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1159
*/
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1160
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1161
function unix_time()
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1162
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1163
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
+ − 1164
}