User:Deerstop/vector.js: Difference between revisions
Appearance
Content deleted Content added
←Created page with 'importScript('User:AzaToth/twinkle.js'); importScript('User:Alex_Smotrov/qpreview.js'); importScript('User:Alex Smotrov/histcomb.js'); importScript('User:TheFear...' |
fixing |
||
Line 1: | Line 1: | ||
importScript('User:AzaToth/twinkle.js'); |
|||
importScript('User:Alex_Smotrov/qpreview.js'); |
|||
importScript('User:Alex Smotrov/histcomb.js'); |
|||
importScript('User:TheFearow/qstring.js'); |
|||
// <nowiki>If you are editing a page, click the wikify button on your tab bar to add "{{Wikify|{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}}}" to the top, set "Marked for wikification" as the edit summary, mark it as a minor edit, and submit.</nowiki> |
|||
function doQwikify() { |
|||
document.editform.wpTextbox1.value = '{' + '{' + 'Wikify|date=' + '{' + '{' + 'subst:CURRENTMONTHNAME}} ' + '{' + '{' + 'subst:CURRENTYEAR}}}}\n\n' + document.editform.wpTextbox1.value; |
|||
document.editform.wpSummary.value = 'Marked for wikification'; |
|||
document.editform.wpMinoredit.checked = true; |
|||
document.editform.submit(); |
|||
} |
|||
addOnloadHook(function() { |
|||
if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") { |
|||
// wouldn't it make more sense to just check for wgCanonicalNamespace != "", or am I missing something? |
|||
return; |
|||
} |
|||
if (document.editform) { |
|||
addPortletLink("p-cactions", "javascript:doQwikify()", "wikify", "ca-wikify", "Mark for wikification", ""); |
|||
} |
|||
}); |
|||
// by [[User:Raylu|raylu]] |
|||
// |
|||
//Please leave the following line |
|||
//[[user:Where/easy db]], maintained by [[User:MER-C]] |
|||
//Start db script |
|||
addOnloadHook(function() |
|||
{ |
|||
//check if called from deletion request |
|||
if (document.title.indexOf("Editing ") != -1) |
|||
{ |
|||
if (document.URL.lastIndexOf("&fakeaction=huff") == -1) |
|||
return; |
|||
// does the page exist? |
|||
if (wgCurRevisionId == false) |
|||
{ |
|||
alert("The page has already been deleted."); |
|||
return; |
|||
} |
|||
if (document.URL.lastIndexOf("&reason=off") != -1) |
|||
{ |
|||
var type = prompt("Enter criteria for speedy deletion, e.g. A1, G3"); |
|||
if (type == null) |
|||
return; |
|||
var f = document.editform, t = f.wpTextbox1; |
|||
t.value = "{" + "{db-" + type.toLowerCase() + "}}\n" + t.value; |
|||
f.wpSummary.value = "JS: Requesting speedy deletion ([[WP:CSD#" + type + "|CSD " + type.toUpperCase() + "]])"; |
|||
f.wpSave.click(); |
|||
return; |
|||
} |
|||
else if (document.URL.lastIndexOf("&reason=on") != -1) |
|||
{ |
|||
var type = prompt("Enter reason for speedy deletion"); |
|||
if (type == null) |
|||
return; |
|||
var f = document.editform, t = f.wpTextbox1; |
|||
t.value = "{" + "{db|" + type + "}}\n" + t.value; |
|||
f.wpSummary.value = "JS: Requesting speedy deletion"; |
|||
f.wpSave.click(); |
|||
return; |
|||
} |
|||
} |
|||
if (wgCanonicalNamespace == "Special") |
|||
return; |
|||
addPortletLink("p-cactions", "javascript:easyDb(0)", "db (csd)", "ca-db0", "Request speedy deletion according to WP:CSD", ""); |
|||
addPortletLink("p-cactions", "javascript:easyDb(1)", "db (reason)", "ca-db1", "Request speedy deletion with reason", ""); |
|||
}); |
|||
function easyDb(n) |
|||
{ |
|||
var title = wgPageName.replace("&", "%26").replace("+", "%2B"); |
|||
if (n == 0) |
|||
location.assign("/w/index.php?&action=edit&fakeaction=huff&reason=off&title=" + title); |
|||
if (n == 1) |
|||
location.assign("/w/index.php?&action=edit&fakeaction=huff&reason=on&title=" + title); |
|||
} |
|||
//End db script |
|||
// |
|||
//This script ([[User:ais523/highlightmyname2.js]]) highlights all instances of the |
|||
//logged-in user's username on pages by giving them a bright red background. It only |
|||
//checks bodyContent, not titles or sidebars, and doesn't change edit windows or |
|||
//Special:Preferences. |
|||
//<nowiki><pre> |
|||
function highlightmyname(n,p) //node, parent node |
|||
{ |
|||
while(n!=null) |
|||
{ |
|||
if(n.nodeType==3) //text node |
|||
{ |
|||
if(n.data.toLowerCase().indexOf(wgUserName.toLowerCase())!=-1) |
|||
{ |
|||
var ix=n.data.toLowerCase().indexOf(wgUserName.toLowerCase()); |
|||
var t1=ix?document.createTextNode(n.data.substr(0,ix)):null; |
|||
var t2=document.createTextNode(n.data.substr(ix,wgUserName.length)); |
|||
var t3=ix+wgUserName.length==n.data.length?null: |
|||
document.createTextNode(n.data.substr(ix+wgUserName.length)); |
|||
var s1=document.createElement("SPAN"); |
|||
s1.style.backgroundColor="Silver"; |
|||
s1.appendChild(t2); |
|||
var s2=document.createElement("SPAN"); |
|||
if(t1!=null) s2.appendChild(t1); |
|||
s2.appendChild(s1); |
|||
if(t3!=null) s2.appendChild(t3); |
|||
p.replaceChild(s2,n); |
|||
if(t3!=null) highlightmyname(t3,s2); //find remaining occurences in the new nodes |
|||
n=s2.nextSibling; |
|||
} |
|||
else |
|||
n=n.nextSibling; |
|||
} |
|||
else |
|||
{ |
|||
if(n.firstChild!=null) highlightmyname(n.firstChild,n); |
|||
n=n.nextSibling; |
|||
} |
|||
} |
|||
} |
|||
addOnloadHook(function() { |
|||
if(location.href.indexOf("?ais523")==-1&&location.href.indexOf("&ais523")==-1&& |
|||
location.href.indexOf("?action=edit")==-1&&location.href.indexOf("?action=submit")==-1&& |
|||
location.href.indexOf("&action=edit")==-1&&location.href.indexOf("&action=submit")==-1&& |
|||
location.href.indexOf("&action=raw")==-1&&wgPageName!="Special:Preferences") |
|||
highlightmyname(document.getElementById('bodyContent').firstChild, |
|||
document.getElementById('bodyContent')); |
|||
}); |
|||
//</pre></nowiki> |
|||
//[[Category:Wikipedia scripts]] |
|||
// [[User:Dschwen/highlightredirects.js]] - please include this line |
|||
document.write('<script type="text/javascript" src="' |
|||
+ 'http://en.wikipedia.org/w/index.php?title=User:Dschwen/highlightredirects.js' |
|||
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); |
|||
/* Watchlist notifier ([[User:Ais523/watchlistnotifier.js]]); displays a message every time a watched page changes. */ |
|||
//<pre><nowiki> |
|||
var wmwpajax; |
|||
// From [[WP:US]] mainpage (wpajax renamed to wmwpajax) |
|||
wmwpajax={ |
|||
download:function(bundle) { |
|||
// mandatory: bundle.url |
|||
// optional: bundle.onSuccess (xmlhttprequest, bundle) |
|||
// optional: bundle.onFailure (xmlhttprequest, bundle) |
|||
// optional: bundle.otherStuff OK too, passed to onSuccess and onFailure |
|||
var x = window.XMLHttpRequest ? new XMLHttpRequest() |
|||
: window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") |
|||
: false; |
|||
if (x) { |
|||
x.onreadystatechange=function() { |
|||
x.readyState==4 && wmwpajax.downloadComplete(x,bundle); |
|||
}; |
|||
x.open("GET",bundle.url,true); |
|||
x.send(null); |
|||
} |
|||
return x; |
|||
}, |
|||
downloadComplete:function(x,bundle) { |
|||
x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true ) |
|||
|| ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText+': '+bundle.url)); |
|||
} |
|||
}; |
|||
// Example: |
|||
// function dlComplete(xmlreq, data) { |
|||
// alert(data.message + xmlreq.responseText); |
|||
// } |
|||
// wmwpajax.download({url:'http://en.wikipedia.org/w/index.php?title=Thresher&action=raw', |
|||
// onSuccess: dlComplete, message: "Here's what we got:\n\n" }); |
|||
// End of [[WP:US]] quote |
|||
function wmWatchEditFound(xmlreq, data) { |
|||
var watchrev, watchsum, watchrevold, watchpage, junk; |
|||
if(xmlreq.responseText.indexOf('revid=')==-1) |
|||
{ |
|||
document.getElementById('contentSub').innerHTML+= |
|||
"<div class='watchlistnotify'>(<i>watchlistnotifier can't determine whether a "+ |
|||
"watched page has changed<i>)</div>"; |
|||
return; |
|||
} |
|||
watchrev=xmlreq.responseText.split('revid="')[1].split('"')[0]; |
|||
try |
|||
{ |
|||
watchrevold=document.cookie.split('ais523wmwatchrev=')[1].split('.')[0]; |
|||
} |
|||
catch(junk) {watchrevold=0;} |
|||
if(wgPageName == "Special:Watchlist") |
|||
{ |
|||
document.cookie="ais523wmwatchrev="+watchrev+".; path=/"; |
|||
var aas=document.getElementById('bodyContent').getElementsByTagName('a'); |
|||
var i=aas.length; |
|||
while(i--) |
|||
{ |
|||
if(aas[i].href.indexOf('diff=')!=-1&&watchrevold) |
|||
if(+(aas[i].href.split('diff=')[1].split('&')[0])>watchrevold) |
|||
aas[i].parentNode.style.fontWeight='bold'; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
watchsum=xmlreq.responseText.split('comment="')[1].split('"')[0]; |
|||
watchpage=xmlreq.responseText.split('title="')[1].split('"')[0]; |
|||
watchsum=watchsum.split('<').join('<').split('>').join('>'); |
|||
watchpage=watchpage.split('<').join('<').split('>').join('>'); |
|||
if(watchrev!=watchrevold) |
|||
document.getElementById('contentSub').innerHTML+= |
|||
"<div class='watchlistnotify'>\""+watchpage+'" changed: "'+watchsum+ |
|||
'". (<a href="/wiki/Special:Watchlist">watchlist</a>)</div>'; |
|||
} |
|||
} |
|||
addOnloadHook(function() { |
|||
/* Find the top item in the watchlist, and its edit summary. We only need one item, so |
|||
set the limit to 1 to ease the load on the server. */ |
|||
wmwpajax.download({url:'http://en.wikipedia.org/w/api.php?action=query&list=watchlist&wllimit=1&'+ |
|||
'wldir=older&format=xml&wlprop=comment|ids|title', onSuccess: wmWatchEditFound}); |
|||
}); |
|||
// </nowiki></pre> |
|||
// [[Category:Wikipedia scripts]] |
|||
function doAddQuickPreview() { |
|||
if ((wgAction != "edit") && (wgAction != "submit")) return; |
|||
var qbutton = document.getElementById("wpPreview").cloneNode(false); |
|||
qbutton.value = "Quick preview"; |
|||
qbutton.type="button"; |
|||
qbutton.tabindex="6"; |
|||
qbutton.accessKey="g"; |
|||
qbutton.id="dlQuickPreview"; |
|||
qbutton.title="Preview your changes"; |
|||
qbutton.addEventListener("click", doQuickPreview, false); |
|||
document.getElementById("wpPreview").parentNode.insertBefore(qbutton,document.getElementById("wpDiff")); |
|||
} |
|||
function doQuickPreview() { |
|||
var bt = document.getElementById("dlQuickPreview"); |
|||
document.getElementById("contentSub").innerHTML = "Getting preview"; |
|||
bt.value="Getting preview"; |
|||
bt.disabled=true; |
|||
var form = document.editform; |
|||
var postData = { |
|||
'wpMinoredit': form.wpMinoredit.checked, |
|||
'wpWatchthis': form.wpWatchthis.checked, |
|||
'wpStarttime': form.wpStarttime.value, |
|||
'wpEdittime': form.wpEdittime.value, |
|||
'wpAutoSummary': form.wpAutoSummary.value, |
|||
'wpEditToken': form.wpEditToken.value, |
|||
'wpSummary': "Quick preview", |
|||
'wpTextbox1': document.editform.wpTextbox1.value |
|||
}; |
|||
var addr = document.URL; |
|||
addr = addr.replace("&action=edit", "&action=submit"); |
|||
addr += "&wpPreview=true&live=true"; |
|||
var qwxmlhttp = sajax_init_object(null); |
|||
qwxmlhttp.overrideMimeType('text/xml'); |
|||
qwxmlhttp.open( 'POST' , addr, true); |
|||
qwxmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); |
|||
qwxmlhttp.onload = function() { |
|||
document.getElementById("wikiPreview").innerHTML = unescape(qwxmlhttp.responseText.replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&").replace(/"/g,'"')); |
|||
bt.disabled=false; |
|||
bt.value = "Quick preview"; |
|||
document.getElementById("contentSub").innerHTML = ""; |
|||
} |
|||
qwxmlhttp.send(QueryString.create(postData)); |
|||
} |
|||
/*<pre>*/ |
|||
/* * * * * * * * * * * * * * * * * * |
|||
* MediaWiki QuickEdit 2 by ASM |
|||
* Version: Apr 2008 |
|||
* * * * * * * * * * * * * * * * * * |
|||
* |
|||
* Translate QuickEdit into your language: |
|||
* [[:de:Benutzer:ASM/quickedit-lang.js]] |
|||
* |
|||
* How to use |
|||
* |
|||
* Insert into your monobook.js: |
|||
* |
|||
document.write('<script src="' |
|||
+ 'http://de.wikipedia.org/w/index.php?title=Benutzer:ASM/quickedit.js' |
|||
+ '&action=raw&ctype=text/javascript"></script>'); |
|||
* |
|||
* - - - Please DO NOT copy this script (in order to use it) - - - |
|||
* -> if you have any suggestions, bugs etc. please contact me |
|||
* |
|||
* This script uses the following external scripts: |
|||
* • diff.js by Cacycle - [[:en:User:Cacycle/diff.js]] |
|||
* • SearchBox.js by Zocky - [[:en:User:Zocky/SearchBox.js]] |
|||
* |
|||
* You can use these variables to customize QuickEdit: |
|||
* |
|||
* var qeEnabled = true; // Activate Script? |
|||
* var qeEnableSection0 = true; // Enable QuickEdit link for section 0 (introduction)? |
|||
* var qeEnableAccessKeys = true; // Activate access keys? |
|||
* var qeTextboxHeight = 20; // Height of the textbox |
|||
* var qeSignature = '--~~~~'; // Signature (use '' to hide signature tab) |
|||
* |
|||
* * * * * * * * * * * * * * * * * */ |
|||
/////////// Einstellungen /////////// |
|||
if (typeof(qeEnabled) == 'undefined') qeEnabled = true; |
|||
if (typeof(qeEnableSection0) == 'undefined') qeEnableSection0 = true; |
|||
if (typeof(qeTextboxHeight) == 'undefined') qeTextboxHeight = 20; |
|||
if (typeof(qeEnableAccessKeys) == 'undefined') qeEnableAccessKeys = true; |
|||
if (typeof(qeSignature) == 'undefined') qeSignature = '--~~~~'; |
|||
if (typeof(qeShowErrors) == 'undefined') qeShowErrors = false; |
|||
//////// Ende Einstellungen //////// |
|||
// version |
|||
var qeVersion = '2.3-2498'; |
|||
// qeMode constants |
|||
var MODE_QUICKEDIT = 0; |
|||
var MODE_PREVIEW = 1; |
|||
var MODE_DIFF = 2; |
|||
var MODE_PREF = 3; |
|||
// qeRequestState constants |
|||
var REQ_IDLE = 0; |
|||
var REQ_RECEIVE = 1; |
|||
var REQ_SUBMIT = 2; |
|||
// only initialize once |
|||
var qeIsInit = false; |
|||
// 2D-Array mit allen Sections und den jeweiligen Unterknoten |
|||
var qeSections = new Array(); |
|||
// Aktuell bearbeitete Section |
|||
var qeEdit = -1; |
|||
// Aktueller Modus |
|||
var qeMode = MODE_QUICKEDIT; |
|||
// Aktuell im Vorschau-Modus? |
|||
var qePreviewDisabled = false; |
|||
// preferences mode |
|||
var qePref = null; |
|||
// Link zum Bearbeiten der Abschnitte |
|||
var qeEditLink = false; |
|||
// Knoten |
|||
var qeParent = false; |
|||
var qeForm = false; |
|||
var qePreview = false; |
|||
var qeDiff = false; |
|||
var qeToolbar = false; |
|||
var qeOriginalText = null; |
|||
// Form action |
|||
var qeFormAction = false; |
|||
// XmlHttpRequest |
|||
var qeRequest = false; |
|||
// request state |
|||
var qeRequestState = REQ_IDLE; |
|||
// ondblclick |
|||
var qeOnDoubleClick = null; |
|||
// special chars sticky? |
|||
var qeStickyMode = false; |
|||
// scroll mode? |
|||
var qeScrollMode = true; |
|||
var qeTextboxHeightPixel = false; |
|||
////// Start Script ////// |
|||
qeInitTimer = null; |
|||
qeTries = 0; |
|||
addOnloadHook(qeInitTimeout); |
|||
// init wrapper |
|||
function qeInitTimeout() |
|||
{ |
|||
if (!qeInitTimer) qeInitTimer = window.setInterval(qeInitTimeout, 500); |
|||
var ex = true; |
|||
if (!qeEnabled || qeIsInit) ex = false; // check init |
|||
if (ex && !document.getElementById('ca-edit')) ex = false; // check editable |
|||
if (ex && document.location.search.indexOf('printable=yes') != -1) ex = false; // printable |
|||
if (ex && qeTries > 10) ex = false; |
|||
if (!ex) { window.clearInterval(qeInitTimer); return; } // abort if anything was false |
|||
qeTries++; |
|||
if (typeof(qeLanguages) != 'undefined') // then we can init QuickEdit |
|||
{ |
|||
window.clearInterval(qeInitTimer); |
|||
qeInit(); |
|||
} |
|||
} |
|||
function qeInit() |
|||
{ |
|||
if (!qeEnabled || qeIsInit) return; |
|||
qeIsInit = true; |
|||
// check if page is editable |
|||
if (!document.getElementById('ca-edit')) return; |
|||
// check if page is print page |
|||
if (document.location.search.indexOf('printable=yes') != -1) return; |
|||
// check if action is view or purge |
|||
if (match = /[?&]action=([a-z]+)/.exec(window.location.href)) |
|||
if (match[1] != 'view' && match[1] != 'purge') |
|||
return; |
|||
qeSetLang(); |
|||
if (!qeInitAjax()) return; |
|||
try { qeLoadExternalScripts(); } catch (e) {} |
|||
qeChangeSectionLinks(); |
|||
} |
|||
function qeLoadExternalScripts() |
|||
{ |
|||
// load Cacycle's diff script if not loaded |
|||
if (typeof(WDiffString) != 'function') ImportScriptPlain(qeResource('diff')); |
|||
// load search script |
|||
ImportScriptPlain(qeResource('search')); |
|||
// load stylesheet |
|||
ImportCSS(qeResource('style')); |
|||
} |
|||
// wrapper functions for ImportScriptEx |
|||
function ImportScriptPlain(script) { ImportScriptEx(script, false); } |
|||
function ImportCSS(css) { ImportScriptEx(css, true); } |
|||
function ImportScriptEx(script, css) |
|||
{ |
|||
var head = document.getElementsByTagName('head')[0]; |
|||
var link = document.createElement(css?'link':'script'); |
|||
link.setAttribute('charset', 'utf-8'); |
|||
link.setAttribute('type', css?'text/css':'text/javascript'); |
|||
link.setAttribute(css?'href':'src', script); |
|||
if (css) link.setAttribute('rel', 'stylesheet'); |
|||
head.appendChild(link); |
|||
} |
|||
function qeContentSub(text) |
|||
{ |
|||
var cs = document.getElementById('contentSub'); |
|||
if (cs.innerHTML) |
|||
cs.innerHTML += ' - ' + text; |
|||
else |
|||
cs.innerHTML = text; |
|||
} |
|||
function qeShowError(err) |
|||
{ |
|||
if (qeShowErrors) qeContentSub(qePhrase('quickedit') + ' ' + qePhrase('error') + ': ' + err); |
|||
} |
|||
function qeAlert(err) |
|||
{ |
|||
alert(qePhrase('quickedit') + ' ' + qePhrase('error') + ': ' + err); |
|||
} |
|||
function qeGetElementsByClassName(tagname, classname) |
|||
{ |
|||
var ret = new Array(); |
|||
var tags = document.getElementsByTagName(tagname); |
|||
for (i = 0; i < tags.length; i++) |
|||
if (tags[i].className == classname) |
|||
ret.push(tags[i]); |
|||
return ret; |
|||
} |
|||
function qeChangeSectionLinks() |
|||
{ |
|||
qeEditLink = document.getElementById('ca-edit').firstChild.href + '§ion='; |
|||
// get all sections |
|||
var sections = qeGetElementsByClassName('span', 'editsection'); |
|||
var jumptonav = document.getElementById('jump-to-nav'); |
|||
// Hauptabschnitt |
|||
if (qeEnableSection0) |
|||
{ |
|||
var heading = qeGetElementsByClassName('h1', 'firstHeading')[0]; |
|||
if (!heading || !jumptonav) |
|||
qeShowError('Section 0 nicht gefunden.'); |
|||
else |
|||
{ |
|||
// id verpassen |
|||
heading.id = 'section-0'; |
|||
// Knoten ins Array packen |
|||
qeSections[0] = new Array(); |
|||
var nosections = (sections.length == 0); |
|||
var node = jumptonav.nextSibling; |
|||
while (node != null && node.className != 'editsection' |
|||
&& node.className != 'printfooter' && (nosections|| !/^H[1-6]$/.test(node.nodeName))) |
|||
{ |
|||
if (node.nodeType == 1 && node.nodeName != 'SCRIPT') // avoid displaying in-<body> scripts |
|||
qeSections[0].push(node); |
|||
node = node.nextSibling; |
|||
} |
|||
// Link hinzufügen |
|||
var newspan = document.createElement('span'); |
|||
newspan.style.fontSize = '8pt'; |
|||
newspan.style.marginLeft = '10px'; |
|||
newspan.dir = 'ltr'; |
|||
newspan.appendChild(document.createTextNode('[')); |
|||
var newlink = document.createElement('a'); |
|||
newlink.href = 'javascript:qeEditSection(0)'; |
|||
newlink.id = 'sectionlink-0'; |
|||
newlink.className = 'sectionlink'; |
|||
newlink.appendChild(document.createTextNode(qePhrase('quickedit'))); |
|||
newspan.appendChild(newlink); |
|||
newspan.appendChild(document.createTextNode(']')); |
|||
// not appended to heading anymore |
|||
// heading.appendChild(newspan); |
|||
var cs = document.getElementById('contentSub'); |
|||
cs.style.display = 'block'; |
|||
cs.appendChild(newspan); |
|||
} |
|||
} // qeEnableSection0 |
|||
// Abschnitte |
|||
for (i = 0; i < sections.length; i++) |
|||
{ |
|||
// Section-Link suchen |
|||
var link = sections[i].childNodes[1].href; |
|||
var section = null, match = null; |
|||
if (match = /section=([0-9]+)/.exec(link)) |
|||
var section = +match[1]; |
|||
else break; |
|||
if (!section) continue; |
|||
sections[i].style.fontSize = '8pt'; |
|||
// QuickEdit-Link erstellen |
|||
var newnode = document.createElement('a'); |
|||
newnode.href = 'javascript:qeEditSection(' + section + ')'; |
|||
newnode.title = 'QuickEdit Section ' + section; |
|||
newnode.id = 'sectionlink-' + section; |
|||
newnode.className = 'sectionlink'; |
|||
newnode.appendChild(document.createTextNode(qePhrase('quickedit'))); |
|||
var where = sections[i].childNodes[2]; |
|||
sections[i].insertBefore(document.createTextNode('/'), where); |
|||
sections[i].insertBefore(newnode, where); |
|||
//// |
|||
// dem div eine ID verpassen |
|||
sections[i].id = 'editsection-' + section; |
|||
// zugehörige hX Überschrift suchen |
|||
var hx = sections[i].parentNode; |
|||
hx.id = 'section-' + section; |
|||
//// |
|||
// alle zu dieser Section gehörigen Knoten suchen und ins Array packen |
|||
qeSections[section] = new Array(); |
|||
var node = hx.nextSibling; |
|||
while (node != null && node.className != 'editsection' |
|||
&& node.className != 'printfooter' && !/^H[1-6]$/.test(node.nodeName)) |
|||
{ |
|||
if (node.nodeType == 1) |
|||
qeSections[section].push(node); |
|||
node = node.nextSibling; |
|||
} |
|||
} |
|||
} |
|||
function qeEditSection(section) |
|||
{ |
|||
if (qeRequestState || !qeEditLink) return; |
|||
section = parseInt(section); |
|||
// es wird bereits ein Abschnitt bearbeitet |
|||
// wenn es der aktuelle ist -> Bearbeiten abbrechen, sonst nichts tun |
|||
if (qeEdit != -1) |
|||
{ |
|||
if (qeEdit == section) qeAbortEdit(); |
|||
return; |
|||
} |
|||
qeEdit = section; |
|||
// save body.ondblclick |
|||
if (document.getElementsByTagName('body')[0].getAttribute('ondblclick')) |
|||
{ |
|||
qeOnDoubleClick = document.getElementsByTagName('body')[0].getAttribute('ondblclick'); |
|||
document.getElementsByTagName('body')[0].setAttribute('ondblclick', null); |
|||
} |
|||
// Inhalt des Abschnitts ausblenden |
|||
var nodes = qeSections[section]; |
|||
for (i = 0; i < nodes.length; i++) |
|||
nodes[i].style.display = 'none'; |
|||
//// |
|||
// andere Links ändern |
|||
var links = qeGetElementsByClassName('a', 'sectionlink'); |
|||
for (i = 0; i < links.length; i++) |
|||
{ |
|||
if (i == 0) links[i].parentNode.style.display = 'none'; |
|||
if (links[i].id != 'sectionlink-' + qeEdit) |
|||
links[i].style.color = '#bfbfbf'; |
|||
} |
|||
// Form anzeigen |
|||
qeMakeForm(); |
|||
var hx = document.getElementById('section-' + section); |
|||
hx.parentNode.insertBefore(qeParent, hx.nextSibling); |
|||
qeForm.firstChild.childNodes[4].value = qePhrase('loading') + '...'; |
|||
//// |
|||
// save textboxheight |
|||
if (!qeTextboxHeightPixel) |
|||
qeTextboxHeightPixel = qeGetStyle(document.getElementById('wpTextbox1'), 'height') || |
|||
Math.Round(qeTextboxHeight * 16.8) + 'px'; |
|||
// make sure the QuickEdit tab is activated and toolbar is hidden |
|||
qeSwitch(0); |
|||
qeSetToolbar(0); |
|||
qeGetSection(); |
|||
} |
|||
function qeAbortEdit() |
|||
{ |
|||
if (qeEdit == -1 || qeRequestState) return; |
|||
// Inhalt des Abschnitts wieder einblenden |
|||
var nodes = qeSections[qeEdit]; |
|||
for (i = 0; i < nodes.length; i++) |
|||
nodes[i].style.display = is_gecko?null:'block'; |
|||
var links = qeGetElementsByClassName('a', 'sectionlink'); |
|||
for (i = 0; i < links.length; i++) |
|||
{ |
|||
if (i == 0) links[i].parentNode.style.display = 'inline'; |
|||
if (links[i].id != 'sectionlink-' + qeEdit) |
|||
links[i].style.color = null; |
|||
} |
|||
// make sure cancel link does not look hovered anymore |
|||
qeTabMouseOverOut(document.getElementById('qeTabCancel'), 1); |
|||
qeParent.parentNode.removeChild(qeParent); |
|||
qeForm.firstChild.childNodes[4].value = ''; |
|||
qeEdit = -1; |
|||
// qeRequest.abort(); |
|||
qeRequestState = REQ_IDLE; |
|||
qeOriginalText = null; |
|||
// restore body.ondblclick |
|||
if (qeOnDoubleClick) |
|||
document.getElementsByTagName('body')[0].setAttribute('ondblclick', qeOnDoubleClick); |
|||
} |
|||
function qeMakeForm() |
|||
{ |
|||
if (qeForm) return; |
|||
if (qeSections.length == 1) qeTextboxHeight += 5; // higher textbox for the main section only |
|||
// create parent div |
|||
qeParent = document.createElement('div'); |
|||
qeParent.style.clear = 'both'; |
|||
// create tabs [CSS] |
|||
var ul = document.createElement('ul'); |
|||
ul.className = 'qeTabs'; |
|||
var li1 = document.createElement('li'); |
|||
var a = document.createElement('a'); |
|||
a.href = 'javascript:qeSwitch(0)'; |
|||
a.style.textDecoration = 'none'; |
|||
a.style.padding = '0 8px'; |
|||
a.appendChild(document.createTextNode(qePhrase('quickedit'))); |
|||
li1.appendChild(a); |
|||
// [CSS] |
|||
li1.id = 'qeTabEdit'; |
|||
li1.title = qePhrase('tQuickEdit'); |
|||
li1.className = 'qeTabs'; |
|||
li1.setAttribute('onmouseover', 'qeTabMouseOverOut(this, 0)'); |
|||
li1.setAttribute('onmouseout', 'qeTabMouseOverOut(this, 1)'); |
|||
var li2 = li1.cloneNode(true); |
|||
li2.id = 'qeTabPreview'; |
|||
li2.title = qePhrase('tLivePrev'); |
|||
li2.firstChild.href = 'javascript:qeSwitch(1)'; |
|||
li2.firstChild.firstChild.nodeValue = qePhrase('liveprev'); |
|||
// make li1 look selected |
|||
li1.style.borderColor = '#888'; |
|||
li1.style.borderBottom = 'none'; |
|||
li1.style.fontWeight = 'bold'; |
|||
li1.style.zIndex = '3'; |
|||
// tab 2a - diff mode |
|||
var li2a = li2.cloneNode(true); |
|||
li2a.id = 'qeTabDiff'; |
|||
li2a.title = qePhrase('tDiff'); |
|||
li2a.firstChild.href = 'javascript:qeSwitch(2)'; |
|||
li2a.firstChild.firstChild.nodeValue = qePhrase('diff'); |
|||
// tab 3 |
|||
var li4 = li2.cloneNode(true); |
|||
li4.id = 'qeTabSubmit'; |
|||
li4.style.marginLeft = '16px'; |
|||
li4.title = qePhrase('tSubmit'); |
|||
li4.firstChild.href = 'javascript:qeSubmit(0)'; |
|||
li4.firstChild.firstChild.nodeValue = qePhrase('submit'); |
|||
// tab 4 |
|||
var li5 = li2.cloneNode(true); |
|||
li5.id = 'qeTabRealPreview'; |
|||
li5.title = qePhrase('tPreview'); |
|||
li5.firstChild.href = 'javascript:qeSubmit(1)'; |
|||
li5.firstChild.firstChild.nodeValue = qePhrase('preview'); |
|||
// tab 5 |
|||
var li6 = li2.cloneNode(true); |
|||
li6.id = 'qeTabCancel'; |
|||
li6.title = qePhrase('tCancel'); |
|||
li6.firstChild.href = 'javascript:qeAbortEdit()'; |
|||
li6.firstChild.firstChild.nodeValue = qePhrase('cancel'); |
|||
var li8 = li2.cloneNode(true); |
|||
li8.id = 'qeTabSig'; |
|||
li8.title = qePhrase('tSig'); |
|||
li8.style.marginLeft = '16px'; |
|||
li8.firstChild.href = 'javascript:qeAddSignature()'; |
|||
li8.firstChild.firstChild.nodeValue = qePhrase('sig'); |
|||
if (qeEnableAccessKeys) |
|||
{ |
|||
li1.firstChild.accessKey = 'e'; // quickedit |
|||
li2.firstChild.accessKey = 'p'; // live prev |
|||
li2a.firstChild.accessKey= 'v'; // diff |
|||
li4.firstChild.accessKey = 's'; // submit |
|||
li6.firstChild.accessKey = 'a'; // cancel |
|||
li8.firstChild.accessKey = 'f'; // sig |
|||
} |
|||
// [CSS] |
|||
var li3 = document.createElement('li'); |
|||
li3.className = 'qeTabsVersion'; |
|||
li3.title = 'MediaWiki QuickEdit ' + qeVersion; |
|||
var version = qePhrase('header') + ' ' + qeVersion.substr(0, qeVersion.indexOf('-')); |
|||
li3.appendChild(document.createTextNode(version)); |
|||
if (qeLanguages[qeLang-1][0] != wgUserLanguage) |
|||
{ |
|||
var a = document.createElement('a'); |
|||
a.href = 'http://de.wikipedia.org/wiki/Benutzer:ASM/quickedit-lang.js'; |
|||
a.style.marginLeft = '3px'; |
|||
a.style.color = '#aaa'; |
|||
a.appendChild(document.createTextNode('Add your translation!')); |
|||
li3.appendChild(a); |
|||
} |
|||
// options tab |
|||
var li7 = li2.cloneNode(true); |
|||
li7.id = 'qeTabPref'; |
|||
li7.title = qePhrase('pref'); |
|||
li7.style.marginLeft = '16px'; |
|||
li7.firstChild.href = 'javascript:qePreferences()'; |
|||
li7.firstChild.firstChild.nodeValue = qePhrase('pref'); |
|||
ul.appendChild(li3); |
|||
ul.appendChild(li1); |
|||
ul.appendChild(li2); |
|||
ul.appendChild(li2a); |
|||
ul.appendChild(li4); |
|||
ul.appendChild(li5); |
|||
ul.appendChild(li6); |
|||
if (qeSignature) ul.appendChild(li8); // sig tab |
|||
// ul.appendChild(li7); new feature: wip. temporarily disabled |
|||
qeParent.appendChild(ul); |
|||
// create frame div [CSS] |
|||
var framediv = document.createElement('div'); |
|||
framediv.id = 'framediv'; |
|||
qeParent.appendChild(framediv); |
|||
// create form |
|||
qeForm = document.createElement('form'); |
|||
qeForm.method = 'post'; |
|||
qeForm.onsubmit = qeSubmitByReturn; |
|||
// create preview div [CSS] |
|||
qePreview = document.createElement('div'); |
|||
qePreview.id = 'qePreview'; |
|||
qePreview.style.display = 'none'; |
|||
qePreview.style.overflow = qeScrollMode ? 'scroll':'hidden'; |
|||
qePreview.style.backgroundColor = qeGetBGColor(); |
|||
// create diff div [CSS] |
|||
qeDiff = document.createElement('div'); |
|||
qeDiff.id = 'qeDiff'; |
|||
qeDiff.style.display = 'none'; |
|||
// preview message |
|||
var div = document.createElement('div'); |
|||
div.style.padding = '100px 0'; |
|||
div.style.textAlign = 'center'; |
|||
div.style.color = '#aaa'; |
|||
div.style.cursor = 'default'; |
|||
div.appendChild(document.createTextNode(qePhrase('loadprev') + '...')); |
|||
qePreview.appendChild(div); |
|||
framediv.appendChild(qeDiff); |
|||
framediv.appendChild(qePreview); |
|||
framediv.appendChild(qeForm); |
|||
//// |
|||
// add form div |
|||
qeForm.appendChild(document.createElement('div')); |
|||
var elements = new Array( |
|||
// subject type name |
|||
new Array('input', 'hidden', 'wpSection'), |
|||
new Array('input', 'hidden', 'wpStarttime'), |
|||
new Array('input', 'hidden', 'wpEdittime'), |
|||
new Array('input', 'hidden', 'wpSummary'), |
|||
new Array('textarea', 'wpTextbox1'), |
|||
new Array('input', 'hidden', 'wpEditToken'), |
|||
new Array('input', 'hidden', 'wpAutoSummary') |
|||
); |
|||
for (i = 0; i < elements.length; i++) |
|||
{ |
|||
var e = elements[i]; |
|||
var newnode = document.createElement(e[0]); |
|||
if (e[0] == 'input') |
|||
{ |
|||
newnode.type = e[1]; |
|||
newnode.name = e[2]; |
|||
} |
|||
else if (e[0] == 'textarea') |
|||
{ |
|||
newnode.id = e[1]; |
|||
newnode.name = e[1]; |
|||
newnode.appendChild(document.createTextNode('')); |
|||
newnode.rows = qeTextboxHeight; |
|||
newnode.style.width = '99%'; |
|||
newnode.style.border = '1px solid #ddd'; |
|||
} |
|||
qeForm.firstChild.appendChild(newnode); |
|||
} |
|||
if (qeEnableAccessKeys) qeForm.firstChild.childNodes[4].accessKey = ','; |
|||
qeForm.firstChild.childNodes[4].tabIndex = 1; |
|||
// the toolbar |
|||
qeToolbar = document.createElement('div'); |
|||
qeToolbar.id = 'qeToolbar'; |
|||
qeToolbar.style.display = 'block'; |
|||
qeToolbar.style.minHeight='5px'; |
|||
// close button [CSS] |
|||
var img = document.createElement('img'); |
|||
img.id = 'qeClose'; |
|||
img.title = qePhrase('close'); |
|||
img.src = qeResource('x'); |
|||
img.setAttribute('onclick', 'qeSetToolbar(0)'); |
|||
// search box |
|||
var search = document.createElement('div'); |
|||
search.id = 'qeSearch'; |
|||
search.style.marginTop = '0.4em'; |
|||
search.style.marginBottom = '0.4em'; |
|||
qeCreateSearchBox(search); |
|||
// special chars |
|||
var chars = document.createElement('div'); |
|||
chars.id = 'specialchars-container'; |
|||
chars.style.overflow = 'hidden'; |
|||
chars.style.marginBottom = '0.2em'; |
|||
qeToolbar.appendChild(img); |
|||
qeToolbar.appendChild(search); |
|||
qeToolbar.appendChild(chars); |
|||
qeForm.appendChild(qeToolbar); |
|||
// create bottom bar |
|||
newnode = document.createElement('div'); |
|||
newnode.style.paddingTop= '5px'; |
|||
newnode.style.borderTop = '1px dotted #aaa'; |
|||
// mini toolbar (lower right corner) |
|||
var span = document.createElement('span'); |
|||
span.style.cssFloat = 'right'; |
|||
span.style.verticalAlign= 'middle'; |
|||
span.style.marginTop = '0.2em'; |
|||
// search box icon [CSS] |
|||
var img = document.createElement('img'); |
|||
img.id = 'icon-search'; |
|||
img.src = qeResource('searchbox'); |
|||
img.title = qePhrase('searchbox'); |
|||
img.setAttribute('onclick', 'qeSetToolbar(1)'); |
|||
span.appendChild(img); |
|||
// special chars icon |
|||
var img = img.cloneNode(false); |
|||
img.id = 'icon-specialchars'; |
|||
img.src = qeResource('chars'); |
|||
img.title = qePhrase('chars'); |
|||
img.style.borderLeft = '1px solid #ccc'; |
|||
img.setAttribute('onclick', 'qeSetToolbar(2)'); |
|||
span.appendChild(img); |
|||
// scroll icon |
|||
var img = img.cloneNode(false); |
|||
img.src = null; |
|||
img.title = null; |
|||
img.id = 'icon-scroll'; |
|||
img.style.display = 'none'; // hidden by default (only visible in preview mode) |
|||
img.setAttribute('onclick', 'qeToggleScroll()'); |
|||
span.appendChild(img); |
|||
newnode.appendChild(span); |
|||
// Speichern |
|||
var c = document.createElement('a'); |
|||
c.href = 'javascript:qeSubmit(0)'; |
|||
c.title = qePhrase('tSubmit'); |
|||
c.style.cursor = 'pointer'; |
|||
c.appendChild(document.createTextNode(qePhrase('submit'))); |
|||
newnode.appendChild(c); |
|||
// Vorschau |
|||
newnode.appendChild(document.createTextNode(' ')); |
|||
c = document.createElement('a'); |
|||
c.href = 'javascript:qeSubmit(1)'; |
|||
c.title = qePhrase('tPreview'); |
|||
c.style.marginLeft = '5px'; |
|||
c.style.cursor = 'pointer'; |
|||
c.appendChild(document.createTextNode(qePhrase('preview'))); |
|||
newnode.appendChild(c); |
|||
// Zusammenfassung |
|||
newnode.appendChild(document.createTextNode(' ')); |
|||
c = document.createElement('input'); |
|||
c.type = 'text'; |
|||
c.size = '70'; |
|||
c.id = 'qeSummary'; |
|||
c.maxLength = '200'; |
|||
c.style.marginLeft = '5px'; |
|||
c.tabIndex = 2; |
|||
c.addEventListener('keydown', qeSubmitByReturn, false); |
|||
newnode.appendChild(c); |
|||
// Kleine Änderung |
|||
newnode.appendChild(document.createTextNode(' ')); |
|||
var checkboxes = document.createElement('span'); |
|||
checkboxes.style.whiteSpace = 'nowrap'; |
|||
checkboxes.appendChild(document.createElement('input')); |
|||
checkboxes.childNodes[0].type = 'checkbox'; |
|||
checkboxes.childNodes[0].id = 'wpMinoredit'; |
|||
checkboxes.childNodes[0].name = 'wpMinoredit'; |
|||
checkboxes.childNodes[0].value = '1'; |
|||
checkboxes.childNodes[0].style.marginLeft = '5px'; |
|||
checkboxes.childNodes[0].tabIndex = 3; |
|||
checkboxes.childNodes[0].title = qePhrase('tMinor'); |
|||
if (qeEnableAccessKeys) checkboxes.childNodes[0].accessKey = 'i'; |
|||
checkboxes.appendChild(document.createElement('label')); |
|||
checkboxes.childNodes[1].htmlFor = 'wpMinoredit'; |
|||
checkboxes.childNodes[1].style.fontWeight = 'bold'; |
|||
checkboxes.childNodes[1].style.fontSize = '8pt'; |
|||
checkboxes.childNodes[1].style.position = 'relative'; |
|||
checkboxes.childNodes[1].style.bottom = '2px'; |
|||
checkboxes.childNodes[1].title = qePhrase('tMinor'); |
|||
checkboxes.childNodes[1].appendChild(document.createTextNode(qePhrase('k'))); |
|||
// Beobachten |
|||
checkboxes.appendChild(document.createTextNode(' ')); |
|||
checkboxes.appendChild(document.createElement('input')); |
|||
checkboxes.childNodes[3].type = 'checkbox'; |
|||
checkboxes.childNodes[3].id = 'wpWatchthis'; |
|||
checkboxes.childNodes[3].name = 'wpWatchthis'; |
|||
checkboxes.childNodes[3].value = '1'; |
|||
checkboxes.childNodes[3].style.marginLeft = '5px'; |
|||
checkboxes.childNodes[3].tabIndex = 4; |
|||
checkboxes.childNodes[3].title = qePhrase('tWatch'); |
|||
if (qeEnableAccessKeys) checkboxes.childNodes[3].accessKey = 'w'; |
|||
checkboxes.appendChild(document.createElement('label')); |
|||
checkboxes.childNodes[4].htmlFor = 'wpWatchthis'; |
|||
checkboxes.childNodes[4].style.fontWeight = 'bold'; |
|||
checkboxes.childNodes[4].style.fontSize = '8pt'; |
|||
checkboxes.childNodes[4].style.position = 'relative'; |
|||
checkboxes.childNodes[4].style.bottom = '2px'; |
|||
checkboxes.childNodes[4].title = qePhrase('tWatch'); |
|||
checkboxes.childNodes[4].appendChild(document.createTextNode(qePhrase('b'))); |
|||
newnode.appendChild(checkboxes); |
|||
qeForm.appendChild(newnode); |
|||
} |
|||
function qeFillForm(formaction, wpStarttime, wpEdittime, wpSummary, wpTextbox1, |
|||
wpEditToken, wpAutoSummary, wpWatchthis) |
|||
{ |
|||
if (!qeForm) return; |
|||
// save form action since we need it for preview |
|||
qeFormAction = formaction; |
|||
qeForm.firstChild.childNodes[0].value = qeEdit; |
|||
qeForm.firstChild.childNodes[1].value = wpStarttime; |
|||
qeForm.firstChild.childNodes[2].value = wpEdittime; |
|||
qeForm.firstChild.childNodes[3].value = wpSummary; |
|||
qeForm.firstChild.childNodes[4].value = wpTextbox1; |
|||
qeForm.firstChild.childNodes[5].value = wpEditToken; |
|||
qeForm.firstChild.childNodes[6].value = wpAutoSummary; |
|||
document.getElementById('wpWatchthis').checked = wpWatchthis; |
|||
qeForm.action = formaction; |
|||
document.getElementById('qeSummary').value = wpSummary; |
|||
// store the original text for diff |
|||
qeOriginalText = wpTextbox1; |
|||
} |
|||
function qeSetToolbar(type) |
|||
{ |
|||
var search = document.getElementById('qeSearch'), |
|||
chars = document.getElementById('specialchars-container'), |
|||
close = document.getElementById('qeClose'); |
|||
search.style.display = (type == 1)?'block':'none'; |
|||
chars.style.display = (type == 2)?'block':'none'; |
|||
close.style.display = (type != 0)?'block':'none'; |
|||
} |
|||
function qeToggleScroll() |
|||
{ |
|||
if (qeMode != MODE_PREVIEW) return; |
|||
qeScrollMode = !qeScrollMode; |
|||
var img = document.getElementById('icon-scroll'); |
|||
img.src = qeScrollMode ? qeResource('arrowdown') : qeResource('arrowup'); |
|||
img.title = qeScrollMode ? qePhrase('scrolloff'): qePhrase('scrollon'); |
|||
qePreview.style.height = qeScrollMode ? qeTextboxHeightPixel : null; |
|||
qePreview.style.overflow = qeScrollMode ? 'scroll' : 'hidden'; |
|||
} |
|||
// QuickEdit 2.3: Search |
|||
function qeCreateSearchBox(node) |
|||
{ |
|||
sr$f = node; |
|||
node.style.color = '#888'; |
|||
node.style.fontSize = '0.83em'; |
|||
node.appendChild(document.createTextNode(qePhrase('srsearch') + ': ')); |
|||
// search box |
|||
var input = document.createElement('input'); |
|||
input.id = 'srSearch'; |
|||
input.type = 'text'; |
|||
input.style.marginRight = '0.7em'; |
|||
input.setAttribute('onkeypress', 'event.which == 13 && srNext()'); |
|||
node.appendChild(input); |
|||
sr$s = input; |
|||
node.appendChild(document.createTextNode(qePhrase('srreplace') + ': ')); |
|||
// replace box |
|||
input = input.cloneNode(false); |
|||
input.id = 'srReplace'; |
|||
node.appendChild(input); |
|||
sr$r = input; |
|||
// the find and replace-links |
|||
var a = document.createElement('a'); |
|||
a.href = 'javascript:srBack()'; |
|||
a.style.color = '#888'; |
|||
a.appendChild(document.createTextNode('<')); |
|||
node.appendChild(a); |
|||
var links = [['srNext()', '0.4em', qePhrase('srfind') + ' >'], |
|||
['srReplace();srBack()', '1em', '<'], |
|||
['srReplace()', '0.4em', qePhrase('srreplace')], |
|||
['srReplace;srNext()', '0.4em', '>'], |
|||
['srReplaceall()', '1em', qePhrase('srreplaceall')]]; |
|||
for (var i = 0; i < links.length; i++) |
|||
{ |
|||
var a = a.cloneNode(false); |
|||
a.href = 'javascript:' + links[i][0]; |
|||
a.style.marginLeft = links[i][1]; |
|||
a.appendChild(document.createTextNode(links[i][2])); |
|||
node.appendChild(a); |
|||
} |
|||
// two checkboxes |
|||
var input = document.createElement('input'); |
|||
input.id = 'srCase'; |
|||
input.type = 'checkbox'; |
|||
input.style.marginLeft = '1em'; |
|||
input.setAttribute('onclick', 'document.getElementById("srSearch").focus()'); |
|||
var label = document.createElement('label'); |
|||
label.htmlFor = 'srCase'; |
|||
label.appendChild(document.createTextNode(qePhrase('srmatchcase'))); |
|||
node.appendChild(input); |
|||
node.appendChild(label); |
|||
sr$mc = input; |
|||
var input = input.cloneNode(false); |
|||
var label = label.cloneNode(false); |
|||
input.id = 'srRegexp'; |
|||
label.htmlFor = 'srRegexp'; |
|||
label.appendChild(document.createTextNode(qePhrase('srregexp'))); |
|||
node.appendChild(input); |
|||
node.appendChild(label); |
|||
sr$re = input; |
|||
// set up searchbox.js specific variables |
|||
sr$t = qeForm.firstChild.childNodes[4]; |
|||
} |
|||
// QuickEdit 2.1: Preferences stuff |
|||
function qePreferences() |
|||
{ |
|||
if (qeMode == MODE_PREF) |
|||
{ |
|||
qePrefMode = false; |
|||
qeDestroyPrefForm(); |
|||
return; |
|||
} |
|||
qePrefMode = true; |
|||
qeMakePrefForm(); |
|||
} |
|||
function qeMakePrefForm() |
|||
{ |
|||
// set the style of the pref tab selected |
|||
var tab = document.getElementById('qeTabPref'); |
|||
tab.style.border = '1px solid #888'; |
|||
tab.style.borderBottom = 'none'; |
|||
tab.style.fontWeight = 'bold'; |
|||
tab.style.marginLeft = '0px'; |
|||
// hide preview div, the form and the other tabs |
|||
qeForm.style.display = 'none'; |
|||
qePreview.style.display = 'none'; |
|||
var ul = qeParent.firstChild; |
|||
for (var i = 0; i < ul.childNodes.length && ul.childNodes[i] != tab; i++) |
|||
ul.childNodes[i].style.display = 'none'; |
|||
// create pref div |
|||
qePref = document.createElement('div'); |
|||
qePref.style.textAlign = 'center'; |
|||
qePref.style.minHeight = '200px'; |
|||
qePref.style.lineHeight = '2em'; |
|||
qePref.style.border = '1px dotted #aaa'; |
|||
qePref.style.backgroundColor = '#fff'; |
|||
var h = document.createElement('div'); |
|||
h.style.borderBottom = '1px solid #aaa'; |
|||
h.style.textAlign = 'left'; |
|||
h.style.fontSize = '14px'; |
|||
h.style.fontWeight = 'bold'; |
|||
h.style.paddingLeft = '10px'; |
|||
h.style.margin = '20px 50px'; |
|||
h.appendChild(document.createTextNode(qePhrase('prefheading'))); |
|||
qePref.appendChild(h); |
|||
for (var i = 0; i < qeOptions.length; i++) |
|||
{ |
|||
var name = qeOptions[i][0], type = qeOptions[i][1], defaultval = qeOptions[i][2], |
|||
userval = qeOptions[i][3]; |
|||
if (!userval) userval = defaultval; |
|||
var e = document.createElement('input'), // input element |
|||
d = document.createElement('label'); // description |
|||
// set input element attributes |
|||
e.id = 'o-' + name; |
|||
e.name = e.id; |
|||
if (type == 'bool') |
|||
{ |
|||
e.type = 'checkbox'; |
|||
e.checked = (userval == 'true'); |
|||
} |
|||
// set description attributes |
|||
d.htmlFor = e.id; |
|||
d.style.fontWeight = 'bold'; |
|||
d.style.marginRight = '5px'; |
|||
d.appendChild(document.createTextNode(qePhrase('o' + name))); |
|||
qePref.appendChild(d); |
|||
qePref.appendChild(e); |
|||
if (i != qeOptions.length - 1) |
|||
qePref.appendChild(document.createElement('br')); |
|||
} |
|||
// insert node before preview |
|||
qePreview.parentNode.insertBefore(qePref, qePreview); |
|||
} |
|||
function qeDestroyPrefForm() |
|||
{ |
|||
qePref.parentNode.removeChild(qePref); |
|||
qePref = null; |
|||
// restore: form, tabs |
|||
qeForm.style.display = 'block'; |
|||
var ul = qeParent.firstChild; |
|||
for (var i = 0; i < ul.childNodes.length; i++) |
|||
ul.childNodes[i].style.display = 'inline'; |
|||
// reset tab style |
|||
var tab = document.getElementById('qeTabPref'); |
|||
tab.style.border = '1px solid #aaa'; |
|||
tab.style.borderBottom = 'none'; |
|||
tab.style.fontWeight = 'normal'; |
|||
tab.style.marginLeft = '16px'; |
|||
qeSwitch(0); // make sure to get back into edit mode |
|||
} |
|||
// QuickEdit 2: Preview stuff |
|||
function qeSwitch(type) |
|||
{ |
|||
if (qeEdit == -1 || qeRequestState || qeMode == MODE_PREF) return; |
|||
if (type == 3 && typeof(WDiffString) != 'function') // diff mode |
|||
{ |
|||
qeDiff.appendChild(document.createTextNode('Error: Couldn\'t load diff.js')); |
|||
return; |
|||
} |
|||
switch (type) |
|||
{ |
|||
case 1: var lid = document.getElementById('qeTabPreview'); break; |
|||
case 2: var lid = document.getElementById('qeTabDiff'); break; |
|||
default: var lid = document.getElementById('qeTabEdit'); break; |
|||
} |
|||
switch (qeMode) |
|||
{ |
|||
case MODE_PREVIEW: var lia = document.getElementById('qeTabPreview'); break; |
|||
case MODE_DIFF: var lia = document.getElementById('qeTabDiff'); break; |
|||
default: var lia = document.getElementById('qeTabEdit'); break; |
|||
} |
|||
lia.style.border = '1px solid #aaa'; |
|||
lia.style.fontWeight = 'normal'; |
|||
lia.style.zIndex = '1'; |
|||
lid.style.border = '1px solid #888'; |
|||
lid.style.fontWeight = 'bold'; |
|||
lid.style.zIndex = '3'; |
|||
lia.style.borderBottom = lid.style.borderBottom = '1px none #aaa'; |
|||
// now check if there is any change |
|||
type = parseInt(type); |
|||
if (type == qeMode) return; |
|||
qeMode = type; |
|||
if (qeMode != MODE_DIFF) qeDiff.innerHTML = ''; |
|||
// switch to preview |
|||
if (qeMode == MODE_PREVIEW) |
|||
{ |
|||
// set scroll mode image |
|||
var img = document.getElementById('icon-scroll'); |
|||
img.src = qeScrollMode ? qeResource('arrowdown') : qeResource('arrowup'); |
|||
img.title = qeScrollMode ? qePhrase('scrolloff'): qePhrase('scrollon'); |
|||
img.style.display = 'inline'; |
|||
// set preview height |
|||
if (qeScrollMode) qePreview.style.height = qeTextboxHeightPixel; |
|||
// set bg color according to the background of the current section |
|||
qePreview.style.backgroundColor = |
|||
qeGetBGColorOf(document.getElementById('section-' + qeEdit)) |
|||
|| qeGetBGColor(); |
|||
// remove all child nodes from previous previews, if any |
|||
for (var i = 1; i < qePreview.childNodes.length; i++) |
|||
qePreview.removeChild(qePreview.childNodes[i]); |
|||
// hide quickedit, hide diff |
|||
qeForm.firstChild.style.display = 'none'; |
|||
qeDiff.style.display = 'none'; |
|||
// show preview |
|||
qePreview.style.display = 'block'; |
|||
qePreview.firstChild.style.display = 'block'; |
|||
qeLoadPreview(); |
|||
} |
|||
else if (qeMode == MODE_QUICKEDIT) |
|||
{ |
|||
// hide diff, hide preview |
|||
qeDiff.style.display = 'none'; |
|||
qePreview.style.display = 'none'; |
|||
document.getElementById('icon-scroll').style.display = 'none'; |
|||
// show quickedit |
|||
qeForm.firstChild.style.display = 'block'; |
|||
} |
|||
else // MODE_DIFF |
|||
{ |
|||
// hide quickedit, hide preview |
|||
qeForm.firstChild.style.display = 'none'; |
|||
qePreview.style.display = 'none'; |
|||
document.getElementById('icon-scroll').style.display = 'none'; |
|||
// show diff |
|||
qeDiff.style.display = 'block'; |
|||
qeDiff.style.height = qeTextboxHeightPixel; |
|||
qeLoadDiff(); |
|||
} |
|||
} |
|||
function qeLoadDiff() |
|||
{ |
|||
var currenttext = document.getElementById('wpTextbox1').value; |
|||
qeDiff.innerHTML = WDiffShortenOutput(WDiffString(qeOriginalText, currenttext)); |
|||
var div = document.createElement('div'); |
|||
div.style.textAlign = 'right'; |
|||
div.style.position = 'relative'; |
|||
div.style.bottom = '10px'; |
|||
var span = document.createElement('span'); |
|||
span.style.fontSize = '8pt'; |
|||
span.style.color = '#aaa'; |
|||
span.style.marginRight = '10%'; |
|||
span.appendChild(document.createTextNode('Using ')); |
|||
var a = document.createElement('a'); |
|||
a.href = qeResource('diffscript'); |
|||
a.style.textDecoration = 'underline'; |
|||
a.style.color = '#aaa'; |
|||
a.appendChild(document.createTextNode('diff.js')); |
|||
span.appendChild(a); |
|||
span.appendChild(document.createTextNode(' by Cacycle')); |
|||
div.appendChild(span); |
|||
qeDiff.appendChild(div); |
|||
} |
|||
function qeLoadPreview() |
|||
{ |
|||
if (qeEdit == -1 || qeRequestState || !qeEditLink || qeMode != MODE_PREVIEW || !qeFormAction) |
|||
return; |
|||
var link = qeEditLink + qeEdit; |
|||
qeRequestState = REQ_SUBMIT; |
|||
qeRequest.onreadystatechange = qeAjaxResponse; |
|||
qeRequest.open('POST', qeFormAction, true); |
|||
var send = qeMakeFormRequest(); |
|||
qeRequest.overrideMimeType('text/xml'); |
|||
qeRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); |
|||
qeRequest.setRequestHeader('Content-length', send.length); |
|||
qeRequest.setRequestHeader('Content', send.length); |
|||
qeRequest.send(send); |
|||
} |
|||
function qeMakeFormRequest() |
|||
{ |
|||
if (!qeForm) return null; |
|||
var str = ''; |
|||
var inputs = qeForm.getElementsByTagName('input'); |
|||
for (var i = 0; i < inputs.length; i++) |
|||
if (inputs[i].value && inputs[i].value.length > 0) |
|||
str += '&' + inputs[i].name + '=' + encodeURIComponent(inputs[i].value); |
|||
str += '&wpPreview=Preview' + |
|||
'&wpTextbox1=' + |
|||
encodeURIComponent(document.getElementById('wpTextbox1').value); |
|||
return str.substr(1); |
|||
} |
|||
function qeTabMouseOverOut(obj, out) |
|||
{ |
|||
var coloronly = false; |
|||
/* if (obj.id == 'qeTabEdit' || obj.id == 'qeTabPreview' || obj.id == 'qeTabPref') |
|||
{ |
|||
if (qeMode == MODE_PREF) |
|||
{ |
|||
if (obj.id == 'qeTabPref') coloronly = true; |
|||
} |
|||
*/ |
|||
if ((qeMode == MODE_PREVIEW && obj.id == 'qeTabPreview') || |
|||
(qeMode == MODE_QUICKEDIT && obj.id == 'qeTabEdit') || |
|||
(qeMode == MODE_DIFF && obj.id == 'qeTabDiff')) |
|||
coloronly = true; |
|||
// } |
|||
obj.style.backgroundColor = out?'#fafafa':'#fff'; |
|||
if (!coloronly) |
|||
{ |
|||
obj.style.borderColor = out?'#aaa':'#888'; |
|||
obj.style.zIndex = out?1:3; |
|||
} |
|||
} |
|||
// Ajax stuff |
|||
function qeInitAjax() |
|||
{ |
|||
try |
|||
{ |
|||
if (window.XMLHttpRequest) |
|||
{ |
|||
qeRequest = new XMLHttpRequest(); |
|||
qeRequest.overrideMimeType('text/xml'); |
|||
} |
|||
else if (window.ActiveXObject) |
|||
qeRequest = new ActiveXObject('Microsoft.XMLHTTP'); |
|||
else throw 'Kein AJAX-Objekt vorhanden'; |
|||
} |
|||
catch (e) |
|||
{ |
|||
qeShowError(e); |
|||
return false; |
|||
} |
|||
if (!qeRequest) |
|||
{ |
|||
qeShowError('AJAX-Objekt konnte nicht erstellt werden'); |
|||
return false; |
|||
} |
|||
return true; |
|||
} |
|||
function qeGetSection() |
|||
{ |
|||
if (qeEdit == -1 || !qeForm || !qeRequest || !qeEditLink || qeRequestState) return; |
|||
var link = qeEditLink + qeEdit; |
|||
qeRequestState = REQ_RECEIVE; |
|||
qeRequest.onreadystatechange = qeAjaxResponse; |
|||
qeRequest.open('GET', link, true); |
|||
qeRequest.send(null); |
|||
} |
|||
function qeAjaxResponse() |
|||
{ |
|||
if (!qeRequestState) |
|||
{ |
|||
alert('QuickEdit Fehler: qeAjaxResponse'); |
|||
return; |
|||
} |
|||
// receive |
|||
if (qeRequestState == REQ_RECEIVE && qeEdit != -1) |
|||
{ |
|||
if (qeRequest.readyState != 4 || qeRequest.status != 200) |
|||
return; |
|||
qeRequestState = REQ_IDLE; |
|||
var xml = qeRequest.responseXML; |
|||
try // MediaWiki bug 6986 workaround |
|||
{ |
|||
var wpTextbox1 = xml.getElementById('wpTextbox1').value; |
|||
} |
|||
catch (e) |
|||
{ |
|||
xml = qeFixXML(qeRequest.responseText); |
|||
if (!xml) |
|||
{ |
|||
qeShowError('XML parsing fehlgeschlagen.'); |
|||
return; |
|||
} |
|||
var wpTextbox1 = xml.getElementById('wpTextbox1').value; |
|||
} |
|||
var wpStarttime, wpEdittime, wpSummary, |
|||
wpEditToken, wpAutoSummary, wpWatchthis; |
|||
var inputs = xml.getElementsByTagName('input'); |
|||
for (i = 0; i < inputs.length; i++) |
|||
{ |
|||
if (inputs[i].name == 'wpSection') wpSection = inputs[i].value; |
|||
else if (inputs[i].name == 'wpStarttime') wpStarttime = inputs[i].value; |
|||
else if (inputs[i].name == 'wpEdittime') wpEdittime = inputs[i].value; |
|||
else if (inputs[i].name == 'wpSummary') wpSummary = inputs[i].value; |
|||
else if (inputs[i].name == 'wpEditToken') wpEditToken = inputs[i].value; |
|||
else if (inputs[i].name == 'wpAutoSummary') wpAutoSummary = inputs[i].value; |
|||
else if (inputs[i].name == 'wpWatchthis') wpWatchthis = inputs[i].checked; |
|||
} |
|||
var formaction = xml.getElementById('editform').action; |
|||
var specialchars = document.getElementById('specialchars-container'); |
|||
if (specialchars.childNodes.length == 0 && xml.getElementById('specialchars')) |
|||
{ |
|||
var node = xml.getElementById('specialchars').cloneNode(true); |
|||
node.style.background = 'none'; |
|||
node.style.border = 'none'; |
|||
node.style.fontSize = '8pt'; |
|||
for (var i = 0; i < node.childNodes.length; i++) |
|||
if (node.childNodes[i].nodeName == 'A') |
|||
{ |
|||
node.removeChild(node.childNodes[i]); |
|||
node.removeChild(node.childNodes[i+1]); |
|||
break; |
|||
} |
|||
specialchars.appendChild(node); |
|||
addCharSubsetMenu(); // wikipedia script |
|||
} |
|||
// sollte nie passieren, wenn doch -> fatal error |
|||
if (wpSection != qeEdit) |
|||
{ |
|||
qeAlert(qePhrase('varmismatch')); |
|||
qeRequestState = REQ_IDLE; |
|||
qeAbortEdit(); |
|||
return; |
|||
} |
|||
qeFillForm(formaction, wpStarttime, wpEdittime, wpSummary, wpTextbox1, |
|||
wpEditToken, wpAutoSummary, wpWatchthis); |
|||
return; |
|||
} |
|||
// preview (submit) |
|||
if (qeRequestState == REQ_SUBMIT && qeEdit != -1) |
|||
{ |
|||
if (qeRequest.readyState != 4 || qeRequest.status != 200) |
|||
return; |
|||
qeRequestState = REQ_IDLE; |
|||
try |
|||
{ |
|||
var xml = qeRequest.responseXML; |
|||
var prev = xml.getElementById('wikiPreview').cloneNode(true); |
|||
} |
|||
catch (e) |
|||
{ |
|||
// try to fix it, then try to parse again |
|||
try |
|||
{ |
|||
xml = qeFixXML(qeRequest.responseText); |
|||
prev = xml.getElementById('wikiPreview').cloneNode(true); |
|||
} |
|||
catch (e) |
|||
{ |
|||
qePreviewDisabled = true; |
|||
qePreview.firstChild.firstChild.nodeValue = qePhrase('noprev'); |
|||
var tab = document.getElementById('qeTabPreview'); |
|||
tab.firstChild.style.color = '#888'; |
|||
return; |
|||
} |
|||
} |
|||
qePreview.firstChild.style.display = 'none'; |
|||
while (prev.childNodes.length > 0 && prev.firstChild.className != 'previewnote') |
|||
prev.removeChild(prev.firstChild); |
|||
prev.removeChild(prev.firstChild); |
|||
qePreview.appendChild(prev); |
|||
return; |
|||
} |
|||
} |
|||
function qeSubmitByReturn(e) |
|||
{ |
|||
if (e && e.keyCode == 13) qeSubmit(0); |
|||
return false; |
|||
} |
|||
function qeSubmit(preview) |
|||
{ |
|||
if (qeEdit == -1 || !qeRequest || !qeForm || qeRequestState) |
|||
return; |
|||
qeForm.firstChild.childNodes[3].value = document.getElementById('qeSummary').value; |
|||
if (preview == 1) |
|||
{ |
|||
var prev = document.createElement('input'); |
|||
prev.name = 'wpPreview'; |
|||
prev.value = 'Preview'; |
|||
prev.type = 'hidden'; |
|||
qeForm.appendChild(prev); |
|||
} |
|||
qeForm.submit(); |
|||
} |
|||
// MediaWiki bug 6986 workaround |
|||
function qeFixXML(text) |
|||
{ |
|||
var pos = text.indexOf('<h1 class="firstHeading">'); |
|||
var pos2 = text.indexOf('</h1>'); |
|||
if (pos == -1 || pos2 == -1) return null; |
|||
text = text.substring(0, pos) + text.substring(pos2+5); |
|||
/************ removed, should be working now |
|||
// two workarounds for wiki commons |
|||
if (wgServer.indexOf('commons') != -1) |
|||
{ |
|||
// replace the old <br>-tags with <br /> |
|||
text = text.replace(/<br>/g, '<br />'); |
|||
// append a </p> which is missing at the end of the copyright notice below the textarea |
|||
backsl = String.fromCharCode(92); // as we know, MediaWiki strips backslashes out |
|||
regex = eval('/' + 'rel="nofollow">Wikipedia<' + backsl + '/a><' + backsl + '/span>/'); |
|||
text = text.replace(regex, '$0'+'</p>'); |
|||
} |
|||
************/ |
|||
var parser = new DOMParser(); |
|||
var newdoc = parser.parseFromString(text, "text/xml"); |
|||
return newdoc; |
|||
} |
|||
// Signature |
|||
function qeAddSignature() |
|||
{ |
|||
wpTextbox1 = document.getElementById('wpTextbox1'); |
|||
// IE support |
|||
if (document.selection) |
|||
{ |
|||
wpTextbox1.focus(); |
|||
sel = document.selection.createRange(); |
|||
sel.text = qeSignature; |
|||
} |
|||
// MOZILLA/NETSCAPE support |
|||
else if (wpTextbox1.selectionStart || wpTextbox1.selectionStart == '0') |
|||
{ |
|||
var startpos = wpTextbox1.selectionStart; |
|||
var endpos = wpTextbox1.selectionEnd; |
|||
wpTextbox1.value = wpTextbox1.value.substring(0, startpos) |
|||
+ qeSignature |
|||
+ wpTextbox1.value.substring(endpos, wpTextbox1.value.length); |
|||
wpTextbox1.focus(); |
|||
endpos += qeSignature.length; |
|||
if (endpos > wpTextbox1.length) endpos = wpTextbox1.length; |
|||
wpTextbox1.setSelectionRange(endpos, endpos); |
|||
} |
|||
else |
|||
{ |
|||
wpTextbox1.value += qeSignature; |
|||
wpTextbox1.focus(); |
|||
} |
|||
} |
|||
// Language stuff |
|||
function qeGetBGColor() |
|||
{ |
|||
var ret = qeGetStyle(document.getElementById('content'), 'background-color'); |
|||
return ret?ret:'#fff'; |
|||
} |
|||
function qeGetBGColorOf(node) |
|||
{ |
|||
var col = qeGetStyle(node, 'background-color'); |
|||
while (node && (!col || col == 'transparent')) |
|||
{ |
|||
node = node.parentNode; |
|||
col = qeGetStyle(node, 'background-color'); |
|||
} |
|||
return (node && col)?col:null; |
|||
} |
|||
function qeGetStyle(elem, style) |
|||
{ |
|||
if (document.defaultView) |
|||
return document.defaultView.getComputedStyle(elem, null).getPropertyValue(style); |
|||
return null; |
|||
} |
|||
function qeSetLang() |
|||
{ |
|||
// default: English |
|||
qeLang = 2; |
|||
for (var i = 0; i < qeLanguages.length; i++) |
|||
if (qeLanguages[i][0] == wgUserLanguage) |
|||
{ |
|||
qeLang = i + 1; |
|||
break; |
|||
} |
|||
qeSetPrefix(); |
|||
} |
|||
function qePhrase(name) |
|||
{ |
|||
for (var i = 0; i < qePhrases.length; i++) |
|||
if (qePhrases[i][0] == name) |
|||
return qePhrases[i][qeLang]; |
|||
return 'UNDEFINED PHRASE: ' + name; |
|||
} |
|||
function qeSetPrefix() |
|||
{ |
|||
// ausgeliehen vom Wikipedia-Script |
|||
var pref = 'Alt'; |
|||
if (is_safari || navigator.userAgent.toLowerCase().indexOf('mac') + 1 |
|||
|| navigator.userAgent.toLowerCase().indexOf('konqueror') + 1 ) |
|||
pref = qePhrase('strg'); |
|||
else if (is_opera) pref = qePhrase('shift') + '-Esc'; |
|||
else if (is_ff2_x11) pref = qePhrase('strg') + '-' + qePhrase('shift'); |
|||
else if (is_ff2_win) pref = 'Alt-' + qePhrase('shift'); |
|||
pref += '-'; |
|||
// p: number of the entry in the current phrase which is to be copied (EN if available, DE otherwise) |
|||
for (var i = 0; i < qePhrases.length; i++) |
|||
{ |
|||
// check for KEY: |
|||
if (qePhrases[i][0].charAt(0) == 't') |
|||
for (var j = 1; j < qePhrases[i].length; j++) |
|||
qePhrases[i][j] = qePhrases[i][j].replace(/KEY:(.)/, pref + '$1'); |
|||
for (var j = 1; j < qePhrases[i].length; j++) |
|||
{ |
|||
if (j < 3 && qePhrases[i][j].length > 0) var p = j; |
|||
if (qePhrases[i][j].length == 0) qePhrases[i][j] = qePhrases[i][p] + '**'; |
|||
} |
|||
} |
|||
} |
|||
function qeResource(name) |
|||
{ |
|||
var commonsurl = 'http://upload.wikimedia.org/wikipedia/commons/'; |
|||
var wikiurl = 'http://XX.wikipedia.org/w/index.php?title=TT&action=raw&ctype=text/TYPE'; |
|||
for (var i = 0; i < qeResources.length; i++) |
|||
if (qeResources[i][0] == name) |
|||
{ |
|||
var res = qeResources[i][1]; |
|||
if (res.indexOf('c:') == 0) |
|||
return commonsurl + res.substr(2); |
|||
var type = 0; |
|||
if (res.indexOf('js:') == 0) type = 1; |
|||
else if (res.indexOf('css:') == 0) type = 2; |
|||
if (type) |
|||
{ |
|||
wikiurl = wikiurl.replace(/XX/, res.substring(res.indexOf(':') + 1, |
|||
res.indexOf(':', res.indexOf(':')+1))); |
|||
wikiurl = wikiurl.replace(/TT/, res.substring(res.indexOf(':', res.indexOf(':')+1)+1)); |
|||
wikiurl = wikiurl.replace(/TYPE/, (type == 1)?'javascript':'css'); |
|||
return wikiurl; |
|||
} |
|||
return qeResources[i][1]; |
|||
} |
|||
return ''; |
|||
} |
|||
var qeResources = [ |
|||
['arrowup', 'c:1/13/WikEd_align_top.png'], |
|||
['arrowdown', 'c:a/a8/WikEd_align_down.png'], |
|||
['chars', 'c:0/0d/WikEd_case_sensitive.png'], |
|||
['searchbox', 'c:3/31/WikEd_preview.png'], |
|||
['x', 'c:6/61/Crystal_128_error.png'], |
|||
['language', 'js:de:Benutzer:ASM/quickedit-lang.js'], |
|||
['diff', 'js:en:User:Cacycle/diff.js'], |
|||
['style', 'css:de:Benutzer:ASM/quickedit.css'], |
|||
['diffscript','http://en.wikipedia.org/wiki/User:Cacycle/diff.js'], |
|||
['search', 'js:de:Benutzer:ASM/quickedit-search.js'] |
|||
]; |
|||
// import languages from external script ([[Benutzer:ASM/quickedit-lang.js]]) |
|||
ImportScriptPlain(qeResource('language')); |
|||
// array content: var name | var type | default value | user value |
|||
// phrase name describing the option is is "'o' + var name" |
|||
// the user value will be read by the script from a cookie |
|||
// if there is no value set, the default value will be used |
|||
var qeOptions = [ |
|||
['qeScrollMode', 'bool', 'true', null], |
|||
['qeStickyMode', 'bool', 'false', null] |
|||
]; |
|||
/*</pre>*/ |
|||
/*<pre>*/ |
|||
// from [[MediaWiki:Onlyifediting.js]] |
|||
function addCharSubsetMenu() |
|||
{ |
|||
var specialchars = document.getElementById('specialchars'); |
|||
if (specialchars) |
|||
{ |
|||
switch(wgContentLanguage){ |
|||
case "ca": |
|||
edittoolsOptions= |
|||
/*català*/ |
|||
["matemàtiques","fonètica","diacrítiques","ciríl·lic","alt alemany antic", |
|||
"anglés antic","àrab","berber","bosni/serbocroata","castellà","escandinau", |
|||
"eslovac","esperanto","estonià","francés","gal·lés","grec","grec antic", |
|||
"hawaià","hebreu","holandés","hongarés","indoeuropeu","irlandés", |
|||
"islandés","italià","japonés (romanji)","jiddisch","letó","lituà","maltés", |
|||
"navajo i apatxe", "pinyin","polonés","portugués","romanés","serbi", |
|||
"turc i ll. turqueses", "txec","vietnamita"]; break; |
|||
case "de": |
|||
edittoolsOptions= |
|||
/*Deutsch*/ |
|||
["Standard","WikiSyntax","IPA-Lautschrift","Lateinisch","AHD","Altenglisch", |
|||
"Altgriechisch","Arabisch","DMG-Umschrift","Esperanto","Estnisch", |
|||
"Französisch","Galicisch","Griechisch","Hawaiianisch","Isländisch", |
|||
"Italienisch","Jiddisch","Katalanisch","Kroatisch","Kyrillisch", |
|||
"Lettisch","Litauisch","Maltesisch","Pinyin","Polnisch","Portugiesisch", |
|||
"Romanisch","Rumänisch","Serbisch","Skandinavisch","Slowakisch","Spanisch", |
|||
"Tschechisch","Türkisch","Ungarisch","Vietnamesisch" |
|||
]; break; |
|||
case "it": |
|||
edittoolsOptions= |
|||
/*Italiano*/ |
|||
["Latino esteso","Wiki","Greco antico","Greco moderno","Cirillico","Arabo", |
|||
"Ebraico e yiddish","Armeno","Geroglifico","Vietnamita","IPA", |
|||
"Matematica" |
|||
]; break; |
|||
default : edittoolsOptions=["Your Edittools are not defined"]; |
|||
} |
|||
var menu = '<select style="display:inline" onChange="chooseCharSubset(selectedIndex)">'; |
|||
for(index in edittoolsOptions){ |
|||
menu += '<option>' + edittoolsOptions[index] + '</option>'; |
|||
} |
|||
menu += '</select>'; |
|||
specialchars.innerHTML = menu + specialchars.innerHTML; |
|||
// Standard-CharSubset |
|||
chooseCharSubset(0); |
|||
} |
|||
} |
|||
// CharSubset-Auswahl |
|||
function chooseCharSubset(s) |
|||
{ |
|||
var l = document.getElementById('specialchars').getElementsByTagName('p'); |
|||
for (var i = 0; i < l.length ; i++) |
|||
{ |
|||
l[i].style.display = (i == s) ? 'inline' : 'none'; |
|||
l[i].style.visibility = (i == s) ? 'visible' : 'hidden'; // for the CSS-unsure it-wp ;) |
|||
} |
|||
} |
|||
/*</pre>*/ |
|||
//note: this script MUST be added to the end of your monobook at all times. |
|||
//so when you add a new script to the end of your monobook, re-order them so this one is on the bottom. |
|||
addOnloadHook(function() { |
|||
if(!document.getElementById('wpSummary') || document.getElementById('wpSummary').value != '' || !document.getElementById('wpTextbox1')) return; |
|||
var my_value; |
|||
if(wgCanonicalNamespace == 'User_talk') { |
|||
if(wgPageName.indexOf('/') == -1 && wgTitle.split('/')[0] != wgUserName) |
|||
my_value = 'Respond to '+wgTitle; |
|||
else if(wgPageName.indexOf('archive') != -1 && wgTitle.split('/')[0] != wgUserName) |
|||
my_value = 'Reviving archive'; |
|||
else if(wgPageName.indexOf('archive') != -1 && wgTitle.split('/')[0] == wgUserName) |
|||
my_value = 'Archiving...'; |
|||
else if(wgPageName.indexOf('/') == -1 && wgTitle.split('/')[0] == wgUserName) |
|||
my_value = 'Reply'; |
|||
else |
|||
my_value = 'minor edit'; |
|||
} else if(wgCanonicalNamespace == 'User') { |
|||
if(wgTitle.split('/')[0] == wgUserName) |
|||
my_value = 'fixing'; |
|||
else |
|||
my_value = 'fixing a minor mistake'; |
|||
//note: leave as "Project". thats how mediawiki outputs it |
|||
} else if(wgCanonicalNamespace == 'Project'||wgCanonicalNamespace == 'Project_talk') { |
|||
if((/\w+ for deletion/i).test(wgTitle)) |
|||
my_value = 'Add my opinion'; |
|||
else if((/requests for adminship/i).test(wgTitle)) |
|||
my_value = 'Support'; |
|||
else if((/administrator.s noticeboard/i).test(wgTitle)) |
|||
my_value = 'Reply'; |
|||
else if((/administrator intervention against vandalism/i).test(wgTitle)) |
|||
my_value = 'Reporting user'; |
|||
else |
|||
my_value = 'Reply'; |
|||
} else { |
|||
my_value = 'minor edit'; |
|||
} |
|||
document.getElementById('wpSummary').value = my_value; |
|||
document.getElementById('wpSummary').onfocus = function() { |
|||
if(this.value != my_value) return; |
|||
this.selectionStart = 0; |
|||
this.selectionEnd = this.value.length; |
|||
} |
|||
}); |
|||
// |
|||
addOnloadHook(doAddQuickPreview); |