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
1125
367768040a61
Javascript lib: UX: When whiteOutReportSuccess() is called on a whiteout over a miniPrompt, the miniPrompt and whiteout are now flown out together. Also, a bit of improvement to message box DOM object destruction code; this fixes problems with message boxes appearing below the shade when ajax auth is done 3 or more times in one page load.
Dan
diff
changeset
+ − 675
function whiteOutReportSuccess(whitey, nodestroy_mp)
628
+ − 676
{
1125
367768040a61
Javascript lib: UX: When whiteOutReportSuccess() is called on a whiteout over a miniPrompt, the miniPrompt and whiteout are now flown out together. Also, a bit of improvement to message box DOM object destruction code; this fixes problems with message boxes appearing below the shade when ajax auth is done 3 or more times in one page load.
Dan
diff
changeset
+ − 677
whiteOutDestroyWithImage(whitey, cdnPath + '/images/check.png', nodestroy_mp);
810
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
1125
367768040a61
Javascript lib: UX: When whiteOutReportSuccess() is called on a whiteout over a miniPrompt, the miniPrompt and whiteout are now flown out together. Also, a bit of improvement to message box DOM object destruction code; this fixes problems with message boxes appearing below the shade when ajax auth is done 3 or more times in one page load.
Dan
diff
changeset
+ − 680
function whiteOutReportFailure(whitey, nodestroy_mp)
810
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 681
{
1125
367768040a61
Javascript lib: UX: When whiteOutReportSuccess() is called on a whiteout over a miniPrompt, the miniPrompt and whiteout are now flown out together. Also, a bit of improvement to message box DOM object destruction code; this fixes problems with message boxes appearing below the shade when ajax auth is done 3 or more times in one page load.
Dan
diff
changeset
+ − 682
if ( typeof(nodestroy_mp) == undefined )
367768040a61
Javascript lib: UX: When whiteOutReportSuccess() is called on a whiteout over a miniPrompt, the miniPrompt and whiteout are now flown out together. Also, a bit of improvement to message box DOM object destruction code; this fixes problems with message boxes appearing below the shade when ajax auth is done 3 or more times in one page load.
Dan
diff
changeset
+ − 683
nodestroy_mp = true;
367768040a61
Javascript lib: UX: When whiteOutReportSuccess() is called on a whiteout over a miniPrompt, the miniPrompt and whiteout are now flown out together. Also, a bit of improvement to message box DOM object destruction code; this fixes problems with message boxes appearing below the shade when ajax auth is done 3 or more times in one page load.
Dan
diff
changeset
+ − 684
367768040a61
Javascript lib: UX: When whiteOutReportSuccess() is called on a whiteout over a miniPrompt, the miniPrompt and whiteout are now flown out together. Also, a bit of improvement to message box DOM object destruction code; this fixes problems with message boxes appearing below the shade when ajax auth is done 3 or more times in one page load.
Dan
diff
changeset
+ − 685
whiteOutDestroyWithImage(whitey, cdnPath + '/images/checkbad.png', nodestroy_mp);
810
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 686
}
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 687
1125
367768040a61
Javascript lib: UX: When whiteOutReportSuccess() is called on a whiteout over a miniPrompt, the miniPrompt and whiteout are now flown out together. Also, a bit of improvement to message box DOM object destruction code; this fixes problems with message boxes appearing below the shade when ajax auth is done 3 or more times in one page load.
Dan
diff
changeset
+ − 688
function whiteOutDestroyWithImage(whitey, image, nodestroy_mp)
810
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 689
{
628
+ − 690
// 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
+ − 691
whitey.style.backgroundImage = 'url(' + image + ')';
1125
367768040a61
Javascript lib: UX: When whiteOutReportSuccess() is called on a whiteout over a miniPrompt, the miniPrompt and whiteout are now flown out together. Also, a bit of improvement to message box DOM object destruction code; this fixes problems with message boxes appearing below the shade when ajax auth is done 3 or more times in one page load.
Dan
diff
changeset
+ − 692
if ( whitey.isMiniPrompt && !nodestroy_mp )
367768040a61
Javascript lib: UX: When whiteOutReportSuccess() is called on a whiteout over a miniPrompt, the miniPrompt and whiteout are now flown out together. Also, a bit of improvement to message box DOM object destruction code; this fixes problems with message boxes appearing below the shade when ajax auth is done 3 or more times in one page load.
Dan
diff
changeset
+ − 693
{
1129
+ − 694
setTimeout(function()
+ − 695
{
+ − 696
whiteOutDestroyOnMiniPrompt(whitey);
+ − 697
}, 500);
1125
367768040a61
Javascript lib: UX: When whiteOutReportSuccess() is called on a whiteout over a miniPrompt, the miniPrompt and whiteout are now flown out together. Also, a bit of improvement to message box DOM object destruction code; this fixes problems with message boxes appearing below the shade when ajax auth is done 3 or more times in one page load.
Dan
diff
changeset
+ − 698
return true;
367768040a61
Javascript lib: UX: When whiteOutReportSuccess() is called on a whiteout over a miniPrompt, the miniPrompt and whiteout are now flown out together. Also, a bit of improvement to message box DOM object destruction code; this fixes problems with message boxes appearing below the shade when ajax auth is done 3 or more times in one page load.
Dan
diff
changeset
+ − 699
}
679
+ − 700
if ( aclDisableTransitionFX )
+ − 701
{
+ − 702
domObjChangeOpac(80, whitey);
+ − 703
}
+ − 704
else
+ − 705
{
+ − 706
domOpacity(whitey, 60, 80, 500);
+ − 707
setTimeout(function()
+ − 708
{
+ − 709
domOpacity(whitey, 60, 0, 500);
+ − 710
}, 750);
+ − 711
}
628
+ − 712
setTimeout(function()
+ − 713
{
810
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 714
if ( whitey )
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 715
if ( whitey.parentNode )
7fd2b8a58ae4
JS core: whiteOutReportSuccess now has a sister whiteOutReportFailure(); both abstracted to function whiteOutDestroyWithImage(whitey, image_url)
Dan
diff
changeset
+ − 716
whitey.parentNode.removeChild(whitey);
628
+ − 717
}, 1250);
+ − 718
}
+ − 719
691
+ − 720
/**
+ − 721
* Whites out a form and disables all buttons under it. Useful for onsubmit functions.
+ − 722
* @example
+ − 723
<code>
+ − 724
<form action="foo" onsubmit="whiteOutForm(this);">
+ − 725
</code>
+ − 726
* @param object Form object
+ − 727
* @return object Whiteout div
+ − 728
*/
+ − 729
+ − 730
function whiteOutForm(form)
+ − 731
{
+ − 732
if ( !form.getElementsByTagName )
+ − 733
return false;
+ − 734
+ − 735
// disable all buttons
+ − 736
var buttons = form.getElementsByTagName('input');
+ − 737
for ( var i = 0; i < buttons.length; i++ )
+ − 738
{
+ − 739
if ( buttons[i].type == 'button' || buttons[i].type == 'submit' || buttons[i].type == 'image' )
+ − 740
{
+ − 741
buttons[i].disabled = 'disabled';
+ − 742
// ... but also make a hidden element to preserve any flags
+ − 743
var clone = buttons[i].cloneNode(true);
+ − 744
clone.type = 'hidden';
+ − 745
clone.disabled = false;
+ − 746
console.debug(clone);
+ − 747
form.appendChild(clone);
+ − 748
}
+ − 749
}
+ − 750
var buttons = form.getElementsByTagName('button');
+ − 751
for ( var i = 0; i < buttons.length; i++ )
+ − 752
{
+ − 753
buttons[i].disabled = 'disabled';
+ − 754
// ... but also make a hidden element to preserve any flags
+ − 755
if ( buttons[i].name )
+ − 756
{
+ − 757
var clone = document.createElement('input');
+ − 758
clone.type = 'hidden';
+ − 759
clone.name = buttons[i].name;
+ − 760
clone.value = ( buttons[i].value ) ? buttons[i].value : '';
+ − 761
form.appendChild(clone);
+ − 762
}
+ − 763
}
+ − 764
+ − 765
return whiteOutElement(form);
+ − 766
}
+ − 767
582
+ − 768
// other DHTML functions
+ − 769
+ − 770
function fetch_offset(obj)
+ − 771
{
+ − 772
var left_offset = obj.offsetLeft;
+ − 773
var top_offset = obj.offsetTop;
+ − 774
while ((obj = obj.offsetParent) != null) {
+ − 775
left_offset += obj.offsetLeft;
+ − 776
top_offset += obj.offsetTop;
+ − 777
}
+ − 778
return { 'left' : left_offset, 'top' : top_offset };
+ − 779
}
+ − 780
+ − 781
function fetch_dimensions(o) {
+ − 782
var w = o.offsetWidth;
+ − 783
var h = o.offsetHeight;
+ − 784
return { 'w' : w, 'h' : h };
+ − 785
}
+ − 786
+ − 787
function findParentForm(o)
+ − 788
{
+ − 789
if ( o.tagName == 'FORM' )
+ − 790
return o;
+ − 791
while(true)
+ − 792
{
+ − 793
o = o.parentNode;
+ − 794
if ( !o )
+ − 795
return false;
+ − 796
if ( o.tagName == 'FORM' )
+ − 797
return o;
+ − 798
}
+ − 799
return false;
+ − 800
}
+ − 801
+ − 802
function bannerOn(text)
+ − 803
{
+ − 804
darken(true);
+ − 805
var thediv = document.createElement('div');
+ − 806
thediv.className = 'mdg-comment';
+ − 807
thediv.style.padding = '0';
+ − 808
thediv.style.marginLeft = '0';
+ − 809
thediv.style.position = 'absolute';
+ − 810
thediv.style.display = 'none';
+ − 811
thediv.style.padding = '4px';
+ − 812
thediv.style.fontSize = '14pt';
+ − 813
thediv.id = 'mdgDynamic_bannerDiv_'+Math.floor(Math.random() * 1000000);
+ − 814
thediv.innerHTML = text;
+ − 815
+ − 816
var body = document.getElementsByTagName('body');
+ − 817
body = body[0];
+ − 818
body.appendChild(thediv);
+ − 819
body.style.cursor = 'wait';
+ − 820
+ − 821
thediv.style.display = 'block';
+ − 822
dim = fetch_dimensions(thediv);
+ − 823
thediv.style.display = 'none';
+ − 824
bdim = { 'w' : getWidth(), 'h' : getHeight() };
+ − 825
so = getScrollOffset();
+ − 826
+ − 827
var left = (bdim['w'] / 2) - ( dim['w'] / 2 );
+ − 828
+ − 829
var top = (bdim['h'] / 2);
+ − 830
top = top - ( dim['h'] / 2 );
+ − 831
+ − 832
top = top + so;
+ − 833
+ − 834
thediv.style.top = top + 'px';
+ − 835
thediv.style.left = left + 'px';
+ − 836
+ − 837
thediv.style.display = 'block';
+ − 838
+ − 839
return thediv.id;
+ − 840
}
+ − 841
+ − 842
function bannerOff(id)
+ − 843
{
+ − 844
e = document.getElementById(id);
+ − 845
if(!e) return;
+ − 846
e.innerHTML = '';
+ − 847
e.style.display = 'none';
+ − 848
var body = document.getElementsByTagName('body');
+ − 849
body = body[0];
+ − 850
body.style.cursor = 'default';
+ − 851
enlighten(true);
+ − 852
}
+ − 853
+ − 854
function disableUnload(message)
+ − 855
{
+ − 856
if(typeof message != 'string') message = 'You may want to save your changes first.';
+ − 857
window._unloadmsg = message;
+ − 858
window.onbeforeunload = function(e)
+ − 859
{
+ − 860
if ( !e )
+ − 861
e = window.event;
+ − 862
e.returnValue = window._unloadmsg;
+ − 863
}
+ − 864
}
+ − 865
+ − 866
function enableUnload()
+ − 867
{
+ − 868
window._unloadmsg = null;
+ − 869
window.onbeforeunload = null;
+ − 870
}
+ − 871
+ − 872
/**
+ − 873
* Gets the highest z-index of all divs in the document
+ − 874
* @return integer
+ − 875
*/
+ − 876
function getHighestZ()
+ − 877
{
+ − 878
z = 0;
+ − 879
var divs = document.getElementsByTagName('div');
+ − 880
for(var i = 0; i < divs.length; i++)
+ − 881
{
1125
367768040a61
Javascript lib: UX: When whiteOutReportSuccess() is called on a whiteout over a miniPrompt, the miniPrompt and whiteout are now flown out together. Also, a bit of improvement to message box DOM object destruction code; this fixes problems with message boxes appearing below the shade when ajax auth is done 3 or more times in one page load.
Dan
diff
changeset
+ − 882
if(divs[i].style.zIndex > z && divs[i].style.display != 'none' && divs[i].innerHTML != '') z = divs[i].style.zIndex;
582
+ − 883
}
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
+ − 884
return parseInt(z);
582
+ − 885
}
+ − 886
592
+ − 887
var shift = false;
582
+ − 888
function isKeyPressed(event)
+ − 889
{
+ − 890
if (event.shiftKey==1)
+ − 891
{
+ − 892
shift = true;
+ − 893
}
+ − 894
else
+ − 895
{
+ − 896
shift = false;
+ − 897
}
+ − 898
}
+ − 899
+ − 900
function moveDiv(div, newparent)
+ − 901
{
+ − 902
var backup = div;
+ − 903
var oldparent = div.parentNode;
+ − 904
oldparent.removeChild(div);
+ − 905
newparent.appendChild(backup);
+ − 906
}
+ − 907
+ − 908
var busyBannerID;
+ − 909
function goBusy(msg)
+ − 910
{
+ − 911
if(!msg) msg = 'Please wait...';
+ − 912
body = document.getElementsByTagName('body');
+ − 913
body = body[0];
+ − 914
body.style.cursor = 'wait';
+ − 915
busyBannerID = bannerOn(msg);
+ − 916
}
+ − 917
+ − 918
function unBusy()
+ − 919
{
+ − 920
body = document.getElementsByTagName('body');
+ − 921
body = body[0];
+ − 922
body.style.cursor = 'default';
+ − 923
bannerOff(busyBannerID);
+ − 924
}
+ − 925
+ − 926
function setAjaxLoading()
+ − 927
{
+ − 928
if ( document.getElementById('ajaxloadicon') )
+ − 929
{
+ − 930
document.getElementById('ajaxloadicon').src=ajax_load_icon;
+ − 931
}
+ − 932
}
+ − 933
+ − 934
function unsetAjaxLoading()
+ − 935
{
+ − 936
if ( document.getElementById('ajaxloadicon') )
+ − 937
{
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
+ − 938
document.getElementById('ajaxloadicon').src=cdnPath + '/images/spacer.gif';
582
+ − 939
}
+ − 940
}
+ − 941
+ − 942
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;}
+ − 943
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=/";}
+ − 944
function eraseCookie(name) {createCookie(name,"",-1);}
+ − 945
+ − 946
/*
+ − 947
* AJAX login box (experimental)
+ − 948
* Moved / rewritten in login.js
+ − 949
*/
+ − 950
+ − 951
// Included only for API-compatibility
+ − 952
function ajaxPromptAdminAuth(call_on_ok, level)
+ − 953
{
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
+ − 954
ajaxLoginInit(call_on_ok, level);
582
+ − 955
}
+ − 956
+ − 957
/**
+ − 958
* Insert a DOM object _after_ the specified child.
+ − 959
* @param object Parent node
+ − 960
* @param object Node to insert
+ − 961
* @param object Node to insert after
+ − 962
*/
+ − 963
+ − 964
function insertAfter(parent, baby, bigsister)
+ − 965
{
+ − 966
try
+ − 967
{
+ − 968
if ( parent.childNodes[parent.childNodes.length-1] == bigsister )
+ − 969
parent.appendChild(baby);
+ − 970
else
+ − 971
parent.insertBefore(baby, bigsister.nextSibling);
+ − 972
}
+ − 973
catch(e)
+ − 974
{
+ − 975
alert(e.toString());
+ − 976
if ( window.console )
+ − 977
{
+ − 978
// Firebug support
+ − 979
window.console.warn(e);
+ − 980
}
+ − 981
}
+ − 982
}
+ − 983
+ − 984
/**
+ − 985
* Validates an e-mail address.
+ − 986
* @param string E-mail address
+ − 987
* @return bool
+ − 988
*/
+ − 989
+ − 990
function validateEmail(email)
+ − 991
{
+ − 992
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;
+ − 993
}
+ − 994
+ − 995
/**
+ − 996
* Validates a username.
+ − 997
* @param string Username to test
+ − 998
* @return bool
+ − 999
*/
+ − 1000
+ − 1001
function validateUsername(username)
+ − 1002
{
+ − 1003
var regex = new RegExp('^[^<>&\?\'"%\n\r/]+$', '');
+ − 1004
return ( username.match(regex) ) ? true : false;
+ − 1005
}
+ − 1006
+ − 1007
/*
+ − 1008
* Utility functions, moved from windows.js
+ − 1009
*/
+ − 1010
+ − 1011
function getHeight() {
+ − 1012
var myHeight = 0;
+ − 1013
if( typeof( window.innerWidth ) == 'number' ) {
+ − 1014
myHeight = window.innerHeight;
+ − 1015
} else if( document.documentElement &&
+ − 1016
( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
+ − 1017
myHeight = document.documentElement.clientHeight;
+ − 1018
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
+ − 1019
myHeight = document.body.clientHeight;
+ − 1020
}
+ − 1021
return myHeight;
+ − 1022
}
+ − 1023
+ − 1024
function getWidth() {
+ − 1025
var myWidth = 0;
+ − 1026
if( typeof( window.innerWidth ) == 'number' ) {
+ − 1027
myWidth = window.innerWidth;
+ − 1028
} else if( document.documentElement &&
+ − 1029
( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) {
+ − 1030
myWidth = document.documentElement.clientWidth;
+ − 1031
} else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) {
+ − 1032
myWidth = document.body.clientWidth;
+ − 1033
}
+ − 1034
return myWidth;
+ − 1035
}
+ − 1036
+ − 1037
/**
+ − 1038
* Sanitizes a page URL string so that it can safely be stored in the database.
+ − 1039
* @param string Page ID to sanitize
+ − 1040
* @return string Cleaned text
+ − 1041
*/
+ − 1042
+ − 1043
function sanitize_page_id(page_id)
+ − 1044
{
+ − 1045
// Remove character escapes
+ − 1046
page_id = dirtify_page_id(page_id);
+ − 1047
+ − 1048
var regex = new RegExp('[A-Za-z0-9\\[\\]\./:;\(\)@_-]', 'g');
+ − 1049
pid_clean = page_id.replace(regex, 'X');
+ − 1050
var pid_dirty = [];
+ − 1051
for ( var i = 0; i < pid_clean.length; i++ )
+ − 1052
pid_dirty[i] = pid_clean.substr(i, 1);
+ − 1053
+ − 1054
for ( var i = 0; i < pid_dirty.length; i++ )
+ − 1055
{
+ − 1056
var chr = pid_dirty[i];
+ − 1057
if ( chr == 'X' )
+ − 1058
continue;
+ − 1059
var cid = chr.charCodeAt(0);
+ − 1060
cid = cid.toString(16).toUpperCase();
+ − 1061
if ( cid.length < 2 )
+ − 1062
{
+ − 1063
cid = '0' + cid;
+ − 1064
}
+ − 1065
pid_dirty[i] = "." + cid;
+ − 1066
}
+ − 1067
+ − 1068
var pid_chars = [];
+ − 1069
for ( var i = 0; i < page_id.length; i++ )
+ − 1070
pid_chars[i] = page_id.substr(i, 1);
+ − 1071
+ − 1072
var page_id_cleaned = '';
+ − 1073
+ − 1074
for ( var id in pid_chars )
+ − 1075
{
+ − 1076
var chr = pid_chars[id];
+ − 1077
if ( pid_dirty[id] == 'X' )
+ − 1078
page_id_cleaned += chr;
+ − 1079
else
+ − 1080
page_id_cleaned += pid_dirty[id];
+ − 1081
}
+ − 1082
+ − 1083
return page_id_cleaned;
+ − 1084
}
+ − 1085
+ − 1086
/**
+ − 1087
* Removes character escapes in a page ID string
+ − 1088
* @param string Page ID string to dirty up
+ − 1089
* @return string
+ − 1090
*/
+ − 1091
+ − 1092
function dirtify_page_id(page_id)
+ − 1093
{
+ − 1094
// First, replace spaces with underscores
+ − 1095
page_id = page_id.replace(/ /g, '_');
+ − 1096
+ − 1097
var matches = page_id.match(/\.[A-Fa-f0-9][A-Fa-f0-9]/g);
+ − 1098
+ − 1099
if ( matches != null )
+ − 1100
{
+ − 1101
for ( var i = 0; i < matches.length; i++ )
+ − 1102
{
+ − 1103
var match = matches[i];
+ − 1104
var byt = (match.substr(1)).toUpperCase();
+ − 1105
var code = eval("0x" + byt);
+ − 1106
var regex = new RegExp('\\.' + byt, 'g');
+ − 1107
page_id = page_id.replace(regex, String.fromCharCode(code));
+ − 1108
}
+ − 1109
}
+ − 1110
+ − 1111
return page_id;
+ − 1112
}
+ − 1113
740
+ − 1114
/*
+ − 1115
the getElementsByClassName function I pilfered from this guy. It's
+ − 1116
a useful function that'll return any/all tags with a specific css class.
+ − 1117
+ − 1118
Written by Jonathan Snook, http://www.snook.ca/jonathan
+ − 1119
Add-ons by Robert Nyman, http://www.robertnyman.com
+ − 1120
+ − 1121
Modified to match all elements that match the class name plus an integer after the name
+ − 1122
This is used in Enano to allow sliding sidebar widgets that use their own CSS
+ − 1123
*/
+ − 1124
function getElementsByClassName(oElm, strTagName, strClassName)
+ − 1125
{
+ − 1126
// first it gets all of the specified tags
+ − 1127
var arrElements = (strTagName == "*" && document.all) ? document.all : oElm.getElementsByTagName(strTagName);
+ − 1128
+ − 1129
// then it sets up an array that'll hold the results
+ − 1130
var arrReturnElements = new Array();
+ − 1131
+ − 1132
// some regex stuff you don't need to worry about
+ − 1133
strClassName = strClassName.replace(/\-/g, "\\-");
+ − 1134
+ − 1135
var oRegExp = new RegExp("(^|\\s)" + strClassName + "([0-9]*)(\\s|$)");
+ − 1136
var oElement;
+ − 1137
+ − 1138
// now it iterates through the elements it grabbed above
+ − 1139
for(var i=0; i<arrElements.length; i++)
+ − 1140
{
+ − 1141
oElement = arrElements[i];
+ − 1142
+ − 1143
// if the class matches what we're looking for it ads to the results array
+ − 1144
if(oElement.className.match(oRegExp))
+ − 1145
{
+ − 1146
arrReturnElements.push(oElement);
+ − 1147
}
+ − 1148
}
+ − 1149
+ − 1150
// then it kicks the results back to us
+ − 1151
return (arrReturnElements)
+ − 1152
}
+ − 1153
582
+ − 1154
/**
+ − 1155
* Equivalent to PHP's in_array function.
+ − 1156
*/
+ − 1157
+ − 1158
function in_array(needle, haystack)
+ − 1159
{
+ − 1160
for(var i in haystack)
+ − 1161
{
+ − 1162
if(haystack[i] == needle) return i;
+ − 1163
}
+ − 1164
return false;
+ − 1165
}
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1166
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1167
/**
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1168
* Equivalent of PHP's time()
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1169
* @return int
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1170
*/
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1171
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1172
function unix_time()
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1173
{
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
diff
changeset
+ − 1174
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
+ − 1175
}