Benutzer:Sarras/monobook.js
aus Wikipedia, der freien Enzyklopädie
Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Internet Explorer/Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
- Opera: Strg+F5
//DÜP-Monobook-Import ([[Benutzer:Ireas/düp-monobook.js]])
var duepTabsNachGanzLinks = true;
importScript('Benutzer:Ireas/düp-monobook.js');
includePage('Benutzer:Magnus_Manske/import_bib.js');
function new_import_bib () {
if ( wgNamespaceNumber != 0 && wgNamespaceNumber != 2 && wgNamespaceNumber != 100 ) return ;
toolbox = document.getElementById ( 'p-tb' ) ;
ul = toolbox.getElementsByTagName ( 'ul' ) [0];
li = document.createElement ( 'li' ) ;
a1 = document.createElement ( 'a' ) ;
a1.href = 'http://toolserver.org/~magnus/import_bib.php?title='+wgPageName ;
a1.appendChild ( document.createTextNode ( 'BibRef' ) ) ;
li.appendChild ( a1 ) ;
li.appendChild ( document.createTextNode ( ": " ) ) ;
a2 = document.createElement ( 'a' ) ;
a2.href = 'http://toolserver.org/~magnus/bibber.php?title='+wgPageName ;
a2.appendChild ( document.createTextNode ( 'Ersetzen' ) ) ;
li.appendChild ( a2 ) ;
if ( wgAction == "edit" ) {
a3 = document.createElement ( 'a' ) ;
a3.href = '#' ;
a3.onclick = function () { import_bib_new() ; return false ; }
a3.appendChild ( document.createTextNode ( 'Neu' ) ) ;
li.appendChild ( document.createTextNode ( " / " ) ) ;
li.appendChild ( a3 ) ;
}
ul.appendChild ( li ) ;
}
$(new_import_bib);
function import_bib_new () {
ibbox = document.createElement ( 'div' ) ;
ibbox.id = 'ibbox' ;
ibbox.style.position = 'fixed' ;
ibbox.style.top = '200px' ;
ibbox.style.left = '0' ;
ibbox.style.right = '0' ;
// ibbox.style.margin = 'auto' ;
ibbox2 = document.createElement ( 'div' ) ;
ibbox2.style.width = '400px' ;
ibbox2.style.margin = 'auto' ;
ibbox2.style.background = 'white' ;
ibbox2.style.border = '2px solid blue' ;
tb = document.getElementById('wpTextbox1')
sel = import_bib_get_selection(tb);
sel = sel.replace ( /[^\dX]/gi , '' ) ;
s = "<table border='1' width='100%'>" ;
s += "<tr><th>ISBN</th><td><input id='isbn' type='text' value='"+sel+"'/></td><td><input type='button' onclick='import_bib_check_isbn()' value='Prüfen/einfügen' /></td></tr>" ;
s += "<tr><th>Als</th><td colspan=2><input id='als_ref' name='als' type='radio' value='ref' checked />Referenz <input id='als_list' name='als' type='radio' value='list' />Listenelement</td></tr>" ;
s += "<tr><th>Seite(n)</th><td colspan='2'><input size='40' id='pages' type='text'/></td></tr>" ;
s += "<tr><th>Kommentar</th><td colspan='2'><input size='40' id='comment' type='text'/></td></tr>" ;
s += "<tr><td colspan='3' align='center'><input type='button' onclick='import_bib_close_box()' value='Abbruch' /></td></tr>" ;
s += "</table>" ;
ibbox2.innerHTML = s ;
ibbox.appendChild ( ibbox2 ) ;
document.getElementsByTagName('body')[0].appendChild ( ibbox ) ;
// setTimeout ( 10 , function(){document.getElementById('isbn').focus()} ) ;
}
function import_bib_check_isbn () {
isbn = document.getElementById('isbn').value ;
isbn = isbn.replace ( /[^\dX]/gi , '' ) ;
url = 'http://de.wikipedia.org/w/api.php?format=json&action=query&titles=Vorlage:BibISBN/'+isbn ;
var client = new XMLHttpRequest();
client.open("GET", url,false);
client.send();
json_text = client.responseText ;
json = eval('(' + json_text + ')');
page = json['query']['pages']['-1'] ;
if ( page ) {
if ( confirm ( 'Eintrag für ISBN '+isbn+' existiert noch nicht. Jetzt anlegen?' ) ) {
url = 'http://toolserver.org/~magnus/bibcomm.php?prefill=google&mode=new&type=isbn&entry_isbn='+isbn ;
window.open(url);//,"win1","fullscreen=0,statusbar=yes")
} else return ;
} else {
import_bib_add_new ( isbn ) ;
}
return false ;
}
function import_bib_add_new ( id ) {
comment = document.getElementById('comment').value ;
pages = document.getElementById('pages').value ;
bib = "{{BibISBN|" + id ;
if ( comment != '' ) bib += '|' + comment ;
if ( pages != '' ) bib += '|Seite=' + pages ;
bib += '}}' ;
if ( document.getElementById('als_ref').checked ) bib = "<ref>" + bib + "</ref>" ;
else bib = "* " + bib + "\n" ;
import_bib_close_box() ;
tb = document.getElementById('wpTextbox1') ;
tb.focus();
import_bib_insert ( tb , bib ) ;
}
function import_bib_close_box() {
box = document.getElementById('ibbox') ;
box.parentNode.removeChild(box);
}
function import_bib_insert(el,ins) {
if (el.setSelectionRange){
el.value = el.value.substring(0,el.selectionStart) + ins + el.value.substring(el.selectionStart,el.selectionEnd) + el.value.substring(el.selectionEnd,el.value.length);
}
else if (document.selection && document.selection.createRange) {
el.focus();
var range = document.selection.createRange();
range.text = ins + range.text;
}
}
function import_bib_get_selection(el) {
if (el.setSelectionRange){
return el.value.substring(el.selectionStart,el.selectionEnd) ;
}
return "" ;
}