Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function init_page_numbers() {
- if(document.URL.indexOf("match=") > 0 ) return;
- //create a dummy pagenumber at the end to provide the end position
- //because this is often not found correctly, especially with gaps in the page ranges
- $('<span id="dummy-pagenumber" class="pagenum"></span>').insertBefore('#catlinks');
- self.pagenum_ml = get_elements_by_classname( 'pagenum', 'span' );
- if( self.proofreadpage_source_href && self.pagenum_ml.length>1){
- var optlist = get_optlist();
- mw.util.addPortletLink ('p-displayOptions', 'javascript:hide_pagenumbers();', ws_msg('hide_page_numbers'), 'option-pageNumbers', '', 'n' );
- var cs = self.pagenum_ml[0].parentNode.parentNode;
- //this happens for empty pages ; check if there are other cases
- if(cs.tagName=="P") cs = cs.parentNode;
- /* Measure the line height and the height of an empty span */
- var ct = document.createElement("div");
- ct.setAttribute("id","my-ct");
- cs.insertBefore(ct,cs.firstChild);
- var ss = document.createElement("div"); /*we need a div, not a span*/
- ss.innerHTML=" <span></span>"; /*empty span following some text */
- ss.setAttribute("id","my-ss");
- cs.appendChild(ss);
- /* container for page numbers */
- var div_pagenums = document.createElement("div");
- div_pagenums.setAttribute("id","ct-pagenums");
- /* insert the container in the grandparent node, or parent, or self */
- var mcs = document.getElementById("text-wrap");
- if(!mcs) {
- if(cs.parentNode.parentNode.style.position=="relative") mcs = cs.parentNode.parentNode;
- else if(cs.parentNode.style.position=="relative") mcs = cs.parentNode;
- else { mcs = cs; mcs.style.position = "relative"; }
- }
- mcs.appendChild(div_pagenums);
- /* container for the highlight */
- var div_popup = document.createElement("div");
- var opacity="background-color:#000000;opacity:0.2;-ms-filter:alpha(opacity=20);filter:alpha(opacity=20);";
- div_popup.setAttribute("id","ct-popup");
- div_popup.style.cssText = "position:absolute;width:100%;";
- div_popup.innerHTML = "<div style=\""+opacity+"float:right;width:0px;\" > </div>"
- +"<div style=\""+opacity+"width:100%;height:0px;clear:both;\"></div>"
- +"<div style=\""+opacity+"width:0px;\"> </div>";
- cs.appendChild(div_popup);
- refresh_pagenumbers();
- }
- $('#dummy-pagenumber').remove(); //don't leave this hanging around to confuse other scripts
- }
Advertisement
Add Comment
Please, Sign In to add comment