r55120 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55119‎ | r55120 | r55121 >
Date:23:11, 15 August 2009
Author:dale
Status:deferred
Tags:
Comment:
* fixed upload interface to use jsonfm html as plain/text was not working
Modified paths:
  • /trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js
@@ -201,7 +201,7 @@
202202
203203 //add json format
204204 if( $j(_this.editForm).find("[name='format']").length == 0)
205 - $j(_this.editForm).append('<input type="hidden" name="format" value="json">');
 205+ $j(_this.editForm).append('<input type="hidden" name="format" value="jsonfm">');
206206
207207 //add text format type request (IE tries to "run"/download the script otherwise)
208208 if( $j(_this.editForm).find("[name='ctypetext']").length == 0)
@@ -261,34 +261,22 @@
262262 var doc = iframe.contentDocument ? iframe.contentDocument : frames[iframe.id].document;
263263 // fixing Opera 9.26
264264 if (doc.readyState && doc.readyState != 'complete'){
265 - // Opera fires load event multiple times
266 - // Even when the DOM is not ready yet
267 - // this fix should not affect other browsers
268265 return;
269 - }
270 -
 266+ }
271267 // fixing Opera 9.64
272 - if (doc.body && doc.body.innerHTML == "false"){
273 - // In Opera 9.64 event was fired second time
274 - // when body.innerHTML changed from false
275 - // to server response approx. after 1 sec
 268+ if (doc.body && doc.body.innerHTML == "false"){
276269 return;
277 - }
278 -
279 - var response;
280 -
 270+ }
 271+ var response;
281272 if (doc.XMLDocument){
282273 // response is a xml document IE property
283274 response = doc.XMLDocument;
284275 } else if (doc.body){
285 - // response is html document or plain text
286 - response = doc.body.innerHTML;
287 - // try and parse the api response:
288 - if (doc.body.firstChild && doc.body.firstChild.nodeName.toUpperCase() == 'PRE'){
289 - response = doc.body.firstChild.firstChild.nodeValue;
290 - }
291 - if (response) {
292 - response = window["eval"]("(" + response + ")");
 276+ // get the json str:
 277+ json_str = $j(doc.body).find('pre').html();
 278+ //htmlentties
 279+ if (json_str) {
 280+ response = window["eval"]("(" +json_str + ")");
293281 } else {
294282 response = {};
295283 }
@@ -296,6 +284,7 @@
297285 // response is a xml document
298286 var response = doc;
299287 }
 288+ //do proccess the api result
300289 _this.processApiResult( response );
301290 },
302291 doHttpUpload:function( opt ){

Status & tagging log