Thành viên:Vietbio/monobook.js
Bách khoa toàn thư mở Wikipedia
Cache: Sau khi lưu biểu mẫu này, phải bỏ thông tin vùng đệm (cache) của trình duyệt cho những thay đổi hiện ra được: Mozilla, Firefox, Netscape, Safari: Giữ nút Shift
trong khi bấm Reload
, hay bấm Ctrl
+Shift
+R
. Internet Explorer: Bấm Ctrl
+F5
. Opera, Konqueror: Bấm F5
.
Nếu bạn viết mã JavaScript, chú ý đọc hướng dẫn để tránh mâu thuẫn với mã mặc định của mạng.
/* <nowiki> */ // Live Preview wpShowImages = true; document.write('<script type="text/javascript" src="http://en.wikipedia.org/w/index.php?title=User:Pilaf/livepreview.js&action=raw&ctype=text/javascript&dontcountme=s"></script>'); window.onload = Main; function Main() { LivePreviewInstall(); } // Vietnamese Input Method //document.write('<script type="text/javascript" src="http://rhos.sourceforge.net/pro/him.js"></script>'); //document.write('<script type="text/javascript" //src="http://vi.wikipedia.org/w/index.php?title=User:Tttrung/ahim.js&action=raw&ctype=text/javascript&dontcountme=s"></script>'); //function Main() //{ method = 1; on_off = 1; dockspell = 0; dauCu = 0; // HIM(); //} //window.onload = Main; var mpTitle = "Wikipedia:WikiProject Usability/Main Page/Draft"; var isMainPage = (document.title.substr(0, mpTitle.length) == mpTitle) if (isMainPage) { document.write('<style type="text/css"> #siteSub, #contentSub { display: none!important; } #content, #content div.thumb, #p-cactions li a, #p-cactions li a:hover, #p-cactions li.selected a { background: #fff!important; } </style>'); var mpSmallEnabled; var mpMinWidth = 700; function mainPageTransform() { var mpContentEl = document.getElementById("bodyContent"); var mpBrowseEl = document.getElementById("EnWpMpBrowse"); var mpContainEl = document.getElementById("EnWpMpBrowseContainer"); var mpMarginEl = document.getElementById("EnWpMpMargin"); var mpEl = document.getElementById("EnWpMainPage"); if (!mpContentEl || !mpBrowseEl || !mpContainEl || !mpMarginEl || !mpEl) return; if (!mpSmallEnabled && mpContentEl.offsetWidth < mpMinWidth) { mpContainEl.insertBefore(mpBrowseEl, mpContainEl.firstChild); mpBrowseEl.className = "EnWpMpBrowseBottom"; mpMarginEl.style.marginRight = 0; mpSmallEnabled = true; } else if (mpSmallEnabled && mpContentEl.offsetWidth > mpMinWidth) { mpEl.insertBefore(mpBrowseEl, mpEl.firstChild); mpBrowseEl.className = "EnWpMpBrowseRight"; mpMarginEl.style.marginRight = "13.8em"; mpSmallEnabled = false; } } var onloadFuncts = [ mainPageTransform ]; if (window.addEventListener) window.addEventListener("resize", mainPageTransform, false); else if (window.attachEvent) window.attachEvent("onresize", mainPageTransform); } /* Bottom tabs */ /* function morelinks() { var tabs = document.getElementById('p-cactions').cloneNode(true); tabs.id = 'mytabs'; var listitems = tabs.getElementsByTagName('LI'); for (i=0;i<listitems.length;i++) { if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id; } document.getElementById('column-content').appendChild(tabs); } addLoadEvent(morelinks); */ /* [[:en:Wikipedia:WikiProject User scripts/Scripts/Fix diff width|Fix diff width]] */ function FixDiffWidth() { var diffSigns = new Array(); var fixDiffWidth = function () { var tables = document.getElementsByTagName('table'); for (var i = 0; i < tables.length; i++) if (tables[i].className == 'diff') { var rows = tables[i].getElementsByTagName('tr'); var diffDiv = document.createElement('div'); diffDiv.style.backgroundColor = 'white'; diffDiv.className = 'xdiff'; for (var j = 0; j < rows.length; j++) { var rowDiv = document.createElement('div'); rowDiv.style.width = '100%'; rowDiv.style.margin = '0 0 3px 0'; rowDiv.style.overflow = 'hidden'; // trick, makes it expand vertically to contain floats rowDiv.className = 'xdiff-row'; var colDiv = null; var cols = rows[j].getElementsByTagName('td'); for (var k = 0; k < cols.length; k++) { if (!colDiv) { colDiv = document.createElement('div'); colDiv.style.cssFloat = 'left'; colDiv.style.clear = 'none'; colDiv.style.position = 'relative'; colDiv.style.width = '49%'; colDiv.className = 'xdiff-col'; rowDiv.appendChild(colDiv); } var innerDiv = document.createElement('div'); if (cols[k].getAttribute('colspan') == 2 || cols[k].className.substring(0,5) == 'diff-') { innerDiv.style.overflow = 'auto'; // scroll if necessary! innerDiv.style.padding = '1px'; if (cols[k].getAttribute('colspan') != 2) { innerDiv.style.margin = '0 0 0 2em'; innerDiv.style.fontSize = '85%'; // from MediaWiki:Monobook.css if (cols[k].className == 'diff-addedline') innerDiv.style.backgroundColor = '#cfc'; if (cols[k].className == 'diff-deletedline') innerDiv.style.backgroundColor = '#ffa'; if (cols[k].className == 'diff-context') innerDiv.style.backgroundColor = '#eee'; } innerDiv.style.textAlign = cols[k].getAttribute('align'); innerDiv.className = (cols[k].className ? "x"+cols[k].className : ""); } else if (cols[k].firstChild && (cols[k].firstChild.nextSibling || cols[k].firstChild.nodeType != 3 || cols[k].firstChild.nodeValue.match(/\S/))) { innerDiv.style.width = '2em'; innerDiv.style.textAlign = 'center'; innerDiv.style.position = 'absolute'; innerDiv.className = 'xdiff-sign'; diffSigns.push(innerDiv); } else continue; for (var node = cols[k].firstChild; node; node = node.nextSibling) innerDiv.appendChild(node.cloneNode(true)); innerDiv.appendChild(document.createTextNode(String.fromCharCode(0xa0))); // add nbsp colDiv.appendChild(innerDiv); if (innerDiv.className != 'xdiff-sign') colDiv = null; // start new columns } // force rowDiv to expand, just in case position trick fails var clearer = document.createElement('span'); clearer.clear = 'left'; rowDiv.appendChild(clearer); diffDiv.appendChild(rowDiv); } tables[i].parentNode.replaceChild(diffDiv, tables[i]); } }; // finally, a kluge to vertically center the +/- signs var centerDiffSigns = function () { for (var i = 0; i < diffSigns.length; i++) { var parentHeight; if (!( parentHeight = diffSigns[i].parentNode )) continue; if (!( parentHeight = parentHeight.clientHeight )) continue; diffSigns[i].style.top = Math.round((parentHeight - diffSigns[i].offsetHeight)/2) + "px"; } }; fixDiffWidth(); hookEvent('resize', centerDiffSigns); setTimeout(centerDiffSigns, 250); } if (window.addEventListener) addLoadEvent(FixDiffWidth); /* [[:en:Wikipedia:WikiProject User scripts/Scripts/addLink|addLink]] */ function addLink(where, url, name, id, title, key, after) { //* where is the id of the toolbar where the button should be added; // i.e. one of "p-cactions", "p-personal", or "p-navigation". //* url is the URL which will be called when the button is clicked. // javascript: urls can be used to do more complex things. //* name is what will appear as the name of the button. //* id is the id of the button; it's best to define one. // Use a prefix to make sure its unique. Optional. //* title is the tooltip title that gives a longer description // of the button; if you define a accesskey, mention it here. Optional. //* key is the char you want for the accesskey. Optional. //* after is the id of the button you want to follow this one. Optional. var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); var tabs = document.getElementById(where).getElementsByTagName('ul')[0]; if(after) { tabs.insertBefore(li,document.getElementById(after)); } else { tabs.appendChild(li); } if(id) { if(key && title) { ta[id] = [key, title]; } else if(key) { ta[id] = [key, '']; } else if(title) { ta[id] = ['', title];} } // re-render the title and accesskeys from existing code in wikibits.js akeytt(); return li; } /* [[:en:Wikipedia:WikiProject User scripts/Scripts/Add purge to tabs|addPurge]] */ function AddPurge () { var x = document.getElementById('ca-history'); if(!x) return; if(x.children) x = x.children[0].href; else x = x.childNodes[0].href; addLink("p-cactions", x.replace(/=history/, "=purge"), 'Làm sạch', 'ca-purge', 'Làm sạch vùng nhớ đệm của trang này', 0); } addLoadEvent(AddPurge); /* Chia ra [[Thành viên:Mxn/Trang Chính 3]] thành tab */ /* Dựa trên mã nguồn của [http://vi.wikipedia.org/skins-1.5/common/wikibits.js] */ // fold sections for Trang Chính // XXX: needs testing on IE/Mac and safari // more comments to follow function tabbedsects() { var container = document.getElementById('page-sects'); if (!container || !document.createElement) return; if (container.nodeName.toLowerCase() == 'a') return; // Occasional IE problem container.className = container.className + 'jsprefs'; var sections = new Array(); children = container.childNodes; var seci = 0; for (i = 0; i < children.length; i++) { if (children[i].nodeName.toLowerCase() == 'div') { children[i].id = 'prefsection-' + seci; children[i].className = 'prefsection'; if (is_opera || is_khtml) children[i].className = 'prefsection operaprefsection'; legends = children[i].getElementsByTagName('h2'); sections[seci] = new Object(); legends[0].className = 'mainLegend'; if (legends[0] && legends[0].firstChild.nodeValue) sections[seci].text = legends[0].firstChild.nodeValue; else sections[seci].text = '# ' + seci; sections[seci].secid = children[i].id; seci++; if (sections.length != 1) children[i].style.display = 'none'; else var selectedid = children[i].id; } } var toc = document.createElement('ul'); toc.id = 'preftoc'; toc.selectedid = selectedid; for (i = 0; i < sections.length; i++) { var li = document.createElement('li'); if (i == 0) li.className = 'selected'; var a = document.createElement('a'); a.href = '#' + sections[i].secid; a.onmousedown = a.onclick = uncoversection; a.appendChild(document.createTextNode(sections[i].text)); a.secid = sections[i].secid; li.appendChild(a); toc.appendChild(li); } container.parentNode.insertBefore(toc, container.parentNode.childNodes[0]); // document.getElementById('prefsubmit').id = 'prefcontrol'; } function uncoversection() { oldsecid = this.parentNode.parentNode.selectedid; newsec = document.getElementById(this.secid); if (oldsecid != this.secid) { ul = document.getElementById('preftoc'); document.getElementById(oldsecid).style.display = 'none'; newsec.style.display = 'block'; ul.selectedid = this.secid; lis = ul.getElementsByTagName('li'); for (i = 0; i< lis.length; i++) lis[i].className = ''; this.parentNode.className = 'selected'; } return false; } addLoadEvent(tabbedsects); /* </nowiki> */