Index: trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php |
— | — | @@ -119,7 +119,7 @@ |
120 | 120 | $wgJSAutoloadClasses['j.fn.hoverIntent'] = $mvjsp . 'jquery/plugins/jquery.hoverIntent.js'; |
121 | 121 | |
122 | 122 | //libAddMedia: |
123 | | - $wgJSAutoloadClasses['upFirefogg'] = $mvjsp . 'libAddMedia/firefogg.js'; |
| 123 | + $wgJSAutoloadClasses['mvFirefogg'] = $mvjsp . 'libAddMedia/mvFirefogg.js'; |
124 | 124 | $wgJSAutoloadClasses['mvUploader'] = $mvjsp . 'libAddMedia/mvUploader.js'; |
125 | 125 | $wgJSAutoloadClasses['remoteSearchDriver'] = $mvjsp . 'libAddMedia/remoteSearchDriver.js'; |
126 | 126 | $wgJSAutoloadClasses['seqRemoteSearchDriver'] = $mvjsp . 'libAddMedia/seqRemoteSearchDriver.js'; |
Index: trunk/extensions/MetavidWiki/skins/add_media_wizard.js |
— | — | @@ -44,9 +44,10 @@ |
45 | 45 | //load jQuery and what not (we need to refactor the loading system for mv_embed) |
46 | 46 | mvJsLoader.loadBaseLibs(function(){ |
47 | 47 | mvJsLoader.doLoad( { |
| 48 | + 'mvFirefogg' : 'libAddMedia/mvFirefogg.js', |
48 | 49 | 'mvUploader' : 'libAddMedia/mvUploader.js' |
49 | 50 | },function(){ |
50 | | - mvUp = new mvUploader(); |
| 51 | + mvUp = new mvUploader( { 'api_url' : wg_local_wiki_api_url } ); |
51 | 52 | }); |
52 | 53 | }); |
53 | 54 | }); |
Index: trunk/extensions/MetavidWiki/skins/mv_custom.css |
— | — | @@ -540,7 +540,7 @@ |
541 | 541 | font-size:115%;". |
542 | 542 | width:40%; |
543 | 543 | height:50%; |
544 | | - margin: -20% 10% -20% 10%; |
| 544 | + /*margin: -20% 10% -20% 10%;*/ |
545 | 545 | padding: 10px; |
546 | 546 | z-index:100; |
547 | 547 | } |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/searchLibs/mediaWikiSearch.js |
— | — | @@ -24,8 +24,7 @@ |
25 | 25 | |
26 | 26 | //build the image request object: |
27 | 27 | var reqObj = { |
28 | | - 'action':'query', |
29 | | - 'format':'json', |
| 28 | + 'action':'query', |
30 | 29 | 'generator':'search', |
31 | 30 | 'gsrsearch': encodeURIComponent( $j('#rsd_q').val() ), |
32 | 31 | 'gsrnamespace':6, //(only search the "file" namespace (audio, video, images) |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mvFirefogg.js |
— | — | @@ -4,7 +4,8 @@ |
5 | 5 | |
6 | 6 | var default_firefogg_options = { |
7 | 7 | 'upload_done_action':'redirect', |
8 | | - 'enabled':false |
| 8 | + 'enabled':false, |
| 9 | + 'api_url':false |
9 | 10 | } |
10 | 11 | var mvFirefogg = function(initObj){ |
11 | 12 | return this.init( initObj ); |
— | — | @@ -18,10 +19,11 @@ |
19 | 20 | 'maxSize': 400, |
20 | 21 | 'videoBitrate': 400 |
21 | 22 | }, |
| 23 | + formData:{}, //the form to be submited |
| 24 | + |
22 | 25 | init : function( iObj ){ |
23 | 26 | if(!iObj) |
24 | 27 | iObj = {}; |
25 | | - js_log("wtf"); |
26 | 28 | //inherit iObj properties: |
27 | 29 | for(var i in default_firefogg_options){ |
28 | 30 | if(iObj[i]){ |
— | — | @@ -45,7 +47,7 @@ |
46 | 48 | $j('#wgfogg_installed,#wgEnableFirefogg').show(); |
47 | 49 | |
48 | 50 | if( $j('#wgEnableFirefogg').length > 0 ){ |
49 | | - this.fogg = new Firefogg(); |
| 51 | + _this.fogg = new Firefogg(); |
50 | 52 | //do the version check: |
51 | 53 | if( this.fogg.version.replace(/[^0-9]/gi, '') < this.min_firefogg_version.replace(/[^0-9]/gi, '' ) ){ |
52 | 54 | //show wrong version error: |
— | — | @@ -100,7 +102,7 @@ |
101 | 103 | }, |
102 | 104 | select_fogg:function(){ |
103 | 105 | var _this = this; |
104 | | - if(_this.fogg.selectVideo()) { |
| 106 | + if( _this.fogg.selectVideo() ) { |
105 | 107 | //update destination filename: |
106 | 108 | if( _this.fogg.sourceFilename ){ |
107 | 109 | var sf = _this.fogg.sourceFilename; |
— | — | @@ -127,13 +129,14 @@ |
128 | 130 | } |
129 | 131 | |
130 | 132 | //setup the form handling |
131 | | - var editForm = $j('#mw-upload-form').get(0); |
| 133 | + _this.editForm = $j('#mw-upload-form').get(0); |
132 | 134 | |
133 | 135 | //set up the org_onsubmit if not set: |
134 | 136 | if( typeof( _this.org_onsubmit ) == 'undefined' ) |
135 | | - _this.org_onsubmit = editForm.onsubmit; |
| 137 | + _this.org_onsubmit = _this.editForm.onsubmit; |
136 | 138 | |
137 | | - editForm.onsubmit = function() { |
| 139 | + _this.editForm.onsubmit = function() { |
| 140 | + |
138 | 141 | //run the original onsubmit (if not run yet set flag to avoid excessive chaining ) |
139 | 142 | if( typeof( _this.org_onsubmit ) == 'function' ){ |
140 | 143 | if( ! _this.org_onsubmit() ){ |
— | — | @@ -141,125 +144,187 @@ |
142 | 145 | return false; |
143 | 146 | } |
144 | 147 | } |
145 | | - //get the input |
146 | | - //var formData = _this.getEditFormData( editForm ); |
147 | | - var tmpAryData = $j( editForm ).serializeArray(); |
| 148 | + //get the input form data in flat json: |
| 149 | + var tmpAryData = $j( _this.editForm ).serializeArray(); |
148 | 150 | for(var i=0; i < tmpAryData.length; i++){ |
149 | 151 | if( tmpAryData[i]['name'] ) |
150 | | - formData[ mpAryData[i]['name'] ] = mpAryData[i]['value']; |
151 | | - } |
152 | | - |
| 152 | + _this.formData[ tmpAryData[i]['name'] ] = tmpAryData[i]['value']; |
| 153 | + } |
| 154 | + //hard code a value |
| 155 | + _this.formData['wpSourceType']='file'; |
| 156 | + |
153 | 157 | //display the loader: |
154 | 158 | $j('#dlbox-centered,#dlbox-overlay').show(); |
155 | 159 | |
156 | 160 | //for some unknown reason we have to drop down the #p-search z-index: |
157 | 161 | $j('#p-search').css('z-index', 1); |
158 | 162 | |
159 | | - //check the upload mode: |
160 | | - if( _this.upload_mode == 'autodetect'){ |
161 | | - |
162 | | - }else{ |
163 | | - |
164 | | - } |
165 | | - var options = JSON.stringify( _this.encoder_settings ); |
166 | | - _this.fogg.encode(options); |
167 | | - |
168 | | - var encodingStatus = function() { |
169 | | - var status = _this.fogg.status(); |
| 163 | + //select upload mode: |
| 164 | + _this.doUploadSwitch(); |
| 165 | + //don't submit the form (firefogg will handle that) |
| 166 | + return false; |
| 167 | + } |
| 168 | + } |
| 169 | + }, |
| 170 | + doUploadSwitch:function(){ |
| 171 | + var _this = this; |
| 172 | + //check the upload mode: |
| 173 | + if( _this.upload_mode == 'autodetect' ){ |
| 174 | + if( ! _this.api_url ) |
| 175 | + return js_error( 'Error: can\'t autodetect mode without api url' ); |
| 176 | + do_api_req( { |
| 177 | + 'data':{ 'action':'paraminfo','modules':'upload' }, |
| 178 | + 'url':_this.api_url |
| 179 | + }, function(data){ |
| 180 | + if( typeof data.paraminfo == 'undefined' || typeof data.paraminfo.modules == 'undefined' ) |
| 181 | + return js_error( 'Error: bad api results' ); |
| 182 | + if( typeof data.paraminfo.modules[0].classname == 'undefined'){ |
| 183 | + js_log( 'Autodetect Upload Mode: \'post\' '); |
| 184 | + _this.upload_mode = 'post'; |
| 185 | + }else{ |
| 186 | + for( var i in data.paraminfo.modules[0].parameters ){ |
| 187 | + var pname = data.paraminfo.modules[0].parameters[i].name; |
| 188 | + if( pname == 'chunks' ){ |
| 189 | + js_log( 'Autodetect Upload Mode: chunks ' ); |
| 190 | + _this.upload_mode = 'chunks'; |
| 191 | + break; |
| 192 | + } |
| 193 | + } |
| 194 | + //somewhat verbose |
| 195 | + if( _this.upload_mode != 'chunks'){ |
| 196 | + return js_error('Upload API without chunks param is not supported'); |
| 197 | + } |
| 198 | + } |
| 199 | + _this.doUploadSwitch(); |
| 200 | + }); |
| 201 | + }else if( _this.upload_mode == 'post') { |
| 202 | + _this.doEncUpload(); |
| 203 | + }else if( _this.upload_mode == 'chunks'){ |
| 204 | + _this.doChunkUpload(); |
| 205 | + }else{ |
| 206 | + js_error( 'Error: unrecongized upload mode: ' + _this.upload_mode ); |
| 207 | + } |
| 208 | + }, |
| 209 | + //doChunkUpload does both uploading and encoding at the same time and uploads one meg chunks as they are ready |
| 210 | + doChunkUpload : function(){ |
| 211 | + var _this = this; |
| 212 | + _this.fogg.upload( JSON.stringify( _this.encoder_settings ), _this.editForm.action , JSON.stringify( _this.formData ) ); |
| 213 | + //update upload status: |
| 214 | + _this.doUploadStatus(); |
| 215 | + }, |
| 216 | + //doEncUpload first encodes then uploads |
| 217 | + doEncUpload : function(){ |
| 218 | + var _this = this; |
| 219 | + _this.fogg.encode( JSON.stringify( _this.encoder_settings ) ); |
| 220 | + |
| 221 | + //setup a local function for timed callback: |
| 222 | + var encodingStatus = function() { |
| 223 | + var status = _this.fogg.status(); |
170 | 224 | |
171 | | - //update progress bar |
172 | | - _this.fogg_update_progress( _this.fogg.progress() ); |
| 225 | + //update progress bar |
| 226 | + _this.fogg_update_progress( _this.fogg.progress() ); |
173 | 227 | |
174 | | - //loop to get new status if still encoding |
175 | | - if( _this.fogg.state == 'encoding' ) { |
176 | | - setTimeout(encodingStatus, 500); |
177 | | - } |
178 | | - //encoding done, state can also be 'encoding failed' |
179 | | - else if ( _this.fogg.state == 'encoding done' ) { |
180 | | - //hide the fogg-status-transcode |
181 | | - $j('#fogg-status-transcode').hide(); |
| 228 | + //loop to get new status if still encoding |
| 229 | + if( _this.fogg.state == 'encoding' ) { |
| 230 | + setTimeout(encodingStatus, 500); |
| 231 | + }else if ( _this.fogg.state == 'encoding done' ) { //encoding done, state can also be 'encoding failed' |
| 232 | + //now call the upload function |
| 233 | + |
| 234 | + //hide the fogg-status-transcode |
| 235 | + $j('#fogg-status-transcode').hide(); |
182 | 236 | |
183 | | - //show the fogg-status-upload |
184 | | - $j('#fogg-status-upload').show(); |
185 | | - |
186 | | - //hard code some values |
187 | | - formData['wpSourceType']='file'; |
188 | | - |
189 | | - var data = JSON.stringify( formData ); |
190 | | - //send to the post url: |
191 | | - _this.fogg.post( editForm.action, 'wpUploadFile', data); |
192 | | - var uploadStatus = function() { |
193 | | - var status = _this.fogg.status(); |
194 | | - //js_log(' up stats: ' + status + ' p:' + _this.fogg.progress() + ' state: '+ _this.fogg.state + ' result page:' + result_page); |
195 | | - |
196 | | - //update progress bar |
197 | | - _this.fogg_update_progress( _this.fogg.progress() ); |
198 | | - |
199 | | - //loop to get new status if still uploading |
200 | | - if(_this.fogg.state == 'uploading') { |
201 | | - setTimeout(uploadStatus, 500); |
202 | | - } |
203 | | - //upload sucesfull, state can also be 'upload failed' |
204 | | - else if( _this.fogg.state == 'upload done' ) { |
205 | | - //js_log( 'firefogg:upload done: '); |
206 | | - //@@todo handle errors same problem as #695 in remoteSearchDriver.js |
207 | | - //we need to add image uploading to the api rather than parse the HTML output of the pages |
208 | | - var result_page = _this.fogg.responseText; |
209 | | - var sstring = 'var wgTitle = "' + formData['wpDestFile'].replace('_',' '); |
210 | | - if( result_page && result_page.toLowerCase().indexOf( sstring.toLowerCase() ) != -1){ |
211 | | - js_log('upload done got redirect found: ' +sstring + ' r:' + _this.upload_done_action); |
212 | | - if( _this.upload_done_action == 'redirect'){ |
213 | | - window.location = wgArticlePath.replace(/\$1/, 'File:' + formData['wpDestFile'] ); |
214 | | - }else{ |
215 | | - //check if the add_done_action is a callback: |
216 | | - if( typeof _this.upload_done_action == 'function' ) |
217 | | - _this.upload_done_action(); |
218 | | - } |
219 | | - }else{ |
220 | | - js_log('upload page error: did not find: ' +sstring); |
221 | | - var error_txt = 'Unkown error'; |
222 | | - if(!result_page){ |
223 | | - //@@todo fix this: |
224 | | - //the mediaWiki upload system does not have an API so we can\'t accuratly read errors |
225 | | - error_txt = 'Your upload should be accessible <a href="' + |
226 | | - wgArticlePath.replace(/\$1/, 'File:' + formData['wpDestFile'] ) + '">'+ |
227 | | - 'here</a> \n'; |
228 | | - }else{ |
229 | | - sp = result_page.indexOf('<span class="error">'); |
230 | | - if(sp!=-1){ |
231 | | - se = result_page.indexOf('</span>', sp); |
232 | | - error_txt = result_page.substr(sp, (sp-se)); |
233 | | - }else{ |
234 | | - //look for warning: |
235 | | - sp = result_page.indexOf('<ul class="warning">') |
236 | | - if(sp!=-1){ |
237 | | - se = result_page.indexOf('</ul>', sp); |
238 | | - error_txt = result_page.substr(sp, (sp-se)); |
239 | | - } |
240 | | - } |
241 | | - } |
242 | | - e = document.getElementById('dlbox-centered'); |
243 | | - if(e) |
244 | | - e.innerHTML = '<h3>Upload Completed:</h3>' + error_txt; |
245 | | - } |
246 | | - } |
247 | | - //upload error: |
248 | | - else{ |
249 | | - alert('firefogg upload error: ' + _this.fogg.state); |
250 | | - } |
251 | | - } |
252 | | - uploadStatus(); |
253 | | - }else if(_this.fogg.state == 'encoding fail'){ |
254 | | - //@@todo error handling: |
255 | | - alert('encoding failed'); |
256 | | - } |
257 | | - } |
258 | | - encodingStatus(); |
259 | | - //don't submit the form (let firefogg handle it) |
260 | | - return false; |
261 | | - }; //addHandler mapping |
262 | | - }else{ |
263 | | - //remove upload binding if no file was selected |
264 | | - } |
265 | | - } |
| 237 | + //show the fogg-status-upload |
| 238 | + $j('#fogg-status-upload').show(); |
| 239 | + |
| 240 | + //send to the post url: |
| 241 | + _this.fogg.post( _this.editForm.action, 'wpUploadFile', JSON.stringify( _this.formData ) ); |
| 242 | + //update upload status: |
| 243 | + _this.doUploadStatus(); |
| 244 | + }else if(_this.fogg.state == 'encoding fail'){ |
| 245 | + //@@todo error handling: |
| 246 | + alert('encoding failed'); |
| 247 | + } |
| 248 | + } |
| 249 | + encodingStatus(); |
| 250 | + }, |
| 251 | + doUploadStatus:function() { |
| 252 | + var _this = this; |
| 253 | + //setup a local function for timed callback: |
| 254 | + var uploadStatus = function(){ |
| 255 | + var status = _this.fogg.status(); |
| 256 | + js_log(' up stats: ' + status + ' p:' + _this.fogg.progress() + ' state: '+ _this.fogg.state + ' result page:' + _this.fogg.responseText); |
| 257 | + |
| 258 | + //update progress bar |
| 259 | + _this.fogg_update_progress( _this.fogg.progress() ); |
| 260 | + |
| 261 | + //loop to get new status if still uploading (could also be encoding if we are in chunk upload mode) |
| 262 | + if( _this.fogg.state == 'encoding' || _this.fogg.state == 'uploading') { |
| 263 | + setTimeout(uploadStatus, 500); |
| 264 | + } |
| 265 | + //check upload state |
| 266 | + else if( _this.fogg.state == 'upload done' || _this.fogg.state == 'done' ) { |
| 267 | + js_log( 'firefogg:upload done: '); |
| 268 | + //@@todo handle errors same problem as #695 in remoteSearchDriver.js |
| 269 | + |
| 270 | + //if in "post" upload mode read the html response: |
| 271 | + if( _this.upload_mode == 'post' ) { |
| 272 | + //var foo = _this; |
| 273 | + //var cat = _this.fogg.responseText; |
| 274 | + //var cat_json = eval('var result =' + _this.fogg.responseText ); |
| 275 | + //debugger; |
| 276 | + js_log('done upload response is:' + _this.fogg.responseText ); |
| 277 | + _this.procPageResponse( _this.fogg.responseText ); |
| 278 | + }else if( _this.upload_mode == 'chunks'){ |
| 279 | + //should have an json result:\ |
| 280 | + var foo = _this; |
| 281 | + var cat = _this.fogg.responseText; |
| 282 | + var cat_json = eval('var result =' + _this.fogg.responseText ); |
| 283 | + debugger; |
| 284 | + } |
| 285 | + } |
| 286 | + //upload error: |
| 287 | + else{ |
| 288 | + alert('firefogg upload error: ' + _this.fogg.state ); |
| 289 | + } |
| 290 | + } |
| 291 | + uploadStatus(); |
| 292 | + }, |
| 293 | + procPageResponse:function( result_page ){ |
| 294 | + js_log('f:procPageResponse'); |
| 295 | + var sstring = 'var wgTitle = "' + this.formData['wpDestFile'].replace('_',' '); |
| 296 | + if( result_page && result_page.toLowerCase().indexOf( sstring.toLowerCase() ) != -1){ |
| 297 | + js_log( 'upload done got redirect found: ' + sstring + ' r:' + _this.upload_done_action ); |
| 298 | + if( _this.upload_done_action == 'redirect' ){ |
| 299 | + window.location = wgArticlePath.replace( /\$1/, 'File:' + formData['wpDestFile'] ); |
| 300 | + }else{ |
| 301 | + //check if the add_done_action is a callback: |
| 302 | + if( typeof _this.upload_done_action == 'function' ) |
| 303 | + _this.upload_done_action(); |
| 304 | + } |
| 305 | + }else{ |
| 306 | + js_log( 'upload page error: did not find: ' +sstring + ' in ' + "\n" + result_page ); |
| 307 | + var error_txt = 'Unkown error'; |
| 308 | + if( !result_page ){ |
| 309 | + //@@todo fix this: |
| 310 | + //the mediaWiki upload system does not have an API so we can\'t acuratly read errors |
| 311 | + error_txt = 'Your upload should be accessible <a href="' + |
| 312 | + wgArticlePath.replace(/\$1/, 'File:' + this.formData['wpDestFile'] ) + '">'+ |
| 313 | + 'here</a> \n'; |
| 314 | + }else{ |
| 315 | + sp = result_page.indexOf('<span class="error">'); |
| 316 | + if(sp!=-1){ |
| 317 | + se = result_page.indexOf('</span>', sp); |
| 318 | + error_txt = result_page.substr(sp, (sp-se)); |
| 319 | + }else{ |
| 320 | + //look for warning: |
| 321 | + sp = result_page.indexOf('<ul class="warning">') |
| 322 | + if(sp!=-1){ |
| 323 | + se = result_page.indexOf('</ul>', sp); |
| 324 | + error_txt = result_page.substr(sp, (sp-se)); |
| 325 | + } |
| 326 | + } |
| 327 | + } |
| 328 | + $j( '#dlbox-centered' ).html( '<h3>Upload Completed:</h3>' + error_txt); |
| 329 | + } |
| 330 | + } |
266 | 331 | } |
\ No newline at end of file |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/remoteSearchDriver.js |
— | — | @@ -420,8 +420,7 @@ |
421 | 421 | var _this = this; |
422 | 422 | reqObj={ |
423 | 423 | 'action':'query', |
424 | | - 'titles': _this.cFileNS + ':' + rTitle, |
425 | | - 'format':'json' |
| 424 | + 'titles': _this.cFileNS + ':' + rTitle |
426 | 425 | }; |
427 | 426 | do_api_req( { |
428 | 427 | 'data':reqObj, |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mvUploader.js |
— | — | @@ -16,7 +16,8 @@ |
17 | 17 | |
18 | 18 | var default_upload_options = { |
19 | 19 | 'target_div':'', |
20 | | - 'upload_done_action':'redirect' |
| 20 | + 'upload_done_action':'redirect', |
| 21 | + 'api_url':false |
21 | 22 | } |
22 | 23 | |
23 | 24 | var mvUploader = function(initObj){ |
— | — | @@ -89,6 +90,8 @@ |
90 | 91 | _this.upload_done_action( rTitle ); |
91 | 92 | } |
92 | 93 | }; |
| 94 | + if( _this.api_url ) |
| 95 | + intFirefoggObj['api_url'] = _this.api_url; |
93 | 96 | js_log('new mvFirefogg'); |
94 | 97 | //if firefog is not taking over the submit we can here: |
95 | 98 | _this.fogg = new mvFirefogg( intFirefoggObj ); |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mvSequencer.js |
— | — | @@ -452,7 +452,6 @@ |
453 | 453 | if(typeof this.sequenceEditToken == 'undefined'){ |
454 | 454 | var reqObj = { |
455 | 455 | 'action':'query', |
456 | | - 'format':'json', |
457 | 456 | 'prop':'info', |
458 | 457 | 'intoken':'edit', |
459 | 458 | 'titles': this_seq.plObj.mTitle |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/mvClipEdit.js |
— | — | @@ -184,7 +184,6 @@ |
185 | 185 | if(_this.media_type == 'template' && !_this.rObj.tVars){ |
186 | 186 | mv_set_loading('#sub_cliplib_ic'); |
187 | 187 | var reqObj ={ 'action':'query', |
188 | | - 'format':'json', |
189 | 188 | 'prop':'revisions', |
190 | 189 | 'titles': _this.rObj.uri, |
191 | 190 | 'rvprop':'content' |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js |
— | — | @@ -1067,7 +1067,7 @@ |
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | //does a remote or local api request based on request url |
1071 | | -//@param : url, data, cbParam, callback |
| 1071 | +//@param options: url, data, cbParam, callback |
1072 | 1072 | function do_api_req( options, callback ){ |
1073 | 1073 | if(typeof options.data != 'object'){ |
1074 | 1074 | js_log('Error: request paramaters must be an object'); |
— | — | @@ -1083,9 +1083,14 @@ |
1084 | 1084 | options.url = options.url.replace('index.php', 'api.php'); |
1085 | 1085 | } |
1086 | 1086 | if(typeof options.data == 'undefined') |
1087 | | - options.data = {}; |
1088 | | - //build request string: (force the format to json): |
1089 | | - if( parseUri(document.URL).host == parseUri( options['api_url'] ).host ){ |
| 1087 | + options.data = {}; |
| 1088 | + |
| 1089 | + //set the format to json (if not already set) |
| 1090 | + if(typeof options.data['format'] == 'undefined') |
| 1091 | + options.data['format'] = 'json'; |
| 1092 | + |
| 1093 | + //build request string: |
| 1094 | + if( parseUri( document.URL ).host == parseUri( options['api_url'] ).host ){ |
1090 | 1095 | //local request do api request directly |
1091 | 1096 | $j.ajax({ |
1092 | 1097 | type: "POST", |
— | — | @@ -1097,8 +1102,10 @@ |
1098 | 1103 | } |
1099 | 1104 | }); |
1100 | 1105 | }else{ |
| 1106 | + //set the callback param if not already set: |
1101 | 1107 | if( typeof options.jsonCB == 'undefined') |
1102 | 1108 | options.jsonCB = 'callback'; |
| 1109 | + |
1103 | 1110 | var req_url = options.url; |
1104 | 1111 | var paramAnd = (req_url.indexOf('?')==-1)?'?':'&'; |
1105 | 1112 | //put all the values into the GET req: |
— | — | @@ -1306,5 +1313,6 @@ |
1307 | 1314 | |
1308 | 1315 | function js_error(string){ |
1309 | 1316 | alert(string); |
| 1317 | + return false; |
1310 | 1318 | } |
1311 | 1319 | |