/*; Original source: http://pl.wikipedia.org/wiki/MediaWiki:Wikibugs.js; Russian adaptation: [[:ru:User:Александр Сигачёв]], [[:ru:User:Putnik]], [[:ru:User:LEMeZza]]; English adaptation: [[:ru:User:Claymore]];; Original idea: [[:pl:User:Dodek]], [[:pl:User:Adziura]]; Implementation: [[:pl:User:Nux]], [[:pl:User:Saper]], [[:pl:User:Beau]], [[:ru:User:Putnik]]*/varwb$description="Please give us the full description of the error you found. Cite your sources if you can."varwb$badPages=newArray("Wikipedia:Error reports","Main page")$(function(){varel=document.getElementById('n-bug_in_article')if(el)el.getElementsByTagName('a')[0].onclick=wb$popWikibug})functionwb$popWikibug(){varlink_wiki=window.wgArticlePath.replace(/\$1/,'wiki')varlink_tocreate=window.wgArticlePath.replace(/\$1/,'Wikipedia:Requested articles')varlink_bebold=window.wgArticlePath.replace(/\$1/,'Wikipedia:Be_bold')varlink_buglist=window.wgArticlePath.replace(/\$1/,'Wikipedia:Error_reports')wb$popBugBoth("Wikipedia:Error reports",'\ <div style="float:right;width:200px;padding:4px 10px;margin:2px 0px 0px 10px;font-size:90%;border:2px solid #900"><p><strong>Do not\u00A0report</strong> \u00A0errors on\u00A0other sites (for example, <strong>Facebook</strong> or <strong>Twitter</strong>), they will be ignored.</p>\ <p>Please do not report about articles you can'tfind,youcanadda<ahref="' + link_tocreate + '">requestforitscreation</a> instead.</p></div>\<pstyle="margin-top:0px">Ifyoufoundanerror,pleasetrytofixityourself,the<ahref="' + link_wiki + '">wiki</a> technology on this site enables you to do this. Do not hesitate, one of the main Wikipedian rules says: <a href="' + link_bebold + '">be bold</a>"! If you can't fix the error, report it using this form.</p><p>Do not post your telephone number or e-mail.</p>\<ul><li><ahref="' + link_buglist + '">Currenterrorreports.</a></li></ul>\') return false}function wb$getEditToken(page){ var objhttp = (window.XMLHttpRequest) ? new XMLHttpRequest(): new ActiveXObject('Microsoft.XMLHTTP') if (!objhttp) return objhttp.onreadystatechange=function() { if (objhttp.readyState == 4) { if (objhttp.status == 200) { var r_sti = /value="(\d+)" name=["']wpStarttime["']/ var r_eti = /value="(\d+)" name=["']wpEdittime["']/varr_etk=/value="(.*?)" name=["']wpEditToken["']/varr_asm=/name="wpAutoSummary" type="hidden" value="(.*?)"/sti=r_sti.exec(objhttp.responseText)eri=r_eti.exec(objhttp.responseText)etk=r_etk.exec(objhttp.responseText)asm=r_asm.exec(objhttp.responseText)document.getElementById('Starttime').value=sti[1]document.getElementById('Edittime').value=eri[1]document.getElementById('EditToken').value=etk[1]document.getElementById('AutoSummary').value=asm[1]}elsealert(objhttp.status)}}objhttp.open("GET",mw.config.get('wgServer')+mw.config.get('wgScript')+"?title="+encodeURIComponent(page)+"&action=edit")objhttp.send("")}functionwb$isValidPageName(name){if(name=="")returnfalseif(name.substr(0,10)=="Special:")returnfalsename=name.replace(/_/g," ")for(vari=0;i<wb$badPages.length;i++)if(name==wb$badPages[i])returnfalsereturntrue}functionwb$checkForm(form){varpage=form.wpSummary.valuevarcontent=form.wpTextbox1.valueif(content==""||content==wb$description||content.length<20||!content.match(' ')){alert("The description is too short, please expand it.")form.wpTextbox1.focus()returnfalse}page=page.replace(/^http:\/\/en\.wikipedia\.org\/wiki\/(.+)$/,"$1")page=page.replace(/_/g," ")page=decodeURIComponent(page)if(page==wgPageName.replace(/_/g," ")&&wb$isValidPageName(wgPageName)){if(wgNamespaceNumber==6){page="[[:File:"+wgTitle+"|"+wgTitle+"]]"content="[[File:"+wgTitle+"|thumb|left|100px]]\n* "+content+"\r\n{{clear}}"}else{page=page.replace(/^(Category:|File:|\/)/,":$1")page="[["+page+"]]"}}else{page=page.replace(/\[\[([^\[\]\|]+)\|[^\[\]\|]+\]\]/g,"$1")page=page.replace(/[\[\]\|]/g,"")page=page.replace(/^\s+/g,"")page=page.replace(/\s+$/g,"")if(!wb$isValidPageName(page)){alert("Enter the page name.")if(wb$isValidPageName(wgPageName))form.wpSummary.value=wgPageNameelse{form.wpSummary.value=""form.wpSummary.focus()}returnfalse}if(page.indexOf(':')>0)page='[[:'+page+']]'elsepage='[['+page+']]'}form.submit.disabled='disabled'if(wgUserName!=null)content+='\r\n\r\nPosted by: ~~'+'~~'elsecontent+='\r\n\r\nPosted by: '+form.author.value+' ~~'+'~~'form.wpTextbox1.value=contentform.wpSummary.value=pagereturntrue}functionwb$goToEditPage(){varedit_el=document.getElementById('ca-edit')varedit_href=window.wgArticlePath.replace(/\$1/,'Wikipedia:Error_reports')if(edit_el)edit_href=edit_el.getElementsByTagName('a')[0].hrefwindow.location=edit_href}functionwb$popBugBoth(action_page,infoHTML){varglob=document.body// shadowvarnel=document.createElement('div')nel.id='specpop-globhidden'nel.style.cssText='background:white;filter:alpha(opacity=75);opacity:0.75;position:absolute;left:0px;top:0px;z-index:2000'nel.style.width=document.documentElement.scrollWidth+'px'nel.style.height=document.documentElement.scrollHeight+'px'glob.appendChild(nel)// move the dialogwindow.scroll(0,150)// informationvaredit_el=document.getElementById('ca-edit')if(edit_el)varcan_edit=trueelsevarcan_edit=falsenel=document.createElement('div')nel.id='specpop-info'nel.style.cssText='font-size:13px;background:white;padding:21px 30px;border:1px solid black;position:absolute;width:500px;min-height:300px;top:200px;z-index:2002'if(nel.style.maxHeight==undefined)nel.style.height='300px'// IE blahvartmp=Math.floor(glob.clientWidth/2)-300if(tmp<5)tmp=5nel.style.left=tmp+'px'nel.innerHTML=infoHTMLif(window.wgUserName==null)nel.innerHTML=nel.innerHTML+'<p><strong>Attention.</strong> Your IP address will be logged in the page history.</p>'nel.innerHTML=nel.innerHTML+'<p style="text-align:center;margin-top:15px">\ '+(can_edit?'<input type="button" value="Fix it myselft" onclick="wb$goToEditPage()" />':'')+'\ <input type="button" value="Report the error" onclick="wb$elementsRemove(\'specpop-info\')" /> \ <input type="button" value="Cancel" onclick="wb$elementsRemove(\'specpop-info\',\'specpop-form\',\'specpop-globhidden\',\'specpop-pos\')" />\ </p>'glob.appendChild(nel)varaction_url=window.wgServer+window.wgScript+"?title="+encodeURIComponent(action_page)+"&action=submit"// formnel=document.createElement('div')nel.id='specpop-form'nel.style.cssText='background:white;padding:5px 10px;border:1px solid black;position:absolute;width:330px;min-height:300px;top:200px;z-index:2001'if(nel.style.maxHeight==undefined)nel.style.height='300px'// IE blahnel.style.left=(Math.floor(glob.clientWidth/2)-165)+'px'//nel.style.top = (this.offsetTop-100)+'px'nel.innerHTML='<form id="fm1" action="'+action_url+'" method="post" enctype="multipart/form-data" onsubmit="return wb$checkForm(this)">\ Page name:<br /><input type="text" name="wpSummary" id="wpSummary" style="width:320px" /><br />\ <input type="hidden" name="wpSection" value="new" />\ <input type="hidden" name="wpSave" value="Save" />\ <input type="hidden" id="Starttime" name="wpStarttime" value="" />\ <input type="hidden" id="Edittime" name="wpEdittime" value="" />\ <input type="hidden" id="EditToken" name="wpEditToken" value="" />\ <input type="hidden" id="AutoSummary" name="wpAutoSummary" value="" />\ <input type="hidden" name="wpScrolltop" value="0" />\ Message:<br /><textarea id="TextBox" name="wpTextbox1" style="width:320px;height:200px" onfocus="if (this.value == wb$description) {this.value = \'\'}">'+wb$description+'</textarea><br />\ Signature:<input type="text" name="author" id="wikibug-input-author" /><br />\ <input type="submit" id="submit" value="Send" /> \ <input type="button" value="Cancel" onclick="wb$elementsRemove(\'specpop-form\',\'specpop-globhidden\',\'specpop-pos\')" />\ </form>'glob.appendChild(nel)if(wb$isValidPageName(wgPageName))document.getElementById('wpSummary').value=wgPageName.replace(/_/g," ")if(wgUserName!=null){varauthor=document.getElementById("wikibug-input-author")author.value='~~'+'~~'author.disabled='disabled'}wb$getEditToken(action_page)}functionwb$elementsRemove(){varelfor(vari=arguments.length-1;i>=0;i--){el=document.getElementById(arguments[i])if(el)el.parentNode.removeChild(el)}}