User:Pmartin/cache.js
function addcache() {
if (typeof no_external_cache !== "undefined" && no_external_cache) {
return;
}
var links = document.getElementsByClassName('external');
for (var i = 0, l = links.length; i < l; i++) {
var current_link = links[i];
var path = current_link.href;
if (path.indexOf("http://wikiwix.com/cache/") > -1 || path.indexOf("http://web.archive.org/web/") > -1 || path.indexOf("wikipedia.org") > -1 || path.indexOf("wikimedia.org") > -1 || path.indexOf("stable.toolserver.org") > -1) {
continue;
}
var element_parent = current_link.parentNode;
if (hasClass(element_parent, "noarchive")) {
continue;
}
var page_title = getTextContent(current_link);
var last = document.createElement("small");
last.className = "cachelinks";
last.appendChild(document.createTextNode("\u00a0["));
var link = document.createElement("a");
link.setAttribute("href", "http://wikiwix.com/cache/?url=" + path.replace(/%/g, "%25").replace(/&/g, "%26") + "&title=" + encodeURIComponent(page_title));
link.setAttribute("title", "archive of " + page_title);
link.appendChild(document.createTextNode("archive"));
last.appendChild(link);
last.appendChild(document.createTextNode("]"));
element_parent.insertBefore(last, current_link.nextSibling);
}
}
// If we're on an article page, run addcache
if (wgNamespaceNumber === 0) {
$( addcache );
}
// Retrieves the actual text content of a node and its descendant nodes
// Copyright Harmen Christophe, http://openweb.eu.org/articles/validation_avancee, CC
function getTextContent(oNode) {
if(!oNode) return null;
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;
}
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.