function ocr_callback(ocrtext){ var tb = document.getElementById("wpTextbox1"); tb.value = ocrtext; tb.disabled=false; } function add_ocr() { var tb = document.getElementById("wpTextbox1"); tb.disabled=true; var input = document.getElementById("wpOcr"); if(input) input.disabled=true; if( proofreadPageWidth <= 1024 ) thumb_url = proofreadPageViewURL; else thumb_url = proofreadPageThumbURL.replace('##WIDTH##',1024); request_url = "http://toolserver.org/~thomasv/ocr.php?url="+thumb_url+"&lang="+wgContentLanguage+"&user="+wgUserName; var scriptObj = document.createElement("script"); scriptObj.setAttribute("type", "text/javascript"); scriptObj.setAttribute("src", request_url); scriptObj.setAttribute("id", "ocr_cb"); var headLoc = document.getElementsByTagName("head").item(0); headLoc.appendChild(scriptObj); } function addOCRButton2(id,comment,source,onclick){ var tb = document.getElementById("toolbar"); if(tb){ var image = document.createElement("img"); image.width = 46; image.height = 22; image.border = 0; image.className = "mw-toolbar-editbutton"; image.style.cursor = "pointer"; image.alt = "OCR"; image.title = comment; image.src = source; image.onclick = onclick; tb.appendChild(image); } } addOnloadHook(addOCRButton); function fraktur_ocr(){ self.wgContentLanguage = "de-f"; add_ocr(); self.wgContentLanguage = "de"; } function addOCRButton(){ if(!self.proofreadPageIsEdit) return; if(!self.proofreadPageViewURL) return; //if(wgCurRevisionId) if(self.wgDBname == "dewikisource"){ addOCRButton2("wpOcr","Normale OCR","http://upload.wikimedia.org/wikipedia/commons/e/e0/Button_ocr.png",add_ocr); addOCRButton2("wpOcr","Fraktur OCR","http://upload.wikimedia.org/wikipedia/commons/a/af/Button_Fractur_OCR.png",fraktur_ocr); } else addOCRButton2("wpOcr","Get the text by OCR","http://upload.wikimedia.org/wikipedia/commons/e/e0/Button_ocr.png",add_ocr); } /* cross-domain transclusions through the API */ function iw_trans_callback(res){ //var reg = /

([\s\S]*)<\/p>([^\/]*)/; var target = res.requestid; for(var i=0; item = document.getElementsByTagName("span")[i]; i++ ) { if (item.className == "iwtrans" && item.title==target ){ var txt = res.parse.text['*']; item.innerHTML = txt; //.match(reg)[1]; } } } function iw_trans() { for(var i=0; item = document.getElementsByTagName("span")[i]; i++ ) { if (item.className == "iwtrans") { var m = item.title.split("|"); lang=m[0]; title=m[1]; url = 'http://'+lang+'.wikisource.org/w/api.php?format=json&requestid='+item.title+'&action=parse&text=\{\{:'+title+'\}\}&callback=iw_trans_callback'; importScriptURI(url); //alert(url); } } } addOnloadHook(iw_trans); function iw_pages_callback(res){ var txt = res.parse.text['*']; var target = res.requestid; for(var i=0; item = document.getElementsByTagName("span")[i]; i++ ) { if (item.className == "iwpages" && item.title==target ){ item.innerHTML = txt; } } } function iw_pages() { for(var i=0; item = document.getElementsByTagName("span")[i]; i++ ) { if (item.className == "iwpages") { var m = item.title.split("|"); lang=m[0]; title=m[1]; from=m[2]; to=m[3]; url = 'http://'+lang+'.wikisource.org/w/api.php?format=json&requestid='+item.title+'&action=parse&callback=iw_pages_callback&text='; importScriptURI(url) } } } addOnloadHook(iw_pages);