KKeine Bearbeitungszusammenfassung |
KKeine Bearbeitungszusammenfassung |
||
Zeile 18: | Zeile 18: | ||
*/ |
*/ |
||
function main() { |
function main() { |
||
⚫ | |||
init(); |
init(); |
||
− | alert('showHints'); |
||
showHints(); |
showHints(); |
||
} |
} |
||
Zeile 39: | Zeile 37: | ||
nextChild: $('#editform') ? $('#editform') : $('#WikiaArticle') |
nextChild: $('#editform') ? $('#editform') : $('#WikiaArticle') |
||
} |
} |
||
⚫ | |||
− | |||
// Defining of all possible user messages. |
// Defining of all possible user messages. |
||
uhMessages = { |
uhMessages = { |
Version vom 22. April 2011, 20:26 Uhr
/**
* The text that is shown is stored here temporarily.
*/
var uhText;
/**
* The config for the script.
*/
var uhConfig;
/**
* The messages that are shown to the user.
*/
var uhMessages;
/**
* The main funtion of the Script.
*/
function main() {
init();
showHints();
}
/**
* Inits the Script.
*/
function init() {
// Stores the text that is shown for easier handling.
uhText = {
head: '',
body: ''
}
// Defining of the config for the script.
uhConfig = {
useUserLang: true,
nextChild: $('#editform') ? $('#editform') : $('#WikiaArticle')
}
alert(nextChild);
// Defining of all possible user messages.
uhMessages = {
de: {
unregistered: {
head: 'Achtung: Du bearbeitest diesen Artikel unangemeldet!',
body: '<br>Hallo Unbekannter,<br><br>'
+ 'du bearbeitest den Artikel <a href="/wiki/' + wgPageName + '">' + wgPageName + '</a> gerade unangemeldet. '
+ 'Bitte beachte, dass dies dazu führt, dass deine IP-Adresse für immer in der Versionsgeschichte gespeichert wird. '
+ 'Außerdem gibt es keine Möglichkeit für andere Benutzer, dich einfach zu kontaktieren.<br><br>'
+ 'Falls du schon einen Benutzeraccount hast, <a href="/index.php?title=Special:UserLogin&returnto=' + wgPageName + '">melde dich an</a>. '
+ 'Ansonsten <a href="/index.php?title=Special:UserLogin&type=signup&returnto=' + wgPageName + '">lege dir bitte einen Benutzeraccount an</a>. '
+ 'Mit diesem kannst du ganz einfach deine Beiträge im Auge behalten und dich besser mit dem Rest der Community verständigen.'
+ 'Des Weiteren kannst du mit einem Konto <a href="/wiki/Special:Leaderboard">Abzeichen und Bearbeitungspunkte</a> erhalten.<br><br>'
+ 'Mit freundlichen Grüßen, die <a href="/index.php?title=Special:ListUsers&group=sysop">Administratoren</a> des ' + wgSitename + '<br><br>'
+ 'PS: Mit einem Benutzerkonto kannst du in jedem Wiki bei <a href="http://de.wikia.com/">Wikia</a> aktiv sein - du brauchst dich nicht noch einmal neu anmelden.'
},
mediawiki: {
head: 'MediaWiki Seite',
body: 'Hallo ' + (wgUserName ? wgUserName : 'Unbekannter') + ',<br><br>'
+ 'du betrachtest eine MediaWiki Seite. '
+ 'Diese Seiten werden für globale Einstellungen des Wikis genutzt. '
+ 'Aus diesem Grund ist es nur <a href="/index.php?title=Special:ListUsers&group=sysop">Administratoren</a> und <a href="/index.php?title=Special:ListUsers&group=bureaucrat">Bürokraten</a> erlaubt, diese Seiten zu bearbeiten.<br><br>'
+ 'Mit freundlichen Grüßen, die <a href="/index.php?title=Special:ListUsers&group=sysop">Administratoren</a> des ' + wgSitename
}
},
en: {
unregistered: {
head: 'Attention: You are editing while not being logged in!',
body: 'Hello wanderer,'
+ 'you are editing <a href="/wiki/' + wgPageName + '">' + wgPageName + '</a> while not being logged in. '
+ 'Please note that this will cause your IP-Adress being recorded in the version history forever. '
+ 'In addition, there is no way for other users to contact you easily.<br><br>'
+ 'If you already have an useraccount, <a href="/index.php?title=Special:UserLogin&returnto=' + wgPageName + '">please log in</a>. '
+ 'Otherwise <a href="/index.php?title=Special:UserLogin&type=signup&returnto=' + wgPageName + '">please sign in and create a new user account</a>. '
+ 'It\'s an easy way to keep track of your contributions and helps you to communicate with the rest of the community.'
+ 'Also you can claim <a href="/wiki/Spezial:Leaderboard">badges and edit point\'s</a> with an registered account.<br><br>'
+ 'Greetings, the <a href="/index.php?title=Special:ListUsers&group=sysop">administrators</a> of the ' + wgSitename + '<br><br>'
+ 'PS: With this user account you are able to edit in every wiki hosted on <a href="http://www.wikia.com/">Wikia</a> - you need not to register again.'
},
mediawiki: {
head: 'MediaWiki Page',
body: 'Hello ' + (wgUserName ? wgUserName : 'wanderer') + ',<br><br>'
+ 'you are viewing a MediaWiki page. '
+ 'Those pages are used to define global settings for the wiki. '
+ 'For this reason it is just allowed to <a href="/index.php?title=Special:ListUsers&group=sysop">administrators</a> and <a href="/index.php?title=Special:ListUsers&group=bureaucrat">bureaucrats</a> to edit this page.<br><br>'
+ 'Greetings, the <a href="/index.php?title=Special:ListUsers&group=sysop">administrators</a> of the ' + wgSitename
}
}
}
// Selection of the language which is used
var lang = 'en';
if((uhConfig.useUserLang ? wgUserLanguage : wgContentLanguage) in uhMessages) {
lang = uhConfig.useUserLang ? wgUserLanguage : wgContentLanguage;
}
// Update of the user messages.
uhMessages = uhMessages[lang];
}
/**
* Proves if a hint should be shown and shows it.
*/
function showHints() {
// Shows a hint if an unregistered user does an edit.
if(!wgUserName && (wgAction == "edit" || wgAction == "submit")) {
uhText.head = uhMessages.unregistered.head;
uhText.body = uhMessages.unregistered.body;
showUserHint();
}
// Shows a hint on MediaWiki Pages.
if(wgNamespaceNumber == 8 && !arrayContains(new Array('sysop', 'bureaucrat', 'staff'), wgUserGroups)) {
uhText.head = uhMessages.mediawiki.head;
uhText.body = uhMessages.mediawiki.body;
showUserHint();
}
}
/**
* Returns true if an array contains at least one of the words.
*
* words - Array with the words that should be cotained.
* array - Array that should contain the words.
*/
function arrayContains(words, array) {
if(!words || !array) {
return false;
}
for(var i = 0; i < words.length; i++) {
for(var j = 0; j < array.length; j++) {
if(words[i] == array[j]) {
return true;
}
}
}
return false;
}
/**
* Shows the hint to the user.
*/
function showUserHint() {
var uhWrapper = newElement('div', null, 'userHint-wrapper', null);
uhConfig.nextChild.parentNode.insertBefore(uhWrapper, uhConfig.nextChild);
var uhHead = newElement('div', null, 'userHint-head', uhWrapper);
newElement('hr', null, null, uhWrapper);
var uhBody = newElement('div', null, 'userHint-body', uhWrapper);
uhHead.innerHTML = uhText.head;
uhBody.innerHTML = uhText.body;
}
/**
* Creates a new element.
*
* @param type - the type of the new element
* @param id - the id of the new element (optional, if not used type null)
* @param classes - the class(es) of the new element (optional, if not used type null)
* @param parent - the parent of the new element (optional, if not used type null)
* @return the new element
*/
function newElement(type, id, classes, parent) {
var new_element = document.createElement(type);
if(id) {
new_element.id = id;
}
if(classes) {
new_element.className = classes;
}
if(parent) {
parent.appendChild(new_element);
}
return new_element;
}
// Calls the main function.
addOnloadHook(main);