📄 wikibits.js
字号:
}function escapeQuotesHTML(text) { var re = new RegExp('&',"g"); text = text.replace(re,"&"); var re = new RegExp('"',"g"); text = text.replace(re,"""); var re = new RegExp('<',"g"); text = text.replace(re,"<"); var re = new RegExp('>',"g"); text = text.replace(re,">"); return text;}// apply tagOpen/tagClose to selection in textarea,// use sampleText instead of selection if there is none// copied and adapted from phpBBfunction insertTags(tagOpen, tagClose, sampleText) { if (document.editform) var txtarea = document.editform.wpTextbox1; else { // some alternate form? take the first one we can find var areas = document.getElementsByTagName('textarea'); var txtarea = areas[0]; } // IE if (document.selection && !is_gecko) { var theSelection = document.selection.createRange().text; if (!theSelection) theSelection=sampleText; txtarea.focus(); if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any theSelection = theSelection.substring(0, theSelection.length - 1); document.selection.createRange().text = tagOpen + theSelection + tagClose + " "; } else { document.selection.createRange().text = tagOpen + theSelection + tagClose; } // Mozilla } else if(txtarea.selectionStart || txtarea.selectionStart == '0') { var replaced = false; var startPos = txtarea.selectionStart; var endPos = txtarea.selectionEnd; if (endPos-startPos) replaced = true; var scrollTop = txtarea.scrollTop; var myText = (txtarea.value).substring(startPos, endPos); if (!myText) myText=sampleText; if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " "; } else { subst = tagOpen + myText + tagClose; } txtarea.value = txtarea.value.substring(0, startPos) + subst + txtarea.value.substring(endPos, txtarea.value.length); txtarea.focus(); //set new selection if (replaced) { var cPos = startPos+(tagOpen.length+myText.length+tagClose.length); txtarea.selectionStart = cPos; txtarea.selectionEnd = cPos; } else { txtarea.selectionStart = startPos+tagOpen.length; txtarea.selectionEnd = startPos+tagOpen.length+myText.length; } txtarea.scrollTop = scrollTop; // All other browsers get no toolbar. // There was previously support for a crippled "help" // bar, but that caused more problems than it solved. } // reposition cursor if possible if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();}function akeytt() { if (typeof ta == "undefined" || !ta) return; var pref = 'alt-'; if (is_safari || navigator.userAgent.toLowerCase().indexOf('mac') + 1 || navigator.userAgent.toLowerCase().indexOf('konqueror') + 1 ) pref = 'control-'; if (is_opera) pref = 'shift-esc-'; for (var id in ta) { var n = document.getElementById(id); if (n) { var a = null; var ak = ''; // Are we putting accesskey in it if (ta[id][0].length > 0) { // Is this object a object? If not assume it's the next child. if (n.nodeName.toLowerCase() == "a") { a = n; } else { a = n.childNodes[0]; } if (a) { a.accessKey = ta[id][0]; ak = ' ['+pref+ta[id][0]+']'; } } else { // We don't care what type the object is when assigning tooltip a = n; ak = ''; } if (a) { a.title = ta[id][1]+ak; } } }}function setupRightClickEdit() { if (document.getElementsByTagName) { var divs = document.getElementsByTagName('div'); for (var i = 0; i < divs.length; i++) { var el = divs[i]; if(el.className == 'editsection') { addRightClickEditHandler(el); } } }}function addRightClickEditHandler(el) { for (var i = 0; i < el.childNodes.length; i++) { var link = el.childNodes[i]; if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') { var editHref = link.getAttribute('href'); // find the following a var next = el.nextSibling; while (next.nodeType != 1) next = next.nextSibling; // find the following header next = next.nextSibling; while (next.nodeType != 1) next = next.nextSibling; if (next && next.nodeType == 1 && next.nodeName.match(/^[Hh][1-6]$/)) { next.oncontextmenu = function() { document.location = editHref; return false; } } } }}function setupCheckboxShiftClick() { if (document.getElementsByTagName) { var uls = document.getElementsByTagName('ul'); var len = uls.length; for (var i = 0; i < len; ++i) { addCheckboxClickHandlers(uls[i]); } }}function addCheckboxClickHandlers(ul, start, finish) { if (ul.checkboxHandlersTimer) { clearInterval(ul.checkboxHandlersTimer); } if ( !ul.childNodes ) { return; } var len = ul.childNodes.length; if (len < 2) { return; } start = start || 0; finish = finish || start + 250; if ( finish > len ) { finish = len; } ul.checkboxes = ul.checkboxes || []; ul.lastCheckbox = ul.lastCheckbox || null; for (var i = start; i<finish; ++i) { var child = ul.childNodes[i]; if ( child && child.childNodes && child.childNodes[0] ) { var cb = child.childNodes[0]; if ( !cb.nodeName || cb.nodeName.toLowerCase() != 'input' || !cb.type || cb.type.toLowerCase() != 'checkbox' ) { return; } cb.index = ul.checkboxes.push(cb) - 1; cb.container = ul; cb.onmouseup = checkboxMouseupHandler; } } if (finish < len) { var f=function(){ addCheckboxClickHandlers(ul, finish, finish+250); }; ul.checkboxHandlersTimer=setInterval(f, 200); }}function checkboxMouseupHandler(e) { if (typeof e == 'undefined') { e = window.event; } if ( !e.shiftKey || this.container.lastCheckbox === null ) { this.container.lastCheckbox = this.index; return true; } var endState = !this.checked; if ( is_opera ) { // opera has already toggled the checkbox by this point endState = !endState; } var start, finish; if ( this.index < this.container.lastCheckbox ) { start = this.index + 1; finish = this.container.lastCheckbox; } else { start = this.container.lastCheckbox; finish = this.index - 1; } for (var i = start; i <= finish; ++i ) { this.container.checkboxes[i].checked = endState; } this.container.lastCheckbox = this.index; return true;}function toggle_element_activation(ida,idb) { if (!document.getElementById) return; document.getElementById(ida).disabled=true; document.getElementById(idb).disabled=false;}function toggle_element_check(ida,idb) { if (!document.getElementById) return; document.getElementById(ida).checked=true; document.getElementById(idb).checked=false;}function fillDestFilename(id) { if (!document.getElementById) return; var path = document.getElementById(id).value; // Find trailing part var slash = path.lastIndexOf('/'); var backslash = path.lastIndexOf('\\'); var fname; if (slash == -1 && backslash == -1) { fname = path; } else if (slash > backslash) { fname = path.substring(slash+1, 10000); } else { fname = path.substring(backslash+1, 10000); } // Capitalise first letter and replace spaces by underscores fname = fname.charAt(0).toUpperCase().concat(fname.substring(1,10000)).replace(/ /g, '_'); // Output result var destFile = document.getElementById('wpDestFile'); if (destFile) destFile.value = fname;}function considerChangingExpiryFocus() { if (!document.getElementById) return; var drop = document.getElementById('wpBlockExpiry'); if (!drop) return; var field = document.getElementById('wpBlockOther'); if (!field) return; var opt = drop.value; if (opt == 'other') field.style.display = ''; else field.style.display = 'none';}function scrollEditBox() { var editBoxEl = document.getElementById("wpTextbox1"); var scrollTopEl = document.getElementById("wpScrolltop"); var editFormEl = document.getElementById("editform"); if (editBoxEl && scrollTopEl) { if (scrollTopEl.value) editBoxEl.scrollTop = scrollTopEl.value; editFormEl.onsubmit = function() { document.getElementById("wpScrolltop").value = document.getElementById("wpTextbox1").scrollTop; } }}hookEvent("load", scrollEditBox);function allmessagesfilter() { text = document.getElementById('allmessagesinput').value; k = document.getElementById('allmessagestable'); if (!k) { return;} var items = k.getElementsByTagName('span'); if ( text.length > allmessages_prev.length ) { for (var i = items.length-1, j = 0; i >= 0; i--) { j = allmessagesforeach(items, i, j); } } else { for (var i = 0, j = 0; i < items.length; i++) { j = allmessagesforeach(items, i, j); } } allmessages_prev = text;}function allmessagesforeach(items, i, j) { var hItem = items[i].getAttribute('id'); if (hItem.substring(0,17) == 'sp-allmessages-i-') { if (items[i].firstChild && items[i].firstChild.nodeName == '#text' && items[i].firstChild.nodeValue.indexOf(text) != -1) { var itemA = document.getElementById( hItem.replace('i', 'r1') ); var itemB = document.getElementById( hItem.replace('i', 'r2') ); if ( itemA.style.display != '' ) { var s = "allmessageshider(\"" + hItem.replace('i', 'r1') + "\", \"" + hItem.replace('i', 'r2') + "\", '')"; var k = window.setTimeout(s,j++*5); } } else { var itemA = document.getElementById( hItem.replace('i', 'r1') ); var itemB = document.getElementById( hItem.replace('i', 'r2') ); if ( itemA.style.display != 'none' ) { var s = "allmessageshider(\"" + hItem.replace('i', 'r1') + "\", \"" + hItem.replace('i', 'r2') + "\", 'none')"; var k = window.setTimeout(s,j++*5); } } } return j;}function allmessageshider(idA, idB, cstyle) { var itemA = document.getElementById( idA ); var itemB = document.getElementById( idB ); if (itemA) { itemA.style.display = cstyle; } if (itemB) { itemB.style.display = cstyle; }}function allmessagesmodified() { allmessages_modified = !allmessages_modified; k = document.getElementById('allmessagestable'); if (!k) { return;} var items = k.getElementsByTagName('tr'); for (var i = 0, j = 0; i< items.length; i++) { if (!allmessages_modified ) { if ( items[i].style.display != '' ) { var s = "allmessageshider(\"" + items[i].getAttribute('id') + "\", null, '')"; var k = window.setTimeout(s,j++*5); } } else if (items[i].getAttribute('class') == 'def' && allmessages_modified) { if ( items[i].style.display != 'none' ) { var s = "allmessageshider(\"" + items[i].getAttribute('id') + "\", null, 'none')"; var k = window.setTimeout(s,j++*5); } } }}function allmessagesshow() { k = document.getElementById('allmessagesfilter'); if (k) { k.style.display = ''; } allmessages_prev = ''; allmessages_modified = false;}hookEvent("load", allmessagesshow);hookEvent("load", mwSetupToolbar);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -