Aide:IRC/Wikilinks
Permet d'afficher des Wikiliens dans le programme.
Installation:
- Copier le code ci-dessous dans un fichier nommé ' Wikilinks.js '
- Ajouter le script dans la section ChatZilla, Préférences..., Paramètres globaux, Démarrage.
- Pour ajouter le script lorsque ChatZilla est ouvert, utilisez la commande /load file:///C:/Dossier%20Un/Dossier%20Deux/Wikilinks.js.
//***************
//Traduction par King_Benjamin
//Note: Ce script est en cours de Traduction, il peut changer souvent
//***************
//***********************************************
// Script Wikilinks pour ChatZilla de IceKarma
// Version 1.2
// 1.2 Par James Ross:
// - Met les liens normaux cliquables.
// Version 2.0
// 2.0 Par Glen Mailer:
// - Script converti pour le nouveau module API;
// - Enlèvement de parties inutilisés;
// - Adapté pour le code de ChatZilla.
// 2.1 Par Alphax:
// - Ajoute la fonctionnalité pour les modèles.
// 2.2 Par Alphax:
// - Tous les modèles sont correctement mis en place.
// 2.3 Par Pathoschild:
// - Retour à la 2.2 (2.3 brise tous les liens qu'y n'ont pas un préfixe d'inter-langue;
// - Ajoute mailto: wikiliens défaillants (Basé sur le code 2.3 par Stigmj).
// 2.4 Par Stigmj:
// - Ajoute la prise en charge des couleurs MIRC.
// 2.5 Par GeorgeMoney:
// - Code travaillé pour le changement dans API.
// 2.6 Par Pathoschild:
// - Corrige le préfixe pour les interwikiliens brisés ([[w:foo]]);
// - add support for namespace template syntax;
// - fix modifiers msg, msgnw, raw; correct int (points to "mediawiki:foo", not "template:int:foo");
// - Aucun paramètre pour les liens: {{[[template:foo|foo]]|bar}}.
// 2.7 Par Pathoschild:
// - Ajoute la prise en charge de la syntaxe des liens externes.
//
// Ce fichier est mis par les auteurs dans le domaine public.
//***********************************************
plugin.id = "WikiLinks";
plugin.prefary = [
["class", "wiki-link", ""],
];
//
// Plugin management
//
plugin.init =
function init(glob) {
plugin.major = 2;
plugin.minor = 7;
plugin.version = plugin.major + "." + plugin.minor;
plugin.description = "Munges wikiML links to be clickable in the output window";
plugin.prefary = plugin.prefary.concat(plugin.prefary);
}
plugin.disable =
function disable()
{
client.munger.delRule("wiki-link");
client.munger.delRule("wiki-template-link");
client.munger.delRule("wiki-external-link");
client.commandManager.removeCommands(plugin.commands);
display( plugin.id + " v" + plugin.version + " disabled.");
return true;
}
plugin.enable =
function enable()
{
client.munger.addRule("wiki-link", /(\[(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*\[(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*[^\]]+(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*\](?:[\x1f\x02\x0f\x03\x16]\d{1,2})*\])/, insertWikiLink, 10, 10);
client.munger.addRule("wiki-template-link", /(\{(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*\{(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*[^\}]+(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*\}(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*\})/, insertWikiTemplateLink, 10, 10);
client.munger.addRule("wiki-external-link", /(\[http:\/\/[^\s]+ [^\]]+\])/, insertWikiExtLink, 10, 10);
var cmdary = [
[ "wiki-links-class", cmdClass, CMD_CONSOLE, "[<className>]" ],
];
plugin.commands = client.commandManager.defineCommands(cmdary);
display( plugin.id + " v" + plugin.version + " enabled.");
return true;
}
//
// Mungers
//
function insertWikiLink(matchText,containerTag, data, mungerEntry) {
var wikiLink = matchText;
var linkTitle;
wikiLink = matchText.replace(/^\[(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*\[(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*/, "");
wikiLink = wikiLink.replace(/(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*\](?:[\x1f\x02\x0f\x03\x16]\d{1,2})*\]$/, "");
linkTitle = wikiLink;
// fix bad links (but leave linkTitle)
wikiLink = wikiLink.replace(/^w:/, "");
if (linkTitle.match(/\|/)) {
var ary = linkTitle.match(/^(.*?)\|(.*)$/);
wikiLink = ary[1];
linkTitle = ary[2];
}
wikiLink = escape(wikiLink.replace(/ /g, "_"));
var anchor = document.createElementNS( "http://www.w3.org/1999/xhtml",
"html:a");
anchor.setAttribute("href", "http://fr.wikipedia.org/wiki/" + wikiLink);
anchor.setAttribute("class", "chatzilla-link "+plugin.prefs["class"]);
mungerEntry.enabled = false;
data.inLink = true;
client.munger.munge(linkTitle, anchor, data);
mungerEntry.enabled = true;
delete data.inLink;
//insertHyphenatedWord(linkTitle, anchor, data);
containerTag.appendChild(document.createTextNode("[["));
containerTag.appendChild(anchor);
containerTag.appendChild(document.createTextNode("]]"));
}
function insertWikiTemplateLink(matchText,containerTag, data, mungerEntry) {
var wikiLink = matchText;
var linkTitle;
wikiLink = matchText.replace(/^\{(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*\{(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*/, "");
wikiLink = wikiLink.replace(/(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*\}(?:[\x1f\x02\x0f\x03\x16]\d{1,2})*\}$/, "");
linkTitle = wikiLink;
// fix parameters
if(linkTitle.match(/^[^\|]+\|/)) {
linkParam = linkTitle.replace(/^[^\|]+\|(.*)$/, "|$1");
linkTitle = linkTitle.replace(/^([^\|]+)\|.*$/, "$1");
wikiLink = linkTitle;
}
else {
linkParam = false;
}
// fix bad links (but leave linkTitle)
wikiLink = wikiLink.replace(/^(?:template|msgnw|raw|subst):/, ""); // modifiers
// set namespace by syntax
if(wikiLink.match(/^:[a-z\s]*:?/i)) {
wikiLink = wikiLink.replace(/^:([a-z\s]+):/i, "$1:"); // most ns
wikiLink = wikiLink.replace(/^:/, ""); // main
}
else if(wikiLink.match(/^int:/i)) {
wikiLink = wikiLink.replace(/^int:/i, "MediaWiki:"); // fix modifier
}
else {
wikiLink = wikiLink.replace(/^/, "Modèle:");
}
// construct link
wikiLink = escape(wikiLink.replace(/ /g, "_"));
var anchor = document.createElementNS( "http://www.w3.org/1999/xhtml",
"html:a");
anchor.setAttribute("href", "http://fr.wikipedia.org/wiki/" + wikiLink);
anchor.setAttribute("class", "chatzilla-link "+plugin.prefs["class"]);
mungerEntry.enabled = false;
data.inLink = true;
client.munger.munge(linkTitle, anchor, data);
mungerEntry.enabled = true;
delete data.inLink;
//insertHyphenatedWord(linkTitle, anchor, data);
containerTag.appendChild(document.createTextNode("{{"));
containerTag.appendChild(anchor);
if(linkParam) {
containerTag.appendChild(document.createTextNode(linkParam));
}
containerTag.appendChild(document.createTextNode("}}"));
}
function insertWikiExtLink(matchText,containerTag, data, mungerEntry) {
var wikiExtLink = matchText;
var linkTitle = matchText;
// separate link and text
wikiExtLink = wikiExtLink.replace(/^\[(http:\/\/[^\s]+)\s+.*$/, "$1");
linkTitle = linkTitle.replace(/^\[http:\/\/[^\s]+ ([^\]]+)\]$/, "$1");
// create link
var anchor = document.createElementNS( "http://www.w3.org/1999/xhtml",
"html:a");
anchor.setAttribute("href", wikiExtLink);
anchor.setAttribute("class", "chatzilla-link "+plugin.prefs["class"]);
anchor.setAttribute("style", "text-decoration:underline;");
mungerEntry.enabled = false;
data.inLink = true;
client.munger.munge(linkTitle, anchor, data);
mungerEntry.enabled = true;
delete data.inLink;
// show link syntax
containerTag.appendChild(anchor);
// add external link icon
var img = document.createElementNS( "http://www.w3.org/1999/xhtml",
"html:img");
img.setAttribute("src", 'http://upload.wikimedia.org/wikipedia/commons/4/44/External.png');
containerTag.appendChild(img);
}
//
// Commands
//
function cmdClass(e) {
if ( null != e.linkclass )
plugin.prefs["class"] = e.linkclass;
display( "Current value: " + plugin.prefs["class"] );
}
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.