Index: trunk/phase3/skins/common/ajax.js |
— | — | @@ -1,30 +1,35 @@ |
2 | 2 | // remote scripting library |
3 | 3 | // (c) copyright 2005 modernmethod, inc |
4 | 4 | var sajax_debug_mode = false; |
5 | | -var sajax_request_type = "GET"; |
| 5 | +var sajax_request_type = 'GET'; |
6 | 6 | |
7 | 7 | /** |
8 | | -* if sajax_debug_mode is true, this function outputs given the message into |
9 | | -* the element with id = sajax_debug; if no such element exists in the document, |
10 | | -* it is injected. |
11 | | -*/ |
12 | | -function sajax_debug(text) { |
13 | | - if (!sajax_debug_mode) return false; |
| 8 | + * if sajax_debug_mode is true, this function outputs given the message into |
| 9 | + * the element with id = sajax_debug; if no such element exists in the document, |
| 10 | + * it is injected. |
| 11 | + */ |
| 12 | +function sajax_debug( text ) { |
| 13 | + if ( !sajax_debug_mode ) { |
| 14 | + return false; |
| 15 | + } |
14 | 16 | |
15 | | - var e= document.getElementById('sajax_debug'); |
| 17 | + var e = document.getElementById( 'sajax_debug' ); |
16 | 18 | |
17 | | - if (!e) { |
18 | | - e= document.createElement("p"); |
19 | | - e.className= 'sajax_debug'; |
20 | | - e.id= 'sajax_debug'; |
| 19 | + if ( !e ) { |
| 20 | + e = document.createElement( 'p' ); |
| 21 | + e.className = 'sajax_debug'; |
| 22 | + e.id = 'sajax_debug'; |
21 | 23 | |
22 | | - var b= document.getElementsByTagName("body")[0]; |
| 24 | + var b = document.getElementsByTagName( 'body' )[0]; |
23 | 25 | |
24 | | - if (b.firstChild) b.insertBefore(e, b.firstChild); |
25 | | - else b.appendChild(e); |
| 26 | + if ( b.firstChild ) { |
| 27 | + b.insertBefore( e, b.firstChild ); |
| 28 | + } else { |
| 29 | + b.appendChild( e ); |
| 30 | + } |
26 | 31 | } |
27 | 32 | |
28 | | - var m= document.createElement("div"); |
| 33 | + var m = document.createElement( 'div' ); |
29 | 34 | m.appendChild( document.createTextNode( text ) ); |
30 | 35 | |
31 | 36 | e.appendChild( m ); |
— | — | @@ -33,123 +38,131 @@ |
34 | 39 | } |
35 | 40 | |
36 | 41 | /** |
37 | | -* compatibility wrapper for creating a new XMLHttpRequest object. |
38 | | -*/ |
| 42 | + * Compatibility wrapper for creating a new XMLHttpRequest object. |
| 43 | + */ |
39 | 44 | function sajax_init_object() { |
40 | | - sajax_debug("sajax_init_object() called..") |
| 45 | + sajax_debug( 'sajax_init_object() called..' ); |
41 | 46 | var A; |
42 | 47 | try { |
43 | 48 | // Try the new style before ActiveX so we don't |
44 | 49 | // unnecessarily trigger warnings in IE 7 when |
45 | 50 | // set to prompt about ActiveX usage |
46 | 51 | A = new XMLHttpRequest(); |
47 | | - } catch (e) { |
| 52 | + } catch ( e ) { |
48 | 53 | try { |
49 | | - A=new ActiveXObject("Msxml2.XMLHTTP"); |
50 | | - } catch (e) { |
| 54 | + A = new ActiveXObject( 'Msxml2.XMLHTTP' ); |
| 55 | + } catch ( e ) { |
51 | 56 | try { |
52 | | - A=new ActiveXObject("Microsoft.XMLHTTP"); |
53 | | - } catch (oc) { |
54 | | - A=null; |
| 57 | + A = new ActiveXObject( 'Microsoft.XMLHTTP' ); |
| 58 | + } catch ( oc ) { |
| 59 | + A = null; |
55 | 60 | } |
56 | 61 | } |
57 | 62 | } |
58 | | - if (!A) |
59 | | - sajax_debug("Could not create connection object."); |
| 63 | + if ( !A ) { |
| 64 | + sajax_debug( 'Could not create connection object.' ); |
| 65 | + } |
60 | 66 | |
61 | 67 | return A; |
62 | 68 | } |
63 | 69 | |
64 | 70 | /** |
65 | | -* Perform an ajax call to mediawiki. Calls are handeled by AjaxDispatcher.php |
66 | | -* func_name - the name of the function to call. Must be registered in $wgAjaxExportList |
67 | | -* args - an array of arguments to that function |
68 | | -* target - the target that will handle the result of the call. If this is a function, |
69 | | -* if will be called with the XMLHttpRequest as a parameter; if it's an input |
70 | | -* element, its value will be set to the resultText; if it's another type of |
71 | | -* element, its innerHTML will be set to the resultText. |
72 | | -* |
73 | | -* Example: |
74 | | -* sajax_do_call('doFoo', [1, 2, 3], document.getElementById("showFoo")); |
75 | | -* |
76 | | -* This will call the doFoo function via MediaWiki's AjaxDispatcher, with |
77 | | -* (1, 2, 3) as the parameter list, and will show the result in the element |
78 | | -* with id = showFoo |
79 | | -*/ |
80 | | -function sajax_do_call(func_name, args, target) { |
| 71 | + * Perform an AJAX call to MediaWiki. Calls are handled by AjaxDispatcher.php |
| 72 | + * func_name - the name of the function to call. Must be registered in $wgAjaxExportList |
| 73 | + * args - an array of arguments to that function |
| 74 | + * target - the target that will handle the result of the call. If this is a function, |
| 75 | + * if will be called with the XMLHttpRequest as a parameter; if it's an input |
| 76 | + * element, its value will be set to the resultText; if it's another type of |
| 77 | + * element, its innerHTML will be set to the resultText. |
| 78 | + * |
| 79 | + * Example: |
| 80 | + * sajax_do_call( 'doFoo', [1, 2, 3], document.getElementById( 'showFoo' ) ); |
| 81 | + * |
| 82 | + * This will call the doFoo function via MediaWiki's AjaxDispatcher, with |
| 83 | + * (1, 2, 3) as the parameter list, and will show the result in the element |
| 84 | + * with id = showFoo |
| 85 | + */ |
| 86 | +function sajax_do_call( func_name, args, target ) { |
81 | 87 | var i, x, n; |
82 | 88 | var uri; |
83 | 89 | var post_data; |
84 | 90 | uri = wgServer + |
85 | | - ((wgScript == null) ? (wgScriptPath + "/index.php") : wgScript) + |
86 | | - "?action=ajax"; |
87 | | - if (sajax_request_type == "GET") { |
88 | | - if (uri.indexOf("?") == -1) |
89 | | - uri = uri + "?rs=" + encodeURIComponent(func_name); |
90 | | - else |
91 | | - uri = uri + "&rs=" + encodeURIComponent(func_name); |
92 | | - for (i = 0; i < args.length; i++) |
93 | | - uri = uri + "&rsargs[]=" + encodeURIComponent(args[i]); |
94 | | - //uri = uri + "&rsrnd=" + new Date().getTime(); |
| 91 | + ( ( wgScript == null ) ? ( wgScriptPath + '/index.php' ) : wgScript ) + |
| 92 | + '?action=ajax'; |
| 93 | + if ( sajax_request_type == 'GET' ) { |
| 94 | + if ( uri.indexOf( '?' ) == -1 ) { |
| 95 | + uri = uri + '?rs=' + encodeURIComponent( func_name ); |
| 96 | + } else { |
| 97 | + uri = uri + '&rs=' + encodeURIComponent( func_name ); |
| 98 | + } |
| 99 | + for ( i = 0; i < args.length; i++ ) { |
| 100 | + uri = uri + '&rsargs[]=' + encodeURIComponent( args[i] ); |
| 101 | + } |
| 102 | + //uri = uri + '&rsrnd=' + new Date().getTime(); |
95 | 103 | post_data = null; |
96 | 104 | } else { |
97 | | - post_data = "rs=" + encodeURIComponent(func_name); |
98 | | - for (i = 0; i < args.length; i++) |
99 | | - post_data = post_data + "&rsargs[]=" + encodeURIComponent(args[i]); |
| 105 | + post_data = 'rs=' + encodeURIComponent( func_name ); |
| 106 | + for ( i = 0; i < args.length; i++ ) { |
| 107 | + post_data = post_data + '&rsargs[]=' + encodeURIComponent( args[i] ); |
| 108 | + } |
100 | 109 | } |
101 | 110 | x = sajax_init_object(); |
102 | | - if (!x) { |
103 | | - alert("AJAX not supported"); |
| 111 | + if ( !x ) { |
| 112 | + alert( 'AJAX not supported' ); |
104 | 113 | return false; |
105 | 114 | } |
106 | 115 | |
107 | 116 | try { |
108 | | - x.open(sajax_request_type, uri, true); |
109 | | - } catch (e) { |
110 | | - if (window.location.hostname == "localhost") { |
111 | | - alert("Your browser blocks XMLHttpRequest to 'localhost', try using a real hostname for development/testing."); |
| 117 | + x.open( sajax_request_type, uri, true ); |
| 118 | + } catch ( e ) { |
| 119 | + if ( window.location.hostname == 'localhost' ) { |
| 120 | + alert( "Your browser blocks XMLHttpRequest to 'localhost', try using a real hostname for development/testing." ); |
112 | 121 | } |
113 | 122 | throw e; |
114 | 123 | } |
115 | | - if (sajax_request_type == "POST") { |
116 | | - x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1"); |
117 | | - x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); |
| 124 | + if ( sajax_request_type == 'POST' ) { |
| 125 | + x.setRequestHeader( 'Method', 'POST ' + uri + ' HTTP/1.1' ); |
| 126 | + x.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' ); |
118 | 127 | } |
119 | | - x.setRequestHeader("Pragma", "cache=yes"); |
120 | | - x.setRequestHeader("Cache-Control", "no-transform"); |
| 128 | + x.setRequestHeader( 'Pragma', 'cache=yes' ); |
| 129 | + x.setRequestHeader( 'Cache-Control', 'no-transform' ); |
121 | 130 | x.onreadystatechange = function() { |
122 | | - if (x.readyState != 4) |
| 131 | + if ( x.readyState != 4 ) { |
123 | 132 | return; |
| 133 | + } |
124 | 134 | |
125 | | - sajax_debug("received (" + x.status + " " + x.statusText + ") " + x.responseText); |
| 135 | + sajax_debug( 'received (' + x.status + ' ' + x.statusText + ') ' + x.responseText ); |
126 | 136 | |
127 | | - //if (x.status != 200) |
128 | | - // alert("Error: " + x.status + " " + x.statusText + ": " + x.responseText); |
| 137 | + //if ( x.status != 200 ) |
| 138 | + // alert( 'Error: ' + x.status + ' ' + x.statusText + ': ' + x.responseText ); |
129 | 139 | //else |
130 | 140 | |
131 | 141 | if ( typeof( target ) == 'function' ) { |
132 | 142 | target( x ); |
133 | | - } |
134 | | - else if ( typeof( target ) == 'object' ) { |
| 143 | + } else if ( typeof( target ) == 'object' ) { |
135 | 144 | if ( target.tagName == 'INPUT' ) { |
136 | | - if (x.status == 200) target.value= x.responseText; |
137 | | - //else alert("Error: " + x.status + " " + x.statusText + " (" + x.responseText + ")"); |
| 145 | + if ( x.status == 200 ) { |
| 146 | + target.value= x.responseText; |
| 147 | + } |
| 148 | + //else alert( 'Error: ' + x.status + ' ' + x.statusText + ' (' + x.responseText + ')' ); |
| 149 | + } else { |
| 150 | + if ( x.status == 200 ) { |
| 151 | + target.innerHTML = x.responseText; |
| 152 | + } else { |
| 153 | + target.innerHTML = '<div class="error">Error: ' + x.status + |
| 154 | + ' ' + x.statusText + ' (' + x.responseText + ')</div>'; |
| 155 | + } |
138 | 156 | } |
139 | | - else { |
140 | | - if (x.status == 200) target.innerHTML = x.responseText; |
141 | | - else target.innerHTML= "<div class='error'>Error: " + x.status + " " + x.statusText + " (" + x.responseText + ")</div>"; |
142 | | - } |
| 157 | + } else { |
| 158 | + alert( 'bad target for sajax_do_call: not a function or object: ' + target ); |
143 | 159 | } |
144 | | - else { |
145 | | - alert("bad target for sajax_do_call: not a function or object: " + target); |
146 | | - } |
147 | 160 | |
148 | 161 | return; |
149 | 162 | } |
150 | 163 | |
151 | | - sajax_debug(func_name + " uri = " + uri + " / post = " + post_data); |
152 | | - x.send(post_data); |
153 | | - sajax_debug(func_name + " waiting.."); |
| 164 | + sajax_debug( func_name + ' uri = ' + uri + ' / post = ' + post_data ); |
| 165 | + x.send( post_data ); |
| 166 | + sajax_debug( func_name + ' waiting..' ); |
154 | 167 | delete x; |
155 | 168 | |
156 | 169 | return true; |
— | — | @@ -164,4 +177,3 @@ |
165 | 178 | delete request; |
166 | 179 | return supportsAjax; |
167 | 180 | } |
168 | | - |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -1560,7 +1560,7 @@ |
1561 | 1561 | * to ensure that client-side caches do not keep obsolete copies of global |
1562 | 1562 | * styles. |
1563 | 1563 | */ |
1564 | | -$wgStyleVersion = '300'; |
| 1564 | +$wgStyleVersion = '301'; |
1565 | 1565 | |
1566 | 1566 | /** |
1567 | 1567 | * This will cache static pages for non-logged-in users to reduce |