r21605 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21604‎ | r21605 | r21606 >
Date:09:06, 26 April 2007
Author:thomasv
Status:old
Tags:
Comment:
non greedy regexp for page body
Modified paths:
  • /trunk/extensions/ProofreadPage/proofread.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/proofread.js
@@ -32,30 +32,37 @@
3333
3434 if(proofreadPageIsEdit) {
3535 text = document.getElementById("wpTextbox1");
36 - if (text) {
37 - text.setAttribute("style", "width:100%; height:100%;"); //width seems to be set by monobook already...
 36+ if (!text) return;
 37+ text.setAttribute("style", "width:100%; height:100%;"); //width seems to be set by monobook already...
3838
39 - re = /^(\{\{PageQuality\|[0-9][0-9*]%\}\}|)<noinclude>([\s\S]*?)<\/noinclude>([\s\S]*?)(<noinclude>([\s\S]*?)<\/noinclude>|)\n$/;
40 - m = text.value.match(re);
41 - if(m) {
42 - pageHeader = m2[2];
43 - pageBody = m2[1]+m2[3];
44 - pageFooter = m2[5];
45 - }
46 - else {
47 - pageBody = text.value;
48 - pageHeader = '';
49 - pageFooter = '';
50 - }
 39+ re = /^(\{\{PageQuality\|[0-9][0-9]%\}\}|)<noinclude>([\s\S]*?)<\/noinclude>([\s\S]*)<noinclude>([\s\S]*?)<\/noinclude>\n$/;
 40+ m = text.value.match(re);
 41+ if(m) {
 42+ pageHeader = m[2];
 43+ pageBody = m[1]+m[3];
 44+ pageFooter = m[4];
5145 }
52 - } else {
 46+ else {
 47+ re2 = /^(\{\{PageQuality\|[0-9][0-9]%\}\}|)<noinclude>([\s\S]*?)<\/noinclude>([\s\S]*?)\n$/;
 48+ m2 = text.value.match(re2);
 49+ if(m2) {
 50+ pageHeader = m2[2];
 51+ pageBody = m2[1]+m2[3];
 52+ pageFooter = '';
 53+ }
 54+ else {
 55+ pageHeader = '';
 56+ pageBody = text.value;
 57+ pageFooter = '';
 58+ }
 59+ }
 60+ }
 61+ else {
5362 text = document.getElementById("bodyContent");
 63+ if(!text) return;
5464 }
55 - if(!text) return;
5665
5766
58 -
59 -
6067 //image
6168 image = document.createElement("img");
6269 image.setAttribute("src", image_url);