Jump to content

User:Smartse/vector.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Smartse (talk | contribs) at 11:53, 9 February 2011. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
importScript('User:Ioeth/friendly.js');
importScript('User:Shubinator/DYKcheck.js'); //DYKcheck tool
importScript('User:Ale_jrb/Scripts/igloo.js'); // [[User:Ale_jrb/Scripts/igloo]]

//Adds 'Check Refs' to the toolbox, links to http://toolserver.org/~dispenser/cgi-bin/reflinks.py -- Dispenser's reference title fixer.
 
function refcheck()
{
addPortletLink("p-tb", "http://toolserver.org/~dispenser/cgi-bin/webreflinks.py?page=" + wgPageName + "&citeweb=on", "Check Refs");
}
 
function linkcheck()
{
addPortletLink("p-tb", "http://toolserver.org/~dispenser/cgi-bin/webchecklinks.py?page=" + wgPageName, "Check Links");
}
 
if ( wgNamespaceNumber == 0 ) {
addOnloadHook(refcheck);
addOnloadHook(linkcheck);
}

//Easyblock
importScript('User:Animum/easyblock.js');
 
//CSD Deleter and Decliner
importScript('User:Ale_jrb/Scripts/csdcheck.js');
var notifyByDefaultDel	= true;
importScript('User:Ale_jrb/Scripts/csdhelper.js');


addOnloadHook(function () {
 
if (wgNamespaceNumber == 0) {
if ((typeof no_external_cache != "undefined") && (no_external_cache)) return;
addcache();
}
 
function addcache() {
var external_links;
if (document.getElementsByClassName) {
external_links = document.getElementsByClassName('external');
} else {
external_links = getElementsByClass('external',document.getElementById("bodyContent"),'a');
}
 
if (external_links.length > 50) return;
 
for( i = 0;i < external_links.length;i++)
{
var chemin = external_links[i].href;
var titre = getTextContent(external_links[i]);
 
if(chemin.indexOf("http://wikiwix.com/cache/")==-1 && chemin.indexOf("http://web.archive.org/web/*/")==-1 && chemin.indexOf("wikipedia.org")==-1)
{
var li = external_links[i].parentNode;
var depth = 0;
while ((depth < 3) && (li.tagName != "LI") && (li.parentNode != null)) {
li = li.parentNode;
depth++;
}
 
if (li.tagName != "LI") continue;
 
var last = document.createElement("small");
last.setAttribute("class", "cachelinks");
last.style.color = "#3366BB";
last.appendChild(document.createTextNode("\u00a0["));
insertAfter(external_links[i].parentNode, last, external_links[i]);
 
var link = document.createElement("a");
link.setAttribute("href", "http://wikiwix.com/cache/?url=" + chemin.replace(/&/g, "%26"));
link.setAttribute("title", "archive de "+ titre);
link.appendChild(document.createTextNode("archive"));
link.style.color = "#3366BB";
last.appendChild(link);
last.appendChild(document.createTextNode("]"));
}
}
}
 
 
// Récupère proprement le contenu textuel d'un noeud et de ses noeuds descendants
// Copyright Harmen Christophe, http://openweb.eu.org/articles/validation_avancee, CC
function getTextContent(oNode) {
if (typeof(oNode.textContent)!="undefined") {return oNode.textContent;}
switch (oNode.nodeType) {
case 3: // TEXT_NODE
case 4: // CDATA_SECTION_NODE
return oNode.nodeValue;
break;
case 7: // PROCESSING_INSTRUCTION_NODE
case 8: // COMMENT_NODE
if (getTextContent.caller!=getTextContent) {
return oNode.nodeValue;
}
break;
case 9: // DOCUMENT_NODE
case 10: // DOCUMENT_TYPE_NODE
case 12: // NOTATION_NODE
return null;
break;
}
var _textContent = "";
oNode = oNode.firstChild;
while (oNode) {
_textContent += getTextContent(oNode);
oNode = oNode.nextSibling;
}
return _textContent;
}
 
/**
* insertAfter : insérer un élément dans une page
*/
function insertAfter(parent, node, referenceNode) {
parent.insertBefore(node, referenceNode.nextSibling);
}
 
}
);