From: Michael Dale Date: Sat, 15 Aug 2009 23:11:28 +0000 (+0000) Subject: * fixed upload interface to use jsonfm html as plain/text was not working X-Git-Tag: 1.31.0-rc.0~40282 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=c6e0f5ccc22409f7820a16a413b800b0408a5435;p=lhc%2Fweb%2Fwiklou.git * fixed upload interface to use jsonfm html as plain/text was not working --- diff --git a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js index 2be2ab6f30..9a8681e239 100644 --- a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js +++ b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js @@ -201,7 +201,7 @@ mvBaseUploadInterface.prototype = { //add json format if( $j(_this.editForm).find("[name='format']").length == 0) - $j(_this.editForm).append(''); + $j(_this.editForm).append(''); //add text format type request (IE tries to "run"/download the script otherwise) if( $j(_this.editForm).find("[name='ctypetext']").length == 0) @@ -261,34 +261,22 @@ mvBaseUploadInterface.prototype = { var doc = iframe.contentDocument ? iframe.contentDocument : frames[iframe.id].document; // fixing Opera 9.26 if (doc.readyState && doc.readyState != 'complete'){ - // Opera fires load event multiple times - // Even when the DOM is not ready yet - // this fix should not affect other browsers return; - } - + } // fixing Opera 9.64 - if (doc.body && doc.body.innerHTML == "false"){ - // In Opera 9.64 event was fired second time - // when body.innerHTML changed from false - // to server response approx. after 1 sec + if (doc.body && doc.body.innerHTML == "false"){ return; - } - - var response; - + } + var response; if (doc.XMLDocument){ // response is a xml document IE property response = doc.XMLDocument; } else if (doc.body){ - // response is html document or plain text - response = doc.body.innerHTML; - // try and parse the api response: - if (doc.body.firstChild && doc.body.firstChild.nodeName.toUpperCase() == 'PRE'){ - response = doc.body.firstChild.firstChild.nodeValue; - } - if (response) { - response = window["eval"]("(" + response + ")"); + // get the json str: + json_str = $j(doc.body).find('pre').html(); + //htmlentties + if (json_str) { + response = window["eval"]("(" +json_str + ")"); } else { response = {}; } @@ -296,6 +284,7 @@ mvBaseUploadInterface.prototype = { // response is a xml document var response = doc; } + //do proccess the api result _this.processApiResult( response ); }, doHttpUpload:function( opt ){