r50144 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50143‎ | r50144 | r50145 >
Date:21:45, 2 May 2009
Author:thomasv
Status:ok
Tags:
Comment:
fix for external images
Modified paths:
  • /trunk/extensions/ProofreadPage/proofread.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/proofread.js
@@ -45,31 +45,24 @@
4646
4747
4848
49 -
5049 function pr_image_url(requested_width){
51 - var image_url;
 50+ var thumb_url;
5251
5352 if(self.proofreadPageExternalURL) {
54 - image_url = proofreadPageExternalURL;
 53+ thumb_url = proofreadPageViewURL;
5554 }
5655 else {
57 -
5856 //enforce quantization: width must be multiple of 100px
5957 var width = (100*requested_width)/100;
60 -
 58+ //compare to the width of the image
6159 if(width < proofreadPageWidth) {
62 - self.DisplayWidth = width;
63 - self.DisplayHeight = width*proofreadPageHeight/proofreadPageWidth;
64 - image_url = proofreadPageThumbURL.replace('##WIDTH##',""+width);
 60+ thumb_url = proofreadPageThumbURL.replace('##WIDTH##',""+width);
6561 }
6662 else {
67 - self.DisplayWidth = proofreadPageWidth;
68 - self.DisplayHeight = proofreadPageHeight;
69 - image_url = proofreadPageViewURL;
 63+ thumb_url = proofreadPageViewURL;
7064 }
7165 }
72 -
73 - return image_url;
 66+ return thumb_url;
7467 }
7568
7669
@@ -187,10 +180,7 @@
188181 var ffox=0; var ffoy=0;
189182
190183
191 -var zoomw=160;
192 -var zoomh=120;
193184
194 -
195185 /*relative coordinates of the mouse pointer*/
196186 function get_xy(evt){
197187 if(typeof(evt) == 'object') {
@@ -547,9 +537,9 @@
548538 desired_width = parseInt(window.innerWidth/2-70);
549539 }
550540 }
551 - //this function sets self.DisplayWidth and self.DisplayHeight
552541 var thumb_url = pr_image_url(desired_width);
553542
 543+ //self.DisplayHeight is known if the image is not external
554544 if(self.DisplayHeight)
555545 self.TextBoxHeight = self.DisplayHeight;
556546 else
@@ -560,14 +550,14 @@
561551 var image = document.createElement("img");
562552 image.setAttribute("src", thumb_url);
563553 image.setAttribute("id", "ProofReadImage");
 554+ image.setAttribute("width", desired_width);
564555 image.style.cssText = "padding:0;margin:0;border:0;";
565556 image_container.appendChild(image);
566557 }
567558 else{
568 - var image_url = proofreadPageViewURL;
569 - var s = "<div id=\"pr_container\" style=\"background:#000000; overflow: auto; width: 100%; height:"+self.DisplayHeight+"px;\">";
570 - s = s + "<img id=\"ProofReadImage\" src=\""+ image_url +"\" alt=\""+ image_url +"\"";
571 - s = s + " width=\"" + self.DisplayWidth +"\"></div>";
 559+ var s = "<div id=\"pr_container\" style=\"background:#000000; overflow: auto; width: "+desired_width+"px;\">";
 560+ s = s + "<img id=\"ProofReadImage\" src=\""+ proofreadPageViewURL +"\" alt=\""+ proofreadPageViewURL +"\"";
 561+ s = s + " width=\"" + desired_width +"\"></div>";
572562 image_container.innerHTML = s;
573563 document.getElementById("wpTextbox1").style.cssText = "height:"+(self.TextBoxHeight-7)+"px";
574564 pr_zoom(0);
@@ -582,7 +572,8 @@
583573 else
584574 self.vertHeight=Math.ceil(window.innerHeight*0.4);
585575
586 - var s = "<div id=\"pr_container\" style= \"background:#000000; overflow: auto; height: " + self.vertHeight + "px; width: 100%;\">";
 576+ var s = "<div id=\"pr_container\" style= \"background:#000000; overflow: auto; height: "
 577+ + self.vertHeight + "px; width: 100%;\">";
587578 s = s + "<img id=\"ProofReadImage\" src=\""+ proofreadPageViewURL +"\" alt=\""+ proofreadPageViewURL +"\"";
588579 s = s + "\"></div>";
589580
@@ -764,7 +755,8 @@
765756 re = /<span class="hiddenStructure" id="pageURL">\[http:\/\/(.*?)\]<\/span>/;
766757 m = re.exec(text.value);
767758 if( m ) {
768 - self.proofreadPageExternalURL = "http://"+m[1];
 759+ self.proofreadPageViewURL = "http://"+m[1];
 760+ self.proofreadPageExternalURL = true;
769761 }
770762 }
771763 else {
@@ -773,7 +765,8 @@
774766 try {
775767 var a = document.getElementById("pageURL");
776768 var b = a.firstChild;
777 - self.proofreadPageExternalURL = b.getAttribute("href");
 769+ self.proofreadPageViewURL = b.getAttribute("href");
 770+ self.proofreadPageExternalURL = true;
778771 } catch(err){};
779772 }
780773 //set to dummy values, not used
@@ -781,7 +774,7 @@
782775 self.proofreadPageHeight = 400;
783776 }
784777
785 - if(!self.proofreadPageViewURL && !self.proofreadPageExternalURL) return;
 778+ if(!self.proofreadPageViewURL) return;
786779
787780 if( self.proofreadpage_setup ) {
788781

Status & tagging log