Index: trunk/extensions/ProofreadPage/proofread_index.js |
— | — | @@ -1,123 +1,135 @@ |
2 | 2 | // Author : ThomasV - License : GPL |
3 | 3 | |
4 | | -//the index template is a sytem message. |
5 | | -//another message in i18n lists the parameters |
6 | | - |
7 | | -function findparam(str2, param_name) { |
8 | | - var pattern = "\\n\\|"+param_name+"=([\\s\\S]*?)\\n\\|([^=\\n\\|]+)="; |
9 | | - var re2 = new RegExp(pattern); |
10 | | - var m2 = str2.match(re2); |
11 | | - if(m2) return m2[1]; |
| 4 | +// the index template is a system message. |
| 5 | +// another message in i18n lists the parameters |
| 6 | +function findparam( str2, param_name ) { |
| 7 | + var pattern = "\\n\\|" + param_name + "=([\\s\\S]*?)\\n\\|([^=\\n\\|]+)="; |
| 8 | + var re2 = new RegExp( pattern ); |
| 9 | + var m2 = str2.match( re2 ); |
| 10 | + if( m2 ) { |
| 11 | + return m2[1]; |
| 12 | + } |
12 | 13 | return ''; |
13 | 14 | } |
14 | 15 | |
15 | 16 | function proofreadpage_index_init() { |
| 17 | + var toolbar = document.getElementById( 'toolbar' ); |
| 18 | + if( toolbar ) { |
| 19 | + toolbar.parentNode.removeChild( toolbar ); |
| 20 | + } |
16 | 21 | |
17 | | - var toolbar = document.getElementById("toolbar"); |
18 | | - if(toolbar) toolbar.parentNode.removeChild(toolbar); |
| 22 | + var text = document.getElementById( 'wpTextbox1' ); |
| 23 | + if( !text ) { |
| 24 | + return; |
| 25 | + } |
19 | 26 | |
20 | | - var text = document.getElementById("wpTextbox1"); |
21 | | - if(!text) return; |
22 | | - |
23 | 27 | params = ''; |
24 | | - if(text.value) { |
| 28 | + if( text.value ) { |
25 | 29 | var re = /\{\{:MediaWiki:Proofreadpage_index_template([\s\S]*)\n\}\}/m; |
26 | | - var m = text.value.match(re); |
27 | | - if(!m) return; |
28 | | - params = m[1]+'\n\|END='; |
| 30 | + var m = text.value.match( re ); |
| 31 | + if( !m ) { |
| 32 | + return; |
| 33 | + } |
| 34 | + params = m[1] + '\n\|END='; |
29 | 35 | } |
30 | | - |
| 36 | + |
31 | 37 | // Certain extensions, like UsabilityInitiative, wrap the textarea |
32 | 38 | var textWrapper = text; |
33 | | - while(textWrapper.parentNode.nodeName != 'FORM') textWrapper = textWrapper.parentNode; |
| 39 | + while( textWrapper.parentNode.nodeName != 'FORM' ) { |
| 40 | + textWrapper = textWrapper.parentNode; |
| 41 | + } |
34 | 42 | var f = textWrapper.parentNode; |
35 | | - var container = document.createElement("div"); |
36 | | - var wrapper = document.createElement("div"); |
| 43 | + var container = document.createElement( 'div' ); |
| 44 | + var wrapper = document.createElement( 'div' ); |
37 | 45 | wrapper.style.display = 'none'; |
38 | | - container.appendChild(wrapper); |
39 | | - wrapper.appendChild(textWrapper); |
| 46 | + container.appendChild( wrapper ); |
| 47 | + wrapper.appendChild( textWrapper ); |
40 | 48 | |
41 | | - var index_attributes = self.prp_index_attributes.split('\n'); |
| 49 | + var index_attributes = self.prp_index_attributes.split( '\n' ); |
42 | 50 | var str = '<table>'; |
43 | | - for(i=0;i<index_attributes.length;i++){ |
44 | | - m = index_attributes[i].split('|'); |
| 51 | + for( i = 0; i < index_attributes.length; i++ ) { |
| 52 | + m = index_attributes[i].split( '|' ); |
45 | 53 | param_name = m[0]; |
46 | 54 | |
47 | | - if(m[1]) param_label=m[1]; else param_label=param_name; |
48 | | - str += '<tr><td>'+param_label+': </td>'; |
| 55 | + if( m[1] ) { |
| 56 | + param_label = m[1]; |
| 57 | + } else { |
| 58 | + param_label = param_name; |
| 59 | + } |
| 60 | + str += '<tr><td>' + param_label + ': </td>'; |
49 | 61 | |
50 | | - value = findparam(params,param_name); |
51 | | - value = value.replace(/\{\{!\}\}/g,'|'); |
| 62 | + value = findparam( params, param_name ); |
| 63 | + value = value.replace( /\{\{!\}\}/g, '|' ); |
52 | 64 | |
53 | | - if( (m[0]=="Header") && (value=="") ) value = prp_default_header; |
54 | | - if( (m[0]=="Footer") && (value=="") ) value = prp_default_footer; |
| 65 | + if( ( m[0] == 'Header' ) && ( value == '' ) ) { |
| 66 | + value = prp_default_header; |
| 67 | + } |
| 68 | + if( ( m[0] == 'Footer' ) && ( value == '' ) ) { |
| 69 | + value = prp_default_footer; |
| 70 | + } |
55 | 71 | |
56 | | - if(m[2]) size=m[2]; else size="1"; |
57 | | - if(size=="1") { |
58 | | - str += '<td><input name="'+param_name+'" size=60 value="'+value+'"/></td></tr>'; |
| 72 | + if( m[2] ) { |
| 73 | + size = m[2]; |
| 74 | + } else { |
| 75 | + size = '1'; |
59 | 76 | } |
60 | | - else{ |
61 | | - str += '<td><textarea name="'+param_name+'" cols=60 rows='+size+'>'+value+'</textarea></td></tr>'; |
| 77 | + if( size == '1' ) { |
| 78 | + str += '<td><input name="' + param_name + '" size=60 value="' + value + '"/></td></tr>'; |
| 79 | + } else { |
| 80 | + str += '<td><textarea name="' + param_name + '" cols=60 rows=' + size + '>' + value + '</textarea></td></tr>'; |
62 | 81 | } |
63 | 82 | } |
64 | 83 | str += '</table>'; |
65 | 84 | container.innerHTML += str; |
66 | 85 | |
67 | | - var saveButton = document.getElementById("wpSave"); |
68 | | - var previewButton = document.getElementById("wpPreview"); |
69 | | - var diffButton = document.getElementById("wpDiff"); |
70 | | - if(saveButton){ |
| 86 | + var saveButton = document.getElementById( 'wpSave' ); |
| 87 | + var previewButton = document.getElementById( 'wpPreview' ); |
| 88 | + var diffButton = document.getElementById( 'wpDiff' ); |
| 89 | + if( saveButton ) { |
71 | 90 | saveButton.onclick = proofreadpage_fill_index; |
72 | 91 | previewButton.onclick = proofreadpage_fill_index; |
73 | 92 | diffButton.onclick = proofreadpage_fill_index; |
74 | | - } |
75 | | - else { |
76 | | - container.firstChild.nextSibling.setAttribute("readonly","readonly"); |
| 93 | + } else { |
| 94 | + container.firstChild.nextSibling.setAttribute( 'readonly', 'readonly' ); |
77 | 95 | } |
78 | 96 | |
79 | | - copywarn = document.getElementById("editpage-copywarn"); |
80 | | - f.insertBefore(container,copywarn); |
81 | | - |
| 97 | + copywarn = document.getElementById( 'editpage-copywarn' ); |
| 98 | + f.insertBefore( container, copywarn ); |
82 | 99 | } |
83 | 100 | |
84 | 101 | function proofreadpage_fill_index() { |
85 | | - var form = document.getElementById("editform"); |
86 | | - var result = "{{:MediaWiki:Proofreadpage_index_template"; |
87 | | - var index_attributes = self.prp_index_attributes.split('\n'); |
| 102 | + var form = document.getElementById( 'editform' ); |
| 103 | + var result = '{{:MediaWiki:Proofreadpage_index_template'; |
| 104 | + var index_attributes = self.prp_index_attributes.split( '\n' ); |
88 | 105 | |
89 | | - for(i=0;i<index_attributes.length;i++){ |
90 | | - m = index_attributes[i].split('|'); |
| 106 | + for( i = 0; i < index_attributes.length; i++ ) { |
| 107 | + m = index_attributes[i].split( '|' ); |
91 | 108 | param_name = m[0]; |
92 | 109 | |
93 | 110 | value = form.elements[param_name].value; |
94 | | - //remove trailing \n |
95 | | - value = value.replace(/\n$/,''); |
| 111 | + // remove trailing \n |
| 112 | + value = value.replace( /\n$/, '' ); |
96 | 113 | |
97 | | - //replace pipe symbol everywhere... |
98 | | - value = value.replace(/\|/g,'{{!}}'); |
| 114 | + // replace pipe symbol everywhere... |
| 115 | + value = value.replace( /\|/g, '{{!}}' ); |
99 | 116 | |
100 | | - //...except in links... |
101 | | - do { |
102 | | - prev = value; |
103 | | - value = value.replace(/\[\[(.*?)\{\{!\}\}(.*?)\]\]/g,'[[$1|$2]]'); |
104 | | - } |
105 | | - while (value != prev); |
| 117 | + // ...except in links... |
| 118 | + do { |
| 119 | + prev = value; |
| 120 | + value = value.replace( /\[\[(.*?)\{\{!\}\}(.*?)\]\]/g, '[[$1|$2]]' ); |
| 121 | + } while ( value != prev ); |
106 | 122 | |
107 | | - //..and in templates |
108 | | - do { |
109 | | - prev = value; |
110 | | - value = value.replace(/\{\{(.*?)\{\{!\}\}(.*?)\}\}/g,'{{$1|$2}}'); |
111 | | - } |
112 | | - while (value != prev); |
| 123 | + // ..and in templates |
| 124 | + do { |
| 125 | + prev = value; |
| 126 | + value = value.replace( /\{\{(.*?)\{\{!\}\}(.*?)\}\}/g, '{{$1|$2}}' ); |
| 127 | + } while ( value != prev ); |
113 | 128 | |
114 | | - result = result + "\n|"+param_name+"="+value; |
| 129 | + result = result + '\n|' + param_name + '=' + value; |
115 | 130 | } |
116 | 131 | result = result + "\n}}"; |
117 | | - form.elements["wpTextbox1"].value = result; |
| 132 | + form.elements['wpTextbox1'].value = result; |
118 | 133 | } |
119 | 134 | |
120 | | - |
121 | | - |
122 | | - |
123 | | -//use hookevent instead of addOnLoadHook, so that the code is evalued after wikibits.js |
124 | | -hookEvent("load", proofreadpage_index_init); |
| 135 | +// use hookevent instead of addOnLoadHook, so that the code is evaluated after wikibits.js |
| 136 | +hookEvent( 'load', proofreadpage_index_init ); |
\ No newline at end of file |
Index: trunk/extensions/ProofreadPage/proofread.js |
— | — | @@ -1,199 +1,207 @@ |
2 | 2 | // Author : ThomasV - License : GPL |
3 | 3 | |
| 4 | +function pr_init_tabs() { |
| 5 | + var a = document.getElementById( 'p-namespaces' ); |
| 6 | + if( !a ) { |
| 7 | + a = document.getElementById( 'p-cactions' ); |
| 8 | + } |
4 | 9 | |
5 | | -function pr_init_tabs(){ |
6 | | - var a = document.getElementById("p-namespaces"); |
7 | | - if(!a) a = document.getElementById("p-cactions"); |
| 10 | + if ( !a ) { |
| 11 | + return; |
| 12 | + } |
| 13 | + var b = a.getElementsByTagName( 'ul' ); |
| 14 | + if ( !b ) { |
| 15 | + return; |
| 16 | + } |
8 | 17 | |
9 | | - if (!a) return; |
10 | | - var b = a.getElementsByTagName("ul"); |
11 | | - if (!b) return; |
12 | | - |
13 | 18 | if( self.proofreadPageThumbURL ) { |
14 | | - var view_url = self.proofreadPageThumbURL.replace('##WIDTH##',"" + self.proofreadPageWidth ); |
15 | | - b[0].innerHTML = b[0].innerHTML |
16 | | - + '<li id="ca-image">' |
17 | | - + '<span><a href="' + escapeQuotesHTML( view_url ) + '">' |
18 | | - + escapeQuotesHTML(proofreadPageMessageImage) + '</a></span></li>'; |
| 19 | + var view_url = self.proofreadPageThumbURL.replace( '##WIDTH##', '' + self.proofreadPageWidth ); |
| 20 | + b[0].innerHTML = b[0].innerHTML + '<li id="ca-image">' + |
| 21 | + '<span><a href="' + escapeQuotesHTML( view_url ) + '">' + |
| 22 | + escapeQuotesHTML( proofreadPageMessageImage ) + '</a></span></li>'; |
19 | 23 | } |
20 | 24 | |
21 | | - if(self.proofreadPageIndexURL){ |
22 | | - b[0].innerHTML = b[0].innerHTML |
23 | | - + '<li id="ca-index">' |
24 | | - + '<span><a href="' + escapeQuotesHTML(proofreadPageIndexURL) |
25 | | - + '" title="' + escapeQuotesHTML(proofreadPageMessageIndex) + '">' |
26 | | - + '<img src="' + wgScriptPath + '/extensions/ProofreadPage/uparrow.png" alt="' |
27 | | - + escapeQuotesHTML(proofreadPageMessageIndex) |
28 | | - + '" width="15" height="15" /></a></span></li>'; |
| 25 | + if( self.proofreadPageIndexURL ) { |
| 26 | + b[0].innerHTML = b[0].innerHTML + '<li id="ca-index">' + |
| 27 | + '<span><a href="' + escapeQuotesHTML( proofreadPageIndexURL ) + |
| 28 | + '" title="' + escapeQuotesHTML( proofreadPageMessageIndex ) + '">' + |
| 29 | + '<img src="' + wgScriptPath + '/extensions/ProofreadPage/uparrow.png" alt="' + |
| 30 | + escapeQuotesHTML( proofreadPageMessageIndex ) + |
| 31 | + '" width="15" height="15" /></a></span></li>'; |
29 | 32 | } |
30 | 33 | |
31 | | - if(self.proofreadPageNextURL){ |
32 | | - b[0].innerHTML = |
33 | | - '<li id="ca-next">' |
34 | | - + '<span><a href="' + escapeQuotesHTML(self.proofreadPageNextURL) |
35 | | - + '" title="' + escapeQuotesHTML(proofreadPageMessageNextPage) + '">' |
36 | | - + '<img src="' + wgScriptPath + '/extensions/ProofreadPage/rightarrow.png" alt="' |
37 | | - + escapeQuotesHTML(proofreadPageMessageNextPage) |
38 | | - + '" width="15" height="15" /></a></span></li>' |
39 | | - + b[0].innerHTML ; |
| 34 | + if( self.proofreadPageNextURL ) { |
| 35 | + b[0].innerHTML = '<li id="ca-next">' + |
| 36 | + '<span><a href="' + escapeQuotesHTML( self.proofreadPageNextURL ) + |
| 37 | + '" title="' + escapeQuotesHTML( proofreadPageMessageNextPage ) + '">' + |
| 38 | + '<img src="' + wgScriptPath + '/extensions/ProofreadPage/rightarrow.png" alt="' + |
| 39 | + escapeQuotesHTML( proofreadPageMessageNextPage ) + |
| 40 | + '" width="15" height="15" /></a></span></li>' + |
| 41 | + b[0].innerHTML; |
40 | 42 | } |
41 | 43 | |
42 | | - if(self.proofreadPagePrevURL){ |
43 | | - b[0].innerHTML = |
44 | | - '<li id="ca-prev">' |
45 | | - + '<span><a href="' + escapeQuotesHTML(self.proofreadPagePrevURL) |
46 | | - + '" title="' + escapeQuotesHTML(proofreadPageMessagePrevPage) + '">' |
47 | | - + '<img src="' + wgScriptPath + '/extensions/ProofreadPage/leftarrow.png" alt="' |
48 | | - + escapeQuotesHTML(proofreadPageMessagePrevPage) |
49 | | - + '" width="15" height="15" /></a></span></li>' |
50 | | - + b[0].innerHTML ; |
51 | | - } |
| 44 | + if( self.proofreadPagePrevURL ) { |
| 45 | + b[0].innerHTML = '<li id="ca-prev">' + |
| 46 | + '<span><a href="' + escapeQuotesHTML( self.proofreadPagePrevURL ) + |
| 47 | + '" title="' + escapeQuotesHTML( proofreadPageMessagePrevPage ) + '">' + |
| 48 | + '<img src="' + wgScriptPath + '/extensions/ProofreadPage/leftarrow.png" alt="' + |
| 49 | + escapeQuotesHTML( proofreadPageMessagePrevPage ) + |
| 50 | + '" width="15" height="15" /></a></span></li>' + |
| 51 | + b[0].innerHTML; |
| 52 | + } |
52 | 53 | } |
53 | 54 | |
54 | | - |
55 | | - |
56 | | - |
57 | | -function pr_image_url(requested_width){ |
58 | | - if(self.proofreadPageExternalURL) { |
| 55 | +function pr_image_url( requested_width ) { |
| 56 | + if( self.proofreadPageExternalURL ) { |
59 | 57 | self.DisplayWidth = requested_width; |
60 | | - self.DisplayHeight = ""; |
| 58 | + self.DisplayHeight = ''; |
61 | 59 | return self.proofreadPageExternalURL; |
62 | | - } |
63 | | - else { |
64 | | - //enforce quantization: width must be multiple of 100px |
65 | | - var width = 100 * Math.round( requested_width /100 ); |
66 | | - //compare to the width of the image |
| 60 | + } else { |
| 61 | + // enforce quantization: width must be multiple of 100px |
| 62 | + var width = 100 * Math.round( requested_width / 100 ); |
| 63 | + // compare to the width of the image |
67 | 64 | width = Math.min( width, proofreadPageWidth ); |
68 | 65 | self.DisplayWidth = width; |
69 | | - self.DisplayHeight = width*proofreadPageHeight/proofreadPageWidth; |
70 | | - return proofreadPageThumbURL.replace( '##WIDTH##', "" + width ); |
| 66 | + self.DisplayHeight = width * proofreadPageHeight / proofreadPageWidth; |
| 67 | + return proofreadPageThumbURL.replace( '##WIDTH##', '' + width ); |
71 | 68 | } |
72 | 69 | } |
73 | 70 | |
74 | | - |
75 | | - |
76 | | -function pr_make_edit_area(container,text){ |
77 | | - |
| 71 | +function pr_make_edit_area( container, text ) { |
78 | 72 | re = /^<noinclude>([\s\S]*?)\n*<\/noinclude>([\s\S]*)<noinclude>([\s\S]*?)<\/noinclude>\n$/; |
79 | | - m = text.match(re); |
80 | | - if(m) { |
| 73 | + m = text.match( re ); |
| 74 | + if( m ) { |
81 | 75 | pageHeader = m[1]; |
82 | 76 | pageBody = m[2]; |
83 | 77 | pageFooter = m[3]; |
84 | | - } |
85 | | - else { |
| 78 | + } else { |
86 | 79 | re2 = /^<noinclude>([\s\S]*?)\n*<\/noinclude>([\s\S]*?)\n$/; |
87 | | - m2 = text.match(re2); |
88 | | - if(m2) { |
| 80 | + m2 = text.match( re2 ); |
| 81 | + if( m2 ) { |
89 | 82 | pageHeader = m2[1]; |
90 | | - //apparently lookahead is not supported by all browsers |
91 | | - //so let us do another regexp |
| 83 | + // apparently lookahead is not supported by all browsers |
| 84 | + // so let us do another regexp |
92 | 85 | re3 = /^([\s\S]*?)<noinclude>([\s\S]*?)<\/noinclude>/; |
93 | | - m3 = m2[2].match(re3); |
94 | | - if(m3){ |
| 86 | + m3 = m2[2].match( re3 ); |
| 87 | + if( m3 ) { |
95 | 88 | pageBody = m3[1]; |
96 | 89 | pageFooter = m3[2]; |
97 | | - } |
98 | | - else{ |
| 90 | + } else { |
99 | 91 | pageBody = m2[2]; |
100 | 92 | pageFooter = ''; |
101 | 93 | } |
102 | | - } |
103 | | - else { |
| 94 | + } else { |
104 | 95 | pageHeader = proofreadPageHeader; |
105 | 96 | pageBody = text; |
106 | 97 | pageFooter = proofreadPageFooter; |
107 | | - if(document.editform) { |
108 | | - document.editform.elements["wpSummary"].value="/* "+proofreadPageMessageQuality1+" */ "; |
| 98 | + if( document.editform ) { |
| 99 | + document.editform.elements['wpSummary'].value = '/* ' + proofreadPageMessageQuality1 + ' */ '; |
109 | 100 | } |
110 | 101 | } |
111 | 102 | } |
112 | 103 | |
113 | | - //find the PageQuality template |
114 | | - //we do this separately from header detection, |
115 | | - //because the template might not be in the header |
| 104 | + // find the PageQuality template |
| 105 | + // we do this separately from header detection, |
| 106 | + // because the template might not be in the header |
116 | 107 | var reg = /<pagequality level=\"(0|1|2|3|4)\" user=\"(.*?)\" \/>/g; |
117 | | - var m4 = reg.exec(pageHeader); |
| 108 | + var m4 = reg.exec( pageHeader ); |
118 | 109 | var old_reg = /\{\{PageQuality\|(0|1|2|3|4)(\|(.*?|))\}\}/g; |
119 | | - var old_m4 = old_reg.exec(pageHeader); |
| 110 | + var old_m4 = old_reg.exec( pageHeader ); |
120 | 111 | if( m4 ) { |
121 | 112 | switch( m4[1] ) { |
122 | | - case "0": self.proofreadpage_quality = 0; break; |
123 | | - case "1": self.proofreadpage_quality = 1; break; |
124 | | - case "2": self.proofreadpage_quality = 2; break; |
125 | | - case "3": self.proofreadpage_quality = 3; break; |
126 | | - case "4": self.proofreadpage_quality = 4; break; |
127 | | - default: self.proofreadpage_quality = 1; |
| 113 | + case '0': |
| 114 | + self.proofreadpage_quality = 0; |
| 115 | + break; |
| 116 | + case '1': |
| 117 | + self.proofreadpage_quality = 1; |
| 118 | + break; |
| 119 | + case '2': |
| 120 | + self.proofreadpage_quality = 2; |
| 121 | + break; |
| 122 | + case '3': |
| 123 | + self.proofreadpage_quality = 3; |
| 124 | + break; |
| 125 | + case '4': |
| 126 | + self.proofreadpage_quality = 4; |
| 127 | + break; |
| 128 | + default: |
| 129 | + self.proofreadpage_quality = 1; |
128 | 130 | } |
129 | 131 | self.proofreadpage_username = m4[2]; |
130 | | - pageHeader = pageHeader.replace(reg,''); |
131 | | - } |
132 | | - else if (old_m4 ) { |
| 132 | + pageHeader = pageHeader.replace( reg, '' ); |
| 133 | + } else if ( old_m4 ) { |
133 | 134 | switch( old_m4[1] ) { |
134 | | - case "0": self.proofreadpage_quality = 0; break; |
135 | | - case "1": self.proofreadpage_quality = 1; break; |
136 | | - case "2": self.proofreadpage_quality = 2; break; |
137 | | - case "3": self.proofreadpage_quality = 3; break; |
138 | | - case "4": self.proofreadpage_quality = 4; break; |
139 | | - default: self.proofreadpage_quality = 1; |
| 135 | + case '0': |
| 136 | + self.proofreadpage_quality = 0; |
| 137 | + break; |
| 138 | + case '1': |
| 139 | + self.proofreadpage_quality = 1; |
| 140 | + break; |
| 141 | + case '2': |
| 142 | + self.proofreadpage_quality = 2; |
| 143 | + break; |
| 144 | + case '3': |
| 145 | + self.proofreadpage_quality = 3; |
| 146 | + break; |
| 147 | + case '4': |
| 148 | + self.proofreadpage_quality = 4; |
| 149 | + break; |
| 150 | + default: |
| 151 | + self.proofreadpage_quality = 1; |
140 | 152 | } |
141 | 153 | self.proofreadpage_username = old_m4[3]; |
142 | | - pageHeader = pageHeader.replace(old_reg,''); |
| 154 | + pageHeader = pageHeader.replace( old_reg, '' ); |
| 155 | + } else { |
| 156 | + self.proofreadpage_quality = 1; |
| 157 | + self.proofreadpage_username = ''; |
143 | 158 | } |
144 | | - else { |
145 | | - self.proofreadpage_quality = 1; |
146 | | - self.proofreadpage_username = ""; |
| 159 | + // detect the container div |
| 160 | + if( pageHeader.match( "^<div class=\"pagetext\">" ) && pageFooter.match( "</div>$" ) ) { |
| 161 | + pageHeader = pageHeader.substr( 22, pageHeader.length ); |
| 162 | + pageFooter = pageFooter.substr( 0, pageFooter.length - 6 ); |
147 | 163 | } |
148 | | - //detect the container div |
149 | | - if( pageHeader.match("^<div class=\"pagetext\">") && pageFooter.match("</div>$") ) { |
150 | | - pageHeader = pageHeader.substr(22,pageHeader.length); |
151 | | - pageFooter = pageFooter.substr(0,pageFooter.length-6); |
152 | | - } |
153 | 164 | |
154 | | - //escape & character |
155 | | - pageBody = pageBody.split("&").join("&") |
156 | | - pageHeader = pageHeader.split("&").join("&") |
157 | | - pageFooter = pageFooter.split("&").join("&") |
| 165 | + // escape & character |
| 166 | + pageBody = pageBody.split( '&' ).join( '&' ); |
| 167 | + pageHeader = pageHeader.split( '&' ).join( '&' ); |
| 168 | + pageFooter = pageFooter.split( '&' ).join( '&' ); |
158 | 169 | |
159 | | - container.innerHTML = '' |
160 | | - + '<div id="prp_header" style="">' |
161 | | - + '<span style="color:gray;font-size:80%;line-height:100%;">' |
162 | | - + escapeQuotesHTML(proofreadPageMessageHeader) + '</span>' |
163 | | - + '<textarea name="wpHeaderTextbox" rows="2" cols="80" tabindex=1>' + pageHeader + '</textarea><br/>' |
164 | | - + '<span style="color:gray;font-size:80%;line-height:100%;">' |
165 | | - + escapeQuotesHTML(proofreadPageMessagePageBody) + '</span></div>' |
166 | | - + '<textarea name="wpTextbox1" id="wpTextbox1" tabindex=1 style="height:' + ( self.DisplayHeight - 6 ) + 'px;">' + pageBody + '</textarea>' |
167 | | - + '<div id="prp_footer" style="">' |
168 | | - + '<span style="color:gray;font-size:80%;line-height:100%;">' |
169 | | - + escapeQuotesHTML(proofreadPageMessageFooter) + '</span><br/>' |
170 | | - + '<textarea name="wpFooterTextbox" rows="2" cols="80" tabindex=1>'+pageFooter+'</textarea></div>'; |
171 | | - |
172 | | - |
| 170 | + container.innerHTML = '' + |
| 171 | + '<div id="prp_header" style="">' + |
| 172 | + '<span style="color:gray;font-size:80%;line-height:100%;">' + |
| 173 | + escapeQuotesHTML( proofreadPageMessageHeader ) + '</span>' + |
| 174 | + '<textarea name="wpHeaderTextbox" rows="2" cols="80" tabindex=1>' + pageHeader + '</textarea><br />' + |
| 175 | + '<span style="color:gray;font-size:80%;line-height:100%;">' + |
| 176 | + escapeQuotesHTML( proofreadPageMessagePageBody ) + '</span></div>' + |
| 177 | + '<textarea name="wpTextbox1" id="wpTextbox1" tabindex=1 style="height:' + ( self.DisplayHeight - 6 ) + 'px;">' + |
| 178 | + pageBody + '</textarea>' + |
| 179 | + '<div id="prp_footer" style="">' + |
| 180 | + '<span style="color:gray;font-size:80%;line-height:100%;">' + |
| 181 | + escapeQuotesHTML( proofreadPageMessageFooter ) + '</span><br />' + |
| 182 | + '<textarea name="wpFooterTextbox" rows="2" cols="80" tabindex=1>' + |
| 183 | + pageFooter + '</textarea></div>'; |
173 | 184 | } |
174 | 185 | |
175 | | - |
176 | 186 | function pr_reset_size() { |
177 | | - |
178 | | - var box = document.getElementById("wpTextbox1"); |
179 | | - var h = document.getElementById("prp_header"); |
180 | | - var f = document.getElementById("prp_footer"); |
181 | | - if( h.style.cssText == 'display:none;') { |
182 | | - box.style.cssText = "height:" + ( self.DisplayHeight - 6 ) + "px"; |
| 187 | + var box = document.getElementById( 'wpTextbox1' ); |
| 188 | + var h = document.getElementById( 'prp_header' ); |
| 189 | + var f = document.getElementById( 'prp_footer' ); |
| 190 | + if( h.style.cssText == 'display:none;' ) { |
| 191 | + box.style.cssText = 'height:' + ( self.DisplayHeight - 6 ) + 'px'; |
183 | 192 | } else { |
184 | 193 | if( self.pr_horiz ) { |
185 | | - box.style.cssText = "height:" + ( self.DisplayHeight - 6 ) + "px"; |
| 194 | + box.style.cssText = 'height:' + ( self.DisplayHeight - 6 ) + 'px'; |
186 | 195 | } else { |
187 | | - box.style.cssText = "height:" + ( self.DisplayHeight - 6 - h.offsetHeight - f.offsetHeight) + "px"; |
| 196 | + box.style.cssText = 'height:' + ( self.DisplayHeight - 6 - h.offsetHeight - f.offsetHeight ) + 'px'; |
188 | 197 | } |
189 | 198 | } |
190 | 199 | } |
191 | 200 | |
192 | 201 | function pr_toggle_visibility() { |
193 | | - |
194 | | - var box = document.getElementById("wpTextbox1"); |
195 | | - var h = document.getElementById("prp_header"); |
196 | | - var f = document.getElementById("prp_footer"); |
197 | | - if( h.style.cssText == ''){ |
| 202 | + var box = document.getElementById( 'wpTextbox1' ); |
| 203 | + var h = document.getElementById( 'prp_header' ); |
| 204 | + var f = document.getElementById( 'prp_footer' ); |
| 205 | + if( h.style.cssText == '' ) { |
198 | 206 | h.style.cssText = 'display:none'; |
199 | 207 | f.style.cssText = 'display:none'; |
200 | 208 | } else { |
— | — | @@ -204,191 +212,189 @@ |
205 | 213 | } |
206 | 214 | |
207 | 215 | function pr_toggle_layout() { |
208 | | - |
209 | 216 | self.pr_horiz = ! self.pr_horiz; |
210 | 217 | pr_fill_table(); |
211 | 218 | pr_reset_size(); |
212 | | - pr_zoom(0); |
| 219 | + pr_zoom( 0 ); |
213 | 220 | } |
214 | 221 | |
215 | | - |
216 | | - |
217 | | - |
218 | | - |
219 | 222 | /* |
220 | | - * Mouse Zoom. Credits: http://valid.tjp.hu/zoom/ |
| 223 | + * Mouse Zoom. Credits: http://valid.tjp.hu/zoom/ |
221 | 224 | */ |
222 | 225 | |
223 | 226 | // global vars |
224 | 227 | var lastxx, lastyy, xx, yy; |
225 | 228 | |
226 | | -var zp_clip; //zp_clip is the large image |
| 229 | +var zp_clip; // zp_clip is the large image |
227 | 230 | var zp_container; |
228 | 231 | |
229 | | -var zoomamount_h=2; |
230 | | -var zoomamount_w=2; |
231 | | -var zoomamount=2; |
232 | | -var zoom_status=''; |
| 232 | +var zoomamount_h = 2; |
| 233 | +var zoomamount_w = 2; |
| 234 | +var zoomamount = 2; |
| 235 | +var zoom_status = ''; |
233 | 236 | |
234 | | -var ieox=0; var ieoy=0; |
235 | | -var ffox=0; var ffoy=0; |
| 237 | +var ieox = 0; |
| 238 | +var ieoy = 0; |
| 239 | +var ffox = 0; |
| 240 | +var ffoy = 0; |
236 | 241 | |
237 | | - |
238 | | - |
239 | | -/*relative coordinates of the mouse pointer*/ |
240 | | -function get_xy(evt){ |
241 | | - |
242 | | - if(typeof(evt) == 'object') { |
243 | | - evt = evt?evt:window.event?window.event:null; if(!evt){ return false;} |
244 | | - if(evt.pageX) { |
245 | | - xx=evt.pageX - ffox; |
246 | | - yy=evt.pageY - ffoy; |
| 242 | +/* relative coordinates of the mouse pointer */ |
| 243 | +function get_xy( evt ) { |
| 244 | + if( typeof( evt ) == 'object' ) { |
| 245 | + evt = evt ? evt : window.event ? window.event : null; |
| 246 | + if( !evt ) { |
| 247 | + return false; |
247 | 248 | } |
248 | | - else { |
249 | | - xx=evt.clientX - ieox; |
250 | | - yy=evt.clientY - ieoy; |
| 249 | + if( evt.pageX ) { |
| 250 | + xx = evt.pageX - ffox; |
| 251 | + yy = evt.pageY - ffoy; |
| 252 | + } else { |
| 253 | + xx = evt.clientX - ieox; |
| 254 | + yy = evt.clientY - ieoy; |
251 | 255 | } |
| 256 | + } else { |
| 257 | + xx = lastxx; |
| 258 | + yy = lastyy; |
252 | 259 | } |
253 | | - else { |
254 | | - xx = lastxx; |
255 | | - yy = lastyy; |
256 | | - } |
257 | | - lastxx = xx; |
| 260 | + lastxx = xx; |
258 | 261 | lastyy = yy; |
259 | | - |
260 | 262 | } |
261 | 263 | |
262 | | -//mouse move |
263 | | -function zoom_move(evt) { |
264 | | - |
265 | | - if(zoom_status != 1) { return false;} |
266 | | - evt = evt?evt:window.event?window.event:null; if(!evt){ return false;} |
267 | | - get_xy(evt); |
268 | | - zp_clip.style.margin = ((yy > objh )?(objh*(1-zoomamount_h)):(yy*(1-zoomamount_h))) + 'px 0px 0px ' |
269 | | - + ((xx > objw )?(objw*(1-zoomamount_w)):(xx*(1-zoomamount_w))) + 'px'; |
| 264 | +// mouse move |
| 265 | +function zoom_move( evt ) { |
| 266 | + if( zoom_status != 1 ) { |
| 267 | + return false; |
| 268 | + } |
| 269 | + evt = evt ? evt : window.event ? window.event : null; |
| 270 | + if( !evt ) { |
| 271 | + return false; |
| 272 | + } |
| 273 | + get_xy( evt ); |
| 274 | + zp_clip.style.margin = ( ( yy > objh ) ? ( objh * ( 1 - zoomamount_h ) ) : |
| 275 | + ( yy * ( 1 - zoomamount_h ) ) ) + 'px 0px 0px ' + |
| 276 | + ( ( xx > objw ) ? ( objw * ( 1 - zoomamount_w ) ) : |
| 277 | + ( xx * ( 1 - zoomamount_w ) ) ) + 'px'; |
270 | 278 | return false; |
271 | 279 | } |
272 | 280 | |
273 | | - |
274 | | - |
275 | | - |
276 | | - |
277 | | - |
278 | 281 | function zoom_off() { |
279 | | - zp_container.style.width='0px'; |
280 | | - zp_container.style.height='0px'; |
| 282 | + zp_container.style.width = '0px'; |
| 283 | + zp_container.style.height = '0px'; |
281 | 284 | zoom_status = 0; |
282 | 285 | } |
283 | 286 | |
284 | | - |
285 | | - |
286 | | - |
287 | 287 | function countoffset() { |
288 | | - zme=document.getElementById("pr_container"); |
289 | | - ieox=0; ieoy=0; |
290 | | - for(zmi=0;zmi<50;zmi++) { |
291 | | - if(zme+1 == 1) { |
| 288 | + zme = document.getElementById( 'pr_container' ); |
| 289 | + ieox = 0; |
| 290 | + ieoy = 0; |
| 291 | + for( zmi = 0; zmi < 50; zmi++ ) { |
| 292 | + if( zme+1 == 1 ) { |
292 | 293 | break; |
293 | | - } |
294 | | - else { |
295 | | - ieox+=zme.offsetLeft; |
296 | | - ieoy+=zme.offsetTop; |
| 294 | + } else { |
| 295 | + ieox += zme.offsetLeft; |
| 296 | + ieoy += zme.offsetTop; |
297 | 297 | } |
298 | | - zme=zme.offsetParent; |
| 298 | + zme=zme.offsetParent; |
299 | 299 | } |
300 | | - ffox=ieox; |
301 | | - ffoy=ieoy; |
302 | | - ieox-=document.body.scrollLeft; |
303 | | - ieoy-=document.body.scrollTop; |
| 300 | + ffox = ieox; |
| 301 | + ffoy = ieoy; |
| 302 | + ieox -= document.body.scrollLeft; |
| 303 | + ieoy -= document.body.scrollTop; |
304 | 304 | } |
305 | 305 | |
| 306 | +function zoom_mouseup( evt ) { |
| 307 | + evt = evt ? evt : window.event ? window.event : null; |
| 308 | + if( !evt ) { |
| 309 | + return false; |
| 310 | + } |
306 | 311 | |
307 | | - |
308 | | - |
309 | | -function zoom_mouseup(evt) { |
310 | | - |
311 | | - evt = evt?evt:window.event?window.event:null; if(!evt){ return false;} |
312 | | - |
313 | | - //only left button; see http://unixpapa.com/js/mouse.html for why it is this complicated |
314 | | - if(evt.which == null) { |
315 | | - if(evt.button != 1) return false; |
| 312 | + // only left button; see http://unixpapa.com/js/mouse.html for why it is this complicated |
| 313 | + if( evt.which == null) { |
| 314 | + if( evt.button != 1 ) { |
| 315 | + return false; |
| 316 | + } |
316 | 317 | } else { |
317 | | - if(evt.which > 1) return false; |
| 318 | + if( evt.which > 1 ) { |
| 319 | + return false; |
| 320 | + } |
318 | 321 | } |
319 | 322 | |
320 | | - if(zoom_status == 0) { |
321 | | - zoom_on(evt); |
| 323 | + if( zoom_status == 0 ) { |
| 324 | + zoom_on( evt ); |
322 | 325 | return false; |
323 | | - } |
324 | | - else if(zoom_status == 1) { |
| 326 | + } else if( zoom_status == 1 ) { |
325 | 327 | zoom_status = 2; |
326 | 328 | return false; |
327 | | - } |
328 | | - else if(zoom_status == 2) { |
329 | | - zoom_off(); |
| 329 | + } else if( zoom_status == 2 ) { |
| 330 | + zoom_off(); |
330 | 331 | return false; |
331 | 332 | } |
332 | 333 | return false; |
333 | 334 | } |
334 | 335 | |
| 336 | +function zoom_on( evt ) { |
| 337 | + evt = evt ? evt : window.event ? window.event : null; |
| 338 | + if( !evt ) { |
| 339 | + return false; |
| 340 | + } |
| 341 | + zoom_status = 1; |
335 | 342 | |
336 | | -function zoom_on(evt) { |
337 | | - evt = evt?evt:window.event?window.event:null; if(!evt){ return false;} |
338 | | - zoom_status=1; |
339 | | - |
340 | | - if(evt.pageX) { |
| 343 | + if( evt.pageX ) { |
341 | 344 | countoffset(); |
342 | | - lastxx=evt.pageX - ffox; |
343 | | - lastyy=evt.pageY - ffoy; |
344 | | - } |
345 | | - else { |
| 345 | + lastxx = evt.pageX - ffox; |
| 346 | + lastyy = evt.pageY - ffoy; |
| 347 | + } else { |
346 | 348 | countoffset(); |
347 | | - lastxx=evt.clientX - ieox; |
348 | | - lastyy=evt.clientY - ieoy; |
| 349 | + lastxx = evt.clientX - ieox; |
| 350 | + lastyy = evt.clientY - ieoy; |
349 | 351 | } |
350 | 352 | |
351 | | - zoomamount_h = zp_clip.height/objh; |
352 | | - zoomamount_w = zp_clip.width/objw; |
| 353 | + zoomamount_h = zp_clip.height / objh; |
| 354 | + zoomamount_w = zp_clip.width / objw; |
353 | 355 | |
354 | | - zp_container.style.width = objw+'px'; |
355 | | - zp_container.style.height = objh+'px'; |
356 | | - zp_clip.style.margin = ((lastyy > objh )?(objh*(1-zoomamount_h)):(lastyy*(1-zoomamount_h))) + 'px 0px 0px ' |
357 | | - + ((lastxx > objw )?(objw*(1-zoomamount_w)):(lastxx*(1-zoomamount_w))) + 'px'; |
| 356 | + zp_container.style.width = objw + 'px'; |
| 357 | + zp_container.style.height = objh + 'px'; |
| 358 | + zp_clip.style.margin = ( ( lastyy > objh ) ? ( objh * ( 1 - zoomamount_h ) ) : |
| 359 | + ( lastyy * ( 1 - zoomamount_h ) ) ) + 'px 0px 0px ' + |
| 360 | + ( ( lastxx > objw ) ? ( objw * ( 1 - zoomamount_w ) ) : ( lastxx * ( 1 - zoomamount_w ) ) ) + 'px'; |
358 | 361 | |
359 | 362 | return false; |
360 | 363 | } |
361 | 364 | |
362 | 365 | |
363 | 366 | //zoom using two images (magnification glass) |
364 | | -function pr_initzoom(){ |
365 | | - if(proofreadPageIsEdit) return; |
366 | | - if( !self.proofreadPageThumbURL ) return; |
367 | | - if(self.DisplayWidth>800) return; |
| 367 | +function pr_initzoom() { |
| 368 | + if( proofreadPageIsEdit ) { |
| 369 | + return; |
| 370 | + } |
| 371 | + if( !self.proofreadPageThumbURL ) { |
| 372 | + return; |
| 373 | + } |
| 374 | + if( self.DisplayWidth > 800 ) { |
| 375 | + return; |
| 376 | + } |
368 | 377 | |
369 | | - zp = document.getElementById("pr_container"); |
370 | | - if(zp){ |
371 | | - var hires_url = pr_image_url(800); |
| 378 | + zp = document.getElementById( 'pr_container' ); |
| 379 | + if( zp ) { |
| 380 | + var hires_url = pr_image_url( 800 ); |
372 | 381 | self.objw = zp.firstChild.width; |
373 | 382 | self.objh = zp.firstChild.height; |
374 | 383 | |
375 | 384 | zp.onmouseup = zoom_mouseup; |
376 | 385 | zp.onmousemove = zoom_move; |
377 | | - zp_container = document.createElement("div"); |
378 | | - zp_container.style.cssText ="position:absolute; width:0; height:0; overflow:hidden;"; |
379 | | - zp_clip = document.createElement("img"); |
380 | | - zp_clip.setAttribute("src", hires_url); |
381 | | - zp_clip.style.cssText = "padding:0;margin:0;border:0;"; |
382 | | - zp_container.appendChild(zp_clip); |
383 | | - zp.insertBefore(zp_container,zp.firstChild); |
384 | | - |
| 386 | + zp_container = document.createElement( 'div' ); |
| 387 | + zp_container.style.cssText = 'position:absolute; width:0; height:0; overflow:hidden;'; |
| 388 | + zp_clip = document.createElement( 'img' ); |
| 389 | + zp_clip.setAttribute( 'src', hires_url ); |
| 390 | + zp_clip.style.cssText = 'padding:0;margin:0;border:0;'; |
| 391 | + zp_container.appendChild( zp_clip ); |
| 392 | + zp.insertBefore( zp_container, zp.firstChild ); |
385 | 393 | } |
386 | 394 | } |
387 | 395 | |
388 | | - |
389 | | - |
390 | 396 | /******************************** |
391 | 397 | * new zoom : mouse wheel |
392 | | - * |
| 398 | + * |
393 | 399 | ********************************/ |
394 | 400 | |
395 | 401 | /* width and margin of the scan */ |
— | — | @@ -408,49 +414,64 @@ |
409 | 415 | /* size of the window */ |
410 | 416 | var pr_width = 0, pr_height = 0; |
411 | 417 | |
412 | | -function set_container_css(show_scrollbars){ |
413 | | - var sl = pr_container.scrollLeft;//read scrollbar values |
| 418 | +function set_container_css( show_scrollbars ) { |
| 419 | + var sl = pr_container.scrollLeft; // read scrollbar values |
414 | 420 | var st = pr_container.scrollTop; |
415 | | - if(show_scrollbars) { |
416 | | - self.container_css = self.container_css.replace("overflow:hidden","overflow:auto"); |
417 | | - self.container_css = self.container_css.replace("cursor:crosshair","cursor:default"); |
418 | | - //we should check if the sb is going to be shown |
419 | | - if(margin_x<0) { sl = - Math.round(margin_x); margin_x=0; } |
420 | | - if(margin_y<0) { st = - Math.round(margin_y); margin_y=0; } |
| 421 | + if( show_scrollbars ) { |
| 422 | + self.container_css = self.container_css.replace( 'overflow:hidden', 'overflow:auto' ); |
| 423 | + self.container_css = self.container_css.replace( 'cursor:crosshair', 'cursor:default' ); |
| 424 | + // we should check if the sb is going to be shown |
| 425 | + if( margin_x < 0 ) { |
| 426 | + sl = - Math.round( margin_x ); |
| 427 | + margin_x = 0; |
| 428 | + } |
| 429 | + if( margin_y < 0 ) { |
| 430 | + st = - Math.round( margin_y ); |
| 431 | + margin_y = 0; |
| 432 | + } |
421 | 433 | } else { |
422 | | - self.container_css = self.container_css.replace("overflow:auto","overflow:hidden"); |
423 | | - self.container_css = self.container_css.replace("cursor:default","cursor:crosshair"); |
424 | | - if(sl) { |
| 434 | + self.container_css = self.container_css.replace( 'overflow:auto', 'overflow:hidden' ); |
| 435 | + self.container_css = self.container_css.replace( 'cursor:default', 'cursor:crosshair' ); |
| 436 | + if( sl ) { |
425 | 437 | margin_x -= sl; |
426 | 438 | sl = 0; |
427 | 439 | } |
428 | | - if(st) { |
| 440 | + if( st ) { |
429 | 441 | margin_y -= st; |
430 | 442 | st = 0; |
431 | 443 | } |
432 | 444 | } |
433 | | - pr_set_margins(margin_x, margin_y, false); |
| 445 | + pr_set_margins( margin_x, margin_y, false ); |
434 | 446 | pr_container.scrollLeft = sl; |
435 | 447 | pr_container.scrollTop = st; |
436 | | - |
437 | 448 | } |
438 | 449 | |
439 | | -function pr_drop(evt){ |
440 | | - evt = evt?evt:window.event?window.event:null; if(!evt){ return false;} |
441 | | - get_xy(evt); if(xx>pr_container.offsetWidth-20 || yy>pr_container.offsetHeight-20) return false; |
| 450 | +function pr_drop( evt ) { |
| 451 | + evt = evt ? evt : window.event ? window.event : null; |
| 452 | + if( !evt ) { |
| 453 | + return false; |
| 454 | + } |
| 455 | + get_xy( evt ); |
| 456 | + if( xx > pr_container.offsetWidth - 20 || yy > pr_container.offsetHeight - 20 ) { |
| 457 | + return false; |
| 458 | + } |
442 | 459 | |
443 | 460 | document.onmouseup = null; |
444 | 461 | document.onmousemove = null; |
445 | 462 | document.onmousedown = null; |
446 | 463 | pr_container.onmousemove = pr_move; |
447 | | - if( is_drag==false ) { |
| 464 | + if( is_drag == false ) { |
448 | 465 | is_zoom = !is_zoom; |
449 | 466 | } else { |
450 | | - if(is_zoom) { |
451 | | - is_zoom=false; |
452 | | - if(boxWidth*boxWidth+boxHeight*boxHeight >= 2500){ |
453 | | - var ratio_x = Math.abs( pr_container.offsetWidth/self.boxWidth ); |
454 | | - pr_set_margins( (margin_x - xMin)*ratio_x, (margin_y - yMin)*ratio_x, img_width*ratio_x ) ; |
| 467 | + if( is_zoom ) { |
| 468 | + is_zoom = false; |
| 469 | + if( boxWidth * boxWidth + boxHeight * boxHeight >= 2500 ) { |
| 470 | + var ratio_x = Math.abs( pr_container.offsetWidth / self.boxWidth ); |
| 471 | + pr_set_margins( |
| 472 | + ( margin_x - xMin ) * ratio_x, |
| 473 | + ( margin_y - yMin ) * ratio_x, |
| 474 | + img_width * ratio_x |
| 475 | + ); |
455 | 476 | } |
456 | 477 | } |
457 | 478 | } |
— | — | @@ -460,34 +481,43 @@ |
461 | 482 | return false; |
462 | 483 | } |
463 | 484 | |
464 | | -function pr_grab(evt){ |
465 | | - evt = evt?evt:window.event?window.event:null; if(!evt){ return false;} |
466 | | - get_xy(evt); if(xx>pr_container.offsetWidth-20 || yy>pr_container.offsetHeight-20) return false; |
| 485 | +function pr_grab( evt ) { |
| 486 | + evt = evt ? evt : window.event ? window.event : null; |
| 487 | + if( !evt ) { |
| 488 | + return false; |
| 489 | + } |
| 490 | + get_xy( evt ); |
| 491 | + if( xx > pr_container.offsetWidth - 20 || yy > pr_container.offsetHeight - 20 ) { |
| 492 | + return false; |
| 493 | + } |
467 | 494 | |
468 | | - //only left button; see http://unixpapa.com/js/mouse.html for why it is this complicated |
469 | | - if(evt.which == null) { |
470 | | - if(evt.button != 1) return false; |
| 495 | + // only left button; see http://unixpapa.com/js/mouse.html for why it is this complicated |
| 496 | + if( evt.which == null ) { |
| 497 | + if( evt.button != 1 ) { |
| 498 | + return false; |
| 499 | + } |
471 | 500 | } else { |
472 | | - if(evt.which > 1) return false; |
| 501 | + if( evt.which > 1 ) { |
| 502 | + return false; |
| 503 | + } |
473 | 504 | } |
474 | 505 | |
475 | | - document.onmousedown = function(){return false;}; |
| 506 | + document.onmousedown = function() { return false; }; |
476 | 507 | document.onmousemove = pr_drag; |
477 | 508 | document.onmouseup = pr_drop; |
478 | 509 | pr_container.onmousemove = pr_drag; |
479 | 510 | |
480 | | - if(evt.pageX) { |
| 511 | + if( evt.pageX ) { |
481 | 512 | countoffset(); |
482 | | - lastxx=evt.pageX - ffox; |
483 | | - lastyy=evt.pageY - ffoy; |
484 | | - } |
485 | | - else { |
| 513 | + lastxx = evt.pageX - ffox; |
| 514 | + lastyy = evt.pageY - ffoy; |
| 515 | + } else { |
486 | 516 | countoffset(); |
487 | | - lastxx=evt.clientX - ieox; |
488 | | - lastyy=evt.clientY - ieoy; |
| 517 | + lastxx = evt.clientX - ieox; |
| 518 | + lastyy = evt.clientY - ieoy; |
489 | 519 | } |
490 | | - |
491 | | - if(is_zoom){ |
| 520 | + |
| 521 | + if( is_zoom ) { |
492 | 522 | init_x = - margin_x + lastxx; |
493 | 523 | init_y = - margin_y + lastyy; |
494 | 524 | } else { |
— | — | @@ -496,22 +526,29 @@ |
497 | 527 | } |
498 | 528 | is_drag = false; |
499 | 529 | return false; |
500 | | - |
501 | 530 | } |
502 | 531 | |
503 | | - |
504 | | -function pr_move(evt) { |
505 | | - evt = evt?evt:window.event?window.event:null; if(!evt){ return false;} |
| 532 | +function pr_move( evt ) { |
| 533 | + evt = evt ? evt : window.event ? window.event : null; |
| 534 | + if( !evt ) { |
| 535 | + return false; |
| 536 | + } |
506 | 537 | countoffset(); |
507 | 538 | get_xy(evt); |
508 | 539 | } |
509 | 540 | |
510 | | -function pr_drag(evt) { |
511 | | - evt = evt?evt:window.event?window.event:null; if(!evt){ return false;} |
512 | | - get_xy(evt); if(xx>pr_container.offsetWidth-20 || yy>pr_container.offsetHeight-20) return false; |
513 | | - if(!is_zoom) { |
514 | | - pr_container.scrollLeft = (init_x-xx); |
515 | | - pr_container.scrollTop = (init_y-yy); |
| 541 | +function pr_drag( evt ) { |
| 542 | + evt = evt ? evt : window.event ? window.event : null; |
| 543 | + if( !evt ) { |
| 544 | + return false; |
| 545 | + } |
| 546 | + get_xy( evt ); |
| 547 | + if( xx > pr_container.offsetWidth - 20 || yy > pr_container.offsetHeight - 20 ) { |
| 548 | + return false; |
| 549 | + } |
| 550 | + if( !is_zoom ) { |
| 551 | + pr_container.scrollLeft = ( init_x - xx ); |
| 552 | + pr_container.scrollTop = ( init_y - yy ); |
516 | 553 | } else { |
517 | 554 | self.xMin = Math.min( init_x + margin_x, xx ); |
518 | 555 | self.yMin = Math.min( init_y + margin_y, yy ); |
— | — | @@ -519,437 +556,477 @@ |
520 | 557 | self.yMax = Math.max( init_y + margin_y, yy ); |
521 | 558 | self.boxWidth = Math.max( xMax-xMin, 1 ); |
522 | 559 | self.boxHeight = Math.max( yMax-yMin, 1 ); |
523 | | - if(boxWidth*boxWidth+boxHeight*boxHeight < 2500){ |
524 | | - pr_rect.style.cssText = "display:none;"; |
| 560 | + if( boxWidth * boxWidth + boxHeight * boxHeight < 2500 ) { |
| 561 | + pr_rect.style.cssText = 'display:none;'; |
525 | 562 | } else { |
526 | | - ratio = pr_container.offsetWidth/pr_container.offsetHeight; |
527 | | - if(boxWidth/boxHeight < ratio ) { |
528 | | - boxWidth = boxHeight*ratio; |
529 | | - if(xx==xMin) xMin = init_x + margin_x - boxWidth; |
| 563 | + ratio = pr_container.offsetWidth / pr_container.offsetHeight; |
| 564 | + if( boxWidth / boxHeight < ratio ) { |
| 565 | + boxWidth = boxHeight * ratio; |
| 566 | + if( xx == xMin ) { |
| 567 | + xMin = init_x + margin_x - boxWidth; |
| 568 | + } |
530 | 569 | } else { |
531 | | - boxHeight = boxWidth/ratio; |
532 | | - if(yy==yMin) yMin = init_y + margin_y - boxHeight; |
| 570 | + boxHeight = boxWidth / ratio; |
| 571 | + if( yy == yMin ) { |
| 572 | + yMin = init_y + margin_y - boxHeight; |
| 573 | + } |
533 | 574 | } |
534 | | - pr_rect.style.cssText = "cursor:crosshair;opacity:0.5;position:absolute;left:"+ xMin +"px;top:"+ yMin +"px;width:"+boxWidth+"px;height:"+boxHeight+"px;background:#000000;"; |
| 575 | + pr_rect.style.cssText = 'cursor:crosshair;opacity:0.5;position:absolute;left:' + |
| 576 | + xMin + 'px;top:' + yMin + 'px;width:' + boxWidth + 'px;height:' + |
| 577 | + boxHeight + 'px;background:#000000;'; |
535 | 578 | } |
536 | 579 | } |
537 | | - if (evt.preventDefault) evt.preventDefault(); |
| 580 | + if ( evt.preventDefault ) { |
| 581 | + evt.preventDefault(); |
| 582 | + } |
538 | 583 | evt.returnValue = false; |
539 | 584 | is_drag = true; |
540 | 585 | return false; |
541 | 586 | } |
542 | 587 | |
543 | 588 | |
544 | | -function pr_set_margins(mx, my, new_width) { |
545 | | - var zp_img = document.getElementById("ProofReadImage"); |
546 | | - if(zp_img) { |
| 589 | +function pr_set_margins( mx, my, new_width ) { |
| 590 | + var zp_img = document.getElementById( 'ProofReadImage' ); |
| 591 | + if( zp_img ) { |
547 | 592 | margin_x = mx; |
548 | 593 | margin_y = my; |
549 | | - zp_img.style.margin = Math.round(margin_y) + 'px 0px 0px ' + Math.round(margin_x) + 'px'; |
550 | | - if(new_width) { |
551 | | - img_width = Math.round(new_width); |
| 594 | + zp_img.style.margin = Math.round( margin_y ) + 'px 0px 0px ' + Math.round( margin_x ) + 'px'; |
| 595 | + if( new_width ) { |
| 596 | + img_width = Math.round( new_width ); |
552 | 597 | zp_img.width = img_width; |
553 | 598 | } |
554 | | - pr_container.style.cssText = self.container_css; //needed by IE6 |
| 599 | + pr_container.style.cssText = self.container_css; // needed by IE6 |
555 | 600 | } |
556 | 601 | } |
557 | 602 | |
558 | | - |
559 | | -function pr_zoom(delta) { |
560 | | - |
561 | | - if (delta == 0) { |
562 | | - //reduce width by 20 pixels in order to prevent horizontal scrollbar from showing up |
563 | | - pr_set_margins(0, 0, pr_container.offsetWidth-20); |
| 603 | +function pr_zoom( delta ) { |
| 604 | + if ( delta == 0 ) { |
| 605 | + // reduce width by 20 pixels in order to prevent horizontal scrollbar |
| 606 | + // from showing up |
| 607 | + pr_set_margins( 0, 0, pr_container.offsetWidth - 20 ); |
564 | 608 | } else { |
565 | 609 | var old_margin_x = margin_x; |
566 | 610 | var old_margin_y = margin_y; |
567 | 611 | var old_width = img_width; |
568 | | - var new_width = Math.round(old_width*Math.pow(1.1,delta)); |
| 612 | + var new_width = Math.round( old_width * Math.pow( 1.1, delta ) ); |
569 | 613 | var delta_w = new_width - old_width; |
570 | | - if(delta_w==0) return; |
571 | | - var s = (delta_w>0)?1:-1; |
572 | | - for(var dw=s; dw != delta_w; dw=dw+s){ |
573 | | - var lambda = (old_width + dw)/old_width; |
574 | | - pr_set_margins(xx - lambda*(xx - old_margin_x), yy - lambda*(yy - old_margin_y), old_width+dw); |
| 614 | + if( delta_w == 0 ) { |
| 615 | + return; |
575 | 616 | } |
| 617 | + var s = ( delta_w > 0 ) ? 1 : -1; |
| 618 | + for( var dw = s; dw != delta_w; dw = dw + s ) { |
| 619 | + var lambda = ( old_width + dw ) / old_width; |
| 620 | + pr_set_margins( |
| 621 | + xx - lambda * ( xx - old_margin_x ), |
| 622 | + yy - lambda * ( yy - old_margin_y ), |
| 623 | + old_width + dw |
| 624 | + ); |
| 625 | + } |
576 | 626 | } |
577 | 627 | } |
578 | 628 | |
579 | | -function pr_zoom_wheel(evt) { |
580 | | - |
581 | | - evt = evt?evt:window.event?window.event:null; if(!evt){ return false;} |
| 629 | +function pr_zoom_wheel( evt ) { |
| 630 | + evt = evt ? evt : window.event ? window.event : null; |
| 631 | + if( !evt ) { |
| 632 | + return false; |
| 633 | + } |
582 | 634 | var delta = 0; |
583 | | - if (evt.wheelDelta) { |
| 635 | + if ( evt.wheelDelta ) { |
584 | 636 | /* IE/Opera. */ |
585 | | - delta = evt.wheelDelta/120; |
| 637 | + delta = evt.wheelDelta / 120; |
| 638 | + } else if ( evt.detail ) { |
| 639 | + /** |
| 640 | + * Mozilla case. |
| 641 | + * In Mozilla, sign of delta is different than in IE. |
| 642 | + * Also, delta is multiple of 3. |
| 643 | + */ |
| 644 | + delta = -evt.detail / 3; |
586 | 645 | } |
587 | | - else if (evt.detail) { |
588 | | - /** Mozilla case. */ |
589 | | - /** In Mozilla, sign of delta is different than in IE. |
590 | | - * Also, delta is multiple of 3. |
591 | | - */ |
592 | | - delta = -evt.detail/3; |
593 | | - } |
594 | | - if(is_zoom && delta) { |
595 | | - if(!self.proofreadpage_disable_wheelzoom) pr_zoom(delta); |
596 | | - if(evt.preventDefault) evt.preventDefault(); |
| 646 | + if( is_zoom && delta ) { |
| 647 | + if( !self.proofreadpage_disable_wheelzoom ) { |
| 648 | + pr_zoom( delta ); |
| 649 | + } |
| 650 | + if( evt.preventDefault ) { |
| 651 | + evt.preventDefault(); |
| 652 | + } |
597 | 653 | evt.returnValue = false; |
598 | 654 | } |
599 | 655 | } |
600 | 656 | |
601 | | - |
602 | | - |
603 | | - |
604 | 657 | /* fill table with textbox and image */ |
605 | | -function pr_fill_table(){ |
606 | | - |
607 | | - //remove existing table |
608 | | - while(self.table.firstChild){ |
609 | | - self.table.removeChild(self.table.firstChild); |
| 658 | +function pr_fill_table() { |
| 659 | + // remove existing table |
| 660 | + while( self.table.firstChild ) { |
| 661 | + self.table.removeChild( self.table.firstChild ); |
610 | 662 | } |
611 | 663 | |
612 | | - //setup the layout |
613 | | - if(!pr_horiz) { |
614 | | - //use a table only here |
615 | | - var t_table = document.createElement("table"); |
616 | | - var t_body = document.createElement("tbody"); |
617 | | - var cell_left = document.createElement("td"); |
618 | | - var cell_right = document.createElement("td"); |
619 | | - t_table.appendChild(t_body); |
| 664 | + // setup the layout |
| 665 | + if( !pr_horiz ) { |
| 666 | + // use a table only here |
| 667 | + var t_table = document.createElement( 'table' ); |
| 668 | + var t_body = document.createElement( 'tbody' ); |
| 669 | + var cell_left = document.createElement( 'td' ); |
| 670 | + var cell_right = document.createElement( 'td' ); |
| 671 | + t_table.appendChild( t_body ); |
620 | 672 | |
621 | | - var t_row = document.createElement("tr"); |
622 | | - t_row.setAttribute("valign","top"); |
623 | | - cell_left.style.cssText = "width:50%; padding-right:0.5em;vertical-align:top;"; |
624 | | - cell_right.setAttribute("rowspan","3"); |
625 | | - cell_right.style.cssText = "vertical-align:top;"; |
626 | | - t_row.appendChild(cell_left); |
627 | | - t_row.appendChild(cell_right); |
628 | | - t_body.appendChild(t_row); |
629 | | - cell_right.appendChild(pr_container_parent); |
630 | | - cell_left.appendChild(self.text_container); |
631 | | - self.table.appendChild(t_table); |
| 673 | + var t_row = document.createElement( 'tr' ); |
| 674 | + t_row.setAttribute( 'valign', 'top' ); |
| 675 | + cell_left.style.cssText = 'width:50%; padding-right:0.5em;vertical-align:top;'; |
| 676 | + cell_right.setAttribute( 'rowspan', '3' ); |
| 677 | + cell_right.style.cssText = 'vertical-align:top;'; |
| 678 | + t_row.appendChild( cell_left ); |
| 679 | + t_row.appendChild( cell_right ); |
| 680 | + t_body.appendChild( t_row ); |
| 681 | + cell_right.appendChild( pr_container_parent ); |
| 682 | + cell_left.appendChild( self.text_container ); |
| 683 | + self.table.appendChild( t_table ); |
632 | 684 | } else { |
633 | | - self.table.appendChild(self.text_container); |
634 | | - form = document.getElementById("editform"); |
635 | | - tb = document.getElementById("toolbar"); |
636 | | - if(tb) tb.parentNode.insertBefore(pr_container_parent,tb); |
637 | | - else if(form) form.parentNode.insertBefore(pr_container_parent,form); |
638 | | - else self.table.insertBefore(pr_container_parent,self.table.firstChild); |
| 685 | + self.table.appendChild( self.text_container ); |
| 686 | + form = document.getElementById( 'editform' ); |
| 687 | + tb = document.getElementById( 'toolbar' ); |
| 688 | + if( tb ) { |
| 689 | + tb.parentNode.insertBefore( pr_container_parent, tb ); |
| 690 | + } else if( form ) { |
| 691 | + form.parentNode.insertBefore( pr_container_parent, form ); |
| 692 | + } else { |
| 693 | + self.table.insertBefore( pr_container_parent, self.table.firstChild ); |
| 694 | + } |
639 | 695 | } |
640 | | - |
641 | | - if(proofreadPageIsEdit) { |
642 | | - if(!pr_horiz){ |
643 | | - self.DisplayHeight = Math.ceil(pr_height*0.85); |
644 | | - self.DisplayWidth = parseInt(pr_width/2-70); |
645 | | - css_wh = "width:"+self.DisplayWidth+"px; height:"+self.DisplayHeight+"px;"; |
646 | | - pr_container_parent.style.cssText="position:relative;width:"+self.DisplayWidth+"px;"; |
| 696 | + |
| 697 | + if( proofreadPageIsEdit ) { |
| 698 | + if( !pr_horiz ) { |
| 699 | + self.DisplayHeight = Math.ceil( pr_height * 0.85); |
| 700 | + self.DisplayWidth = parseInt( pr_width / 2 - 70 ); |
| 701 | + css_wh = 'width:' + self.DisplayWidth + 'px; height:' + self.DisplayHeight + 'px;'; |
| 702 | + pr_container_parent.style.cssText = 'position:relative;width:' + self.DisplayWidth + 'px;'; |
647 | 703 | } else { |
648 | | - self.DisplayHeight = Math.ceil(pr_height*0.4); |
649 | | - css_wh = "width:100%; height:"+self.DisplayHeight+"px;"; |
650 | | - pr_container_parent.style.cssText="position:relative;height:"+self.DisplayHeight+"px;"; |
| 704 | + self.DisplayHeight = Math.ceil( pr_height * 0.4 ); |
| 705 | + css_wh = 'width:100%; height:' + self.DisplayHeight + 'px;'; |
| 706 | + pr_container_parent.style.cssText = 'position:relative;height:' + self.DisplayHeight + 'px;'; |
651 | 707 | } |
652 | | - self.container_css = "position:absolute;top:0px;cursor:default; background:#000000; overflow:auto; " + css_wh; |
| 708 | + self.container_css = 'position:absolute;top:0px;cursor:default; background:#000000; overflow:auto; ' + css_wh; |
653 | 709 | pr_container.style.cssText = self.container_css; |
654 | 710 | } |
655 | | - pr_zoom(0); |
| 711 | + pr_zoom( 0 ); |
656 | 712 | } |
657 | 713 | |
658 | | - |
659 | | - |
660 | 714 | function pr_load_image( view_url ) { |
661 | | - pr_container.innerHTML = "<img id=\"ProofReadImage\" src=\"" |
662 | | - + escapeQuotesHTML( view_url ) |
663 | | - + "\" width=\"" + img_width + "\" />"; |
664 | | - pr_zoom(0); |
| 715 | + pr_container.innerHTML = '<img id="ProofReadImage" src="' + |
| 716 | + escapeQuotesHTML( view_url ) + '" width="' + img_width + '" />'; |
| 717 | + pr_zoom( 0 ); |
665 | 718 | } |
666 | 719 | |
667 | | - |
668 | | - |
669 | 720 | function pr_setup() { |
| 721 | + self.pr_horiz = ( self.proofreadpage_default_layout ==' horizontal' ); |
| 722 | + if( !proofreadPageIsEdit ) { |
| 723 | + pr_horiz = false; |
| 724 | + } |
670 | 725 | |
671 | | - self.pr_horiz = (self.proofreadpage_default_layout=='horizontal'); |
672 | | - if(!proofreadPageIsEdit) pr_horiz = false; |
| 726 | + self.table = document.createElement( 'div' ); |
| 727 | + self.text_container = document.createElement( 'div' ); |
673 | 728 | |
674 | | - self.table = document.createElement("div"); |
675 | | - self.text_container = document.createElement("div"); |
| 729 | + pr_container = document.createElement( 'div' ); |
| 730 | + pr_container.setAttribute( 'id', 'pr_container' ); |
676 | 731 | |
677 | | - pr_container = document.createElement("div"); |
678 | | - pr_container.setAttribute("id", "pr_container"); |
| 732 | + self.pr_container_parent = document.createElement( 'div' ); |
| 733 | + pr_container_parent.appendChild( pr_container ); |
679 | 734 | |
680 | | - self.pr_container_parent = document.createElement("div"); |
681 | | - pr_container_parent.appendChild(pr_container); |
682 | | - |
683 | | - //get the size of the window |
| 735 | + // Get the size of the window |
684 | 736 | if( typeof( window.innerWidth ) == 'number' ) { |
685 | | - //Non-IE |
| 737 | + // Non-IE |
686 | 738 | pr_width = window.innerWidth; |
687 | 739 | pr_height = window.innerHeight; |
688 | 740 | } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { |
689 | | - //IE 6+ in 'standards compliant mode' |
| 741 | + // IE 6+ in 'standards compliant mode' |
690 | 742 | pr_width = document.documentElement.clientWidth; |
691 | 743 | pr_height = document.documentElement.clientHeight; |
692 | 744 | } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { |
693 | | - //IE 4 compatible |
| 745 | + // IE 4 compatible |
694 | 746 | pr_width = document.body.clientWidth; |
695 | 747 | pr_height = document.body.clientHeight; |
696 | 748 | } |
697 | 749 | |
698 | | - //fill the image container |
699 | | - if(!proofreadPageIsEdit) { |
700 | | - //this sets DisplayWidth and DisplayHeight |
701 | | - var thumb_url = pr_image_url(parseInt(pr_width/2-70)); |
702 | | - var image = document.createElement("img"); |
703 | | - image.setAttribute("id", "ProofReadImage"); |
704 | | - image.setAttribute("src", thumb_url); |
705 | | - image.setAttribute("width", self.DisplayWidth); |
706 | | - image.style.cssText = "padding:0;margin:0;border:0;"; |
707 | | - pr_container.appendChild(image); |
708 | | - pr_container.style.cssText = "overflow:hidden;width:"+self.DisplayWidth+"px;"; |
| 750 | + // fill the image container |
| 751 | + if( !proofreadPageIsEdit ) { |
| 752 | + // this sets DisplayWidth and DisplayHeight |
| 753 | + var thumb_url = pr_image_url( parseInt( pr_width / 2 - 70 ) ); |
| 754 | + var image = document.createElement( 'img' ); |
| 755 | + image.setAttribute( 'id', 'ProofReadImage' ); |
| 756 | + image.setAttribute( 'src', thumb_url ); |
| 757 | + image.setAttribute( 'width', self.DisplayWidth ); |
| 758 | + image.style.cssText = 'padding:0;margin:0;border:0;'; |
| 759 | + pr_container.appendChild( image ); |
| 760 | + pr_container.style.cssText = 'overflow:hidden;width:' + self.DisplayWidth + 'px;'; |
709 | 761 | } else { |
710 | | - var w = parseInt(self.proofreadPageEditWidth); |
711 | | - if( !w ) w = self.proofreadPageDefaultEditWidth; |
712 | | - if( !w ) w = 1024; /* Default size in edit mode */ |
713 | | - var view_url = pr_image_url( Math.min( w, self.proofreadPageWidth ) ); |
714 | | - //prevent the container from being resized once the image is downloaded. |
715 | | - img_width = pr_horiz?0:parseInt(pr_width/2-70)-20; |
| 762 | + var w = parseInt( self.proofreadPageEditWidth ); |
| 763 | + if( !w ) { |
| 764 | + w = self.proofreadPageDefaultEditWidth; |
| 765 | + } |
| 766 | + if( !w ) { |
| 767 | + w = 1024; /* Default size in edit mode */ |
| 768 | + } |
| 769 | + var view_url = pr_image_url( Math.min( w, self.proofreadPageWidth ) ); |
| 770 | + // prevent the container from being resized once the image is downloaded. |
| 771 | + img_width = pr_horiz ? 0 : parseInt( pr_width / 2 - 70 ) - 20; |
716 | 772 | pr_container.onmousedown = pr_grab; |
717 | 773 | pr_container.onmousemove = pr_move; |
718 | | - if (pr_container.addEventListener) |
719 | | - pr_container.addEventListener('DOMMouseScroll', pr_zoom_wheel, false); |
720 | | - pr_container.onmousewheel = pr_zoom_wheel;//IE,Opera. |
721 | | - hookEvent( 'load', function() { pr_load_image(view_url); } ); |
| 774 | + if ( pr_container.addEventListener ) { |
| 775 | + pr_container.addEventListener( 'DOMMouseScroll', pr_zoom_wheel, false ); |
| 776 | + } |
| 777 | + pr_container.onmousewheel = pr_zoom_wheel; // IE, Opera. |
| 778 | + hookEvent( 'load', function() { pr_load_image( view_url ); } ); |
722 | 779 | } |
723 | 780 | |
724 | | - table.setAttribute("id", "textBoxTable"); |
725 | | - table.style.cssText = "width:100%;"; |
| 781 | + table.setAttribute( 'id', 'textBoxTable' ); |
| 782 | + table.style.cssText = 'width:100%;'; |
726 | 783 | |
727 | 784 | pr_fill_table(); |
728 | | - |
729 | | - //insert the image |
730 | | - if(proofreadPageIsEdit) { |
731 | | - var text = document.getElementById("wpTextbox1"); |
| 785 | + |
| 786 | + // insert the image |
| 787 | + if( proofreadPageIsEdit ) { |
| 788 | + var text = document.getElementById( 'wpTextbox1' ); |
| 789 | + } else { |
| 790 | + var text = document.getElementById( 'bodyContent' ); |
732 | 791 | } |
733 | | - else { |
734 | | - var text = document.getElementById("bodyContent"); |
| 792 | + if( !text ) { |
| 793 | + return; |
735 | 794 | } |
736 | | - if(!text) return; |
737 | | - var f = text.parentNode; |
738 | | - var new_text = f.removeChild(text); |
| 795 | + var f = text.parentNode; |
| 796 | + var new_text = f.removeChild( text ); |
739 | 797 | |
740 | | - if(proofreadPageIsEdit) { |
741 | | - pr_make_edit_area(self.text_container,new_text.value); |
742 | | - var copywarn = document.getElementById("editpage-copywarn"); |
743 | | - f.insertBefore(table,copywarn); |
744 | | - if ( ! self.proofreadpage_show_headers){ |
| 798 | + if( proofreadPageIsEdit ) { |
| 799 | + pr_make_edit_area( self.text_container, new_text.value ); |
| 800 | + var copywarn = document.getElementById( 'editpage-copywarn' ); |
| 801 | + f.insertBefore( table, copywarn ); |
| 802 | + if ( !self.proofreadpage_show_headers ) { |
745 | 803 | hookEvent( 'load', pr_toggle_visibility ); |
746 | 804 | } |
| 805 | + } else { |
| 806 | + self.text_container.appendChild( new_text ); |
| 807 | + f.appendChild( self.table ); |
747 | 808 | } |
748 | | - else { |
749 | | - self.text_container.appendChild(new_text); |
750 | | - f.appendChild(self.table); |
751 | | - } |
752 | | - |
753 | | - //add buttons |
754 | | - if(proofreadPageIsEdit) { |
755 | 809 | |
756 | | - var toolbar = document.getElementById("toolbar"); |
| 810 | + // add buttons |
| 811 | + if( proofreadPageIsEdit ) { |
| 812 | + var toolbar = document.getElementById( 'toolbar' ); |
757 | 813 | |
758 | | - var image = document.createElement("img"); |
| 814 | + var image = document.createElement( 'img' ); |
759 | 815 | image.width = 23; |
760 | 816 | image.height = 22; |
761 | | - image.className = "mw-toolbar-editbutton"; |
762 | | - image.src = wgScriptPath+'/extensions/ProofreadPage/button_category_plus.png'; |
| 817 | + image.className = 'mw-toolbar-editbutton'; |
| 818 | + image.src = wgScriptPath + '/extensions/ProofreadPage/button_category_plus.png'; |
763 | 819 | image.border = 0; |
764 | 820 | image.alt = proofreadPageMessageToggleHeaders; |
765 | 821 | image.title = proofreadPageMessageToggleHeaders; |
766 | | - image.style.cursor = "pointer"; |
| 822 | + image.style.cursor = 'pointer'; |
767 | 823 | image.onclick = pr_toggle_visibility; |
768 | | - |
769 | | - var image3 = document.createElement("img"); |
| 824 | + |
| 825 | + var image3 = document.createElement( 'img' ); |
770 | 826 | image3.width = 23; |
771 | 827 | image3.height = 22; |
772 | 828 | image3.border = 0; |
773 | | - image3.className = "mw-toolbar-proofread"; |
774 | | - image3.style.cursor = "pointer"; |
775 | | - image3.alt = "-"; |
776 | | - image3.title = "zoom out"; |
777 | | - image3.src = wgScriptPath+"/extensions/ProofreadPage/Button_zoom_out.png"; |
778 | | - image3.onclick = new Function("xx=0;yy=0;pr_zoom(-2);"); |
779 | | - |
780 | | - var image4 = document.createElement("img"); |
| 829 | + image3.className = 'mw-toolbar-proofread'; |
| 830 | + image3.style.cursor = 'pointer'; |
| 831 | + image3.alt = '-'; |
| 832 | + image3.title = 'zoom out'; |
| 833 | + image3.src = wgScriptPath + '/extensions/ProofreadPage/Button_zoom_out.png'; |
| 834 | + image3.onclick = new Function( 'xx=0;yy=0;pr_zoom(-2);' ); |
| 835 | + |
| 836 | + var image4 = document.createElement( 'img' ); |
781 | 837 | image4.width = 23; |
782 | 838 | image4.height = 22; |
783 | 839 | image4.border = 0; |
784 | | - image4.className = "mw-toolbar-proofread"; |
785 | | - image4.style.cursor = "pointer"; |
786 | | - image4.alt = "-"; |
787 | | - image4.title = "reset zoom"; |
788 | | - image4.src = wgScriptPath+"/extensions/ProofreadPage/Button_examine.png"; |
| 840 | + image4.className = 'mw-toolbar-proofread'; |
| 841 | + image4.style.cursor = 'pointer'; |
| 842 | + image4.alt = '-'; |
| 843 | + image4.title = 'reset zoom'; |
| 844 | + image4.src = wgScriptPath + '/extensions/ProofreadPage/Button_examine.png'; |
789 | 845 | image4.onclick = new Function("pr_zoom(0);"); |
790 | | - |
791 | | - var image2 = document.createElement("img"); |
| 846 | + |
| 847 | + var image2 = document.createElement( 'img' ); |
792 | 848 | image2.width = 23; |
793 | 849 | image2.height = 22; |
794 | 850 | image2.border = 0; |
795 | | - image2.className = "mw-toolbar-proofread"; |
796 | | - image2.style.cursor = "pointer"; |
797 | | - image2.alt = "+"; |
798 | | - image2.title = "zoom in"; |
799 | | - image2.src = wgScriptPath+"/extensions/ProofreadPage/Button_zoom_in.png"; |
800 | | - image2.onclick = new Function("xx=0;yy=0;pr_zoom(2);"); |
801 | | - |
802 | | - var image1 = document.createElement("img"); |
| 851 | + image2.className = 'mw-toolbar-proofread'; |
| 852 | + image2.style.cursor = 'pointer'; |
| 853 | + image2.alt = '+'; |
| 854 | + image2.title = 'zoom in'; |
| 855 | + image2.src = wgScriptPath + '/extensions/ProofreadPage/Button_zoom_in.png'; |
| 856 | + image2.onclick = new Function( 'xx=0;yy=0;pr_zoom(2);' ); |
| 857 | + |
| 858 | + var image1 = document.createElement( 'img' ); |
803 | 859 | image1.width = 23; |
804 | 860 | image1.height = 22; |
805 | | - image1.className = "mw-toolbar-editbutton"; |
806 | | - image1.src = wgScriptPath+'/extensions/ProofreadPage/Button_multicol.png'; |
| 861 | + image1.className = 'mw-toolbar-editbutton'; |
| 862 | + image1.src = wgScriptPath + '/extensions/ProofreadPage/Button_multicol.png'; |
807 | 863 | image1.border = 0; |
808 | | - image1.alt = " "; |
809 | | - image1.title = "vertical/horizontal layout"; |
810 | | - image1.style.cursor = "pointer"; |
| 864 | + image1.alt = ' '; |
| 865 | + image1.title = 'vertical/horizontal layout'; |
| 866 | + image1.style.cursor = 'pointer'; |
811 | 867 | image1.onclick = pr_toggle_layout; |
812 | 868 | |
813 | | - pr_rect = document.createElement("div"); |
814 | | - pr_container_parent.appendChild(pr_rect); |
| 869 | + pr_rect = document.createElement( 'div' ); |
| 870 | + pr_container_parent.appendChild( pr_rect ); |
815 | 871 | |
816 | | - if( (!toolbar) || (self.wgWikiEditorPreferences && self.wgWikiEditorPreferences["toolbar"] ) ) { |
817 | | - toolbar = document.createElement("div"); |
818 | | - toolbar.style.cssText="position:absolute;"; |
819 | | - pr_container_parent.appendChild(toolbar); |
| 872 | + if( ( !toolbar ) || ( self.wgWikiEditorPreferences && self.wgWikiEditorPreferences['toolbar'] ) ) { |
| 873 | + toolbar = document.createElement( 'div' ); |
| 874 | + toolbar.style.cssText = 'position:absolute;'; |
| 875 | + pr_container_parent.appendChild( toolbar ); |
820 | 876 | } |
821 | | - toolbar.appendChild(image); |
822 | | - toolbar.appendChild(image3); |
823 | | - toolbar.appendChild(image4); |
824 | | - toolbar.appendChild(image2); |
825 | | - toolbar.appendChild(image1); |
| 877 | + toolbar.appendChild( image ); |
| 878 | + toolbar.appendChild( image3 ); |
| 879 | + toolbar.appendChild( image4 ); |
| 880 | + toolbar.appendChild( image2 ); |
| 881 | + toolbar.appendChild( image1 ); |
826 | 882 | } |
827 | 883 | } |
828 | 884 | |
829 | | - |
830 | | - |
831 | | - |
832 | | - |
833 | 885 | function pr_init() { |
| 886 | + if( document.getElementById( 'pr_container' ) ) { |
| 887 | + return; |
| 888 | + } |
834 | 889 | |
835 | | - if( document.getElementById("pr_container")) return; |
| 890 | + if( document.URL.indexOf( 'action=protect' ) > 0 || document.URL.indexOf( 'action=unprotect' ) > 0 ) { |
| 891 | + return; |
| 892 | + } |
| 893 | + if( document.URL.indexOf( 'action=delete' ) > 0 || document.URL.indexOf( 'action=undelete' ) > 0 ) { |
| 894 | + return; |
| 895 | + } |
| 896 | + if( document.URL.indexOf( 'action=watch' ) > 0 || document.URL.indexOf( 'action=unwatch' ) > 0 ) { |
| 897 | + return; |
| 898 | + } |
| 899 | + if( document.URL.indexOf( 'action=history' ) > 0 ) { |
| 900 | + return; |
| 901 | + } |
836 | 902 | |
837 | | - if(document.URL.indexOf("action=protect") > 0 || document.URL.indexOf("action=unprotect") > 0) return; |
838 | | - if(document.URL.indexOf("action=delete") > 0 || document.URL.indexOf("action=undelete") > 0) return; |
839 | | - if(document.URL.indexOf("action=watch") > 0 || document.URL.indexOf("action=unwatch") > 0) return; |
840 | | - if(document.URL.indexOf("action=history") > 0 ) return; |
841 | | - |
842 | | - /*check if external url is provided*/ |
| 903 | + /* check if external URL is provided */ |
843 | 904 | if( !self.proofreadPageThumbURL ) { |
844 | | - var text = document.getElementById("wpTextbox1"); |
845 | | - if (text) { |
| 905 | + var text = document.getElementById( 'wpTextbox1' ); |
| 906 | + if ( text ) { |
846 | 907 | var proofreadPageIsEdit = true; |
847 | 908 | re = /<span class="hiddenStructure" id="pageURL">\[http:\/\/(.*?)\]<\/span>/; |
848 | | - m = re.exec(text.value); |
849 | | - if( m ) { |
850 | | - self.proofreadPageExternalURL = "http://"+m[1]; |
| 909 | + m = re.exec( text.value ); |
| 910 | + if( m ) { |
| 911 | + self.proofreadPageExternalURL = 'http://' + m[1]; |
851 | 912 | } |
852 | | - } |
853 | | - else { |
| 913 | + } else { |
854 | 914 | var proofreadPageIsEdit = false; |
855 | | - text = document.getElementById("bodyContent"); |
856 | | - try { |
857 | | - var a = document.getElementById("pageURL"); |
| 915 | + text = document.getElementById( 'bodyContent' ); |
| 916 | + try { |
| 917 | + var a = document.getElementById( 'pageURL' ); |
858 | 918 | var b = a.firstChild; |
859 | | - self.proofreadPageExternalURL = b.getAttribute("href"); |
860 | | - } catch(err){}; |
| 919 | + self.proofreadPageExternalURL = b.getAttribute( 'href' ); |
| 920 | + } catch( err ) { |
| 921 | + }; |
861 | 922 | } |
862 | | - //set to dummy values, not used |
| 923 | + // set to dummy values, not used |
863 | 924 | self.proofreadPageWidth = 400; |
864 | 925 | self.proofreadPageHeight = 400; |
865 | 926 | } |
866 | 927 | |
867 | | - if( !self.proofreadPageThumbURL ) return; |
| 928 | + if( !self.proofreadPageThumbURL ) { |
| 929 | + return; |
| 930 | + } |
868 | 931 | |
869 | 932 | if( self.proofreadpage_setup ) { |
870 | | - |
871 | 933 | proofreadpage_setup( |
872 | 934 | proofreadPageWidth, |
873 | | - proofreadPageHeight, |
874 | | - proofreadPageIsEdit); |
| 935 | + proofreadPageHeight, |
| 936 | + proofreadPageIsEdit |
| 937 | + ); |
| 938 | + } else { |
| 939 | + pr_setup(); |
875 | 940 | } |
876 | | - else pr_setup(); |
877 | 941 | |
878 | | - //add css classes to the container div |
879 | | - var c = document.getElementById("pagequality"); |
880 | | - if(c) { |
881 | | - c = c.nextSibling; |
882 | | - if(c.className=="pagetext") { |
883 | | - c.className += " "+self.proofreadPageCss; |
| 942 | + // add CSS classes to the container div |
| 943 | + var c = document.getElementById( 'pagequality' ); |
| 944 | + if( c ) { |
| 945 | + c = c.nextSibling; |
| 946 | + if( c.className == 'pagetext' ) { |
| 947 | + c.className += ' ' + self.proofreadPageCss; |
884 | 948 | } |
885 | 949 | } |
886 | 950 | } |
887 | 951 | |
| 952 | +addOnloadHook( pr_init ); |
| 953 | +addOnloadHook( pr_init_tabs ); |
888 | 954 | |
| 955 | +hookEvent( 'load', pr_initzoom ); |
889 | 956 | |
890 | | -addOnloadHook(pr_init); |
891 | | -addOnloadHook(pr_init_tabs); |
892 | | - |
893 | | - |
894 | | -hookEvent("load", pr_initzoom ); |
895 | | - |
896 | | - |
897 | | -/*Quality buttons*/ |
898 | | - |
899 | | -function pr_add_quality(form,value){ |
900 | | - |
| 957 | +/* Quality buttons */ |
| 958 | +function pr_add_quality( form, value ) { |
901 | 959 | self.proofreadpage_quality = value; |
902 | 960 | self.proofreadpage_username = proofreadPageUserName; |
903 | | - var text=""; |
| 961 | + var text = ''; |
904 | 962 | switch( value ) { |
905 | | - case 0: text = proofreadPageMessageQuality0; break; |
906 | | - case 1: text = proofreadPageMessageQuality1; break; |
907 | | - case 2: text = proofreadPageMessageQuality2; break; |
908 | | - case 3: text = proofreadPageMessageQuality3; break; |
909 | | - case 4: text = proofreadPageMessageQuality4; break; |
| 963 | + case 0: |
| 964 | + text = proofreadPageMessageQuality0; |
| 965 | + break; |
| 966 | + case 1: |
| 967 | + text = proofreadPageMessageQuality1; |
| 968 | + break; |
| 969 | + case 2: |
| 970 | + text = proofreadPageMessageQuality2; |
| 971 | + break; |
| 972 | + case 3: |
| 973 | + text = proofreadPageMessageQuality3; |
| 974 | + break; |
| 975 | + case 4: |
| 976 | + text = proofreadPageMessageQuality4; |
| 977 | + break; |
910 | 978 | } |
911 | | - form.elements["wpSummary"].value="/* " + text + " */ "; |
912 | | - form.elements["wpProofreader"].value=self.proofreadpage_username; |
913 | | - |
| 979 | + form.elements['wpSummary'].value = '/* ' + text + ' */ '; |
| 980 | + form.elements['wpProofreader'].value = self.proofreadpage_username; |
914 | 981 | } |
915 | 982 | |
| 983 | +function pr_add_quality_buttons() { |
| 984 | + var ig = document.getElementById( 'wpWatchthis' ); |
| 985 | + if( !ig ) { |
| 986 | + ig = document.getElementById( 'wpSummary' ); |
| 987 | + } |
| 988 | + if( !ig ) { |
| 989 | + return; |
| 990 | + } |
| 991 | + var f = document.createElement( 'span' ); |
| 992 | + ig.parentNode.insertBefore( f, ig.nextSibling.nextSibling.nextSibling ); |
916 | 993 | |
917 | | -function pr_add_quality_buttons(){ |
918 | | - |
919 | | - var ig = document.getElementById("wpWatchthis"); |
920 | | - if( !ig ) ig = document.getElementById("wpSummary"); |
921 | | - if( !ig ) return; |
922 | | - var f = document.createElement("span"); |
923 | | - ig.parentNode.insertBefore(f,ig.nextSibling.nextSibling.nextSibling); |
924 | | - |
925 | 994 | if( !proofreadPageAddButtons ) { |
926 | | - f.innerHTML = |
927 | | - ' <input type="hidden" name="wpProofreader" value="' + self.proofreadpage_username + '">' |
928 | | - +'<input type="hidden" name="quality" value=' + self.proofreadpage_quality + ' >'; |
| 995 | + f.innerHTML = |
| 996 | + ' <input type="hidden" name="wpProofreader" value="' + self.proofreadpage_username + '">' + |
| 997 | + '<input type="hidden" name="quality" value=' + self.proofreadpage_quality + ' >'; |
929 | 998 | return; |
930 | 999 | } |
931 | 1000 | |
932 | | - f.innerHTML = |
933 | | -' <input type="hidden" name="wpProofreader" value="'+self.proofreadpage_username+'">' |
| 1001 | + f.innerHTML = |
| 1002 | +' <input type="hidden" name="wpProofreader" value="' + self.proofreadpage_username + '">' |
934 | 1003 | +'<span class="quality0"> <input type="radio" name="quality" value=0 onclick="pr_add_quality(this.form,0)" tabindex=4> </span>' |
935 | 1004 | +'<span class="quality2"> <input type="radio" name="quality" value=2 onclick="pr_add_quality(this.form,2)" tabindex=4> </span>' |
936 | 1005 | +'<span class="quality1"> <input type="radio" name="quality" value=1 onclick="pr_add_quality(this.form,1)" tabindex=4> </span>' |
937 | 1006 | +'<span class="quality3"> <input type="radio" name="quality" value=3 onclick="pr_add_quality(this.form,3)" tabindex=4> </span>' |
938 | 1007 | +'<span class="quality4"> <input type="radio" name="quality" value=4 onclick="pr_add_quality(this.form,4)" tabindex=4> </span>'; |
939 | | - f.innerHTML = f.innerHTML + ' ' + escapeQuotesHTML(proofreadPageMessageStatus); |
| 1008 | + f.innerHTML = f.innerHTML + ' ' + escapeQuotesHTML( proofreadPageMessageStatus ); |
940 | 1009 | |
941 | | - if( ! ( ( self.proofreadpage_quality == 4 ) || ( ( self.proofreadpage_quality == 3 ) && ( self.proofreadpage_username != proofreadPageUserName ) ) ) ) { |
| 1010 | + if( !( ( self.proofreadpage_quality == 4 ) || ( ( self.proofreadpage_quality == 3 ) && ( self.proofreadpage_username != proofreadPageUserName ) ) ) ) { |
942 | 1011 | document.editform.quality[4].parentNode.style.cssText = 'display:none'; |
943 | 1012 | document.editform.quality[4].disabled = true; |
944 | 1013 | } |
945 | 1014 | switch( self.proofreadpage_quality ) { |
946 | | - case 4: document.editform.quality[4].checked = true; break; |
947 | | - case 3: document.editform.quality[3].checked = true; break; |
948 | | - case 1: document.editform.quality[2].checked = true; break; |
949 | | - case 2: document.editform.quality[1].checked = true; break; |
950 | | - case 0: document.editform.quality[0].checked = true; break; |
| 1015 | + case 4: |
| 1016 | + document.editform.quality[4].checked = true; |
| 1017 | + break; |
| 1018 | + case 3: |
| 1019 | + document.editform.quality[3].checked = true; |
| 1020 | + break; |
| 1021 | + case 1: |
| 1022 | + document.editform.quality[2].checked = true; |
| 1023 | + break; |
| 1024 | + case 2: |
| 1025 | + document.editform.quality[1].checked = true; |
| 1026 | + break; |
| 1027 | + case 0: |
| 1028 | + document.editform.quality[0].checked = true; |
| 1029 | + break; |
951 | 1030 | } |
952 | 1031 | } |
953 | 1032 | |
954 | | - |
955 | | - |
956 | | -addOnloadHook(pr_add_quality_buttons); |
| 1033 | +addOnloadHook( pr_add_quality_buttons ); |
\ No newline at end of file |
Index: trunk/extensions/ProofreadPage/proofread_article.js |
— | — | @@ -1,21 +1,25 @@ |
2 | 2 | // Author : ThomasV - License : GPL |
3 | 3 | |
4 | | -/* add backlink to index page*/ |
| 4 | +/* add backlink to index page */ |
5 | 5 | function pr_add_source() { |
6 | | - var a = document.getElementById("ca-nstab-main"); |
7 | | - if(!a) return; |
8 | | - var q = document.getElementById("pr_index") |
| 6 | + var a = document.getElementById( 'ca-nstab-main' ); |
| 7 | + if( !a ) { |
| 8 | + return; |
| 9 | + } |
| 10 | + var q = document.getElementById( 'pr_index' ); |
9 | 11 | if( q ) { |
10 | | - href = q.firstChild; |
11 | | - if(!href) return; |
12 | | - q.removeChild(href); |
| 12 | + href = q.firstChild; |
| 13 | + if( !href ) { |
| 14 | + return; |
| 15 | + } |
| 16 | + q.removeChild( href ); |
13 | 17 | href.innerHTML = prp_source; |
14 | | - href.setAttribute("title", prp_source_message); |
15 | | - var new_li = document.createElement("li"); |
16 | | - new_li.appendChild(href); |
17 | | - var new_span = document.createElement("span"); |
18 | | - new_span.appendChild(new_li); |
19 | | - a.parentNode.insertBefore(new_span,a.nextSibling); |
| 18 | + href.setAttribute( 'title', prp_source_message ); |
| 19 | + var new_li = document.createElement( 'li' ); |
| 20 | + new_li.appendChild( href ); |
| 21 | + var new_span = document.createElement( 'span' ); |
| 22 | + new_span.appendChild( new_li ); |
| 23 | + a.parentNode.insertBefore( new_span, a.nextSibling ); |
20 | 24 | } |
21 | 25 | } |
22 | | -addOnloadHook(pr_add_source); |
| 26 | +addOnloadHook( pr_add_source ); |
\ No newline at end of file |