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