author | Dan |
Mon, 28 Jul 2008 13:01:53 -0600 | |
changeset 665 | af7e8ec6aef7 |
parent 651 | ce9d78d7251d |
child 672 | 08a7875258b4 |
permissions | -rw-r--r-- |
582
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
1 |
// all utility functions go in here |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
2 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
3 |
function makeUrl(page, query, html_friendly) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
4 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
5 |
url = contentPath+page; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
6 |
if(url.indexOf('?') > 0) sep = '&'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
7 |
else sep = '?'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
8 |
if(query) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
9 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
10 |
url = url + sep + query; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
11 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
12 |
if(html_friendly) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
13 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
14 |
url = url.replace('&', '&'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
15 |
url = url.replace('<', '<'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
16 |
url = url.replace('>', '>'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
17 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
18 |
return url; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
19 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
20 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
21 |
function makeUrlNS(namespace, page, query, html_friendly) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
22 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
23 |
var url = contentPath+namespace_list[namespace]+(page.replace(/ /g, '_')); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
24 |
if(url.indexOf('?') > 0) sep = '&'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
25 |
else sep = '?'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
26 |
if(query) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
27 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
28 |
url = url + sep + query; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
29 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
30 |
if(html_friendly) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
31 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
32 |
url = url.replace('&', '&'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
33 |
url = url.replace('<', '<'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
34 |
url = url.replace('>', '>'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
35 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
36 |
return append_sid(url); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
37 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
38 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
39 |
function strToPageID(string) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
40 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
41 |
// Convert Special:UploadFile to ['UploadFile', 'Special'], but convert 'Image:Enano.png' to ['Enano.png', 'File'] |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
42 |
for(var i in namespace_list) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
43 |
if(namespace_list[i] != '') |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
44 |
if(namespace_list[i] == string.substr(0, namespace_list[i].length)) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
45 |
return [string.substr(namespace_list[i].length), i]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
46 |
return [string, 'Article']; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
47 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
48 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
49 |
function append_sid(url) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
50 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
51 |
sep = ( url.indexOf('?') > 0 ) ? '&' : '?'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
52 |
if(ENANO_SID.length > 10) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
53 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
54 |
url = url + sep + 'auth=' + ENANO_SID; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
55 |
sep = '&'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
56 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
57 |
if ( pagepass.length > 0 ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
58 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
59 |
url = url + sep + 'pagepass=' + pagepass; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
60 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
61 |
return url; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
62 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
63 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
64 |
var stdAjaxPrefix = append_sid(scriptPath+'/ajax.php?title='+title); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
65 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
66 |
/** |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
67 |
* Core AJAX library |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
68 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
69 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
70 |
function ajaxMakeXHR() |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
71 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
72 |
var ajax; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
73 |
if (window.XMLHttpRequest) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
74 |
ajax = new XMLHttpRequest(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
75 |
} else { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
76 |
if (window.ActiveXObject) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
77 |
ajax = new ActiveXObject("Microsoft.XMLHTTP"); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
78 |
} else { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
79 |
alert('Enano client-side runtime error: No AJAX support, unable to continue'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
80 |
return; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
81 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
82 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
83 |
return ajax; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
84 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
85 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
86 |
function ajaxGet(uri, f, call_editor_safe) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
87 |
// Is the editor open? |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
88 |
if ( editor_open && !call_editor_safe ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
89 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
90 |
// Make sure the user is willing to close the editor |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
91 |
var conf = confirm($lang.get('editor_msg_confirm_ajax')); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
92 |
if ( !conf ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
93 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
94 |
// Kill off any "loading" windows, etc. and cancel the request |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
95 |
unsetAjaxLoading(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
96 |
return false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
97 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
98 |
// The user allowed the editor to be closed. Reset flags and knock out the on-close confirmation. |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
99 |
editor_open = false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
100 |
enableUnload(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
101 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
102 |
ajax = ajaxMakeXHR(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
103 |
if ( !ajax ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
104 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
105 |
console.error('ajaxMakeXHR() failed'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
106 |
return false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
107 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
108 |
ajax.onreadystatechange = f; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
109 |
ajax.open('GET', uri, true); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
110 |
ajax.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" ); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
111 |
ajax.send(null); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
112 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
113 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
114 |
function ajaxPost(uri, parms, f, call_editor_safe) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
115 |
// Is the editor open? |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
116 |
if ( editor_open && !call_editor_safe ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
117 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
118 |
// Make sure the user is willing to close the editor |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
119 |
var conf = confirm($lang.get('editor_msg_confirm_ajax')); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
120 |
if ( !conf ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
121 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
122 |
// Kill off any "loading" windows, etc. and cancel the request |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
123 |
unsetAjaxLoading(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
124 |
return false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
125 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
126 |
// The user allowed the editor to be closed. Reset flags and knock out the on-close confirmation. |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
127 |
editor_open = false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
128 |
enableUnload(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
129 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
130 |
ajax = ajaxMakeXHR(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
131 |
if ( !ajax ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
132 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
133 |
console.error('ajaxMakeXHR() failed'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
134 |
return false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
135 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
136 |
ajax.onreadystatechange = f; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
137 |
ajax.open('POST', uri, true); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
138 |
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
139 |
// Setting Content-length in Safari triggers a warning |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
140 |
if ( !is_Safari ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
141 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
142 |
ajax.setRequestHeader("Content-length", parms.length); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
143 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
144 |
ajax.setRequestHeader("Connection", "close"); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
145 |
ajax.send(parms); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
146 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
147 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
148 |
/** |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
149 |
* Show a friendly error message depicting an AJAX response that is not valid JSON |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
150 |
* @param string Response text |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
151 |
* @param string Custom error message. If omitted, the default will be shown. |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
152 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
153 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
154 |
function handle_invalid_json(response, customerror) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
155 |
{ |
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
156 |
load_component('messagebox'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
157 |
load_component('SpryEffects'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
158 |
load_component('fadefilter'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
159 |
load_component('flyin'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
160 |
load_component('l10n'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
161 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
162 |
darken(); |
582
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
163 |
|
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
164 |
var box = document.createElement('div'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
165 |
var mainwin = document.createElement('div'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
166 |
var panel = document.createElement('div'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
167 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
168 |
// |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
169 |
// main window |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
170 |
// |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
171 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
172 |
mainwin.style.padding = '10px'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
173 |
mainwin.style.width = '580px'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
174 |
mainwin.style.height = '360px'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
175 |
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
parents:
650
diff
changeset
|
176 |
mainwin.style.overflow = 'auto'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
177 |
mainwin.style.backgroundColor = '#ffffff'; |
582
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
178 |
|
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
179 |
// Title |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
180 |
var h3 = document.createElement('h3'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
181 |
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
parents:
650
diff
changeset
|
182 |
h3.appendChild(document.createTextNode(h3_text)); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
183 |
mainwin.appendChild(h3); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
184 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
185 |
if ( typeof(customerror) == 'string' ) |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
186 |
{ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
187 |
var el = document.createElement('p'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
188 |
el.appendChild(document.createTextNode(customerror)); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
189 |
mainwin.appendChild(el); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
190 |
} |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
191 |
else |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
192 |
{ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
193 |
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
parents:
650
diff
changeset
|
194 |
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
parents:
650
diff
changeset
|
195 |
error += 'for this problem:'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
196 |
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
parents:
650
diff
changeset
|
197 |
var el = document.createElement('p'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
198 |
el.appendChild(document.createTextNode(customerror)); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
199 |
mainwin.appendChild(el); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
200 |
var ul = document.createElement('ul'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
201 |
var li1 = document.createElement('li'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
202 |
var li2 = document.createElement('li'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
203 |
var li3 = document.createElement('li'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
204 |
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
parents:
650
diff
changeset
|
205 |
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
parents:
650
diff
changeset
|
206 |
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
parents:
650
diff
changeset
|
207 |
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
parents:
650
diff
changeset
|
208 |
li1.appendChild(document.createTextNode(li1_text)); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
209 |
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
parents:
650
diff
changeset
|
210 |
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
parents:
650
diff
changeset
|
211 |
li3.appendChild(document.createTextNode(li3_text)); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
212 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
213 |
ul.appendChild(li1); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
214 |
ul.appendChild(li2); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
215 |
ul.appendChild(li3); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
216 |
mainwin.appendChild(ul); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
217 |
} |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
218 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
219 |
var p2 = document.createElement('p'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
220 |
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
parents:
650
diff
changeset
|
221 |
p2.appendChild(document.createTextNode(p2_text)); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
222 |
mainwin.appendChild(p2); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
223 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
224 |
var pre = document.createElement('pre'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
225 |
pre.appendChild(document.createTextNode(response)); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
226 |
mainwin.appendChild(pre); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
227 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
228 |
var p3 = document.createElement('p'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
229 |
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
parents:
650
diff
changeset
|
230 |
p3.appendChild(document.createTextNode(p3_text + ' ')); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
231 |
var a = document.createElement('a'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
232 |
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
parents:
650
diff
changeset
|
233 |
a.appendChild(document.createTextNode(a_text + '...')); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
234 |
a._resp = response; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
235 |
a.onclick = function() |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
236 |
{ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
237 |
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
parents:
650
diff
changeset
|
238 |
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
parents:
650
diff
changeset
|
239 |
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
parents:
650
diff
changeset
|
240 |
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
parents:
650
diff
changeset
|
241 |
var mp = miniPromptMessage({ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
242 |
title: vah_title, |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
243 |
message: vah_body, |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
244 |
buttons: [ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
245 |
{ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
246 |
text: btn_confirm, |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
247 |
color: 'blue', |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
248 |
style: { |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
249 |
fontWeight: 'bold' |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
250 |
}, |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
251 |
onclick: function() { |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
252 |
var mp = miniPromptGetParent(this); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
253 |
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
parents:
650
diff
changeset
|
254 |
win.document.write(mp._response); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
255 |
win.document.close(); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
256 |
miniPromptDestroy(this); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
257 |
} |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
258 |
}, |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
259 |
{ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
260 |
text: btn_cancel, |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
261 |
onclick: function() { |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
262 |
miniPromptDestroy(this); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
263 |
} |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
264 |
} |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
265 |
] |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
266 |
}); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
267 |
mp._response = this._resp; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
268 |
return false; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
269 |
} |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
270 |
a.href = '#'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
271 |
p3.appendChild(a); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
272 |
mainwin.appendChild(p3); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
273 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
274 |
// |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
275 |
// panel |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
276 |
// |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
277 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
278 |
panel.style.backgroundColor = '#D0D0D0'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
279 |
panel.style.textAlign = 'right'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
280 |
panel.style.padding = '0 10px'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
281 |
panel.style.lineHeight = '40px'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
282 |
panel.style.width = '580px'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
283 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
284 |
var closer = document.createElement('input'); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
285 |
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
parents:
650
diff
changeset
|
286 |
closer.type = 'button'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
287 |
closer.value = btn_close; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
288 |
closer.onclick = function() |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
289 |
{ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
290 |
var parentdiv = this.parentNode.parentNode; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
291 |
var effect = new Spry.Effect.Blind(parentdiv, { |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
292 |
from: '100%', |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
293 |
to: '0%', |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
294 |
duration: '1000' |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
295 |
}); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
296 |
var observer = { |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
297 |
onPostEffect: function() |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
298 |
{ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
299 |
parentdiv.parentNode.removeChild(parentdiv); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
300 |
enlighten(); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
301 |
} |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
302 |
}; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
303 |
effect.addObserver(observer); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
304 |
effect.start(); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
305 |
} |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
306 |
panel.appendChild(closer); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
307 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
308 |
// |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
309 |
// put it together |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
310 |
// |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
311 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
312 |
box.appendChild(mainwin); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
313 |
box.appendChild(panel); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
314 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
315 |
// 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
parents:
650
diff
changeset
|
316 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
317 |
box.style.display = 'block'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
318 |
box.style.position = 'absolute'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
319 |
domObjChangeOpac(0, box); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
320 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
321 |
var body = document.getElementsByTagName('body')[0]; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
322 |
body.appendChild(box); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
323 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
324 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
325 |
// calculate position of the box |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
326 |
// box should be exactly 640px high, 480px wide |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
327 |
var top = ( getHeight() / 2 ) - ( $(box).Height() / 2 ) + getScrollOffset(); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
328 |
var left = ( getWidth() / 2 ) - ( $(box).Width() / 2 ); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
329 |
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
parents:
650
diff
changeset
|
330 |
box.style.top = top + 'px'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
331 |
box.style.left = left + 'px'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
332 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
333 |
// we have width and height, set display to none and reset opacity |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
334 |
box.style.display = 'none'; |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
335 |
domObjChangeOpac(100, box); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
336 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
337 |
setTimeout(function() |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
338 |
{ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
339 |
(new Spry.Effect.Blind(box, { |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
340 |
from: '0%', |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
341 |
to: '100%', |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
342 |
duration: 1000 |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
343 |
})).start(); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
344 |
}, 1000); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
345 |
} |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
346 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
347 |
/** |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
348 |
* 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
parents:
650
diff
changeset
|
349 |
* @param string |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
350 |
* @return bool true if JSON is valid |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
351 |
*/ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
352 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
353 |
function check_json_response(response) |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
354 |
{ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
355 |
response = trim(response); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
356 |
if ( response.substr(0, 1) == '{' && response.substr(response.length - 1, 1) == '}' ) |
582
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
357 |
{ |
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
358 |
return true; |
582
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
359 |
} |
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
360 |
return false; |
582
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
361 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
362 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
363 |
function ajaxEscape(text) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
364 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
365 |
/* |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
366 |
text = escape(text); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
367 |
text = text.replace(/\+/g, '%2B', text); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
368 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
369 |
text = window.encodeURIComponent(text); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
370 |
return text; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
371 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
372 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
373 |
/** |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
374 |
* String functions |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
375 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
376 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
377 |
// Equivalent to PHP trim() function |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
378 |
function trim(text) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
379 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
380 |
text = text.replace(/^([\s]+)/, ''); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
381 |
text = text.replace(/([\s]+)$/, ''); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
382 |
return text; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
383 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
384 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
385 |
// Equivalent to PHP implode() function |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
386 |
function implode(chr, arr) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
387 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
388 |
if ( typeof ( arr.toJSONString ) == 'function' ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
389 |
delete(arr.toJSONString); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
390 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
391 |
var ret = ''; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
392 |
var c = 0; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
393 |
for ( var i in arr ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
394 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
395 |
if(i=='toJSONString')continue; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
396 |
if ( c > 0 ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
397 |
ret += chr; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
398 |
ret += arr[i]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
399 |
c++; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
400 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
401 |
return ret; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
402 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
403 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
404 |
function form_fetch_field(form, name) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
405 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
406 |
var fields = form.getElementsByTagName('input'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
407 |
if ( fields.length < 1 ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
408 |
return false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
409 |
for ( var i = 0; i < fields.length; i++ ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
410 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
411 |
var field = fields[i]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
412 |
if ( field.name == name ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
413 |
return field; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
414 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
415 |
return false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
416 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
417 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
418 |
function get_parent_form(o) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
419 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
420 |
if ( !o.parentNode ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
421 |
return false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
422 |
if ( o.tagName == 'FORM' ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
423 |
return o; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
424 |
var p = o.parentNode; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
425 |
while(true) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
426 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
427 |
if ( p.tagName == 'FORM' ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
428 |
return p; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
429 |
else if ( !p ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
430 |
return false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
431 |
else |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
432 |
p = p.parentNode; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
433 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
434 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
435 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
436 |
function findParentForm(o) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
437 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
438 |
return get_parent_form(o); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
439 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
440 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
441 |
function domObjChangeOpac(opacity, id) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
442 |
var object = id.style; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
443 |
object.opacity = (opacity / 100); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
444 |
object.MozOpacity = (opacity / 100); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
445 |
object.KhtmlOpacity = (opacity / 100); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
446 |
object.filter = "alpha(opacity=" + opacity + ")"; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
447 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
448 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
449 |
function getScrollOffset() |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
450 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
451 |
var position; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
452 |
if (self.pageYOffset) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
453 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
454 |
position = self.pageYOffset; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
455 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
456 |
else if (document.documentElement && document.documentElement.scrollTop) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
457 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
458 |
position = document.documentElement.scrollTop; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
459 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
460 |
else if (document.body) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
461 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
462 |
position = document.body.scrollTop; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
463 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
464 |
return position; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
465 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
466 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
467 |
// Function to fade classes info-box, warning-box, error-box, etc. |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
468 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
469 |
function fadeInfoBoxes() |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
470 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
471 |
var divs = new Array(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
472 |
d = document.getElementsByTagName('div'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
473 |
j = 0; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
474 |
for(var i in d) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
475 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
476 |
if ( !d[i] ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
477 |
continue; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
478 |
if ( !d[i].tagName ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
479 |
continue; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
480 |
if(d[i].className=='info-box' || d[i].className=='error-box' || d[i].className=='warning-box' || d[i].className=='question-box') |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
481 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
482 |
divs[j] = d[i]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
483 |
j++; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
484 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
485 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
486 |
if(divs.length < 1) return; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
487 |
load_component('fat'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
488 |
for(i in divs) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
489 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
490 |
if(!divs[i].id) divs[i].id = 'autofade_'+Math.floor(Math.random() * 100000); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
491 |
switch(divs[i].className) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
492 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
493 |
case 'info-box': |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
494 |
default: |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
495 |
from = '#3333FF'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
496 |
break; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
497 |
case 'error-box': |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
498 |
from = '#FF3333'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
499 |
break; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
500 |
case 'warning-box': |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
501 |
from = '#FFFF33'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
502 |
break; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
503 |
case 'question-box': |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
504 |
from = '#33FF33'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
505 |
break; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
506 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
507 |
Fat.fade_element(divs[i].id,30,2000,from,Fat.get_bgcolor(divs[i].id)); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
508 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
509 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
510 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
511 |
addOnloadHook(fadeInfoBoxes); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
512 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
513 |
// Alpha fades |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
514 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
515 |
function opacity(id, opacStart, opacEnd, millisec) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
516 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
517 |
var object = document.getElementById(id); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
518 |
domOpacity(object, opacStart, opacEnd, millisec); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
519 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
520 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
521 |
var opacityDOMCache = new Object(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
522 |
function domOpacity(obj, opacStart, opacEnd, millisec) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
523 |
//speed for each frame |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
524 |
var speed = Math.round(millisec / 100); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
525 |
var timer = 0; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
526 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
527 |
// unique ID for this animation |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
528 |
var uniqid = Math.floor(Math.random() * 1000000); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
529 |
opacityDOMCache[uniqid] = obj; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
530 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
531 |
//determine the direction for the blending, if start and end are the same nothing happens |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
532 |
if(opacStart > opacEnd) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
533 |
for(i = opacStart; i >= opacEnd; i--) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
534 |
setTimeout("var obj = opacityDOMCache["+uniqid+"]; domObjChangeOpac(" + i + ",obj)",(timer * speed)); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
535 |
timer++; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
536 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
537 |
} else if(opacStart < opacEnd) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
538 |
for(i = opacStart; i <= opacEnd; i++) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
539 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
540 |
setTimeout("var obj = opacityDOMCache["+uniqid+"]; domObjChangeOpac(" + i + ",obj)",(timer * speed)); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
541 |
timer++; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
542 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
543 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
544 |
setTimeout("delete(opacityDOMCache["+uniqid+"]);",(timer * speed)); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
545 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
546 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
547 |
// change the opacity for different browsers |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
548 |
function changeOpac(opacity, id) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
549 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
550 |
var object = document.getElementById(id); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
551 |
return domObjChangeOpac(opacity, object); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
552 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
553 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
554 |
// draw a white ajax-ey "loading" box over an object |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
555 |
function whiteOutElement(el) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
556 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
557 |
var top = $(el).Top(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
558 |
var left = $(el).Left(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
559 |
var width = $(el).Width(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
560 |
var height = $(el).Height(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
561 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
562 |
var blackout = document.createElement('div'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
563 |
blackout.style.position = 'absolute'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
564 |
blackout.style.top = top + 'px'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
565 |
blackout.style.left = left + 'px'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
566 |
blackout.style.width = width + 'px'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
567 |
blackout.style.height = height + 'px'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
568 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
569 |
blackout.style.backgroundColor = '#FFFFFF'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
570 |
domObjChangeOpac(60, blackout); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
571 |
blackout.style.backgroundImage = 'url(' + scriptPath + '/includes/clientside/tinymce/themes/advanced/skins/default/img/progress.gif)'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
572 |
blackout.style.backgroundPosition = 'center center'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
573 |
blackout.style.backgroundRepeat = 'no-repeat'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
574 |
blackout.style.zIndex = getHighestZ() + 2; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
575 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
576 |
var body = document.getElementsByTagName('body')[0]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
577 |
body.appendChild(blackout); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
578 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
579 |
return blackout; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
580 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
581 |
|
628
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
582 |
/** |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
583 |
* Take a div generated by whiteOutElement() and report success using the glossy "check" graphic. Sets the image, then |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
584 |
* briefly fades in, then fades out and destroys the box so as to re-allow control over the underlying element |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
585 |
*/ |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
586 |
|
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
587 |
function whiteOutReportSuccess(whitey) |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
588 |
{ |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
589 |
// fade the status indicator in and then out |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
590 |
whitey.style.backgroundImage = 'url(' + scriptPath + '/images/check.png)'; |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
591 |
domOpacity(whitey, 60, 80, 500); |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
592 |
setTimeout(function() |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
593 |
{ |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
594 |
domOpacity(whitey, 60, 0, 500); |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
595 |
}, 750); |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
596 |
setTimeout(function() |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
597 |
{ |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
598 |
whitey.parentNode.removeChild(whitey); |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
599 |
}, 1250); |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
600 |
} |
ab6f55abb17e
Rank editor is now in a working (beautiful) state. More intuitive than a Mac.
Dan
parents:
592
diff
changeset
|
601 |
|
582
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
602 |
// other DHTML functions |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
603 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
604 |
function fetch_offset(obj) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
605 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
606 |
var left_offset = obj.offsetLeft; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
607 |
var top_offset = obj.offsetTop; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
608 |
while ((obj = obj.offsetParent) != null) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
609 |
left_offset += obj.offsetLeft; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
610 |
top_offset += obj.offsetTop; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
611 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
612 |
return { 'left' : left_offset, 'top' : top_offset }; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
613 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
614 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
615 |
function fetch_dimensions(o) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
616 |
var w = o.offsetWidth; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
617 |
var h = o.offsetHeight; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
618 |
return { 'w' : w, 'h' : h }; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
619 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
620 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
621 |
function findParentForm(o) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
622 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
623 |
if ( o.tagName == 'FORM' ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
624 |
return o; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
625 |
while(true) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
626 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
627 |
o = o.parentNode; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
628 |
if ( !o ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
629 |
return false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
630 |
if ( o.tagName == 'FORM' ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
631 |
return o; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
632 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
633 |
return false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
634 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
635 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
636 |
function bannerOn(text) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
637 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
638 |
darken(true); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
639 |
var thediv = document.createElement('div'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
640 |
thediv.className = 'mdg-comment'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
641 |
thediv.style.padding = '0'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
642 |
thediv.style.marginLeft = '0'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
643 |
thediv.style.position = 'absolute'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
644 |
thediv.style.display = 'none'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
645 |
thediv.style.padding = '4px'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
646 |
thediv.style.fontSize = '14pt'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
647 |
thediv.id = 'mdgDynamic_bannerDiv_'+Math.floor(Math.random() * 1000000); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
648 |
thediv.innerHTML = text; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
649 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
650 |
var body = document.getElementsByTagName('body'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
651 |
body = body[0]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
652 |
body.appendChild(thediv); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
653 |
body.style.cursor = 'wait'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
654 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
655 |
thediv.style.display = 'block'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
656 |
dim = fetch_dimensions(thediv); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
657 |
thediv.style.display = 'none'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
658 |
bdim = { 'w' : getWidth(), 'h' : getHeight() }; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
659 |
so = getScrollOffset(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
660 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
661 |
var left = (bdim['w'] / 2) - ( dim['w'] / 2 ); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
662 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
663 |
var top = (bdim['h'] / 2); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
664 |
top = top - ( dim['h'] / 2 ); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
665 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
666 |
top = top + so; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
667 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
668 |
thediv.style.top = top + 'px'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
669 |
thediv.style.left = left + 'px'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
670 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
671 |
thediv.style.display = 'block'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
672 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
673 |
return thediv.id; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
674 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
675 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
676 |
function bannerOff(id) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
677 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
678 |
e = document.getElementById(id); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
679 |
if(!e) return; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
680 |
e.innerHTML = ''; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
681 |
e.style.display = 'none'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
682 |
var body = document.getElementsByTagName('body'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
683 |
body = body[0]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
684 |
body.style.cursor = 'default'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
685 |
enlighten(true); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
686 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
687 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
688 |
function disableUnload(message) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
689 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
690 |
if(typeof message != 'string') message = 'You may want to save your changes first.'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
691 |
window._unloadmsg = message; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
692 |
window.onbeforeunload = function(e) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
693 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
694 |
if ( !e ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
695 |
e = window.event; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
696 |
e.returnValue = window._unloadmsg; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
697 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
698 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
699 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
700 |
function enableUnload() |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
701 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
702 |
window._unloadmsg = null; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
703 |
window.onbeforeunload = null; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
704 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
705 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
706 |
/** |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
707 |
* Gets the highest z-index of all divs in the document |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
708 |
* @return integer |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
709 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
710 |
function getHighestZ() |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
711 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
712 |
z = 0; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
713 |
var divs = document.getElementsByTagName('div'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
714 |
for(var i = 0; i < divs.length; i++) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
715 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
716 |
if(divs[i].style.zIndex > z) z = divs[i].style.zIndex; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
717 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
718 |
return z; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
719 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
720 |
|
592 | 721 |
var shift = false; |
582
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
722 |
function isKeyPressed(event) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
723 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
724 |
if (event.shiftKey==1) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
725 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
726 |
shift = true; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
727 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
728 |
else |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
729 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
730 |
shift = false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
731 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
732 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
733 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
734 |
function moveDiv(div, newparent) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
735 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
736 |
var backup = div; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
737 |
var oldparent = div.parentNode; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
738 |
oldparent.removeChild(div); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
739 |
newparent.appendChild(backup); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
740 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
741 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
742 |
var busyBannerID; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
743 |
function goBusy(msg) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
744 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
745 |
if(!msg) msg = 'Please wait...'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
746 |
body = document.getElementsByTagName('body'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
747 |
body = body[0]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
748 |
body.style.cursor = 'wait'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
749 |
busyBannerID = bannerOn(msg); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
750 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
751 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
752 |
function unBusy() |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
753 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
754 |
body = document.getElementsByTagName('body'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
755 |
body = body[0]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
756 |
body.style.cursor = 'default'; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
757 |
bannerOff(busyBannerID); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
758 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
759 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
760 |
function setAjaxLoading() |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
761 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
762 |
if ( document.getElementById('ajaxloadicon') ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
763 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
764 |
document.getElementById('ajaxloadicon').src=ajax_load_icon; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
765 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
766 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
767 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
768 |
function unsetAjaxLoading() |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
769 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
770 |
if ( document.getElementById('ajaxloadicon') ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
771 |
{ |
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
parents:
628
diff
changeset
|
772 |
document.getElementById('ajaxloadicon').src=cdnPath + '/images/spacer.gif'; |
582
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
773 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
774 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
775 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
776 |
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;} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
777 |
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=/";} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
778 |
function eraseCookie(name) {createCookie(name,"",-1);} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
779 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
780 |
/* |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
781 |
* AJAX login box (experimental) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
782 |
* Moved / rewritten in login.js |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
783 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
784 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
785 |
// Included only for API-compatibility |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
786 |
function ajaxPromptAdminAuth(call_on_ok, level) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
787 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
788 |
ajaxLogonInit(call_on_ok, level); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
789 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
790 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
791 |
/** |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
792 |
* Insert a DOM object _after_ the specified child. |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
793 |
* @param object Parent node |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
794 |
* @param object Node to insert |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
795 |
* @param object Node to insert after |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
796 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
797 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
798 |
function insertAfter(parent, baby, bigsister) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
799 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
800 |
try |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
801 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
802 |
if ( parent.childNodes[parent.childNodes.length-1] == bigsister ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
803 |
parent.appendChild(baby); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
804 |
else |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
805 |
parent.insertBefore(baby, bigsister.nextSibling); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
806 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
807 |
catch(e) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
808 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
809 |
alert(e.toString()); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
810 |
if ( window.console ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
811 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
812 |
// Firebug support |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
813 |
window.console.warn(e); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
814 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
815 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
816 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
817 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
818 |
/** |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
819 |
* Validates an e-mail address. |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
820 |
* @param string E-mail address |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
821 |
* @return bool |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
822 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
823 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
824 |
function validateEmail(email) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
825 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
826 |
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; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
827 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
828 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
829 |
/** |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
830 |
* Validates a username. |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
831 |
* @param string Username to test |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
832 |
* @return bool |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
833 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
834 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
835 |
function validateUsername(username) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
836 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
837 |
var regex = new RegExp('^[^<>&\?\'"%\n\r/]+$', ''); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
838 |
return ( username.match(regex) ) ? true : false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
839 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
840 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
841 |
/* |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
842 |
* Utility functions, moved from windows.js |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
843 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
844 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
845 |
function getHeight() { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
846 |
var myHeight = 0; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
847 |
if( typeof( window.innerWidth ) == 'number' ) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
848 |
myHeight = window.innerHeight; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
849 |
} else if( document.documentElement && |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
850 |
( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
851 |
myHeight = document.documentElement.clientHeight; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
852 |
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
853 |
myHeight = document.body.clientHeight; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
854 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
855 |
return myHeight; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
856 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
857 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
858 |
function getWidth() { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
859 |
var myWidth = 0; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
860 |
if( typeof( window.innerWidth ) == 'number' ) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
861 |
myWidth = window.innerWidth; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
862 |
} else if( document.documentElement && |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
863 |
( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
864 |
myWidth = document.documentElement.clientWidth; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
865 |
} else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) { |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
866 |
myWidth = document.body.clientWidth; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
867 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
868 |
return myWidth; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
869 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
870 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
871 |
/** |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
872 |
* Sanitizes a page URL string so that it can safely be stored in the database. |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
873 |
* @param string Page ID to sanitize |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
874 |
* @return string Cleaned text |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
875 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
876 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
877 |
function sanitize_page_id(page_id) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
878 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
879 |
// Remove character escapes |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
880 |
page_id = dirtify_page_id(page_id); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
881 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
882 |
var regex = new RegExp('[A-Za-z0-9\\[\\]\./:;\(\)@_-]', 'g'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
883 |
pid_clean = page_id.replace(regex, 'X'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
884 |
var pid_dirty = []; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
885 |
for ( var i = 0; i < pid_clean.length; i++ ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
886 |
pid_dirty[i] = pid_clean.substr(i, 1); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
887 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
888 |
for ( var i = 0; i < pid_dirty.length; i++ ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
889 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
890 |
var chr = pid_dirty[i]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
891 |
if ( chr == 'X' ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
892 |
continue; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
893 |
var cid = chr.charCodeAt(0); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
894 |
cid = cid.toString(16).toUpperCase(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
895 |
if ( cid.length < 2 ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
896 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
897 |
cid = '0' + cid; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
898 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
899 |
pid_dirty[i] = "." + cid; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
900 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
901 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
902 |
var pid_chars = []; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
903 |
for ( var i = 0; i < page_id.length; i++ ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
904 |
pid_chars[i] = page_id.substr(i, 1); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
905 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
906 |
var page_id_cleaned = ''; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
907 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
908 |
for ( var id in pid_chars ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
909 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
910 |
var chr = pid_chars[id]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
911 |
if ( pid_dirty[id] == 'X' ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
912 |
page_id_cleaned += chr; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
913 |
else |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
914 |
page_id_cleaned += pid_dirty[id]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
915 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
916 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
917 |
return page_id_cleaned; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
918 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
919 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
920 |
/** |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
921 |
* Removes character escapes in a page ID string |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
922 |
* @param string Page ID string to dirty up |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
923 |
* @return string |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
924 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
925 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
926 |
function dirtify_page_id(page_id) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
927 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
928 |
// First, replace spaces with underscores |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
929 |
page_id = page_id.replace(/ /g, '_'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
930 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
931 |
var matches = page_id.match(/\.[A-Fa-f0-9][A-Fa-f0-9]/g); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
932 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
933 |
if ( matches != null ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
934 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
935 |
for ( var i = 0; i < matches.length; i++ ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
936 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
937 |
var match = matches[i]; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
938 |
var byt = (match.substr(1)).toUpperCase(); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
939 |
var code = eval("0x" + byt); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
940 |
var regex = new RegExp('\\.' + byt, 'g'); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
941 |
page_id = page_id.replace(regex, String.fromCharCode(code)); |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
942 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
943 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
944 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
945 |
return page_id; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
946 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
947 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
948 |
/** |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
949 |
* Equivalent to PHP's in_array function. |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
950 |
*/ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
951 |
|
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
952 |
function in_array(needle, haystack) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
953 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
954 |
for(var i in haystack) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
955 |
{ |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
956 |
if(haystack[i] == needle) return i; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
957 |
} |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
958 |
return false; |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff
changeset
|
959 |
} |
651
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
960 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
961 |
/** |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
962 |
* Equivalent of PHP's time() |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
963 |
* @return int |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
964 |
*/ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
965 |
|
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
966 |
function unix_time() |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
967 |
{ |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
968 |
return parseInt((new Date()).getTime()/1000); |
ce9d78d7251d
Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents:
650
diff
changeset
|
969 |
} |